]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
build-sys: Add option to link systemctl statically
authorFelipe Sateler <fsateler@debian.org>
Tue, 22 May 2018 19:08:57 +0000 (15:08 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 31 May 2018 14:05:00 +0000 (16:05 +0200)
Systemctl is special because it is required for many tasks that may need to
be performed when the system is not fully configured and/or partially
broken:

1. Installing/Uninstalling services during OS installs and upgrades
2. Shutting down the system

Therefore reduce the number of dependencies that systemctl pulls in, by
not linking to systemd-shared. This brings a bit of resilience to
systemctl (and its aliases shutdown, reboot, etc), by linking against
less external libraries.

Because this extra resilience comes at a cost of approximately 580 KB
extra space, this is done behind a meson build option.

meson.build
meson_options.txt

index 484271ff1c0c236a515317c048cb7f39272fa268..18b4ace5b9744977e17c6c8888d10dd3e65288b4 100644 (file)
@@ -1708,9 +1708,19 @@ exe = executable('systemd-socket-activate', 'src/activate/activate.c',
                  install : true)
 public_programs += [exe]
 
+
+if get_option('link-systemctl-shared')
+        systemctl_link_with = [libshared]
+else
+        systemctl_link_with = [libsystemd_static,
+                               libshared_static,
+                               libjournal_client,
+                               libbasic_gcrypt]
+endif
+
 exe = executable('systemctl', 'src/systemctl/systemctl.c',
                  include_directories : includes,
-                 link_with : [libshared],
+                 link_with : systemctl_link_with,
                  dependencies : [threads,
                                  libcap,
                                  libselinux,
index 85d794b08be93e99d20f1278ba829b76e0eb0363..557d7843bcde98840397cc0a6c7bb4ad13b69685 100644 (file)
@@ -13,6 +13,8 @@ option('rootprefix', type : 'string',
        description : '''override the root prefix''')
 option('link-udev-shared', type : 'boolean',
        description : 'link systemd-udev and its helpers to libsystemd-shared.so')
+option('link-systemctl-shared', type: 'boolean',
+       description : 'link systemctl against libsystemd-shared.so')
 option('static-libsystemd', type : 'combo',
        choices : ['false', 'true', 'pic', 'no-pic'],
        description : '''install a static library for libsystemd''')