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=(
|
2020-04-28 06:08:48 +02:00
|
|
|
NIX_CFLAGS_COMPILE
|
|
|
|
NIX_CFLAGS_COMPILE_BEFORE
|
|
|
|
NIX_CFLAGS_LINK
|
|
|
|
NIX_CXXSTDLIB_COMPILE
|
|
|
|
NIX_CXXSTDLIB_LINK
|
|
|
|
NIX_GNATFLAGS_COMPILE
|
2017-08-31 21:29:03 +02:00
|
|
|
)
|
|
|
|
var_templates_bool=(
|
2020-04-28 06:08:48 +02:00
|
|
|
NIX_ENFORCE_NO_NATIVE
|
2017-08-08 02:15:10 +02:00
|
|
|
)
|
|
|
|
|
2018-05-07 19:15:34 +02:00
|
|
|
accumulateRoles
|
2017-07-06 23:19:53 +02:00
|
|
|
|
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
|
2020-04-28 06:08:48 +02:00
|
|
|
mangleVarList "$var" ${role_suffixes[@]+"${role_suffixes[@]}"}
|
2017-08-31 21:29:03 +02:00
|
|
|
done
|
2017-08-31 21:29:03 +02:00
|
|
|
for var in "${var_templates_bool[@]}"; do
|
2020-04-28 06:08:48 +02:00
|
|
|
mangleVarBool "$var" ${role_suffixes[@]+"${role_suffixes[@]}"}
|
2017-08-31 21:29:03 +02:00
|
|
|
done
|
2017-07-06 23:19:53 +02:00
|
|
|
|
2024-07-01 04:01:07 +02:00
|
|
|
# Arocc does not support "-B"
|
|
|
|
if [[ -z "@isArocc@" ]]; then
|
2024-06-04 16:35:49 +02:00
|
|
|
# `-B@bintools@/bin' forces cc to use ld-wrapper.sh when calling ld.
|
|
|
|
NIX_CFLAGS_COMPILE_@suffixSalt@="-B@bintools@/bin/ $NIX_CFLAGS_COMPILE_@suffixSalt@"
|
2024-07-01 04:01:07 +02:00
|
|
|
fi
|
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.
|
|
|
|
|
2022-02-11 19:55:51 +01:00
|
|
|
# Currently bootstrap-tools does not split glibc, and gcc files into
|
|
|
|
# separate directories. As a workaround we want resulting cflags to be
|
|
|
|
# ordered as: crt1-cflags libc-cflags cc-cflags. Otherwise we mix crt/libc.so
|
|
|
|
# from different libc as seen in
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/158042
|
|
|
|
#
|
|
|
|
# Note that below has reverse ordering as we prepend flags one-by-one.
|
|
|
|
# Once bootstrap-tools is split into different directories we can stop
|
|
|
|
# relying on flag ordering below.
|
|
|
|
|
|
|
|
if [ -e @out@/nix-support/cc-cflags ]; then
|
|
|
|
NIX_CFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/cc-cflags) $NIX_CFLAGS_COMPILE_@suffixSalt@"
|
|
|
|
fi
|
|
|
|
|
2020-07-01 22:55:06 +02:00
|
|
|
if [[ "$cInclude" = 1 ]] && [ -e @out@/nix-support/libc-cflags ]; then
|
2020-04-28 06:08:48 +02:00
|
|
|
NIX_CFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/libc-cflags) $NIX_CFLAGS_COMPILE_@suffixSalt@"
|
2020-07-01 22:55:06 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -e @out@/nix-support/libc-crt1-cflags ]; then
|
|
|
|
NIX_CFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/libc-crt1-cflags) $NIX_CFLAGS_COMPILE_@suffixSalt@"
|
2008-06-26 13:07:46 +02:00
|
|
|
fi
|
|
|
|
|
2020-04-14 02:44:43 +02: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
|
2008-06-26 13:07:46 +02:00
|
|
|
|
2019-05-11 23:16:17 +02:00
|
|
|
if [ -e @out@/nix-support/gnat-cflags ]; then
|
2020-04-28 06:08:48 +02:00
|
|
|
NIX_GNATFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/gnat-cflags) $NIX_GNATFLAGS_COMPILE_@suffixSalt@"
|
2019-05-11 23:16:17 +02:00
|
|
|
fi
|
|
|
|
|
2016-02-05 11:59:18 +01:00
|
|
|
if [ -e @out@/nix-support/cc-ldflags ]; then
|
2020-04-28 06:08:48 +02:00
|
|
|
NIX_LDFLAGS_@suffixSalt@+=" $(< @out@/nix-support/cc-ldflags)"
|
2008-06-26 13:07:46 +02:00
|
|
|
fi
|
|
|
|
|
2019-04-09 20:21:54 +02:00
|
|
|
if [ -e @out@/nix-support/cc-cflags-before ]; then
|
2020-04-28 06:08:48 +02:00
|
|
|
NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@="$(< @out@/nix-support/cc-cflags-before) $NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@"
|
2019-04-09 20:21:54 +02:00
|
|
|
fi
|
|
|
|
|
2021-04-10 06:11:28 +02:00
|
|
|
# Only add darwin min version flag if a default darwin min version is set,
|
|
|
|
# which is a signal that we're targetting darwin.
|
|
|
|
if [ "@darwinMinVersion@" ]; then
|
2021-04-10 11:06:25 +02:00
|
|
|
mangleVarSingle @darwinMinVersionVariable@ ${role_suffixes[@]+"${role_suffixes[@]}"}
|
2021-04-10 06:11:28 +02:00
|
|
|
|
2021-04-10 11:06:25 +02:00
|
|
|
NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@="-m@darwinPlatformForCC@-version-min=${@darwinMinVersionVariable@_@suffixSalt@:-@darwinMinVersion@} $NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@"
|
2021-04-10 06:11:28 +02:00
|
|
|
fi
|
|
|
|
|
2017-08-08 02:15:10 +02:00
|
|
|
# That way forked processes will not extend these environment variables again.
|
2020-04-28 06:08:48 +02:00
|
|
|
export NIX_CC_WRAPPER_FLAGS_SET_@suffixSalt@=1
|