X Tutup
Skip to content

Commit 4287c85

Browse files
keszybzyuwata
authored andcommitted
meson: create new libsystemd-core.so private shared library
The scheme is very similar to libsystemd-shared.so: instead of building a static library, we build a shared library from the same objects and link the two users to it. Both systemd and systemd-analyze consist mostly of the fairly big code in libcore, so we save a bit on the installation: (-0g, no strip) -rwxr-xr-x 5238864 Dec 14 12:52 /var/tmp/inst1/usr/lib/systemd/systemd -rwxr-xr-x 5399600 Dec 14 12:52 /var/tmp/inst1/usr/bin/systemd-analyze -rwxr-xr-x 244912 Dec 14 13:17 /var/tmp/inst2/usr/lib/systemd/systemd -rwxr-xr-x 461224 Dec 14 13:17 /var/tmp/inst2/usr/bin/systemd-analyze -rwxr-xr-x 5271568 Dec 14 13:17 /var/tmp/inst2/usr/lib/systemd/libsystemd-core-250.so (-0g, strip) -rwxr-xr-x 2522080 Dec 14 13:19 /var/tmp/inst1/usr/lib/systemd/systemd -rwxr-xr-x 2604160 Dec 14 13:19 /var/tmp/inst1/usr/bin/systemd-analyze -rwxr-xr-x 113304 Dec 14 13:19 /var/tmp/inst2/usr/lib/systemd/systemd -rwxr-xr-x 207656 Dec 14 13:19 /var/tmp/inst2/usr/bin/systemd-analyze -rwxr-xr-x 2648520 Dec 14 13:19 /var/tmp/inst2/usr/lib/systemd/libsystemd-core-250.so So for systemd itself we grow a bit (2522080 → 2648520+113304=2761824), but overall we save. The most is saved on all the test files that link to libcore, if they are installed, because there's 15 of them: $ du -s /var/tmp/inst? 220096 /var/tmp/inst1 122960 /var/tmp/inst2 I also considered making systemd-analyze a symlink to /usr/lib/systemd/systemd and turning systemd into a multicall binary. We did something like this with udevd and udevadm. But that solution doesn't fit well in this case. systemd-analyze has a bunch of functionality that is not used in systemd, so the systemd binary would need to grow quite a bit. And we're likely to add new types of verification or introspection features in analyze, and this baggage would only grow. In addition, there are the test binaries which also benefit from this.
1 parent 2588920 commit 4287c85

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

meson.build

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,12 +2021,7 @@ dbus_programs += executable(
20212021
link_with : [libcore,
20222022
libshared],
20232023
dependencies : [versiondep,
2024-
threads,
2025-
librt,
2026-
libseccomp,
2027-
libselinux,
2028-
libmount,
2029-
libblkid],
2024+
libseccomp],
20302025
install_rpath : rootlibexecdir,
20312026
install : true,
20322027
install_dir : rootlibexecdir)
@@ -2042,12 +2037,7 @@ public_programs += executable(
20422037
link_with : [libcore,
20432038
libshared],
20442039
dependencies : [versiondep,
2045-
threads,
2046-
librt,
2047-
libseccomp,
2048-
libselinux,
2049-
libmount,
2050-
libblkid],
2040+
libseccomp],
20512041
install_rpath : rootlibexecdir,
20522042
install : conf.get('ENABLE_ANALYZE'))
20532043

src/core/meson.build

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,18 @@ load_fragment_gperf_nulstr_c = custom_target(
167167
command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
168168
capture : true)
169169

170-
libcore = static_library(
171-
'core',
170+
libcore_name = 'systemd-core-@0@'.format(meson.project_version())
171+
172+
libcore = shared_library(
173+
libcore_name,
172174
libcore_sources,
173175
load_fragment_gperf_c,
174176
load_fragment_gperf_nulstr_c,
175177
include_directories : includes,
178+
c_args : ['-fvisibility=default'],
179+
link_args : ['-shared',
180+
'-Wl,--version-script=' + libshared_sym_path],
181+
link_with : libshared,
176182
dependencies : [versiondep,
177183
threads,
178184
libdl,
@@ -184,8 +190,10 @@ libcore = static_library(
184190
libapparmor,
185191
libselinux,
186192
libmount,
193+
libblkid,
187194
libacl],
188-
build_by_default : false)
195+
install : true,
196+
install_dir : rootlibexecdir)
189197

190198
core_includes = [includes, include_directories('.')]
191199

src/shared/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,13 +465,13 @@ libshared_static = static_library(
465465
libshared = shared_library(
466466
libshared_name,
467467
include_directories : includes,
468+
c_args : ['-fvisibility=default'],
468469
link_args : ['-shared',
469470
'-Wl,--version-script=' + libshared_sym_path],
470471
link_whole : [libshared_static,
471472
libbasic,
472473
libbasic_gcrypt,
473474
libsystemd_static],
474-
c_args : ['-fvisibility=default'],
475475
dependencies : libshared_deps,
476476
install : true,
477477
install_dir : rootlibexecdir)

src/test/meson.build

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,8 @@ tests += [
419419
libmount,
420420
libxz,
421421
liblz4,
422-
libblkid],
422+
libblkid,
423+
libselinux],
423424
[core_includes, journal_includes, udev_includes]],
424425

425426
[['src/test/test-prioq.c']],

tools/oss-fuzz.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ df="$build/dns-fuzzing"
6767
git clone --depth 1 https://github.com/CZ-NIC/dns-fuzzing "$df"
6868
zip -jqr "$OUT/fuzz-dns-packet_seed_corpus.zip" "$df/packet"
6969

70-
install -Dt "$OUT/src/shared/" "$build"/src/shared/libsystemd-shared-*.so
70+
install -Dt "$OUT/src/shared/" \
71+
"$build"/src/shared/libsystemd-shared-*.so \
72+
"$build"/src/core/libsystemd-core-*.so
7173

7274
wget -O "$OUT/fuzz-json.dict" https://raw.githubusercontent.com/rc0r/afl-fuzz/master/dictionaries/json.dict
7375

0 commit comments

Comments
 (0)
X Tutup