diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-06-30 18:26:37 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-06-30 18:26:37 +0000 |
commit | 704daf7a6e4e5f26c5b0ad67ed8bd1b2090aa8ed (patch) | |
tree | 87dbcc37b9d49a2b2c61e961fa41d79cb05b8808 /pkgs/build-support | |
parent | 1085403acdbaa7337d6074074f69ec6698226474 (diff) |
{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.
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/bintools-wrapper/default.nix | 25 | ||||
-rw-r--r-- | pkgs/build-support/cc-wrapper/default.nix | 29 |
2 files changed, 37 insertions, 17 deletions
diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix index 31373d6b23925..786f0f9c5983f 100644 --- a/pkgs/build-support/bintools-wrapper/default.nix +++ b/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/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 159324e0205ee..1fef3c4590862 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/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 |