2020-04-24 23:36:52 +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.
|
|
|
|
|
|
|
|
var_templates_list=(
|
2020-06-18 07:06:33 +00:00
|
|
|
NIX_CFLAGS_COMPILE
|
|
|
|
NIX_CFLAGS_COMPILE_BEFORE
|
|
|
|
NIX_CFLAGS_LINK
|
|
|
|
NIX_CXXSTDLIB_COMPILE
|
|
|
|
NIX_CXXSTDLIB_LINK
|
|
|
|
NIX_GNATFLAGS_COMPILE
|
2020-04-24 23:36:52 +00:00
|
|
|
)
|
|
|
|
var_templates_bool=(
|
2020-06-18 07:06:33 +00:00
|
|
|
NIX_ENFORCE_NO_NATIVE
|
2020-04-24 23:36:52 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
accumulateRoles
|
|
|
|
|
|
|
|
# We need to mangle names for hygiene, but also take parameters/overrides
|
|
|
|
# from the environment.
|
|
|
|
for var in "${var_templates_list[@]}"; do
|
2020-06-18 07:06:33 +00:00
|
|
|
mangleVarList "$var" ${role_suffixes[@]+"${role_suffixes[@]}"}
|
2020-04-24 23:36:52 +00:00
|
|
|
done
|
|
|
|
for var in "${var_templates_bool[@]}"; do
|
2020-06-18 07:06:33 +00:00
|
|
|
mangleVarBool "$var" ${role_suffixes[@]+"${role_suffixes[@]}"}
|
2020-04-24 23:36:52 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# `-B@out@/bin' forces cc to use ld-wrapper.sh when calling ld.
|
2020-06-18 07:06:33 +00:00
|
|
|
NIX_CFLAGS_COMPILE_@suffixSalt@="-B@out@/bin/ $NIX_CFLAGS_COMPILE_@suffixSalt@"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Export and assign separately in order that a failing $(..) will fail
|
|
|
|
# the script.
|
|
|
|
|
|
|
|
if [ -e @out@/nix-support/libc-cflags ]; then
|
2020-06-18 07:06:33 +00:00
|
|
|
NIX_CFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/libc-cflags) $NIX_CFLAGS_COMPILE_@suffixSalt@"
|
2020-04-24 23:36:52 +00:00
|
|
|
fi
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
if [ -e @out@/nix-support/libcxx-cxxflags ]; then
|
|
|
|
NIX_CXXSTDLIB_COMPILE_@suffixSalt@+=" $(< @out@/nix-support/libcxx-cxxflags)"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -e @out@/nix-support/libcxx-ldflags ]; then
|
|
|
|
NIX_CXXSTDLIB_LINK_@suffixSalt@+=" $(< @out@/nix-support/libcxx-ldflags)"
|
|
|
|
fi
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
if [ -e @out@/nix-support/cc-cflags ]; then
|
2020-06-18 07:06:33 +00:00
|
|
|
NIX_CFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/cc-cflags) $NIX_CFLAGS_COMPILE_@suffixSalt@"
|
2020-04-24 23:36:52 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -e @out@/nix-support/gnat-cflags ]; then
|
2020-06-18 07:06:33 +00:00
|
|
|
NIX_GNATFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/gnat-cflags) $NIX_GNATFLAGS_COMPILE_@suffixSalt@"
|
2020-04-24 23:36:52 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -e @out@/nix-support/cc-ldflags ]; then
|
2020-06-18 07:06:33 +00:00
|
|
|
NIX_LDFLAGS_@suffixSalt@+=" $(< @out@/nix-support/cc-ldflags)"
|
2020-04-24 23:36:52 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -e @out@/nix-support/cc-cflags-before ]; then
|
2020-06-18 07:06:33 +00:00
|
|
|
NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@="$(< @out@/nix-support/cc-cflags-before) $NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@"
|
2020-04-24 23:36:52 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# That way forked processes will not extend these environment variables again.
|
2020-06-18 07:06:33 +00:00
|
|
|
export NIX_CC_WRAPPER_FLAGS_SET_@suffixSalt@=1
|