diff options
author | Anthony Cowley <acowley@gmail.com> | 2015-12-17 17:02:40 -0500 |
---|---|---|
committer | Anthony Cowley <acowley@gmail.com> | 2016-01-19 17:47:11 -0500 |
commit | d96893647de5c519c458c1254f043f2d67d9b29c (patch) | |
tree | f44bc4c05735c8587fa1f450a061853a18b679e3 /pkgs/build-support/cc-wrapper | |
parent | 322a69137754aecf8ce9860b55d7c2bedcc7d873 (diff) | |
download | nixlib-d96893647de5c519c458c1254f043f2d67d9b29c.tar nixlib-d96893647de5c519c458c1254f043f2d67d9b29c.tar.gz nixlib-d96893647de5c519c458c1254f043f2d67d9b29c.tar.bz2 nixlib-d96893647de5c519c458c1254f043f2d67d9b29c.tar.lz nixlib-d96893647de5c519c458c1254f043f2d67d9b29c.tar.xz nixlib-d96893647de5c519c458c1254f043f2d67d9b29c.tar.zst nixlib-d96893647de5c519c458c1254f043f2d67d9b29c.zip |
cc-wrapper: fix on darwin
The ld-wrapper.sh script calls `readlink` in some circumstances. We need to ensure that this is the `readlink` from the `coreutils` package so that flag support is as expected. This is accomplished by explicitly setting PATH at the top of each shell script. Without doing this, the following happens with a trivial `main.c`: ``` nix-env -f "<nixpkgs>" -iA pkgs.clang $ clang main.c -L /nix/../nix/store/2ankvagznq062x1gifpxwkk7fp3xwy63-xnu-2422.115.4/Library -o a.out readlink: illegal option -- f usage: readlink [-n] [file ...] ``` The key element is the `..` in the path supplied to the linker via a `-L` flag. With this patch, the above invocation works correctly on darwin, whose native `/usr/bin/readlink` does not support the `-f` flag. The explicit path also ensures that the `grep` called by `cc-wrapper.sh` is the one from Nix. Fixes #6447
Diffstat (limited to 'pkgs/build-support/cc-wrapper')
-rw-r--r-- | pkgs/build-support/cc-wrapper/cc-wrapper.sh | 5 | ||||
-rw-r--r-- | pkgs/build-support/cc-wrapper/default.nix | 13 | ||||
-rw-r--r-- | pkgs/build-support/cc-wrapper/gnat-wrapper.sh | 5 | ||||
-rw-r--r-- | pkgs/build-support/cc-wrapper/ld-wrapper.sh | 5 |
4 files changed, 23 insertions, 5 deletions
diff --git a/pkgs/build-support/cc-wrapper/cc-wrapper.sh b/pkgs/build-support/cc-wrapper/cc-wrapper.sh index 5bd59f8c5850..f7541b15a828 100644 --- a/pkgs/build-support/cc-wrapper/cc-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/cc-wrapper.sh @@ -1,4 +1,8 @@ #! @shell@ -e +path_backup=$PATH +if [ -n "@coreutils@" ]; then + PATH="@coreutils@/bin:@gnugrep@/bin" +fi if [ -n "$NIX_CC_WRAPPER_START_HOOK" ]; then source "$NIX_CC_WRAPPER_START_HOOK" @@ -141,4 +145,5 @@ if [ -n "$NIX_CC_WRAPPER_EXEC_HOOK" ]; then source "$NIX_CC_WRAPPER_EXEC_HOOK" fi +PATH=$path_backup exec @prog@ ${extraBefore[@]} "${params[@]}" "${extraAfter[@]}" diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index bea7e07a2029..110f51891417 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -9,13 +9,14 @@ , cc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? stdenv.shell , zlib ? null, extraPackages ? [], extraBuildCommands ? "" , dyld ? null # TODO: should this be a setup-hook on dyld? -, isGNU ? false, isClang ? cc.isClang or false +, isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null }: with stdenv.lib; assert nativeTools -> nativePrefix != ""; -assert !nativeTools -> cc != null && binutils != null && coreutils != null; +assert !nativeTools -> + cc != null && binutils != null && coreutils != null && gnugrep != null; assert !nativeLibc -> libc != null; # For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper. @@ -37,9 +38,11 @@ stdenv.mkDerivation { inherit cc shell; libc = if nativeLibc then null else libc; - binutils = if nativeTools then null else binutils; - # The wrapper scripts use 'cat', so we may need coreutils. - coreutils = if nativeTools then null else coreutils; + binutils = if nativeTools then "" else binutils; + # The wrapper scripts use 'cat' and 'grep', so we may need coreutils + # and gnugrep. + coreutils = if nativeTools then "" else coreutils; + gnugrep = if nativeTools then "" else gnugrep; passthru = { inherit nativeTools nativeLibc nativePrefix isGNU isClang; }; diff --git a/pkgs/build-support/cc-wrapper/gnat-wrapper.sh b/pkgs/build-support/cc-wrapper/gnat-wrapper.sh index 3514ccd67325..603275e4e695 100644 --- a/pkgs/build-support/cc-wrapper/gnat-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/gnat-wrapper.sh @@ -1,4 +1,8 @@ #! @shell@ -e +path_backup=$PATH +if [ -n "@coreutils@" ]; then + PATH="@coreutils@/bin" +fi if [ -n "$NIX_GNAT_WRAPPER_START_HOOK" ]; then source "$NIX_GNAT_WRAPPER_START_HOOK" @@ -100,4 +104,5 @@ if [ -n "$NIX_GNAT_WRAPPER_EXEC_HOOK" ]; then source "$NIX_GNAT_WRAPPER_EXEC_HOOK" fi +PATH=$path_backup exec @prog@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} diff --git a/pkgs/build-support/cc-wrapper/ld-wrapper.sh b/pkgs/build-support/cc-wrapper/ld-wrapper.sh index 30c531b76479..a7ed2f364cdd 100644 --- a/pkgs/build-support/cc-wrapper/ld-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/ld-wrapper.sh @@ -1,4 +1,8 @@ #! @shell@ -e +path_backup=$PATH +if [ -n "@coreutils@" ]; then + PATH="@coreutils@/bin" +fi if [ -n "$NIX_LD_WRAPPER_START_HOOK" ]; then source "$NIX_LD_WRAPPER_START_HOOK" @@ -163,4 +167,5 @@ if [ -n "$NIX_LD_WRAPPER_EXEC_HOOK" ]; then source "$NIX_LD_WRAPPER_EXEC_HOOK" fi +PATH=$path_backup exec @prog@ ${extraBefore[@]} "${params[@]}" ${extra[@]} |