1# Binutils Wrapper hygiene 2# 3# See comments in cc-wrapper's setup hook. This works exactly the same way. 4 5# Skip setup hook if we're neither a build-time dep, nor, temporarily, doing a 6# native compile. 7# 8# TODO(@Ericson2314): No native exception 9[[ -z ${strictDeps-} ]] || (( "$hostOffset" < 0 )) || return 0 10 11bintoolsWrapper_addLDVars () { 12 # See ../setup-hooks/role.bash 13 local role_post 14 getHostRoleEnvHook 15 16 if [[ -d "$1/lib64" && ! -L "$1/lib64" ]]; then 17 export NIX_LDFLAGS${role_post}+=" -L$1/lib64" 18 fi 19 20 if [[ -d "$1/lib" ]]; then 21 # Don't add the /lib directory if it actually doesn't contain any libraries. For instance, 22 # Python and Haskell packages often only have directories like $out/lib/ghc-8.4.3/ or 23 # $out/lib/python3.6/, so having them in LDFLAGS just makes the linker search unnecessary 24 # directories and bloats the size of the environment variable space. 25 local -a glob=( $1/lib/lib* ) 26 if [ "${#glob[*]}" -gt 0 ]; then 27 export NIX_LDFLAGS${role_post}+=" -L$1/lib" 28 fi 29 fi 30} 31 32# See ../setup-hooks/role.bash 33getTargetRole 34getTargetRoleWrapper 35 36addEnvHooks "$targetOffset" bintoolsWrapper_addLDVars 37 38# shellcheck disable=SC2157 39if [ -n "@bintools_bin@" ]; then 40 addToSearchPath _PATH @bintools_bin@/bin 41fi 42 43# shellcheck disable=SC2157 44if [ -n "@libc_bin@" ]; then 45 addToSearchPath _PATH @libc_bin@/bin 46fi 47 48# shellcheck disable=SC2157 49if [ -n "@coreutils_bin@" ]; then 50 addToSearchPath _PATH @coreutils_bin@/bin 51fi 52 53# Export tool environment variables so various build systems use the right ones. 54 55export NIX_BINTOOLS${role_post}=@out@ 56 57for cmd in \ 58 ar as ld nm objcopy objdump readelf ranlib strip strings size windres 59do 60 if 61 PATH=$_PATH type -p "@targetPrefix@${cmd}" > /dev/null 62 then 63 export "${cmd^^}${role_post}=@targetPrefix@${cmd}"; 64 fi 65done 66 67# If unset, assume the default hardening flags. 68: ${NIX_HARDENING_ENABLE="@default_hardening_flags_str@"} 69export NIX_HARDENING_ENABLE 70 71# No local scope in sourced file 72unset -v role_post cmd upper_case