Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at python-updates 89 lines 3.5 kB view raw
1# N.B. It may be a surprise that the derivation-specific variables are exported, 2# since this is just sourced by the wrapped binaries---the end consumers. This 3# is because one wrapper binary may invoke another (e.g. cc invoking ld). In 4# that case, it is cheaper/better to not repeat this step and let the forked 5# wrapped binary just inherit the work of the forker's wrapper script. 6 7var_templates_list=( 8 NIX_CFLAGS_COMPILE 9 NIX_CFLAGS_COMPILE_BEFORE 10 NIX_CFLAGS_LINK 11 NIX_CXXSTDLIB_COMPILE 12 NIX_CXXSTDLIB_LINK 13 NIX_GNATFLAGS_COMPILE 14) 15var_templates_bool=( 16 NIX_ENFORCE_NO_NATIVE 17) 18 19accumulateRoles 20 21# We need to mangle names for hygiene, but also take parameters/overrides 22# from the environment. 23for var in "${var_templates_list[@]}"; do 24 mangleVarList "$var" ${role_suffixes[@]+"${role_suffixes[@]}"} 25done 26for var in "${var_templates_bool[@]}"; do 27 mangleVarBool "$var" ${role_suffixes[@]+"${role_suffixes[@]}"} 28done 29 30# Prepending `@bintools@/bin' to $PATH forces cc to use ld-wrapper.sh when calling ld. 31# $path_backup is where cc-wrapper.sh stores the $PATH that will be used for the 32# compiler invocation. 33path_backup="@bintools@/bin:$path_backup" 34 35# Export and assign separately in order that a failing $(..) will fail 36# the script. 37 38# Currently bootstrap-tools does not split glibc, and gcc files into 39# separate directories. As a workaround we want resulting cflags to be 40# ordered as: crt1-cflags libc-cflags cc-cflags. Otherwise we mix crt/libc.so 41# from different libc as seen in 42# https://github.com/NixOS/nixpkgs/issues/158042 43# 44# Note that below has reverse ordering as we prepend flags one-by-one. 45# Once bootstrap-tools is split into different directories we can stop 46# relying on flag ordering below. 47 48if [ -e @out@/nix-support/cc-cflags ]; then 49 NIX_CFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/cc-cflags) $NIX_CFLAGS_COMPILE_@suffixSalt@" 50fi 51 52if [[ "$cInclude" = 1 ]] && [ -e @out@/nix-support/libc-cflags ]; then 53 NIX_CFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/libc-cflags) $NIX_CFLAGS_COMPILE_@suffixSalt@" 54fi 55 56if [ -e @out@/nix-support/libc-crt1-cflags ]; then 57 NIX_CFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/libc-crt1-cflags) $NIX_CFLAGS_COMPILE_@suffixSalt@" 58fi 59 60if [ -e @out@/nix-support/libcxx-cxxflags ]; then 61 NIX_CXXSTDLIB_COMPILE_@suffixSalt@+=" $(< @out@/nix-support/libcxx-cxxflags)" 62fi 63 64if [ -e @out@/nix-support/libcxx-ldflags ]; then 65 NIX_CXXSTDLIB_LINK_@suffixSalt@+=" $(< @out@/nix-support/libcxx-ldflags)" 66fi 67 68if [ -e @out@/nix-support/gnat-cflags ]; then 69 NIX_GNATFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/gnat-cflags) $NIX_GNATFLAGS_COMPILE_@suffixSalt@" 70fi 71 72if [ -e @out@/nix-support/cc-ldflags ]; then 73 NIX_LDFLAGS_@suffixSalt@+=" $(< @out@/nix-support/cc-ldflags)" 74fi 75 76if [ -e @out@/nix-support/cc-cflags-before ]; then 77 NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@="$(< @out@/nix-support/cc-cflags-before) $NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@" 78fi 79 80# Only add darwin min version flag if a default darwin min version is set, 81# which is a signal that we're targetting darwin. 82if [ "@darwinMinVersion@" ]; then 83 mangleVarSingle @darwinMinVersionVariable@ ${role_suffixes[@]+"${role_suffixes[@]}"} 84 85 NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@="-m@darwinPlatformForCC@-version-min=${@darwinMinVersionVariable@_@suffixSalt@:-@darwinMinVersion@} $NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@" 86fi 87 88# That way forked processes will not extend these environment variables again. 89export NIX_CC_WRAPPER_FLAGS_SET_@suffixSalt@=1