mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 08:53:21 +00:00
cc-wrapper: Always export environment variables for binutils
Before, this only happened when cross compiling.
This commit is contained in:
parent
aaaa470ff8
commit
093cc00cdd
@ -71,22 +71,6 @@ let
|
||||
-e 's^addCVars^addCVars${_infixSalt}^g' \
|
||||
-e 's^\[ -z "\$crossConfig" \]^\[\[ "${builtins.toString (targetPlatform != hostPlatform)}" || -z "$crossConfig" \]\]^g'
|
||||
|
||||
'' + stdenv.lib.optionalString (textFile == ./setup-hook.sh) ''
|
||||
cat << 'EOF' >> $out
|
||||
for CMD in ar as nm objcopy ranlib strip strings size ld windres
|
||||
do
|
||||
# which is not part of stdenv, but compgen will do for now
|
||||
if
|
||||
PATH=$_PATH type -p ${prefix}$CMD > /dev/null
|
||||
then
|
||||
export ''$(echo "$CMD" | tr "[:lower:]" "[:upper:]")=${prefix}''${CMD};
|
||||
fi
|
||||
done
|
||||
EOF
|
||||
|
||||
sed -i $out -e 's_envHooks_crossEnvHooks_g'
|
||||
'' + ''
|
||||
|
||||
# NIX_ things which we don't both use and define, we revert them
|
||||
#asymmetric=$(
|
||||
# for pre in "" "\\$"
|
||||
@ -143,6 +127,7 @@ stdenv.mkDerivation {
|
||||
inherit cc shell libc_bin libc_dev libc_lib binutils_bin coreutils_bin;
|
||||
gnugrep_bin = if nativeTools then "" else gnugrep;
|
||||
|
||||
binPrefix = prefix;
|
||||
|
||||
passthru = {
|
||||
inherit libc nativeTools nativeLibc nativePrefix isGNU isClang default_cxx_stdlib_compile
|
||||
@ -303,20 +288,24 @@ stdenv.mkDerivation {
|
||||
wrap ${prefix}ld.bfd ${preWrap ./ld-wrapper.sh} ${binutils_bin}/bin/${prefix}ld.bfd
|
||||
fi
|
||||
|
||||
export real_cc=${prefix}cc
|
||||
export real_cxx=${prefix}c++
|
||||
# We export environment variables pointing to the wrapped nonstandard
|
||||
# cmds, lest some lousy configure script use those to guess compiler
|
||||
# version.
|
||||
export named_cc=${prefix}cc
|
||||
export named_cxx=${prefix}c++
|
||||
|
||||
export default_cxx_stdlib_compile="${default_cxx_stdlib_compile}"
|
||||
|
||||
if [ -e $ccPath/${prefix}gcc ]; then
|
||||
wrap ${prefix}gcc ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}gcc
|
||||
ln -s ${prefix}gcc $out/bin/${prefix}cc
|
||||
export real_cc=${prefix}gcc
|
||||
export real_cxx=${prefix}g++
|
||||
export named_cc=${prefix}gcc
|
||||
export named_cxx=${prefix}g++
|
||||
elif [ -e $ccPath/clang ]; then
|
||||
wrap ${prefix}clang ${preWrap ./cc-wrapper.sh} $ccPath/clang
|
||||
ln -s ${prefix}clang $out/bin/${prefix}cc
|
||||
export real_cc=clang
|
||||
export real_cxx=clang++
|
||||
export named_cc=${prefix}clang
|
||||
export named_cxx=${prefix}clang++
|
||||
fi
|
||||
|
||||
if [ -e $ccPath/${prefix}g++ ]; then
|
||||
|
@ -1,5 +1,3 @@
|
||||
export NIX_CC=@out@
|
||||
|
||||
addCVars () {
|
||||
if [ -d $1/include ]; then
|
||||
export NIX_CFLAGS_COMPILE+=" ${ccIncludeFlag:--isystem} $1/include"
|
||||
@ -39,9 +37,26 @@ if [ -n "@coreutils_bin@" ]; then
|
||||
fi
|
||||
|
||||
if [ -z "$crossConfig" ]; then
|
||||
export CC=@real_cc@
|
||||
export CXX=@real_cxx@
|
||||
ENV_PREFIX=""
|
||||
else
|
||||
export BUILD_CC=@real_cc@
|
||||
export BUILD_CXX=@real_cxx@
|
||||
ENV_PREFIX="BUILD_"
|
||||
fi
|
||||
|
||||
export NIX_${ENV_PREFIX}CC=@out@
|
||||
|
||||
export ${ENV_PREFIX}CC=@named_cc@
|
||||
export ${ENV_PREFIX}CXX=@named_cxx@
|
||||
|
||||
for CMD in \
|
||||
cpp \
|
||||
ar as nm objcopy ranlib strip strings size ld windres
|
||||
do
|
||||
if
|
||||
PATH=$_PATH type -p @binPrefix@$CMD > /dev/null
|
||||
then
|
||||
export ${ENV_PREFIX}$(echo "$CMD" | tr "[:lower:]" "[:upper:]")=@binPrefix@${CMD};
|
||||
fi
|
||||
done
|
||||
|
||||
# No local scope available for sourced files
|
||||
unset ENV_PREFIX
|
||||
|
Loading…
Reference in New Issue
Block a user