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:
parent
5ba3972add
commit
9f1e009975
@ -1,37 +1,37 @@
|
||||
# `-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
|
||||
# the script.
|
||||
|
||||
if [ -e @out@/nix-support/libc-cflags ]; then
|
||||
export NIX_CFLAGS_COMPILE
|
||||
NIX_CFLAGS_COMPILE="$(< @out@/nix-support/libc-cflags) $NIX_CFLAGS_COMPILE"
|
||||
export NIX_@infixSalt@_CFLAGS_COMPILE
|
||||
NIX_@infixSalt@_CFLAGS_COMPILE="$(< @out@/nix-support/libc-cflags) $NIX_@infixSalt@_CFLAGS_COMPILE"
|
||||
fi
|
||||
|
||||
if [ -e @out@/nix-support/cc-cflags ]; then
|
||||
export NIX_CFLAGS_COMPILE
|
||||
NIX_CFLAGS_COMPILE="$(< @out@/nix-support/cc-cflags) $NIX_CFLAGS_COMPILE"
|
||||
export NIX_@infixSalt@_CFLAGS_COMPILE
|
||||
NIX_@infixSalt@_CFLAGS_COMPILE="$(< @out@/nix-support/cc-cflags) $NIX_@infixSalt@_CFLAGS_COMPILE"
|
||||
fi
|
||||
|
||||
if [ -e @out@/nix-support/gnat-cflags ]; then
|
||||
export NIX_GNATFLAGS_COMPILE
|
||||
NIX_GNATFLAGS_COMPILE="$(< @out@/nix-support/gnat-cflags) $NIX_GNATFLAGS_COMPILE"
|
||||
export NIX_@infixSalt@_GNATFLAGS_COMPILE
|
||||
NIX_@infixSalt@_GNATFLAGS_COMPILE="$(< @out@/nix-support/gnat-cflags) $NIX_@infixSalt@_GNATFLAGS_COMPILE"
|
||||
fi
|
||||
|
||||
if [ -e @out@/nix-support/libc-ldflags ]; then
|
||||
export NIX_LDFLAGS
|
||||
NIX_LDFLAGS+=" $(< @out@/nix-support/libc-ldflags)"
|
||||
export NIX_@infixSalt@_LDFLAGS
|
||||
NIX_@infixSalt@_LDFLAGS+=" $(< @out@/nix-support/libc-ldflags)"
|
||||
fi
|
||||
|
||||
if [ -e @out@/nix-support/cc-ldflags ]; then
|
||||
export NIX_LDFLAGS
|
||||
NIX_LDFLAGS+=" $(< @out@/nix-support/cc-ldflags)"
|
||||
export NIX_@infixSalt@_LDFLAGS
|
||||
NIX_@infixSalt@_LDFLAGS+=" $(< @out@/nix-support/cc-ldflags)"
|
||||
fi
|
||||
|
||||
if [ -e @out@/nix-support/libc-ldflags-before ]; then
|
||||
export NIX_LDFLAGS_BEFORE
|
||||
NIX_LDFLAGS_BEFORE="$(< @out@/nix-support/libc-ldflags-before) $NIX_LDFLAGS_BEFORE"
|
||||
export NIX_@infixSalt@_LDFLAGS_BEFORE
|
||||
NIX_@infixSalt@_LDFLAGS_BEFORE="$(< @out@/nix-support/libc-ldflags-before) $NIX_@infixSalt@_LDFLAGS_BEFORE"
|
||||
fi
|
||||
|
||||
export NIX_CC_WRAPPER_FLAGS_SET=1
|
||||
export NIX_CC_WRAPPER_@infixSalt@_FLAGS_SET=1
|
||||
|
@ -11,11 +11,11 @@ if [[ -n "@coreutils_bin@" && -n "@gnugrep_bin@" ]]; then
|
||||
PATH="@coreutils_bin@/bin:@gnugrep_bin@/bin"
|
||||
fi
|
||||
|
||||
if [ -n "$NIX_CC_WRAPPER_START_HOOK" ]; then
|
||||
source "$NIX_CC_WRAPPER_START_HOOK"
|
||||
if [ -n "$NIX_CC_WRAPPER_@infixSalt@_START_HOOK" ]; then
|
||||
source "$NIX_CC_WRAPPER_@infixSalt@_START_HOOK"
|
||||
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
|
||||
fi
|
||||
|
||||
@ -63,7 +63,7 @@ while [ "$n" -lt "$nParams" ]; do
|
||||
nonFlagArgs=1
|
||||
elif [ "$p" = -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
|
||||
n+=1
|
||||
@ -106,7 +106,7 @@ fi
|
||||
|
||||
|
||||
# Clear march/mtune=native -- they bring impurity.
|
||||
if [ "$NIX_ENFORCE_NO_NATIVE" = 1 ]; then
|
||||
if [ "$NIX_@infixSalt@_ENFORCE_NO_NATIVE" = 1 ]; then
|
||||
rest=()
|
||||
for p in "${params[@]}"; do
|
||||
if [[ "$p" = -m*=native ]]; then
|
||||
@ -120,36 +120,36 @@ fi
|
||||
|
||||
if [[ "$isCpp" = 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
|
||||
NIX_CFLAGS_LINK+=" $NIX_CXXSTDLIB_LINK"
|
||||
NIX_@infixSalt@_CFLAGS_LINK+=" $NIX_@infixSalt@_CXXSTDLIB_LINK"
|
||||
fi
|
||||
|
||||
source @out@/nix-support/add-hardening.sh
|
||||
|
||||
# Add the flags for the C compiler proper.
|
||||
extraAfter=($NIX_CFLAGS_COMPILE "${hardeningCFlags[@]}")
|
||||
extraAfter=($NIX_@infixSalt@_CFLAGS_COMPILE "${hardeningCFlags[@]}")
|
||||
extraBefore=()
|
||||
|
||||
if [ "$dontLink" != 1 ]; then
|
||||
|
||||
# Add the flags that should only be passed to the compiler when
|
||||
# linking.
|
||||
extraAfter+=($NIX_CFLAGS_LINK "${hardeningLDFlags[@]}")
|
||||
extraAfter+=($NIX_@infixSalt@_CFLAGS_LINK "${hardeningLDFlags[@]}")
|
||||
|
||||
# Add the flags that should be passed to the linker (and prevent
|
||||
# `ld-wrapper' from adding NIX_LDFLAGS again).
|
||||
for i in $NIX_LDFLAGS_BEFORE; do
|
||||
# `ld-wrapper' from adding NIX_@infixSalt@_LDFLAGS again).
|
||||
for i in $NIX_@infixSalt@_LDFLAGS_BEFORE; do
|
||||
extraBefore+=("-Wl,$i")
|
||||
done
|
||||
for i in $NIX_LDFLAGS; do
|
||||
for i in $NIX_@infixSalt@_LDFLAGS; do
|
||||
if [ "${i:0:3}" = -L/ ]; then
|
||||
extraAfter+=("$i")
|
||||
else
|
||||
extraAfter+=("-Wl,$i")
|
||||
fi
|
||||
done
|
||||
export NIX_LDFLAGS_SET=1
|
||||
export NIX_@infixSalt@_LDFLAGS_SET=1
|
||||
fi
|
||||
|
||||
# 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
|
||||
fi
|
||||
|
||||
if [ -n "$NIX_CC_WRAPPER_EXEC_HOOK" ]; then
|
||||
source "$NIX_CC_WRAPPER_EXEC_HOOK"
|
||||
if [ -n "$NIX_CC_WRAPPER_@infixSalt@_EXEC_HOOK" ]; then
|
||||
source "$NIX_CC_WRAPPER_@infixSalt@_EXEC_HOOK"
|
||||
fi
|
||||
|
||||
PATH="$path_backup"
|
||||
|
@ -10,11 +10,11 @@ if [ -n "@coreutils_bin@" ]; then
|
||||
PATH="@coreutils_bin@/bin"
|
||||
fi
|
||||
|
||||
if [ -n "$NIX_GNAT_WRAPPER_START_HOOK" ]; then
|
||||
source "$NIX_GNAT_WRAPPER_START_HOOK"
|
||||
if [ -n "$NIX_@infixSalt@_GNAT_WRAPPER_START_HOOK" ]; then
|
||||
source "$NIX_@infixSalt@_GNAT_WRAPPER_START_HOOK"
|
||||
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
|
||||
fi
|
||||
|
||||
@ -35,7 +35,7 @@ for i in "$@"; do
|
||||
nonFlagArgs=1
|
||||
elif [ "$i" = -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
|
||||
done
|
||||
@ -72,7 +72,7 @@ fi
|
||||
|
||||
|
||||
# Clear march/mtune=native -- they bring impurity.
|
||||
if [ "$NIX_ENFORCE_NO_NATIVE" = 1 ]; then
|
||||
if [ "$NIX_@infixSalt@_ENFORCE_NO_NATIVE" = 1 ]; then
|
||||
rest=()
|
||||
for p in "${params[@]}"; do
|
||||
if [[ "$p" = -m*=native ]]; then
|
||||
@ -86,7 +86,7 @@ fi
|
||||
|
||||
|
||||
# Add the flags for the GNAT compiler proper.
|
||||
extraAfter=($NIX_GNATFLAGS_COMPILE)
|
||||
extraAfter=($NIX_@infixSalt@_GNATFLAGS_COMPILE)
|
||||
extraBefore=()
|
||||
|
||||
if [ "$(basename "$0")x" = "gnatmakex" ]; then
|
||||
@ -95,18 +95,18 @@ fi
|
||||
|
||||
#if [ "$dontLink" != 1 ]; then
|
||||
# # Add the flags that should be passed to the linker (and prevent
|
||||
# # `ld-wrapper' from adding NIX_LDFLAGS again).
|
||||
# for i in $NIX_LDFLAGS_BEFORE; do
|
||||
# # `ld-wrapper' from adding NIX_@infixSalt@_LDFLAGS again).
|
||||
# for i in $NIX_@infixSalt@_LDFLAGS_BEFORE; do
|
||||
# extraBefore+=("-largs" "$i")
|
||||
# done
|
||||
# for i in $NIX_LDFLAGS; do
|
||||
# for i in $NIX_@infixSalt@_LDFLAGS; do
|
||||
# if [ "${i:0:3}" = -L/ ]; then
|
||||
# extraAfter+=("$i")
|
||||
# else
|
||||
# extraAfter+=("-largs" "$i")
|
||||
# fi
|
||||
# done
|
||||
# export NIX_LDFLAGS_SET=1
|
||||
# export NIX_@infixSalt@_LDFLAGS_SET=1
|
||||
#fi
|
||||
|
||||
# Optionally print debug info.
|
||||
@ -119,8 +119,8 @@ if [ -n "$NIX_DEBUG" ]; then
|
||||
printf " %q\n" "${extraAfter[@]}" >&2
|
||||
fi
|
||||
|
||||
if [ -n "$NIX_GNAT_WRAPPER_EXEC_HOOK" ]; then
|
||||
source "$NIX_GNAT_WRAPPER_EXEC_HOOK"
|
||||
if [ -n "$NIX_@infixSalt@_GNAT_WRAPPER_EXEC_HOOK" ]; then
|
||||
source "$NIX_@infixSalt@_GNAT_WRAPPER_EXEC_HOOK"
|
||||
fi
|
||||
|
||||
PATH="$path_backup"
|
||||
|
@ -7,18 +7,18 @@ extraAfter=("--GCC=@out@/bin/gcc")
|
||||
extraBefore=()
|
||||
|
||||
## Add the flags that should be passed to the linker (and prevent
|
||||
## `ld-wrapper' from adding NIX_LDFLAGS again).
|
||||
#for i in $NIX_LDFLAGS_BEFORE; do
|
||||
## `ld-wrapper' from adding NIX_@infixSalt@_LDFLAGS again).
|
||||
#for i in $NIX_@infixSalt@_LDFLAGS_BEFORE; do
|
||||
# extraBefore+=("-largs" "$i")
|
||||
#done
|
||||
#for i in $NIX_LDFLAGS; do
|
||||
#for i in $NIX_@infixSalt@_LDFLAGS; do
|
||||
# if [ "${i:0:3}" = -L/ ]; then
|
||||
# extraAfter+=("$i")
|
||||
# else
|
||||
# extraAfter+=("-largs" "$i")
|
||||
# fi
|
||||
#done
|
||||
#export NIX_LDFLAGS_SET=1
|
||||
#export NIX_@infixSalt@_LDFLAGS_SET=1
|
||||
|
||||
# Optionally print debug info.
|
||||
if [ -n "$NIX_DEBUG" ]; then
|
||||
@ -30,8 +30,8 @@ if [ -n "$NIX_DEBUG" ]; then
|
||||
printf " %q\n" "${extraAfter[@]}" >&2
|
||||
fi
|
||||
|
||||
if [ -n "$NIX_GNAT_WRAPPER_EXEC_HOOK" ]; then
|
||||
source "$NIX_GNAT_WRAPPER_EXEC_HOOK"
|
||||
if [ -n "$NIX_@infixSalt@_GNAT_WRAPPER_EXEC_HOOK" ]; then
|
||||
source "$NIX_@infixSalt@_GNAT_WRAPPER_EXEC_HOOK"
|
||||
fi
|
||||
|
||||
exec @prog@ "${extraBefore[@]}" "$@" "${extraAfter[@]}"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#! @shell@
|
||||
set -e -o pipefail
|
||||
set -eu -o pipefail
|
||||
shopt -s nullglob
|
||||
|
||||
path_backup="$PATH"
|
||||
@ -10,11 +10,11 @@ if [ -n "@coreutils_bin@" ]; then
|
||||
PATH="@coreutils_bin@/bin"
|
||||
fi
|
||||
|
||||
if [ -n "$NIX_LD_WRAPPER_START_HOOK" ]; then
|
||||
source "$NIX_LD_WRAPPER_START_HOOK"
|
||||
if [ -n "$NIX_LD_WRAPPER_@infixSalt@_START_HOOK" ]; then
|
||||
source "$NIX_LD_WRAPPER_@infixSalt@_START_HOOK"
|
||||
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
|
||||
fi
|
||||
|
||||
@ -24,7 +24,7 @@ source @out@/nix-support/utils.sh
|
||||
# Optionally filter out paths not refering to the store.
|
||||
expandResponseParams "$@"
|
||||
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=()
|
||||
nParams=${#params[@]}
|
||||
declare -i n=0
|
||||
@ -59,19 +59,19 @@ source @out@/nix-support/add-hardening.sh
|
||||
extraAfter=("${hardeningLDFlags[@]}")
|
||||
extraBefore=()
|
||||
|
||||
if [ -z "$NIX_LDFLAGS_SET" ]; then
|
||||
extraAfter+=($NIX_LDFLAGS)
|
||||
extraBefore+=($NIX_LDFLAGS_BEFORE)
|
||||
if [ -z "$NIX_@infixSalt@_LDFLAGS_SET" ]; then
|
||||
extraAfter+=($NIX_@infixSalt@_LDFLAGS)
|
||||
extraBefore+=($NIX_@infixSalt@_LDFLAGS_BEFORE)
|
||||
fi
|
||||
|
||||
extraAfter+=($NIX_LDFLAGS_AFTER $NIX_LDFLAGS_HARDEN)
|
||||
extraAfter+=($NIX_@infixSalt@_LDFLAGS_AFTER $NIX_@infixSalt@_LDFLAGS_HARDEN)
|
||||
|
||||
declare -a libDirs
|
||||
declare -A libs
|
||||
relocatable=
|
||||
|
||||
# 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=
|
||||
for p in "${extraBefore[@]}" "${params[@]}" "${extraAfter[@]}"; do
|
||||
case "$prev" in
|
||||
@ -108,7 +108,7 @@ fi
|
||||
|
||||
|
||||
# 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...),
|
||||
# see if it contains a dynamic library used by a -l... flag. If
|
||||
# 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
|
||||
# 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)
|
||||
fi
|
||||
|
||||
@ -156,8 +156,8 @@ if [ -n "$NIX_DEBUG" ]; then
|
||||
printf " %q\n" "${extraAfter[@]}" >&2
|
||||
fi
|
||||
|
||||
if [ -n "$NIX_LD_WRAPPER_EXEC_HOOK" ]; then
|
||||
source "$NIX_LD_WRAPPER_EXEC_HOOK"
|
||||
if [ -n "$NIX_LD_WRAPPER_@infixSalt@_EXEC_HOOK" ]; then
|
||||
source "$NIX_LD_WRAPPER_@infixSalt@_EXEC_HOOK"
|
||||
fi
|
||||
|
||||
PATH="$path_backup"
|
||||
|
@ -1,4 +1,4 @@
|
||||
addCVars () {
|
||||
ccWrapper_addCVars () {
|
||||
if [[ -d "$1/include" ]]; then
|
||||
export NIX_CFLAGS_COMPILE+=" ${ccIncludeFlag:--isystem} $1/include"
|
||||
fi
|
||||
@ -16,7 +16,7 @@ addCVars () {
|
||||
fi
|
||||
}
|
||||
|
||||
envHooks+=(addCVars)
|
||||
envHooks+=(ccWrapper_addCVars)
|
||||
|
||||
# Note 1: these come *after* $out in the PATH (see setup.sh).
|
||||
# Note 2: phase separation makes this look useless to shellcheck.
|
||||
|
Loading…
Reference in New Issue
Block a user