cc-wrapper: Unconditionally use @infixSalt@ accross the board

This is basically a sed job, in preparation of the next commit. The
rules are more or less:

  - s"NIX_(.._WRAPPER_)?([a-zA-Z0-9@]*)"NIX_\1@infixSalt@_\2"g

  - except for non-cc-wrapper-specific vars like `NIX_DEBUG`
This commit is contained in:
John Ericson 2017-06-26 00:43:06 -04:00
parent 5ba3972add
commit 9f1e009975
6 changed files with 63 additions and 63 deletions

View File

@ -1,37 +1,37 @@
# `-B@out@/bin' forces cc to use ld-wrapper.sh when calling ld. # `-B@out@/bin' forces cc to use ld-wrapper.sh when calling ld.
export NIX_CFLAGS_COMPILE="-B@out@/bin/ $NIX_CFLAGS_COMPILE" export NIX_@infixSalt@_CFLAGS_COMPILE="-B@out@/bin/ $NIX_@infixSalt@_CFLAGS_COMPILE"
# Export and assign separately in order that a failing $(..) will fail # Export and assign separately in order that a failing $(..) will fail
# the script. # the script.
if [ -e @out@/nix-support/libc-cflags ]; then if [ -e @out@/nix-support/libc-cflags ]; then
export NIX_CFLAGS_COMPILE export NIX_@infixSalt@_CFLAGS_COMPILE
NIX_CFLAGS_COMPILE="$(< @out@/nix-support/libc-cflags) $NIX_CFLAGS_COMPILE" NIX_@infixSalt@_CFLAGS_COMPILE="$(< @out@/nix-support/libc-cflags) $NIX_@infixSalt@_CFLAGS_COMPILE"
fi fi
if [ -e @out@/nix-support/cc-cflags ]; then if [ -e @out@/nix-support/cc-cflags ]; then
export NIX_CFLAGS_COMPILE export NIX_@infixSalt@_CFLAGS_COMPILE
NIX_CFLAGS_COMPILE="$(< @out@/nix-support/cc-cflags) $NIX_CFLAGS_COMPILE" NIX_@infixSalt@_CFLAGS_COMPILE="$(< @out@/nix-support/cc-cflags) $NIX_@infixSalt@_CFLAGS_COMPILE"
fi fi
if [ -e @out@/nix-support/gnat-cflags ]; then if [ -e @out@/nix-support/gnat-cflags ]; then
export NIX_GNATFLAGS_COMPILE export NIX_@infixSalt@_GNATFLAGS_COMPILE
NIX_GNATFLAGS_COMPILE="$(< @out@/nix-support/gnat-cflags) $NIX_GNATFLAGS_COMPILE" NIX_@infixSalt@_GNATFLAGS_COMPILE="$(< @out@/nix-support/gnat-cflags) $NIX_@infixSalt@_GNATFLAGS_COMPILE"
fi fi
if [ -e @out@/nix-support/libc-ldflags ]; then if [ -e @out@/nix-support/libc-ldflags ]; then
export NIX_LDFLAGS export NIX_@infixSalt@_LDFLAGS
NIX_LDFLAGS+=" $(< @out@/nix-support/libc-ldflags)" NIX_@infixSalt@_LDFLAGS+=" $(< @out@/nix-support/libc-ldflags)"
fi fi
if [ -e @out@/nix-support/cc-ldflags ]; then if [ -e @out@/nix-support/cc-ldflags ]; then
export NIX_LDFLAGS export NIX_@infixSalt@_LDFLAGS
NIX_LDFLAGS+=" $(< @out@/nix-support/cc-ldflags)" NIX_@infixSalt@_LDFLAGS+=" $(< @out@/nix-support/cc-ldflags)"
fi fi
if [ -e @out@/nix-support/libc-ldflags-before ]; then if [ -e @out@/nix-support/libc-ldflags-before ]; then
export NIX_LDFLAGS_BEFORE export NIX_@infixSalt@_LDFLAGS_BEFORE
NIX_LDFLAGS_BEFORE="$(< @out@/nix-support/libc-ldflags-before) $NIX_LDFLAGS_BEFORE" NIX_@infixSalt@_LDFLAGS_BEFORE="$(< @out@/nix-support/libc-ldflags-before) $NIX_@infixSalt@_LDFLAGS_BEFORE"
fi fi
export NIX_CC_WRAPPER_FLAGS_SET=1 export NIX_CC_WRAPPER_@infixSalt@_FLAGS_SET=1

View File

@ -11,11 +11,11 @@ if [[ -n "@coreutils_bin@" && -n "@gnugrep_bin@" ]]; then
PATH="@coreutils_bin@/bin:@gnugrep_bin@/bin" PATH="@coreutils_bin@/bin:@gnugrep_bin@/bin"
fi fi
if [ -n "$NIX_CC_WRAPPER_START_HOOK" ]; then if [ -n "$NIX_CC_WRAPPER_@infixSalt@_START_HOOK" ]; then
source "$NIX_CC_WRAPPER_START_HOOK" source "$NIX_CC_WRAPPER_@infixSalt@_START_HOOK"
fi fi
if [ -z "$NIX_CC_WRAPPER_FLAGS_SET" ]; then if [ -z "$NIX_CC_WRAPPER_@infixSalt@_FLAGS_SET" ]; then
source @out@/nix-support/add-flags.sh source @out@/nix-support/add-flags.sh
fi fi
@ -63,7 +63,7 @@ while [ "$n" -lt "$nParams" ]; do
nonFlagArgs=1 nonFlagArgs=1
elif [ "$p" = -m32 ]; then elif [ "$p" = -m32 ]; then
if [ -e @out@/nix-support/dynamic-linker-m32 ]; then if [ -e @out@/nix-support/dynamic-linker-m32 ]; then
NIX_LDFLAGS+=" -dynamic-linker $(< @out@/nix-support/dynamic-linker-m32)" NIX_@infixSalt@_LDFLAGS+=" -dynamic-linker $(< @out@/nix-support/dynamic-linker-m32)"
fi fi
fi fi
n+=1 n+=1
@ -106,7 +106,7 @@ fi
# Clear march/mtune=native -- they bring impurity. # Clear march/mtune=native -- they bring impurity.
if [ "$NIX_ENFORCE_NO_NATIVE" = 1 ]; then if [ "$NIX_@infixSalt@_ENFORCE_NO_NATIVE" = 1 ]; then
rest=() rest=()
for p in "${params[@]}"; do for p in "${params[@]}"; do
if [[ "$p" = -m*=native ]]; then if [[ "$p" = -m*=native ]]; then
@ -120,36 +120,36 @@ fi
if [[ "$isCpp" = 1 ]]; then if [[ "$isCpp" = 1 ]]; then
if [[ "$cppInclude" = 1 ]]; then if [[ "$cppInclude" = 1 ]]; then
NIX_CFLAGS_COMPILE+=" ${NIX_CXXSTDLIB_COMPILE-@default_cxx_stdlib_compile@}" NIX_@infixSalt@_CFLAGS_COMPILE+=" ${NIX_@infixSalt@_CXXSTDLIB_COMPILE-@default_cxx_stdlib_compile@}"
fi fi
NIX_CFLAGS_LINK+=" $NIX_CXXSTDLIB_LINK" NIX_@infixSalt@_CFLAGS_LINK+=" $NIX_@infixSalt@_CXXSTDLIB_LINK"
fi fi
source @out@/nix-support/add-hardening.sh source @out@/nix-support/add-hardening.sh
# Add the flags for the C compiler proper. # Add the flags for the C compiler proper.
extraAfter=($NIX_CFLAGS_COMPILE "${hardeningCFlags[@]}") extraAfter=($NIX_@infixSalt@_CFLAGS_COMPILE "${hardeningCFlags[@]}")
extraBefore=() extraBefore=()
if [ "$dontLink" != 1 ]; then if [ "$dontLink" != 1 ]; then
# Add the flags that should only be passed to the compiler when # Add the flags that should only be passed to the compiler when
# linking. # linking.
extraAfter+=($NIX_CFLAGS_LINK "${hardeningLDFlags[@]}") extraAfter+=($NIX_@infixSalt@_CFLAGS_LINK "${hardeningLDFlags[@]}")
# Add the flags that should be passed to the linker (and prevent # Add the flags that should be passed to the linker (and prevent
# `ld-wrapper' from adding NIX_LDFLAGS again). # `ld-wrapper' from adding NIX_@infixSalt@_LDFLAGS again).
for i in $NIX_LDFLAGS_BEFORE; do for i in $NIX_@infixSalt@_LDFLAGS_BEFORE; do
extraBefore+=("-Wl,$i") extraBefore+=("-Wl,$i")
done done
for i in $NIX_LDFLAGS; do for i in $NIX_@infixSalt@_LDFLAGS; do
if [ "${i:0:3}" = -L/ ]; then if [ "${i:0:3}" = -L/ ]; then
extraAfter+=("$i") extraAfter+=("$i")
else else
extraAfter+=("-Wl,$i") extraAfter+=("-Wl,$i")
fi fi
done done
export NIX_LDFLAGS_SET=1 export NIX_@infixSalt@_LDFLAGS_SET=1
fi fi
# As a very special hack, if the arguments are just `-v', then don't # As a very special hack, if the arguments are just `-v', then don't
@ -171,8 +171,8 @@ if [ -n "$NIX_DEBUG" ]; then
printf " %q\n" "${extraAfter[@]}" >&2 printf " %q\n" "${extraAfter[@]}" >&2
fi fi
if [ -n "$NIX_CC_WRAPPER_EXEC_HOOK" ]; then if [ -n "$NIX_CC_WRAPPER_@infixSalt@_EXEC_HOOK" ]; then
source "$NIX_CC_WRAPPER_EXEC_HOOK" source "$NIX_CC_WRAPPER_@infixSalt@_EXEC_HOOK"
fi fi
PATH="$path_backup" PATH="$path_backup"

View File

@ -10,11 +10,11 @@ if [ -n "@coreutils_bin@" ]; then
PATH="@coreutils_bin@/bin" PATH="@coreutils_bin@/bin"
fi fi
if [ -n "$NIX_GNAT_WRAPPER_START_HOOK" ]; then if [ -n "$NIX_@infixSalt@_GNAT_WRAPPER_START_HOOK" ]; then
source "$NIX_GNAT_WRAPPER_START_HOOK" source "$NIX_@infixSalt@_GNAT_WRAPPER_START_HOOK"
fi fi
if [ -z "$NIX_GNAT_WRAPPER_FLAGS_SET" ]; then if [ -z "$NIX_@infixSalt@_GNAT_WRAPPER_FLAGS_SET" ]; then
source @out@/nix-support/add-flags.sh source @out@/nix-support/add-flags.sh
fi fi
@ -35,7 +35,7 @@ for i in "$@"; do
nonFlagArgs=1 nonFlagArgs=1
elif [ "$i" = -m32 ]; then elif [ "$i" = -m32 ]; then
if [ -e @out@/nix-support/dynamic-linker-m32 ]; then if [ -e @out@/nix-support/dynamic-linker-m32 ]; then
NIX_LDFLAGS+=" -dynamic-linker $(< @out@/nix-support/dynamic-linker-m32)" NIX_@infixSalt@_LDFLAGS+=" -dynamic-linker $(< @out@/nix-support/dynamic-linker-m32)"
fi fi
fi fi
done done
@ -72,7 +72,7 @@ fi
# Clear march/mtune=native -- they bring impurity. # Clear march/mtune=native -- they bring impurity.
if [ "$NIX_ENFORCE_NO_NATIVE" = 1 ]; then if [ "$NIX_@infixSalt@_ENFORCE_NO_NATIVE" = 1 ]; then
rest=() rest=()
for p in "${params[@]}"; do for p in "${params[@]}"; do
if [[ "$p" = -m*=native ]]; then if [[ "$p" = -m*=native ]]; then
@ -86,7 +86,7 @@ fi
# Add the flags for the GNAT compiler proper. # Add the flags for the GNAT compiler proper.
extraAfter=($NIX_GNATFLAGS_COMPILE) extraAfter=($NIX_@infixSalt@_GNATFLAGS_COMPILE)
extraBefore=() extraBefore=()
if [ "$(basename "$0")x" = "gnatmakex" ]; then if [ "$(basename "$0")x" = "gnatmakex" ]; then
@ -95,18 +95,18 @@ fi
#if [ "$dontLink" != 1 ]; then #if [ "$dontLink" != 1 ]; then
# # Add the flags that should be passed to the linker (and prevent # # Add the flags that should be passed to the linker (and prevent
# # `ld-wrapper' from adding NIX_LDFLAGS again). # # `ld-wrapper' from adding NIX_@infixSalt@_LDFLAGS again).
# for i in $NIX_LDFLAGS_BEFORE; do # for i in $NIX_@infixSalt@_LDFLAGS_BEFORE; do
# extraBefore+=("-largs" "$i") # extraBefore+=("-largs" "$i")
# done # done
# for i in $NIX_LDFLAGS; do # for i in $NIX_@infixSalt@_LDFLAGS; do
# if [ "${i:0:3}" = -L/ ]; then # if [ "${i:0:3}" = -L/ ]; then
# extraAfter+=("$i") # extraAfter+=("$i")
# else # else
# extraAfter+=("-largs" "$i") # extraAfter+=("-largs" "$i")
# fi # fi
# done # done
# export NIX_LDFLAGS_SET=1 # export NIX_@infixSalt@_LDFLAGS_SET=1
#fi #fi
# Optionally print debug info. # Optionally print debug info.
@ -119,8 +119,8 @@ if [ -n "$NIX_DEBUG" ]; then
printf " %q\n" "${extraAfter[@]}" >&2 printf " %q\n" "${extraAfter[@]}" >&2
fi fi
if [ -n "$NIX_GNAT_WRAPPER_EXEC_HOOK" ]; then if [ -n "$NIX_@infixSalt@_GNAT_WRAPPER_EXEC_HOOK" ]; then
source "$NIX_GNAT_WRAPPER_EXEC_HOOK" source "$NIX_@infixSalt@_GNAT_WRAPPER_EXEC_HOOK"
fi fi
PATH="$path_backup" PATH="$path_backup"

View File

@ -7,18 +7,18 @@ extraAfter=("--GCC=@out@/bin/gcc")
extraBefore=() extraBefore=()
## Add the flags that should be passed to the linker (and prevent ## Add the flags that should be passed to the linker (and prevent
## `ld-wrapper' from adding NIX_LDFLAGS again). ## `ld-wrapper' from adding NIX_@infixSalt@_LDFLAGS again).
#for i in $NIX_LDFLAGS_BEFORE; do #for i in $NIX_@infixSalt@_LDFLAGS_BEFORE; do
# extraBefore+=("-largs" "$i") # extraBefore+=("-largs" "$i")
#done #done
#for i in $NIX_LDFLAGS; do #for i in $NIX_@infixSalt@_LDFLAGS; do
# if [ "${i:0:3}" = -L/ ]; then # if [ "${i:0:3}" = -L/ ]; then
# extraAfter+=("$i") # extraAfter+=("$i")
# else # else
# extraAfter+=("-largs" "$i") # extraAfter+=("-largs" "$i")
# fi # fi
#done #done
#export NIX_LDFLAGS_SET=1 #export NIX_@infixSalt@_LDFLAGS_SET=1
# Optionally print debug info. # Optionally print debug info.
if [ -n "$NIX_DEBUG" ]; then if [ -n "$NIX_DEBUG" ]; then
@ -30,8 +30,8 @@ if [ -n "$NIX_DEBUG" ]; then
printf " %q\n" "${extraAfter[@]}" >&2 printf " %q\n" "${extraAfter[@]}" >&2
fi fi
if [ -n "$NIX_GNAT_WRAPPER_EXEC_HOOK" ]; then if [ -n "$NIX_@infixSalt@_GNAT_WRAPPER_EXEC_HOOK" ]; then
source "$NIX_GNAT_WRAPPER_EXEC_HOOK" source "$NIX_@infixSalt@_GNAT_WRAPPER_EXEC_HOOK"
fi fi
exec @prog@ "${extraBefore[@]}" "$@" "${extraAfter[@]}" exec @prog@ "${extraBefore[@]}" "$@" "${extraAfter[@]}"

View File

@ -1,5 +1,5 @@
#! @shell@ #! @shell@
set -e -o pipefail set -eu -o pipefail
shopt -s nullglob shopt -s nullglob
path_backup="$PATH" path_backup="$PATH"
@ -10,11 +10,11 @@ if [ -n "@coreutils_bin@" ]; then
PATH="@coreutils_bin@/bin" PATH="@coreutils_bin@/bin"
fi fi
if [ -n "$NIX_LD_WRAPPER_START_HOOK" ]; then if [ -n "$NIX_LD_WRAPPER_@infixSalt@_START_HOOK" ]; then
source "$NIX_LD_WRAPPER_START_HOOK" source "$NIX_LD_WRAPPER_@infixSalt@_START_HOOK"
fi fi
if [ -z "$NIX_CC_WRAPPER_FLAGS_SET" ]; then if [ -z "$NIX_CC_WRAPPER_@infixSalt@_FLAGS_SET" ]; then
source @out@/nix-support/add-flags.sh source @out@/nix-support/add-flags.sh
fi fi
@ -24,7 +24,7 @@ source @out@/nix-support/utils.sh
# Optionally filter out paths not refering to the store. # Optionally filter out paths not refering to the store.
expandResponseParams "$@" expandResponseParams "$@"
if [[ "$NIX_ENFORCE_PURITY" = 1 && -n "$NIX_STORE" if [[ "$NIX_ENFORCE_PURITY" = 1 && -n "$NIX_STORE"
&& ( -z "$NIX_IGNORE_LD_THROUGH_GCC" || -z "$NIX_LDFLAGS_SET" ) ]]; then && ( -z "$NIX_@infixSalt@_IGNORE_LD_THROUGH_GCC" || -z "$NIX_@infixSalt@_LDFLAGS_SET" ) ]]; then
rest=() rest=()
nParams=${#params[@]} nParams=${#params[@]}
declare -i n=0 declare -i n=0
@ -59,19 +59,19 @@ source @out@/nix-support/add-hardening.sh
extraAfter=("${hardeningLDFlags[@]}") extraAfter=("${hardeningLDFlags[@]}")
extraBefore=() extraBefore=()
if [ -z "$NIX_LDFLAGS_SET" ]; then if [ -z "$NIX_@infixSalt@_LDFLAGS_SET" ]; then
extraAfter+=($NIX_LDFLAGS) extraAfter+=($NIX_@infixSalt@_LDFLAGS)
extraBefore+=($NIX_LDFLAGS_BEFORE) extraBefore+=($NIX_@infixSalt@_LDFLAGS_BEFORE)
fi fi
extraAfter+=($NIX_LDFLAGS_AFTER $NIX_LDFLAGS_HARDEN) extraAfter+=($NIX_@infixSalt@_LDFLAGS_AFTER $NIX_@infixSalt@_LDFLAGS_HARDEN)
declare -a libDirs declare -a libDirs
declare -A libs declare -A libs
relocatable= relocatable=
# Find all -L... switches for rpath, and relocatable flags for build id. # Find all -L... switches for rpath, and relocatable flags for build id.
if [ "$NIX_DONT_SET_RPATH" != 1 ] || [ "$NIX_SET_BUILD_ID" = 1 ]; then if [ "$NIX_@infixSalt@_DONT_SET_RPATH" != 1 ] || [ "$NIX_@infixSalt@_SET_BUILD_ID" = 1 ]; then
prev= prev=
for p in "${extraBefore[@]}" "${params[@]}" "${extraAfter[@]}"; do for p in "${extraBefore[@]}" "${params[@]}" "${extraAfter[@]}"; do
case "$prev" in case "$prev" in
@ -108,7 +108,7 @@ fi
# Add all used dynamic libraries to the rpath. # Add all used dynamic libraries to the rpath.
if [ "$NIX_DONT_SET_RPATH" != 1 ]; then if [ "$NIX_@infixSalt@_DONT_SET_RPATH" != 1 ]; then
# For each directory in the library search path (-L...), # For each directory in the library search path (-L...),
# see if it contains a dynamic library used by a -l... flag. If # see if it contains a dynamic library used by a -l... flag. If
# so, add the directory to the rpath. # so, add the directory to the rpath.
@ -141,7 +141,7 @@ fi
# Only add --build-id if this is a final link. FIXME: should build gcc # Only add --build-id if this is a final link. FIXME: should build gcc
# with --enable-linker-build-id instead? # with --enable-linker-build-id instead?
if [ "$NIX_SET_BUILD_ID" = 1 ] && [ ! "$relocatable" ]; then if [ "$NIX_@infixSalt@_SET_BUILD_ID" = 1 ] && [ ! "$relocatable" ]; then
extraAfter+=(--build-id) extraAfter+=(--build-id)
fi fi
@ -156,8 +156,8 @@ if [ -n "$NIX_DEBUG" ]; then
printf " %q\n" "${extraAfter[@]}" >&2 printf " %q\n" "${extraAfter[@]}" >&2
fi fi
if [ -n "$NIX_LD_WRAPPER_EXEC_HOOK" ]; then if [ -n "$NIX_LD_WRAPPER_@infixSalt@_EXEC_HOOK" ]; then
source "$NIX_LD_WRAPPER_EXEC_HOOK" source "$NIX_LD_WRAPPER_@infixSalt@_EXEC_HOOK"
fi fi
PATH="$path_backup" PATH="$path_backup"

View File

@ -1,4 +1,4 @@
addCVars () { ccWrapper_addCVars () {
if [[ -d "$1/include" ]]; then if [[ -d "$1/include" ]]; then
export NIX_CFLAGS_COMPILE+=" ${ccIncludeFlag:--isystem} $1/include" export NIX_CFLAGS_COMPILE+=" ${ccIncludeFlag:--isystem} $1/include"
fi fi
@ -16,7 +16,7 @@ addCVars () {
fi fi
} }
envHooks+=(addCVars) envHooks+=(ccWrapper_addCVars)
# Note 1: these come *after* $out in the PATH (see setup.sh). # Note 1: these come *after* $out in the PATH (see setup.sh).
# Note 2: phase separation makes this look useless to shellcheck. # Note 2: phase separation makes this look useless to shellcheck.