On Thu, Feb 6, 2020 at 12:34 AM Felipe Sateler <fsate...@debian.org> wrote:
> > > On Mon, Feb 3, 2020 at 3:50 PM Felipe Sateler <fsate...@debian.org> wrote: > >> >> >> On Sun, Feb 2, 2020, 17:04 Zbigniew Jędrzejewski-Szmek <zbys...@in.waw.pl> >> wrote: >> >>> On Thu, Jan 30, 2020 at 11:51:48PM -0300, Felipe Sateler wrote: >>> > On Thu, Jan 30, 2020 at 6:40 PM Michael Biebl <bi...@debian.org> >>> wrote: >>> > >>> > > Hi Felipe >>> > > >>> > > Am 30.01.20 um 22:30 schrieb Felipe Sateler: >>> > > > >>> > > > >>> > > > On Thu, Jan 30, 2020 at 1:39 PM Michael Biebl <bi...@debian.org >>> > > > <mailto:bi...@debian.org>> wrote: >>> > > > >>> > > > Am 28.01.20 um 17:27 schrieb Ansgar: >>> > > > > On Tue, 2020-01-28 at 16:51 +0100, Michael Biebl wrote: >>> > > > >> Am 28.01.20 um 14:59 schrieb Ansgar: >>> > > > >>> I tried linking systemd-{sysusers,tmpfiles} statically >>> against >>> > > > >>> systemd's private library earlier this month. It >>> increases the >>> > > > >>> binaries size by ~100 kB (compared to Installed-Size: 14.2 >>> MB of >>> > > > >>> systemd that is just one percent). >>> > > > >> >>> > > > >> Is that 100K per binary? >>> > > > > >>> > > > > I checked my notes at it was 100 kB per binary: they are 212 >>> kB >>> > > larger >>> > > > > (sysusers 51 kB → 137 kB, tmpfiles 84 kB → 212 kB); I tested >>> with >>> > > > > systemd 243-8. >>> > > > > >>> > > > > It might be possible to make it a bit smaller if one was to >>> somehow >>> > > > > link libsystemd0 for functions available there >>> (libsystemd-shared >>> > > > > currently duplicates those). >>> > > > >>> > > > >>> > > > That is not possible. There is global state that is not to be >>> shared. >>> > > > See >>> https://github.com/systemd/systemd/pull/3516#issuecomment-227482524 >>> > > >>> > > What's your thought on how to solve this libsystemd-shared issue >>> should >>> > > we consider splitting out systemd-{sysusers,tmpfiles} >>> > > >>> > > - link statically (and carry a downstream patch for eternity) >>> > > - move libsystemd-shared to systemd-utils and risk the breakage that >>> can >>> > > result from a partial/aborted upgrade >>> > > - copy, instead of move, the binaries + libsystemd-shared and make >>> the >>> > > resulting systemd-utils package Conflict with systemd (instead of >>> having >>> > > systemd depend on systemd-utils) >>> > > - something else? >>> > > >>> > >>> > I tried linking statically the "can run without systemd-pid1 tools" >>> with >>> > the attached patch. >>> > >>> > Disk usage appears to increase by about 400 kb: >>> > % dpkg --info systemd_244.1-1_amd64.deb|grep Installed >>> > >>> > Installed-Size: 13908 >>> > % dpkg --info ../systemd_244-3_amd64.deb|grep Installed >>> > Installed-Size: 14319 >>> > >>> > Maybe upstream can be persuaded to merge something like this? >>> > >>> > -- >>> > >>> > Saludos, >>> > Felipe Sateler >>> >>> > diff --git a/meson.build b/meson.build >>> > index b8dff8cd94..39cef6b301 100644 >>> > --- a/meson.build >>> > +++ b/meson.build >>> > @@ -1493,6 +1493,29 @@ make_autosuspend_rules_py = >>> find_program('tools/make-autosuspend-rules.py') >>> > >>> > ############################################################ >>> > >>> > + >>> > +libutil = static_library( >>> > + 'util', >>> > + [ >>> > + 'src/shared/acl-util.c', >>> > + 'src/shared/enable-mempool.c', >>> > + 'src/shared/id128-print.c', >>> > + 'src/shared/pager.c', >>> > + 'src/shared/path-lookup.c', >>> > + 'src/shared/pretty-print.c', >>> > + 'src/shared/spawn-ask-password-agent.c', >>> > + 'src/shared/spawn-polkit-agent.c', >>> > + 'src/shared/specifier.c', >>> > + 'src/shared/sysctl-util.c', >>> > + 'src/shared/sysctl-util.h', >>> > + 'src/shared/tmpfile-util-label.c', >>> > + 'src/shared/uid-range.c', >>> > + 'src/shared/verbs.c', >>> > + ] + id128_sources, >>> > + link_with: [libbasic, libsystemd_static], >>> > + include_directories: includes >>> > +) >>> >>> Is creating a separate static library actually necessary? What would >>> the results be if those binaries were linked to the static version of >>> libshared that we already provide support for? I hope the compiler >>> would be able to drop any unused objects and achieve the same size, >>> without having to maintain yet another list of files. >>> >> >> I'd have to recheck, but that was my first idea and didn't pan out (at >> least with the flags we use for the debian package). >> > > It appears I messed up earlier. Indeed using libshared_static (plus > libbasic and libsystemd_static) does the job as well. > So, the attached patch implements this, but before submitting upstream I would like to hear from Michael to see if this makes sense for us. The "externally shippable" programs are: 1. systemd-tmpfiles: this might make sense to ship separately for use in containers and the like. 2. systemd-sysusers: same as tmpfiles. 3. systemd-sysctl: I'm unsure about this one. There is already procps sysctl that parses the same files, and I don't think it makes much sense for non-bootable envs. 4. systemd-path: I don't think anyone wants this if they are not running systemd as pid1 5. systemd-escape: This one is a bit more plausible, but I still think it doesn't make much sense. 6. systemd-id128: generating app-specific ids might be useful even without systemd as pid1. I thus implemented one option for each program. If Michael agrees with my analysis above, we could start with tmpfiles and sysusers, and add others if somebody asks for them. -- Saludos, Felipe Sateler
commit a66f359bfd6479da93aea1c5b0bbbf8c0f7f5dbf Author: Felipe Sateler <fsateler@gmail.com> Date: Thu Feb 20 08:55:44 2020 -0300 build-sys: enable static linking of externally-used programs If downstreams want to ship these utils for use without systemd (eg, for containers or other minimal systems), then they would have to have a copy of libshared. This complicates packaging since everything would have to be upgraded in lockstep. Not only that, but libshared links to most library dependencies of systemd, of which a container that only requires the programs needs very few. diff --git a/meson.build b/meson.build index 004f01521c..bd03735f24 100644 --- a/meson.build +++ b/meson.build @@ -1517,6 +1517,7 @@ make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py') ############################################################ + # binaries that have --help and are intended for use by humans, # usually, but not always, installed in /bin. public_programs = [] @@ -2433,7 +2434,7 @@ install_data('src/sleep/sleep.conf', exe = executable('systemd-sysctl', 'src/sysctl/sysctl.c', include_directories : includes, - link_with : [libshared], + link_with : get_option('link-sysctl-shared') ? [libshared] : [libsystemd_static, libshared_static, libbasic], install_rpath : rootlibexecdir, install : true, install_dir : rootlibexecdir) @@ -2466,7 +2467,7 @@ public_programs += exe exe = executable('systemd-escape', 'src/escape/escape.c', include_directories : includes, - link_with : [libshared], + link_with : get_option('link-escape-shared') ? [libshared] : [libsystemd_static, libshared_static, libbasic], install_rpath : rootlibexecdir, install : true, install_dir : rootbindir) @@ -2500,7 +2501,7 @@ executable('systemd-cgroups-agent', exe = executable('systemd-id128', 'src/id128/id128.c', include_directories : includes, - link_with : [libshared], + link_with : get_option('link-id128-shared') ? [libshared] : [libsystemd_static, libshared_static, libbasic], install_rpath : rootlibexecdir, install : true) public_programs += exe @@ -2508,7 +2509,7 @@ public_programs += exe exe = executable('systemd-path', 'src/path/path.c', include_directories : includes, - link_with : [libshared], + link_with : get_option('link-path-shared') ? [libshared] : [libsystemd_static, libshared_static, libbasic], install_rpath : rootlibexecdir, install : true) public_programs += exe @@ -2606,7 +2607,7 @@ if conf.get('ENABLE_SYSUSERS') == 1 exe = executable('systemd-sysusers', 'src/sysusers/sysusers.c', include_directories : includes, - link_with : [libshared], + link_with : get_option('link-sysusers-shared') ? [libshared] : [libsystemd_static, libshared_static, libbasic], install_rpath : rootlibexecdir, install : true, install_dir : rootbindir) @@ -2617,7 +2618,7 @@ if conf.get('ENABLE_TMPFILES') == 1 exe = executable('systemd-tmpfiles', 'src/tmpfiles/tmpfiles.c', include_directories : includes, - link_with : [libshared], + link_with : get_option('link-tmpfiles-shared') ? [libshared] : [libsystemd_static, libshared_static, libbasic], dependencies : [libacl], install_rpath : rootlibexecdir, install : true, diff --git a/meson_options.txt b/meson_options.txt index 8a1143a7ec..9bc1351088 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -16,6 +16,18 @@ 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('link-sysusers-shared', type: 'boolean', + description : 'link systemd-sysusers against libsystemd-shared.so') +option('link-sysctl-shared', type: 'boolean', + description : 'link systemd-sysctl against libsystemd-shared.so') +option('link-escape-shared', type: 'boolean', + description : 'link systemd-escape against libsystemd-shared.so') +option('link-id128-shared', type: 'boolean', + description : 'link systemd-id128 against libsystemd-shared.so') +option('link-path-shared', type: 'boolean', + description : 'link systemd-path against libsystemd-shared.so') +option('link-tmpfiles-shared', type: 'boolean', + description : 'link systemd-tmpfiles against libsystemd-shared.so') option('static-libsystemd', type : 'combo', choices : ['false', 'true', 'pic', 'no-pic'], description : '''install a static library for libsystemd''')