diff --git a/pkgs/build-support/setup-hooks/multiple-outputs.sh b/pkgs/build-support/setup-hooks/multiple-outputs.sh index 8a62c57dbd071..cf7b8b0a95366 100644 --- a/pkgs/build-support/setup-hooks/multiple-outputs.sh +++ b/pkgs/build-support/setup-hooks/multiple-outputs.sh @@ -2,6 +2,7 @@ preConfigureHooks+=(_multioutConfig) preFixupHooks+=(_multioutDocs) preFixupHooks+=(_multioutDevs) +preFixupHooks+=(_multioutStatics) postFixupHooks+=(_multioutPropagateDev) # _assignFirst varName otherVarNames* @@ -54,6 +55,10 @@ _overrideFirst outputInclude "$outputDev" # so-libs are often among the main things to keep, and so go to $out _overrideFirst outputLib "lib" "out" +# static library files shouldn't be installed adjacent to dynamic libs, since +# they are only ever used at build-time. Put them in $dev. +_overrideFirst outputStatic "static" "$outputDev" + _overrideFirst outputDoc "doc" "out" _overrideFirst outputDevdoc "devdoc" REMOVE # documentation for developers # man and info pages are small and often useful to distribute with binaries @@ -179,6 +184,25 @@ _multioutDevs() { done } +# Move static libraries to the desired outputs. +_multioutStatics() { + if [ "$(getAllOutputNames)" = "out" ] || [ -z "${moveToStatic-1}" ]; then return; fi; + + moveToOutput "lib/*.a" "${!outputStatic}" + + local as=`find "${!outputStatic}/lib" -name "*.a" -type f` + local acount=`echo -n "$as" | wc -l` + if [ $acount != 0 ]; then + # Some of *.a files are linker scripts where moving broke the paths. + local output + for output in $outputs; do + if [ "${!output}" = "${!outputStatic}" ]; then continue; fi + sed "/^GROUP/s|${!output}/lib/lib|${!outputStatic}/lib/lib|g" \ + -i $as + done + fi +} + # Make the "dev" propagate other outputs needed for development. _multioutPropagateDev() { if [ "$(getAllOutputNames)" = "out" ]; then return; fi; diff --git a/pkgs/development/libraries/glibc/default.nix b/pkgs/development/libraries/glibc/default.nix index 1c0c1b09e1542..e395e334cf6ac 100644 --- a/pkgs/development/libraries/glibc/default.nix +++ b/pkgs/development/libraries/glibc/default.nix @@ -163,6 +163,7 @@ in ''; separateDebugInfo = true; + moveToStatic = false; # Default $static output handling breaks things in this drv. passthru = (previousAttrs.passthru or {})