*-wrapper; Switch from infixSalt to suffixSalt
I hate the thing too even though I made it, and rather just get rid of it. But we can't do that yet. In the meantime, this brings us more inline with autoconf and will make it slightly easier for me to write a pkg-config wrapper, which we need.
This commit is contained in:
committed by
John Cotton Ericson
parent
f7a93031a2
commit
1ac5398589
@@ -1,32 +1,32 @@
|
||||
# See cc-wrapper for comments.
|
||||
var_templates_list=(
|
||||
NIX+IGNORE_LD_THROUGH_GCC
|
||||
NIX+LDFLAGS
|
||||
NIX+LDFLAGS_BEFORE
|
||||
NIX+LDFLAGS_AFTER
|
||||
NIX+LDFLAGS_HARDEN
|
||||
NIX+HARDENING_ENABLE
|
||||
NIX_IGNORE_LD_THROUGH_GCC
|
||||
NIX_LDFLAGS
|
||||
NIX_LDFLAGS_BEFORE
|
||||
NIX_LDFLAGS_AFTER
|
||||
NIX_LDFLAGS_HARDEN
|
||||
NIX_HARDENING_ENABLE
|
||||
)
|
||||
var_templates_bool=(
|
||||
NIX+SET_BUILD_ID
|
||||
NIX+DONT_SET_RPATH
|
||||
NIX_SET_BUILD_ID
|
||||
NIX_DONT_SET_RPATH
|
||||
)
|
||||
|
||||
accumulateRoles
|
||||
|
||||
for var in "${var_templates_list[@]}"; do
|
||||
mangleVarList "$var" ${role_infixes[@]+"${role_infixes[@]}"}
|
||||
mangleVarList "$var" ${role_suffixes[@]+"${role_suffixes[@]}"}
|
||||
done
|
||||
for var in "${var_templates_bool[@]}"; do
|
||||
mangleVarBool "$var" ${role_infixes[@]+"${role_infixes[@]}"}
|
||||
mangleVarBool "$var" ${role_suffixes[@]+"${role_suffixes[@]}"}
|
||||
done
|
||||
|
||||
if [ -e @out@/nix-support/libc-ldflags ]; then
|
||||
NIX_@infixSalt@_LDFLAGS+=" $(< @out@/nix-support/libc-ldflags)"
|
||||
NIX_LDFLAGS_@suffixSalt@+=" $(< @out@/nix-support/libc-ldflags)"
|
||||
fi
|
||||
|
||||
if [ -e @out@/nix-support/libc-ldflags-before ]; then
|
||||
NIX_@infixSalt@_LDFLAGS_BEFORE="$(< @out@/nix-support/libc-ldflags-before) $NIX_@infixSalt@_LDFLAGS_BEFORE"
|
||||
NIX_LDFLAGS_BEFORE_@suffixSalt@="$(< @out@/nix-support/libc-ldflags-before) $NIX_LDFLAGS_BEFORE_@suffixSalt@"
|
||||
fi
|
||||
|
||||
export NIX_BINTOOLS_WRAPPER_@infixSalt@_FLAGS_SET=1
|
||||
export NIX_BINTOOLS_WRAPPER_FLAGS_SET_@suffixSalt@=1
|
||||
|
||||
@@ -5,7 +5,7 @@ declare -A hardeningEnableMap=()
|
||||
# Intentionally word-split in case 'NIX_HARDENING_ENABLE' is defined in Nix. The
|
||||
# array expansion also prevents undefined variables from causing trouble with
|
||||
# `set -u`.
|
||||
for flag in ${NIX_@infixSalt@_HARDENING_ENABLE-}; do
|
||||
for flag in ${NIX_HARDENING_ENABLE_@suffixSalt@-}; do
|
||||
hardeningEnableMap["$flag"]=1
|
||||
done
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ let
|
||||
coreutils_bin = if nativeTools then "" else getBin coreutils;
|
||||
|
||||
# See description in cc-wrapper.
|
||||
infixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config;
|
||||
suffixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config;
|
||||
|
||||
# The dynamic linker has different names on different platforms. This is a
|
||||
# shell glob that ought to match it.
|
||||
@@ -83,7 +83,7 @@ stdenv.mkDerivation {
|
||||
shell = getBin shell + shell.shellPath or "";
|
||||
gnugrep_bin = if nativeTools then "" else gnugrep;
|
||||
|
||||
inherit targetPrefix infixSalt;
|
||||
inherit targetPrefix suffixSalt;
|
||||
|
||||
outputs = [ "out" ] ++ optionals propagateDoc ([ "man" ] ++ optional (bintools ? info) "info");
|
||||
|
||||
@@ -95,9 +95,9 @@ stdenv.mkDerivation {
|
||||
(mapc
|
||||
(lambda (arg)
|
||||
(when (file-directory-p (concat arg "/lib"))
|
||||
(setenv "NIX_${infixSalt}_LDFLAGS" (concat (getenv "NIX_${infixSalt}_LDFLAGS") " -L" arg "/lib")))
|
||||
(setenv "NIX_LDFLAGS_${suffixSalt}" (concat (getenv "NIX_LDFLAGS_${suffixSalt}") " -L" arg "/lib")))
|
||||
(when (file-directory-p (concat arg "/lib64"))
|
||||
(setenv "NIX_${infixSalt}_LDFLAGS" (concat (getenv "NIX_${infixSalt}_LDFLAGS") " -L" arg "/lib64"))))
|
||||
(setenv "NIX_LDFLAGS_${suffixSalt}" (concat (getenv "NIX_LDFLAGS_${suffixSalt}") " -L" arg "/lib64"))))
|
||||
'(${concatStringsSep " " (map (pkg: "\"${pkg}\"") pkgs)}))
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@ fi
|
||||
|
||||
source @out@/nix-support/utils.bash
|
||||
|
||||
if [ -z "${NIX_BINTOOLS_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then
|
||||
if [ -z "${NIX_BINTOOLS_WRAPPER_FLAGS_SET_@suffixSalt@:-}" ]; then
|
||||
source @out@/nix-support/add-flags.sh
|
||||
fi
|
||||
|
||||
@@ -24,7 +24,7 @@ fi
|
||||
# Optionally filter out paths not refering to the store.
|
||||
expandResponseParams "$@"
|
||||
if [[ "${NIX_ENFORCE_PURITY:-}" = 1 && -n "${NIX_STORE:-}"
|
||||
&& ( -z "$NIX_@infixSalt@_IGNORE_LD_THROUGH_GCC" || -z "${NIX_@infixSalt@_LDFLAGS_SET:-}" ) ]]; then
|
||||
&& ( -z "$NIX_IGNORE_LD_THROUGH_GCC_@suffixSalt@" || -z "${NIX_LDFLAGS_SET_@suffixSalt@:-}" ) ]]; then
|
||||
rest=()
|
||||
nParams=${#params[@]}
|
||||
declare -i n=0
|
||||
@@ -60,12 +60,12 @@ source @out@/nix-support/add-hardening.sh
|
||||
extraAfter=()
|
||||
extraBefore=(${hardeningLDFlags[@]+"${hardeningLDFlags[@]}"})
|
||||
|
||||
if [ -z "${NIX_@infixSalt@_LDFLAGS_SET:-}" ]; then
|
||||
extraAfter+=($NIX_@infixSalt@_LDFLAGS)
|
||||
extraBefore+=($NIX_@infixSalt@_LDFLAGS_BEFORE)
|
||||
if [ -z "${NIX_LDFLAGS_SET_@suffixSalt@:-}" ]; then
|
||||
extraAfter+=($NIX_LDFLAGS_@suffixSalt@)
|
||||
extraBefore+=($NIX_LDFLAGS_BEFORE_@suffixSalt@)
|
||||
fi
|
||||
|
||||
extraAfter+=($NIX_@infixSalt@_LDFLAGS_AFTER)
|
||||
extraAfter+=($NIX_LDFLAGS_AFTER_@suffixSalt@)
|
||||
|
||||
# Specify the target emulation if nothing is passed in ("-m" overrides this
|
||||
# environment variable). Ensures we never blindly fallback on targeting the host
|
||||
@@ -84,8 +84,8 @@ declare -A libs
|
||||
declare -i relocatable=0 link32=0
|
||||
|
||||
if
|
||||
[ "$NIX_@infixSalt@_DONT_SET_RPATH" != 1 ] \
|
||||
|| [ "$NIX_@infixSalt@_SET_BUILD_ID" = 1 ] \
|
||||
[ "$NIX_DONT_SET_RPATH_@suffixSalt@" != 1 ] \
|
||||
|| [ "$NIX_SET_BUILD_ID_@suffixSalt@" = 1 ] \
|
||||
|| [ -e @out@/nix-support/dynamic-linker-m32 ]
|
||||
then
|
||||
prev=
|
||||
@@ -144,7 +144,7 @@ if [ -e "@out@/nix-support/dynamic-linker-m32" ] && (( "$link32" )); then
|
||||
fi
|
||||
|
||||
# Add all used dynamic libraries to the rpath.
|
||||
if [ "$NIX_@infixSalt@_DONT_SET_RPATH" != 1 ]; then
|
||||
if [ "$NIX_DONT_SET_RPATH_@suffixSalt@" != 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.
|
||||
@@ -186,7 +186,7 @@ fi
|
||||
|
||||
# Only add --build-id if this is a final link. FIXME: should build gcc
|
||||
# with --enable-linker-build-id instead?
|
||||
if [ "$NIX_@infixSalt@_SET_BUILD_ID" = 1 ] && ! (( "$relocatable" )); then
|
||||
if [ "$NIX_SET_BUILD_ID_@suffixSalt@" = 1 ] && ! (( "$relocatable" )); then
|
||||
extraAfter+=(--build-id)
|
||||
fi
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
|
||||
bintoolsWrapper_addLDVars () {
|
||||
# See ../setup-hooks/role.bash
|
||||
local role_post role_pre
|
||||
local role_post
|
||||
getHostRoleEnvHook
|
||||
|
||||
if [[ -d "$1/lib64" && ! -L "$1/lib64" ]]; then
|
||||
export NIX_${role_pre}LDFLAGS+=" -L$1/lib64"
|
||||
export NIX_LDFLAGS${role_post}+=" -L$1/lib64"
|
||||
fi
|
||||
|
||||
if [[ -d "$1/lib" ]]; then
|
||||
@@ -24,7 +24,7 @@ bintoolsWrapper_addLDVars () {
|
||||
# directories and bloats the size of the environment variable space.
|
||||
local -a glob=( $1/lib/lib* )
|
||||
if [ "${#glob[*]}" -gt 0 ]; then
|
||||
export NIX_${role_pre}LDFLAGS+=" -L$1/lib"
|
||||
export NIX_LDFLAGS${role_post}+=" -L$1/lib"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@@ -52,7 +52,7 @@ fi
|
||||
|
||||
# Export tool environment variables so various build systems use the right ones.
|
||||
|
||||
export NIX_${role_pre}BINTOOLS=@out@
|
||||
export NIX_BINTOOLS${role_post}=@out@
|
||||
|
||||
for cmd in \
|
||||
ar as ld nm objcopy objdump readelf ranlib strip strings size windres
|
||||
@@ -60,7 +60,6 @@ do
|
||||
if
|
||||
PATH=$_PATH type -p "@targetPrefix@${cmd}" > /dev/null
|
||||
then
|
||||
export "${role_pre}${cmd^^}=@targetPrefix@${cmd}";
|
||||
export "${cmd^^}${role_post}=@targetPrefix@${cmd}";
|
||||
fi
|
||||
done
|
||||
@@ -70,4 +69,4 @@ done
|
||||
export NIX_HARDENING_ENABLE
|
||||
|
||||
# No local scope in sourced file
|
||||
unset -v role_pre role_post cmd upper_case
|
||||
unset -v role_post cmd upper_case
|
||||
|
||||
Reference in New Issue
Block a user