about summary refs log tree commit diff
path: root/nixpkgs/pkgs
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-30 18:26:37 +0000
committerAlyssa Ross <hi@alyssa.is>2020-11-27 13:27:24 +0000
commit95b17a0a3e7d1e71dd192b06844afcc33063ae44 (patch)
tree449fb0d5594886539eca7120eda045c32f443632 /nixpkgs/pkgs
parent156b690d84f41491bcbb6f90338e9d73b5f4be23 (diff)
downloadnixlib-95b17a0a3e7d1e71dd192b06844afcc33063ae44.tar
nixlib-95b17a0a3e7d1e71dd192b06844afcc33063ae44.tar.gz
nixlib-95b17a0a3e7d1e71dd192b06844afcc33063ae44.tar.bz2
nixlib-95b17a0a3e7d1e71dd192b06844afcc33063ae44.tar.lz
nixlib-95b17a0a3e7d1e71dd192b06844afcc33063ae44.tar.xz
nixlib-95b17a0a3e7d1e71dd192b06844afcc33063ae44.tar.zst
nixlib-95b17a0a3e7d1e71dd192b06844afcc33063ae44.zip
{bintools,cc}-wrapper: Ensure nix-support/*-flags files exist
This will unbreak firefox and a few other packages which try to grab
some of the libcxx flags.

(cherry picked from commit 704daf7a6e4e5f26c5b0ad67ed8bd1b2090aa8ed)
Diffstat (limited to 'nixpkgs/pkgs')
-rw-r--r--nixpkgs/pkgs/build-support/bintools-wrapper/default.nix25
-rw-r--r--nixpkgs/pkgs/build-support/cc-wrapper/default.nix29
2 files changed, 37 insertions, 17 deletions
diff --git a/nixpkgs/pkgs/build-support/bintools-wrapper/default.nix b/nixpkgs/pkgs/build-support/bintools-wrapper/default.nix
index 31373d6b2392..786f0f9c5983 100644
--- a/nixpkgs/pkgs/build-support/bintools-wrapper/default.nix
+++ b/nixpkgs/pkgs/build-support/bintools-wrapper/default.nix
@@ -204,7 +204,8 @@ stdenv.mkDerivation {
     ## General libc support
     ##
     optionalString (libc != null) (''
-      echo "-L${libc_lib}${libc.libdir or "/lib"}" > $out/nix-support/libc-ldflags
+      touch "$out/nix-support/libc-ldflags"
+      echo "-L${libc_lib}${libc.libdir or "/lib"}" >> $out/nix-support/libc-ldflags
 
       echo "${libc_lib}" > $out/nix-support/orig-libc
       echo "${libc_dev}" > $out/nix-support/orig-libc-dev
@@ -230,25 +231,23 @@ stdenv.mkDerivation {
         *) echo "Multiple dynamic linkers found for platform '${targetPlatform.config}'." >&2;;
       esac
 
-      if [ -n "''${dynamicLinker:-}" ]; then
+      if [ -n "''${dynamicLinker-}" ]; then
         echo $dynamicLinker > $out/nix-support/dynamic-linker
 
     '' + (if targetPlatform.isDarwin then ''
         printf "export LD_DYLD_PATH=%q\n" "$dynamicLinker" >> $out/nix-support/setup-hook
-    '' else ''
+      '' else ''
         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
-
-        local ldflagsBefore=(-dynamic-linker "$dynamicLinker")
+      ''
+      # The dynamic linker is passed in `ldflagsBefore' to allow
+      # explicit overrides of the dynamic linker by callers to ld
+      # (the *last* value counts, so ours should come first).
+      + ''
+        echo -dynamic-linker "$dynamicLinker" >> $out/nix-support/libc-ldflags-before
     '') + ''
       fi
-    ''
-    # The dynamic linker is passed in `ldflagsBefore' to allow
-    # explicit overrides of the dynamic linker by callers to ld
-    # (the *last* value counts, so ours should come first).
-    + ''
-      printWords "''${ldflagsBefore[@]}" > $out/nix-support/libc-ldflags-before
     '')
 
     # Ensure consistent LC_VERSION_MIN_MACOSX and remove LC_UUID.
@@ -306,6 +305,10 @@ stdenv.mkDerivation {
     ''
 
     + ''
+      for flags in "$out/nix-support"/*flags*; do
+        substituteInPlace "$flags" --replace $'\n' ' '
+      done
+
       substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh
       substituteAll ${./add-hardening.sh} $out/nix-support/add-hardening.sh
       substituteAll ${../wrapper-common/utils.bash} $out/nix-support/utils.bash
diff --git a/nixpkgs/pkgs/build-support/cc-wrapper/default.nix b/nixpkgs/pkgs/build-support/cc-wrapper/default.nix
index 159324e0205e..1fef3c459086 100644
--- a/nixpkgs/pkgs/build-support/cc-wrapper/default.nix
+++ b/nixpkgs/pkgs/build-support/cc-wrapper/default.nix
@@ -230,12 +230,19 @@ stdenv.mkDerivation {
   ];
 
   postFixup =
+    # Ensure flags files exists, as some other programs cat them. (That these
+    # are considered an exposed interface is a bit dubious, but fine for now.)
+    ''
+      touch "$out/nix-support/cc-cflags"
+      touch "$out/nix-support/cc-ldflags"
+    ''
+
     # Backwards compatability for packages expecting this file, e.g. with
     # `$NIX_CC/nix-support/dynamic-linker`.
     #
     # TODO(@Ericson2314): Remove this after stable release and force
     # everyone to refer to bintools-wrapper directly.
-    ''
+    + ''
       if [[ -f "$bintools/nix-support/dynamic-linker" ]]; then
         ln -s "$bintools/nix-support/dynamic-linker" "$out/nix-support"
       fi
@@ -278,6 +285,8 @@ stdenv.mkDerivation {
     # limits.h file in ../includes-fixed. To remedy the problem,
     # another -idirafter is necessary to add that directory again.
     + optionalString (libc != null) (''
+      touch "$out/nix-support/libc-cflags"
+      touch "$out/nix-support/libc-ldflags"
       echo "-B${libc_lib}${libc.libdir or "/lib/"}" >> $out/nix-support/libc-cflags
     '' + optionalString (!(cc.langD or false)) ''
       echo "-idirafter ${libc_dev}${libc.incdir or "/include"}" >> $out/nix-support/libc-cflags
@@ -294,7 +303,13 @@ stdenv.mkDerivation {
     ##
     ## General libc++ support
     ##
-    + optionalString (libcxx == null && cc ? gcc) ''
+
+    # We have a libc++ directly, we have one via "smuggled" GCC, or we have one
+    # bundled with the C compiler because it is GCC
+    + optionalString (libcxx != null || cc.gcc.langCC or false || (isGNU && cc.langCC or false)) ''
+      touch "$out/nix-support/libcxx-cxxflags"
+      touch "$out/nix-support/libcxx-ldflags"
+    '' + optionalString (libcxx == null && cc ? gcc) ''
       for dir in ${cc.gcc}/include/c++/*; do
         echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
       done
@@ -326,14 +341,16 @@ stdenv.mkDerivation {
       ccCFlags+=" -B${cc_solib}/lib"
 
     '' + optionalString cc.langAda or false ''
+      touch "$out/nix-support/gnat-cflags"
+      touch "$out/nix-support/gnat-ldflags"
       basePath=$(echo $cc/lib/*/*/*)
       ccCFlags+=" -B$basePath -I$basePath/adainclude"
       gnatCFlags="-I$basePath/adainclude -I$basePath/adalib"
 
-      echo "$gnatCFlags" > $out/nix-support/gnat-cflags
+      echo "$gnatCFlags" >> $out/nix-support/gnat-cflags
     '' + ''
-      echo "$ccLDFlags" > $out/nix-support/cc-ldflags
-      echo "$ccCFlags" > $out/nix-support/cc-cflags
+      echo "$ccLDFlags" >> $out/nix-support/cc-ldflags
+      echo "$ccCFlags" >> $out/nix-support/cc-cflags
     '' + optionalString (targetPlatform.isDarwin && (libcxx != null) && (cc.isClang or false)) ''
       echo " -L${libcxx}/lib" >> $out/nix-support/cc-ldflags
     ''
@@ -419,7 +436,7 @@ stdenv.mkDerivation {
     # There are a few tools (to name one libstdcxx5) which do not work
     # well with multi line flags, so make the flags single line again
     + ''
-      for flags in "$out/nix-support"/*flags; do
+      for flags in "$out/nix-support"/*flags*; do
         substituteInPlace "$flags" --replace $'\n' ' '
       done