3
0
Fork 0
forked from mirrors/nixpkgs

cc-wrapper: Add clang specific options to clang specific file

This way gcc doesn't need to be rebuilt because of clang. This also avoids
rebuilding clang when only the wrapper needs to be tweaked.
This commit is contained in:
Manuel Mendez 2022-06-13 14:24:52 -04:00
parent 19b6ccd9ac
commit 0fdc72b7e9
3 changed files with 22 additions and 9 deletions

View file

@ -0,0 +1,11 @@
needsTarget=true
for p in "${params[@]}"; do
case "$p" in
-target | --target=*) needsTarget=false ;;
esac
done
if $needsTarget; then
extraBefore+=(-target @defaultTarget@)
fi

View file

@ -29,7 +29,6 @@ cc1=0
cxxInclude=1
cxxLibrary=1
cInclude=1
needsTarget=@needsTarget@
expandResponseParams "$@"
linkType=$(checkLinkType "${params[@]}")
@ -47,7 +46,6 @@ while (( "$n" < "$nParams" )); do
-nostdinc) cInclude=0 cxxInclude=0 ;;
-nostdinc++) cxxInclude=0 ;;
-nostdlib) cxxLibrary=0 ;;
-target|--target=*) needsTarget=0;;
-x)
case "$p2" in
*-header) dontLink=1 ;;
@ -161,8 +159,8 @@ if [ "$dontLink" != 1 ]; then
export NIX_LINK_TYPE_@suffixSalt@=$linkType
fi
if [ $needsTarget == 1 ]; then
extraAfter+=(-target @defaultTarget@)
if [[ -e @out@/nix-support/add-local-cc-cflags-before.sh ]]; then
source @out@/nix-support/add-local-cflags-before.sh
fi
# As a very special hack, if the arguments are just `-v', then don't

View file

@ -208,7 +208,6 @@ stdenv.mkDerivation {
+ ''
export named_cc=${targetPrefix}cc
export named_cxx=${targetPrefix}c++
export needsTarget=0
if [ -e $ccPath/${targetPrefix}gcc ]; then
wrap ${targetPrefix}gcc $wrapper $ccPath/${targetPrefix}gcc
@ -216,8 +215,6 @@ stdenv.mkDerivation {
export named_cc=${targetPrefix}gcc
export named_cxx=${targetPrefix}g++
elif [ -e $ccPath/clang ]; then
needsTarget=1
export defaultTarget=${targetPlatform.config}
wrap ${targetPrefix}clang $wrapper $ccPath/clang
ln -s ${targetPrefix}clang $out/bin/${targetPrefix}cc
export named_cc=${targetPrefix}clang
@ -228,8 +225,6 @@ stdenv.mkDerivation {
wrap ${targetPrefix}g++ $wrapper $ccPath/${targetPrefix}g++
ln -s ${targetPrefix}g++ $out/bin/${targetPrefix}c++
elif [ -e $ccPath/clang++ ]; then
needsTarget=1
export defaultTarget=${targetPlatform.config}
wrap ${targetPrefix}clang++ $wrapper $ccPath/clang++
ln -s ${targetPrefix}clang++ $out/bin/${targetPrefix}c++
fi
@ -519,6 +514,15 @@ stdenv.mkDerivation {
substituteAll ${../wrapper-common/utils.bash} $out/nix-support/utils.bash
''
##
## General Clang support
## Needs to go after ^ because the for loop eats \n and makes this file an invalid script
##
+ optionalString isClang ''
export defaultTarget=${targetPlatform.config}
substituteAll ${./add-clang-cc-cflags-before.sh} $out/nix-support/add-local-cc-cflags-before.sh
''
##
## Extra custom steps
##