Skip to content

Commit

Permalink
dynamically load compression libraries
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
teknoraver committed Mar 5, 2024
1 parent 1c20c9f commit 3fc72d5
Show file tree
Hide file tree
Showing 17 changed files with 414 additions and 213 deletions.
13 changes: 7 additions & 6 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -1371,16 +1371,19 @@ conf.set10('HAVE_BZIP2', libbzip2.found())
libxz = dependency('liblzma',
required : get_option('xz'))
conf.set10('HAVE_XZ', libxz.found())
libxz_cflags = libxz.partial_dependency(includes: true, compile_args: true)

liblz4 = dependency('liblz4',
version : '>= 1.3.0',
required : get_option('lz4'))
conf.set10('HAVE_LZ4', liblz4.found())
liblz4_cflags = liblz4.partial_dependency(includes: true, compile_args: true)

libzstd = dependency('libzstd',
version : '>= 1.4.0',
required : get_option('zstd'))
conf.set10('HAVE_ZSTD', libzstd.found())
libzstd_cflags = libzstd.partial_dependency(includes: true, compile_args: true)

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

Expand Down Expand Up @@ -1951,8 +1954,7 @@ libsystemd = shared_library(
link_args : ['-shared',
'-Wl,--version-script=' + libsystemd_sym_path],
link_with : [libbasic,
libbasic_gcrypt,
libbasic_compress],
libbasic_gcrypt],
link_whole : [libsystemd_static],
dependencies : [librt,
threads,
Expand All @@ -1969,7 +1971,6 @@ install_libsystemd_static = static_library(
libsystemd_sources,
basic_sources,
basic_gcrypt_sources,
basic_compress_sources,
fundamental_sources,
include_directories : libsystemd_includes,
build_by_default : static_libsystemd != 'false',
Expand All @@ -1981,12 +1982,12 @@ install_libsystemd_static = static_library(
libcap,
libdl,
libgcrypt,
liblz4,
liblz4_cflags,
libmount,
libopenssl,
librt,
libxz,
libzstd,
libxz_cflags,
libzstd_cflags,
threads,
userspace],
c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
Expand Down
Loading

0 comments on commit 3fc72d5

Please sign in to comment.