2017-07-06 23:19:53 +02:00
|
|
|
# N.B. It may be a surprise that the derivation-specific variables are exported,
|
|
|
|
# since this is just sourced by the wrapped binaries---the end consumers. This
|
|
|
|
# is because one wrapper binary may invoke another (e.g. cc invoking ld). In
|
|
|
|
# that case, it is cheaper/better to not repeat this step and let the forked
|
|
|
|
# wrapped binary just inherit the work of the forker's wrapper script.
|
|
|
|
|
2017-08-31 21:29:03 +02:00
|
|
|
var_templates_list=(
|
2017-08-08 02:15:10 +02:00
|
|
|
NIX+CFLAGS_COMPILE
|
|
|
|
NIX+CFLAGS_LINK
|
|
|
|
NIX+CXXSTDLIB_COMPILE
|
|
|
|
NIX+CXXSTDLIB_LINK
|
|
|
|
NIX+GNATFLAGS_COMPILE
|
2017-08-31 21:29:03 +02:00
|
|
|
)
|
|
|
|
var_templates_bool=(
|
2017-08-08 02:15:10 +02:00
|
|
|
NIX+ENFORCE_NO_NATIVE
|
|
|
|
)
|
|
|
|
|
|
|
|
# Accumulate infixes for taking in the right input parameters. See setup-hook
|
2017-07-06 23:19:53 +02:00
|
|
|
# for details.
|
2017-08-08 02:15:10 +02:00
|
|
|
declare -a role_infixes=()
|
|
|
|
if [ "${NIX_CC_WRAPPER_@infixSalt@_TARGET_BUILD:-}" ]; then
|
|
|
|
role_infixes+=(_BUILD_)
|
2017-07-06 23:19:53 +02:00
|
|
|
fi
|
2017-08-08 02:15:10 +02:00
|
|
|
if [ "${NIX_CC_WRAPPER_@infixSalt@_TARGET_HOST:-}" ]; then
|
|
|
|
role_infixes+=(_)
|
2017-08-08 10:20:00 +02:00
|
|
|
fi
|
2017-08-08 02:15:10 +02:00
|
|
|
if [ "${NIX_CC_WRAPPER_@infixSalt@_TARGET_TARGET:-}" ]; then
|
|
|
|
role_infixes+=(_TARGET_)
|
2017-07-06 23:19:53 +02:00
|
|
|
fi
|
|
|
|
|
2017-08-08 02:15:10 +02:00
|
|
|
# We need to mangle names for hygiene, but also take parameters/overrides
|
|
|
|
# from the environment.
|
2017-08-31 21:29:03 +02:00
|
|
|
for var in "${var_templates_list[@]}"; do
|
2017-08-31 20:43:09 +02:00
|
|
|
mangleVarList "$var" "${role_infixes[@]}"
|
2017-08-31 21:29:03 +02:00
|
|
|
done
|
2017-08-31 21:29:03 +02:00
|
|
|
for var in "${var_templates_bool[@]}"; do
|
|
|
|
mangleVarBool "$var" "${role_infixes[@]}"
|
|
|
|
done
|
2017-07-06 23:19:53 +02:00
|
|
|
|
2016-02-05 11:59:18 +01:00
|
|
|
# `-B@out@/bin' forces cc to use ld-wrapper.sh when calling ld.
|
2017-08-08 02:15:10 +02:00
|
|
|
NIX_@infixSalt@_CFLAGS_COMPILE="-B@out@/bin/ $NIX_@infixSalt@_CFLAGS_COMPILE"
|
2008-06-26 13:07:46 +02:00
|
|
|
|
2017-08-02 18:48:51 +02:00
|
|
|
# Export and assign separately in order that a failing $(..) will fail
|
|
|
|
# the script.
|
|
|
|
|
2014-10-10 14:25:23 +02:00
|
|
|
if [ -e @out@/nix-support/libc-cflags ]; then
|
2017-06-26 06:43:06 +02:00
|
|
|
NIX_@infixSalt@_CFLAGS_COMPILE="$(< @out@/nix-support/libc-cflags) $NIX_@infixSalt@_CFLAGS_COMPILE"
|
2008-06-26 13:07:46 +02:00
|
|
|
fi
|
|
|
|
|
2016-02-05 11:59:18 +01:00
|
|
|
if [ -e @out@/nix-support/cc-cflags ]; then
|
2017-06-26 06:43:06 +02:00
|
|
|
NIX_@infixSalt@_CFLAGS_COMPILE="$(< @out@/nix-support/cc-cflags) $NIX_@infixSalt@_CFLAGS_COMPILE"
|
2008-06-26 13:07:46 +02:00
|
|
|
fi
|
|
|
|
|
2014-10-10 14:25:23 +02:00
|
|
|
if [ -e @out@/nix-support/gnat-cflags ]; then
|
2017-06-26 06:43:06 +02:00
|
|
|
NIX_@infixSalt@_GNATFLAGS_COMPILE="$(< @out@/nix-support/gnat-cflags) $NIX_@infixSalt@_GNATFLAGS_COMPILE"
|
2010-01-16 22:32:44 +01:00
|
|
|
fi
|
|
|
|
|
2016-02-05 11:59:18 +01:00
|
|
|
if [ -e @out@/nix-support/cc-ldflags ]; then
|
2017-06-26 06:43:06 +02:00
|
|
|
NIX_@infixSalt@_LDFLAGS+=" $(< @out@/nix-support/cc-ldflags)"
|
2008-06-26 13:07:46 +02:00
|
|
|
fi
|
|
|
|
|
2017-08-08 02:15:10 +02:00
|
|
|
# That way forked processes will not extend these environment variables again.
|
2017-06-26 06:43:06 +02:00
|
|
|
export NIX_CC_WRAPPER_@infixSalt@_FLAGS_SET=1
|