2017-07-06 21:19:53 +00: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-08 00:15:10 +00:00
|
|
|
var_templates=(
|
|
|
|
NIX+CFLAGS_COMPILE
|
|
|
|
NIX+CFLAGS_LINK
|
|
|
|
NIX+CXXSTDLIB_COMPILE
|
|
|
|
NIX+CXXSTDLIB_LINK
|
|
|
|
NIX+GNATFLAGS_COMPILE
|
|
|
|
NIX+IGNORE_LD_THROUGH_GCC
|
|
|
|
NIX+LDFLAGS
|
|
|
|
NIX+LDFLAGS_BEFORE
|
|
|
|
NIX+LDFLAGS_AFTER
|
|
|
|
|
|
|
|
NIX+SET_BUILD_ID
|
|
|
|
NIX+DONT_SET_RPATH
|
|
|
|
NIX+ENFORCE_NO_NATIVE
|
|
|
|
)
|
|
|
|
|
|
|
|
# Accumulate infixes for taking in the right input parameters. See setup-hook
|
2017-07-06 21:19:53 +00:00
|
|
|
# for details.
|
2017-08-08 00:15:10 +00:00
|
|
|
declare -a role_infixes=()
|
|
|
|
if [ "${NIX_CC_WRAPPER_@infixSalt@_TARGET_BUILD:-}" ]; then
|
|
|
|
role_infixes+=(_BUILD_)
|
2017-07-06 21:19:53 +00:00
|
|
|
fi
|
2017-08-08 00:15:10 +00:00
|
|
|
if [ "${NIX_CC_WRAPPER_@infixSalt@_TARGET_HOST:-}" ]; then
|
|
|
|
role_infixes+=(_)
|
2017-08-08 08:20:00 +00:00
|
|
|
fi
|
2017-08-08 00:15:10 +00:00
|
|
|
if [ "${NIX_CC_WRAPPER_@infixSalt@_TARGET_TARGET:-}" ]; then
|
|
|
|
role_infixes+=(_TARGET_)
|
2017-07-06 21:19:53 +00:00
|
|
|
fi
|
|
|
|
|
2017-08-08 00:15:10 +00:00
|
|
|
# We need to mangle names for hygiene, but also take parameters/overrides
|
|
|
|
# from the environment.
|
|
|
|
for var in "${var_templates[@]}"; do
|
2017-08-31 18:43:09 +00:00
|
|
|
mangleVarList "$var" "${role_infixes[@]}"
|
2017-07-06 21:19:53 +00:00
|
|
|
done
|
|
|
|
|
2016-02-05 10:59:18 +00:00
|
|
|
# `-B@out@/bin' forces cc to use ld-wrapper.sh when calling ld.
|
2017-08-08 00:15:10 +00:00
|
|
|
NIX_@infixSalt@_CFLAGS_COMPILE="-B@out@/bin/ $NIX_@infixSalt@_CFLAGS_COMPILE"
|
2008-06-26 11:07:46 +00:00
|
|
|
|
2017-08-02 16:48:51 +00:00
|
|
|
# Export and assign separately in order that a failing $(..) will fail
|
|
|
|
# the script.
|
|
|
|
|
2014-10-10 12:25:23 +00:00
|
|
|
if [ -e @out@/nix-support/libc-cflags ]; then
|
2017-06-26 04:43:06 +00:00
|
|
|
NIX_@infixSalt@_CFLAGS_COMPILE="$(< @out@/nix-support/libc-cflags) $NIX_@infixSalt@_CFLAGS_COMPILE"
|
2008-06-26 11:07:46 +00:00
|
|
|
fi
|
|
|
|
|
2016-02-05 10:59:18 +00:00
|
|
|
if [ -e @out@/nix-support/cc-cflags ]; then
|
2017-06-26 04:43:06 +00:00
|
|
|
NIX_@infixSalt@_CFLAGS_COMPILE="$(< @out@/nix-support/cc-cflags) $NIX_@infixSalt@_CFLAGS_COMPILE"
|
2008-06-26 11:07:46 +00:00
|
|
|
fi
|
|
|
|
|
2014-10-10 12:25:23 +00:00
|
|
|
if [ -e @out@/nix-support/gnat-cflags ]; then
|
2017-06-26 04:43:06 +00:00
|
|
|
NIX_@infixSalt@_GNATFLAGS_COMPILE="$(< @out@/nix-support/gnat-cflags) $NIX_@infixSalt@_GNATFLAGS_COMPILE"
|
2010-01-16 21:32:44 +00:00
|
|
|
fi
|
|
|
|
|
2014-10-10 12:25:23 +00:00
|
|
|
if [ -e @out@/nix-support/libc-ldflags ]; then
|
2017-06-26 04:43:06 +00:00
|
|
|
NIX_@infixSalt@_LDFLAGS+=" $(< @out@/nix-support/libc-ldflags)"
|
2009-02-01 21:26:28 +00:00
|
|
|
fi
|
|
|
|
|
2016-02-05 10:59:18 +00:00
|
|
|
if [ -e @out@/nix-support/cc-ldflags ]; then
|
2017-06-26 04:43:06 +00:00
|
|
|
NIX_@infixSalt@_LDFLAGS+=" $(< @out@/nix-support/cc-ldflags)"
|
2008-06-26 11:07:46 +00:00
|
|
|
fi
|
|
|
|
|
2014-10-10 12:25:23 +00:00
|
|
|
if [ -e @out@/nix-support/libc-ldflags-before ]; then
|
2017-06-26 04:43:06 +00:00
|
|
|
NIX_@infixSalt@_LDFLAGS_BEFORE="$(< @out@/nix-support/libc-ldflags-before) $NIX_@infixSalt@_LDFLAGS_BEFORE"
|
2008-06-26 11:07:46 +00:00
|
|
|
fi
|
|
|
|
|
2017-08-08 00:15:10 +00:00
|
|
|
# That way forked processes will not extend these environment variables again.
|
2017-06-26 04:43:06 +00:00
|
|
|
export NIX_CC_WRAPPER_@infixSalt@_FLAGS_SET=1
|