diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index c26cac24b2f8..a60165d5a954 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -28,6 +28,7 @@ let libc_bin = if nativeLibc then null else libc.bin or libc; libc_dev = if nativeLibc then null else libc.dev or libc; + libc_lib = if nativeLibc then null else libc.out or libc; binutils_bin = if nativeTools then null else binutils.bin or binutils; # The wrapper scripts use 'cat', so we may need coreutils. coreutils_bin = if nativeTools then null else coreutils.bin or coreutils; @@ -40,7 +41,7 @@ stdenv.mkDerivation { preferLocalBuild = true; - inherit cc shell libc_bin libc_dev binutils_bin coreutils_bin; + inherit cc shell libc_bin libc_dev libc_lib binutils_bin coreutils_bin; passthru = { inherit libc nativeTools nativeLibc nativePrefix; }; @@ -58,11 +59,11 @@ stdenv.mkDerivation { '' + optionalString (!nativeLibc) (if (!stdenv.isDarwin) then '' - dynamicLinker="${libc}/lib/$dynamicLinker" + dynamicLinker="${libc_lib}/lib/$dynamicLinker" echo $dynamicLinker > $out/nix-support/dynamic-linker - if [ -e ${libc}/lib/32/ld-linux.so.2 ]; then - echo ${libc}/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32 + if [ -e ${libc_lib}/lib/32/ld-linux.so.2 ]; then + echo ${libc_lib}/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32 fi # The dynamic linker is passed in `ldflagsBefore' to allow @@ -87,11 +88,11 @@ stdenv.mkDerivation { # compile, because it uses "#include_next " to find the # limits.h file in ../includes-fixed. To remedy the problem, # another -idirafter is necessary to add that directory again. - echo "-B${libc}/lib/ -idirafter ${libc_dev}/include -idirafter $cc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags + echo "-B${libc_lib}/lib/ -idirafter ${libc_dev}/include -idirafter $cc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags - echo "-L${libc}/lib" > $out/nix-support/libc-ldflags + echo "-L${libc_lib}/lib" > $out/nix-support/libc-ldflags - echo "${libc}" > $out/nix-support/orig-libc + echo "${libc_lib}" > $out/nix-support/orig-libc '' + (if nativeTools then '' diff --git a/pkgs/build-support/setup-hooks/multiple-outputs.sh b/pkgs/build-support/setup-hooks/multiple-outputs.sh index 3ab77683a41d..f621d4577b43 100644 --- a/pkgs/build-support/setup-hooks/multiple-outputs.sh +++ b/pkgs/build-support/setup-hooks/multiple-outputs.sh @@ -39,9 +39,6 @@ _overrideFirst outputDoc "doc" "out" _overrideFirst outputMan "man" "doc" "$outputBin" _overrideFirst outputInfo "info" "doc" "$outputMan" -# Make stdenv put propagated*BuildInputs into $outputDev instead of $out -propagateIntoOutput="${!outputDev}" - # Add standard flags to put files into the desired outputs. _multioutConfig() { @@ -67,6 +64,7 @@ NIX_NO_SELF_RPATH=1 # Move subpaths that match pattern $1 from under any output/ to the $2 output/ +# Beware: only * ? [..] patterns are accepted. _moveToOutput() { local patt="$1" local dstOut="$2" @@ -108,30 +106,46 @@ _multioutDocs() { # Move development-only stuff to the desired outputs. _multioutDevs() { if [ "$outputs" = "out" ] || [ -z "${moveToDev-1}" ]; then return; fi; - echo "Looking for development-only stuff to move between outputs" + echo "Looking for development-only stuff to move to $outputDev" _moveToOutput include "${!outputInclude}" _moveToOutput lib/pkgconfig "${!outputDev}" - _moveToOutput "lib/*.la" "${!outputDev}" + _moveToOutput share/pkgconfig "${!outputDev}" - echo "Patching *.pc includedir to output ${!outputInclude}" - for f in "${!outputDev}"/lib/pkgconfig/*.pc; do + # don't move libtool files yet + #_moveToOutput "lib/*.la" "${!outputDev}" + + for f in "${!outputDev}"/{lib,share}/pkgconfig/*.pc; do + echo "Patching '$f' includedir to output ${!outputInclude}" sed -i "/^includedir=/s,=\${prefix},=${!outputInclude}," "$f" done } -# Make ${!outputDev} propagate other outputs needed for development +# Make the first output (typically "dev") propagate other outputs needed for development. +# Take the first, because that's what one gets when putting the package into buildInputs. # Note: during the build, probably only the "native" development packages are useful. # With current cross-building setup, all packages are "native" if not cross-building. _multioutPropagateDev() { if [ "$outputs" = "out" ]; then return; fi; - if [ "${!outputInclude}" != "$propagateIntoOutput" ]; then - mkdir -p "$propagateIntoOutput"/nix-support - echo -n " ${!outputInclude}" >> "$propagateIntoOutput"/nix-support/propagated-native-build-inputs - fi - if [ "${!outputLib}" != "$propagateIntoOutput" ]; then - mkdir -p "$propagateIntoOutput"/nix-support - echo -n " ${!outputLib}" >> "$propagateIntoOutput"/nix-support/propagated-native-build-inputs + local outputFirst + for outputFirst in $outputs; do + break + done + + # Default value: propagate binaries, includes and libraries + if [[ ! -v "$propagatedOutputs" ]]; then + local po_dirty="$outputBin $outputInclude $outputLib" + propagatedOutputs=`echo "$po_dirty" \ + | tr -s ' ' '\n' | grep -v -F "$outputFirst" \ + | sort -u | tr '\n' ' ' ` + + elif [ -z "$propagatedOutputs" ]; then + return # variable was explicitly set to empty fi + + mkdir -p "${!outputFirst}"/nix-support + for output in $propagatedOutputs; do + echo -n " ${!output}" >> "${!outputFirst}"/nix-support/propagated-native-build-inputs + done } diff --git a/pkgs/development/interpreters/perl/5.20/default.nix b/pkgs/development/interpreters/perl/5.20/default.nix index 0ad955d03630..cafbe5141c16 100644 --- a/pkgs/development/interpreters/perl/5.20/default.nix +++ b/pkgs/development/interpreters/perl/5.20/default.nix @@ -46,8 +46,8 @@ stdenv.mkDerivation rec { "-Uinstallusrbinperl" "-Dinstallstyle=lib/perl5" "-Duseshrplib" - "-Dlocincpth=${libc}/include" - "-Dloclibpth=${libc}/lib" + "-Dlocincpth=${libc.dev or libc}/include" + "-Dloclibpth=${libc.out or libc}/lib" ] ++ optional enableThreading "-Dusethreads"; diff --git a/pkgs/development/libraries/glibc/common.nix b/pkgs/development/libraries/glibc/common.nix index 4bff795ba5f2..d5caba68903e 100644 --- a/pkgs/development/libraries/glibc/common.nix +++ b/pkgs/development/libraries/glibc/common.nix @@ -119,7 +119,7 @@ stdenv.mkDerivation ({ installFlags = [ "sysconfdir=$(out)/etc" ]; - outputs = [ "out" "dev" "bin" "static" ]; + outputs = [ "dev" "out" "bin" "static" ]; buildInputs = [ ] ++ stdenv.lib.optionals (cross != null) [ gccCross ] diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index b5d31e09153a..1011c4c53480 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -712,27 +712,29 @@ fixupPhase() { prefix=${!output} runHook fixupOutput done - # Multiple-output derivations mostly choose $dev instead of $out - local prOut="${propagateIntoOutput:-$out}" + + # Propagate build inputs and setup hook into the development output. if [ -n "$propagatedBuildInputs" ]; then - mkdir -p "$prOut/nix-support" - echo "$propagatedBuildInputs" > "$prOut/nix-support/propagated-build-inputs" + mkdir -p "${!outputDev}/nix-support" + echo "$propagatedBuildInputs" > "${!outputDev}/nix-support/propagated-build-inputs" fi if [ -n "$propagatedNativeBuildInputs" ]; then - mkdir -p "$prOut/nix-support" - echo "$propagatedNativeBuildInputs" > "$prOut/nix-support/propagated-native-build-inputs" - fi - - if [ -n "$propagatedUserEnvPkgs" ]; then - mkdir -p "$prOut/nix-support" - echo "$propagatedUserEnvPkgs" > "$prOut/nix-support/propagated-user-env-packages" + mkdir -p "${!outputDev}/nix-support" + echo "$propagatedNativeBuildInputs" > "${!outputDev}/nix-support/propagated-native-build-inputs" fi if [ -n "$setupHook" ]; then - mkdir -p "$prOut/nix-support" - substituteAll "$setupHook" "$prOut/nix-support/setup-hook" + mkdir -p "${!outputDev}/nix-support" + substituteAll "$setupHook" "${!outputDev}/nix-support/setup-hook" + fi + + # Propagate user-env packages into the output with binaries, TODO? + + if [ -n "$propagatedUserEnvPkgs" ]; then + mkdir -p "${!outputBin}/nix-support" + echo "$propagatedUserEnvPkgs" > "${!outputBin}/nix-support/propagated-user-env-packages" fi runHook postFixup