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