about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2015-04-18 15:46:00 +0200
committerVladimír Čunát <vcunat@gmail.com>2015-04-18 19:30:28 +0200
commitd484c392aaa4e17f48bd09bcb2e41030f76a920a (patch)
treef75d3dbbfffa26a1d9827d2c938caac1821876a7 /pkgs
parentbf414c9d4f892fd4e392a5f42016b57e84402a8b (diff)
downloadnixlib-d484c392aaa4e17f48bd09bcb2e41030f76a920a.tar
nixlib-d484c392aaa4e17f48bd09bcb2e41030f76a920a.tar.gz
nixlib-d484c392aaa4e17f48bd09bcb2e41030f76a920a.tar.bz2
nixlib-d484c392aaa4e17f48bd09bcb2e41030f76a920a.tar.lz
nixlib-d484c392aaa4e17f48bd09bcb2e41030f76a920a.tar.xz
nixlib-d484c392aaa4e17f48bd09bcb2e41030f76a920a.tar.zst
nixlib-d484c392aaa4e17f48bd09bcb2e41030f76a920a.zip
stdenv multiple-outputs: change propagation rules
Now development stuff is propagated from the first output,
and userEnvPkgs from the one with binaries.

Also don't move *.la files (yet). It causes problems, and they're small.
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/build-support/cc-wrapper/default.nix15
-rw-r--r--pkgs/build-support/setup-hooks/multiple-outputs.sh44
-rw-r--r--pkgs/development/interpreters/perl/5.20/default.nix4
-rw-r--r--pkgs/development/libraries/glibc/common.nix2
-rw-r--r--pkgs/stdenv/generic/setup.sh26
5 files changed, 54 insertions, 37 deletions
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 <limits.h>" 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}"
+
+    # don't move libtool files yet
+    #_moveToOutput "lib/*.la" "${!outputDev}"
 
-    echo "Patching *.pc includedir to output ${!outputInclude}"
-    for f in "${!outputDev}"/lib/pkgconfig/*.pc; do
+    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"
+        mkdir -p "${!outputDev}/nix-support"
+        echo "$propagatedNativeBuildInputs" > "${!outputDev}/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"
+    if [ -n "$setupHook" ]; then
+        mkdir -p "${!outputDev}/nix-support"
+        substituteAll "$setupHook" "${!outputDev}/nix-support/setup-hook"
     fi
 
-    if [ -n "$setupHook" ]; then
-        mkdir -p "$prOut/nix-support"
-        substituteAll "$setupHook" "$prOut/nix-support/setup-hook"
+    # 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