2 fixupCFlagsForDarwin
() {
3 # Because it’s getting called from a Darwin stdenv, avr-gcc will pick up on
4 # Darwin-specific flags, and it will barf and die on -iframework in
5 # particular. Strip them out, so simavr can compile its test firmware.
6 cflagsFilter
='s|-F[^ ]*||g;s|-iframework [^ ]*||g;s|-isystem [^ ]*||g;s| *| |g'
8 # The `CoreFoundation` reference is added by `linkSystemCoreFoundationFramework` in the
9 # Apple SDK’s setup hook. Remove that because avr-gcc will fail due to file not found.
10 ldFlagsFilter
='s|/nix/store/[^-]*-apple-framework-CoreFoundation[^ ]*||g'
12 # `cc-wrapper.sh`` supports getting flags from a system-specific salt. While it is currently a
13 # tuple, that’s not considered a stable interface, so the derivation will provide them.
14 export NIX_CFLAGS_COMPILE_@darwinSuffixSalt@
=${NIX_CFLAGS_COMPILE-}
15 export NIX_LDFLAGS_@darwinSuffixSalt@
=${NIX_LDFLAGS-}
17 echo removing @darwinSuffixSalt@
-specific flags from NIX_CFLAGS_COMPILE
for @avrSuffixSalt@
18 export NIX_CFLAGS_COMPILE_@avrSuffixSalt@
+="$(sed "$cflagsFilter" <<< "$NIX_CFLAGS_COMPILE")"
19 echo removing @darwinSuffixSalt@
-specific flags from NIX_LDFLAGS
for @avrSuffixSalt@
20 export NIX_LDFLAGS_@avrSuffixSalt@
+="$(sed "$ldFlagsFilter;$cflagsFilter" <<< "$NIX_LDFLAGS")"
22 # Make sure the global flags aren’t accidentally influencing the platform-specific flags.
23 export NIX_CFLAGS_COMPILE
=""
27 # This is pretty hacky, but this hook _must_ run after `linkSystemCoreFoundationFramework`.
28 function runFixupCFlagsForDarwinLast
() {
29 preConfigureHooks
+=(fixupCFlagsForDarwin
)
32 if [ -z "${dontFixupCFlagsForDarwin-}" ]; then
33 postUnpackHooks
+=(runFixupCFlagsForDarwinLast
)