diff --git a/meson.build b/meson.build index 2665024426d..ef9a0278c97 100644 --- a/meson.build +++ b/meson.build @@ -599,6 +599,11 @@ endif versiondep = declare_dependency(sources: version_h) +shared_lib_tag = get_option('shared-lib-tag') +if shared_lib_tag == '' + shared_lib_tag = meson.project_version() +endif + sh = find_program('sh') echo = find_program('echo') sed = find_program('sed') @@ -2021,12 +2026,7 @@ dbus_programs += executable( link_with : [libcore, libshared], dependencies : [versiondep, - threads, - librt, - libseccomp, - libselinux, - libmount, - libblkid], + libseccomp], install_rpath : rootlibexecdir, install : true, install_dir : rootlibexecdir) @@ -2042,12 +2042,7 @@ public_programs += executable( link_with : [libcore, libshared], dependencies : [versiondep, - threads, - librt, - libseccomp, - libselinux, - libmount, - libblkid], + libseccomp], install_rpath : rootlibexecdir, install : conf.get('ENABLE_ANALYZE')) @@ -3912,6 +3907,7 @@ summary({ 'D-Bus system directory' : dbussystemservicedir, 'bash completions directory' : bashcompletiondir, 'zsh completions directory' : zshcompletiondir, + 'private shared lib version tag' : shared_lib_tag, 'extra start script' : get_option('rc-local'), 'debug shell' : '@0@ @ @1@'.format(get_option('debug-shell'), get_option('debug-tty')), diff --git a/meson_options.txt b/meson_options.txt index 401f0933d73..23691fb4986 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -3,6 +3,8 @@ option('version-tag', type : 'string', description : 'override the git version string') +option('shared-lib-tag', type : 'string', + description : 'override the private shared library version tag (defaults to project version)') option('mode', type : 'combo', choices : ['developer', 'release'], description : 'autoenable features suitable for systemd development/release builds') diff --git a/src/core/meson.build b/src/core/meson.build index d229d46779a..fd15a7fbefd 100644 --- a/src/core/meson.build +++ b/src/core/meson.build @@ -167,12 +167,18 @@ load_fragment_gperf_nulstr_c = custom_target( command : [awk, '-f', '@INPUT0@', '@INPUT1@'], capture : true) -libcore = static_library( - 'core', +libcore_name = 'systemd-core-@0@'.format(shared_lib_tag) + +libcore = shared_library( + libcore_name, libcore_sources, load_fragment_gperf_c, load_fragment_gperf_nulstr_c, include_directories : includes, + c_args : ['-fvisibility=default'], + link_args : ['-shared', + '-Wl,--version-script=' + libshared_sym_path], + link_with : libshared, dependencies : [versiondep, threads, libdl, @@ -184,8 +190,10 @@ libcore = static_library( libapparmor, libselinux, libmount, + libblkid, libacl], - build_by_default : false) + install : true, + install_dir : rootlibexecdir) core_includes = [includes, include_directories('.')] diff --git a/src/shared/meson.build b/src/shared/meson.build index 5dc58a863d4..f58d623f4a1 100644 --- a/src/shared/meson.build +++ b/src/shared/meson.build @@ -430,7 +430,7 @@ target2 = custom_target( shared_generated_gperf_headers = [target1, target2] shared_sources += shared_generated_gperf_headers -libshared_name = 'systemd-shared-@0@'.format(meson.project_version()) +libshared_name = 'systemd-shared-@0@'.format(shared_lib_tag) libshared_deps = [threads, libacl, @@ -465,13 +465,13 @@ libshared_static = static_library( libshared = shared_library( libshared_name, include_directories : includes, + c_args : ['-fvisibility=default'], link_args : ['-shared', '-Wl,--version-script=' + libshared_sym_path], link_whole : [libshared_static, libbasic, libbasic_gcrypt, libsystemd_static], - c_args : ['-fvisibility=default'], dependencies : libshared_deps, install : true, install_dir : rootlibexecdir) diff --git a/src/test/meson.build b/src/test/meson.build index 9a1c481f226..364cd3dd3fd 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -419,7 +419,8 @@ tests += [ libmount, libxz, liblz4, - libblkid], + libblkid, + libselinux], [core_includes, journal_includes, udev_includes]], [['src/test/test-prioq.c']], diff --git a/test/test-functions b/test/test-functions index 218d0e6888c..95d37d09d59 100644 --- a/test/test-functions +++ b/test/test-functions @@ -1932,11 +1932,9 @@ inst_libs() { while read -r line; do [[ "$line" = 'not a dynamic executable' ]] && break - # Skip a harmless error when running the tests on a system with a significantly - # older systemd version (ldd tries to resolve the unprefixed RPATH for libsystemd.so.0, - # which is in this case older than the already installed libsystemd.so.0 in $initdir). - # The issue is triggered by installing test dependencies in install_missing_libraries(). - [[ "$line" =~ libsystemd.so.*:\ version\ .*\ not\ found ]] && continue + # Ignore errors about our own stuff missing. This is most likely caused + # by ldd attempting to use the unprefixed RPATH. + [[ "$line" =~ libsystemd.*\ not\ found ]] && continue if [[ "$line" =~ $so_regex ]]; then file="${BASH_REMATCH[1]}" @@ -2309,7 +2307,7 @@ inst_binary() { # In certain cases we might attempt to install a binary which is already # present in the test image, yet it's missing from the host system. # In such cases, let's check if the binary indeed exists in the image - # before doing any other chcecks. If it does, immediately return with + # before doing any other checks. If it does, immediately return with # success. if [[ $# -eq 1 ]]; then for path in "" bin sbin usr/bin usr/sbin; do @@ -2328,6 +2326,10 @@ inst_binary() { while read -r line; do [[ "$line" = 'not a dynamic executable' ]] && break + # Ignore errors about our own stuff missing. This is most likely caused + # by ldd attempting to use the unprefixed RPATH. + [[ "$line" =~ libsystemd.*\ not\ found ]] && continue + if [[ "$line" =~ $so_regex ]]; then file="${BASH_REMATCH[1]}" [[ -e "${initdir}/$file" ]] && continue diff --git a/tools/oss-fuzz.sh b/tools/oss-fuzz.sh index 8a19da665eb..244eb83906b 100755 --- a/tools/oss-fuzz.sh +++ b/tools/oss-fuzz.sh @@ -67,7 +67,9 @@ df="$build/dns-fuzzing" git clone --depth 1 https://github.com/CZ-NIC/dns-fuzzing "$df" zip -jqr "$OUT/fuzz-dns-packet_seed_corpus.zip" "$df/packet" -install -Dt "$OUT/src/shared/" "$build"/src/shared/libsystemd-shared-*.so +install -Dt "$OUT/src/shared/" \ + "$build"/src/shared/libsystemd-shared-*.so \ + "$build"/src/core/libsystemd-core-*.so wget -O "$OUT/fuzz-json.dict" https://raw.githubusercontent.com/rc0r/afl-fuzz/master/dictionaries/json.dict