Skip to content

Commit 3fc72d5

Browse files
committed
dynamically load compression libraries
Dynamically load liblz4, libzstd and liblzma with dlopen(). This helps to reduce the size of the initrd image when these libraries are not really needed.
1 parent 1c20c9f commit 3fc72d5

File tree

17 files changed

+414
-213
lines changed

17 files changed

+414
-213
lines changed

meson.build

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,16 +1371,19 @@ conf.set10('HAVE_BZIP2', libbzip2.found())
13711371
libxz = dependency('liblzma',
13721372
required : get_option('xz'))
13731373
conf.set10('HAVE_XZ', libxz.found())
1374+
libxz_cflags = libxz.partial_dependency(includes: true, compile_args: true)
13741375

13751376
liblz4 = dependency('liblz4',
13761377
version : '>= 1.3.0',
13771378
required : get_option('lz4'))
13781379
conf.set10('HAVE_LZ4', liblz4.found())
1380+
liblz4_cflags = liblz4.partial_dependency(includes: true, compile_args: true)
13791381

13801382
libzstd = dependency('libzstd',
13811383
version : '>= 1.4.0',
13821384
required : get_option('zstd'))
13831385
conf.set10('HAVE_ZSTD', libzstd.found())
1386+
libzstd_cflags = libzstd.partial_dependency(includes: true, compile_args: true)
13841387

13851388
conf.set10('HAVE_COMPRESSION', libxz.found() or liblz4.found() or libzstd.found())
13861389

@@ -1951,8 +1954,7 @@ libsystemd = shared_library(
19511954
link_args : ['-shared',
19521955
'-Wl,--version-script=' + libsystemd_sym_path],
19531956
link_with : [libbasic,
1954-
libbasic_gcrypt,
1955-
libbasic_compress],
1957+
libbasic_gcrypt],
19561958
link_whole : [libsystemd_static],
19571959
dependencies : [librt,
19581960
threads,
@@ -1969,7 +1971,6 @@ install_libsystemd_static = static_library(
19691971
libsystemd_sources,
19701972
basic_sources,
19711973
basic_gcrypt_sources,
1972-
basic_compress_sources,
19731974
fundamental_sources,
19741975
include_directories : libsystemd_includes,
19751976
build_by_default : static_libsystemd != 'false',
@@ -1981,12 +1982,12 @@ install_libsystemd_static = static_library(
19811982
libcap,
19821983
libdl,
19831984
libgcrypt,
1984-
liblz4,
1985+
liblz4_cflags,
19851986
libmount,
19861987
libopenssl,
19871988
librt,
1988-
libxz,
1989-
libzstd,
1989+
libxz_cflags,
1990+
libzstd_cflags,
19901991
threads,
19911992
userspace],
19921993
c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))

0 commit comments

Comments
 (0)