systemd: remove lib output

systemd 246 started baking in some strings into $lib/lib/libsystemd.so
which points back to $out.

It might be desirable to not have these strings in there, but instead
have systemd ask the running manager for the really active paths via
IPC, or patch in some more mutable paths (like /run/current-system/…) -
but as long as it is as it is, we should probably should just stop
producing the `lib` output for now.

This does increase the runtime closure for installations not pulling in
systemd.out, or linking against multiple libsystemd's, but doesn't
increase the runtime closure for NixOS itself, as it needs systemd
anyways, and doesn't link against multiple variants of it.

We can also remove the aarch64-specific $out/lib/systemd/catalog hack,
and revive it at a later time if the `lib` output is reintroduced.
This commit is contained in:
Florian Klink 2020-08-12 18:34:09 +02:00
parent 7e189c56a1
commit b68bddfbda

View File

@ -77,7 +77,7 @@ in stdenv.mkDerivation {
"find_program('${stdenv.cc.bintools.targetPrefix}objcopy'"
'';
outputs = [ "out" "lib" "man" "dev" ];
outputs = [ "out" "man" "dev" ];
nativeBuildInputs =
[ pkgconfig intltool gperf libxslt gettext docbook_xsl docbook_xml_dtd_42 docbook_xml_dtd_45
@ -107,7 +107,6 @@ in stdenv.mkDerivation {
"-Ddbussystemservicedir=${placeholder "out"}/share/dbus-1/system-services"
"-Dpamconfdir=${placeholder "out"}/etc/pam.d"
"-Drootprefix=${placeholder "out"}"
"-Drootlibdir=${placeholder "lib"}/lib"
"-Dpkgconfiglibdir=${placeholder "dev"}/lib/pkgconfig"
"-Dpkgconfigdatadir=${placeholder "dev"}/share/pkgconfig"
"-Dloadkeys-path=${kbd}/bin/loadkeys"
@ -276,38 +275,10 @@ in stdenv.mkDerivation {
# "kernel-install" shouldn't be used on NixOS.
find $out -name "*kernel-install*" -exec rm {} \;
# Keep only libudev and libsystemd in the lib output.
mkdir -p $out/lib
mv $lib/lib/security $lib/lib/libnss* $out/lib/
''; # */
enableParallelBuilding = true;
# On aarch64 we "leak" a reference to $out/lib/systemd/catalog in the lib
# output. The result of that is a dependency cycle between $out and $lib.
# Thus nix (rightfully) marks the build as failed. That reference originates
# from an array of strings (catalog_file_dirs) in systemd
# (src/src/journal/catalog.{c,h}). The only consumer (as of v242) of the
# symbol is the main function of journalctl. Still libsystemd.so contains
# the VALUE but not the symbol. Systemd seems to be properly using function
# & data sections together with the linker flags to garbage collect unused
# sections (-Wl,--gc-sections). For unknown reasons those flags do not
# eliminate the unused string constants, in this case on aarch64-linux. The
# hacky way is to just remove the reference after we finished compiling.
# Since it can not be used (there is no symbol to actually refer to it) there
# should not be any harm. It is a bit odd and I really do not like starting
# these kind of hacks but there doesn't seem to be a straight forward way at
# this point in time.
# The reference will be replaced by the same reference the usual nukeRefs
# tooling uses. The standard tooling can not / should not be uesd since it
# is a bit too excessive and could potentially do us some (more) harm.
postFixup = ''
nukedRef=$(echo $out | sed -e "s,$NIX_STORE/[^-]*-\(.*\),$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-\1,")
cat $lib/lib/libsystemd.so | perl -pe "s|$out/lib/systemd/catalog|$nukedRef/lib/systemd/catalog|" > $lib/lib/libsystemd.so.tmp
mv $lib/lib/libsystemd.so.tmp $(readlink -f $lib/lib/libsystemd.so)
'';
# The interface version prevents NixOS from switching to an
# incompatible systemd at runtime. (Switching across reboots is
# fine, of course.) It should be increased whenever systemd changes