path: root/src/core
diff options
authorZbigniew Jędrzejewski-Szmek <>2018-04-25 13:47:18 +0200
committerSven Eden <>2018-08-24 16:47:08 +0200
commitd4db8b6ddb34e6b657f45ba50cbd2d660d6401d5 (patch)
treedf573b8f09be02aae53572558aed09a5dfcbdbdd /src/core
parentf9c0768c897d0604e032962fbfd372de0c8a9735 (diff)
meson: do not link libsystemd_static into libcore (#8813)
(or in terms of the names of the actual files on disk, do not link libsystemd-shared-238.a into libcore.a). libsystemd_static is linked into libsystemd_shared, which in turn means that anything that links to libcore and libsystemd_shared will get libsystemd_static twice: $ cc -o systemd 'systemd@exe/src_core_main.c.o' -Wl,--no-undefined -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -pie -DVALGRIND -Wl,--start-group src/core/libcore.a src/shared/libsystemd-shared-238.a src/shared/ -pthread -lrt -lseccomp -lselinux -lmount -lblkid -Wl,--end-group -lseccomp -lpam -L/lib64 -laudit -lkmod -lmount -lrt -lcap -lacl -lcryptsetup -lgcrypt -lip4tc -lip6tc -lseccomp -lselinux -lidn -llzma -llz4 -lblkid '-Wl,-rpath,$ORIGIN/src/shared' -Wl,-rpath-link,/home/zbyszek/src/systemd/build/src/shared This propagation of the dependency seems correct (in the sense that meson is doing the expected thing based on the given configuration). Linking was done this way in the original meson conversion. I was probably trying to get everything to compile and link, I'm not sure why this particular choice was made. In the meantime, meson has gotten better at propagating dependencies, so it's possible that this had slightly different effect in the original conversion, but I did not verify this. Either way, I think we should drop this. With the patch: $ cc -o systemd 'systemd@exe/src_core_main.c.o' -Wl,--no-undefined -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -pie -DVALGRIND -Wl,--start-group src/core/libcore.a src/shared/ -pthread -lrt -lseccomp -lselinux -lmount -Wl,--end-group -lblkid -lrt -lseccomp -lpam -L/lib64 -laudit -lkmod -lselinux -lmount '-Wl,-rpath,$ORIGIN/src/shared' -Wl,-rpath-link,/home/zbyszek/src/systemd/build/src/shared This is more correct because we're not linking the same code twice. With the patch, libystemd_static is used in exactly four places: - src/shared/ - src/udev/ - - test-bus-error (compared to a bunch more executables before, including systemd, systemd-analyze, test-hostname, test-ns, etc.) Size savings are also noticable: $ size /var/tmp/inst?/usr/lib/systemd/ text data bss dec hex filename 2397826 578488 15920 2992234 2da86a /var/tmp/inst1/usr/lib/systemd/ 2397826 578488 15920 2992234 2da86a /var/tmp/inst2/usr/lib/systemd/ $ size /var/tmp/inst?/usr/lib/systemd/systemd text data bss dec hex filename 1858790 261688 9320 2129798 207f86 /var/tmp/inst1/usr/lib/systemd/systemd 1556358 258704 8072 1823134 1bd19e /var/tmp/inst2/usr/lib/systemd/systemd $ du -s /var/tmp/inst? 52216 /var/tmp/inst1 50844 /var/tmp/inst2 might be related.
Diffstat (limited to 'src/core')
1 files changed, 2 insertions, 1 deletions
diff --git a/src/core/ b/src/core/
index 70941d14d..bfad33b48 100644
--- a/src/core/
+++ b/src/core/
@@ -160,13 +160,14 @@ libcore_la_sources = files('''
# load_fragment_gperf_c,
# load_fragment_gperf_nulstr_c,
# include_directories : includes,
-# link_with : [libshared_static],
# dependencies : [threads,
+# librt,
# libseccomp,
# libpam,
# libaudit,
# libkmod,
# libapparmor,
+# libselinux,
# libmount])
# systemd_sources = files('main.c')