@@ -64,11 +64,11 @@ let self =
64
64
# necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
65
65
disableLargeAddressSpace ? stdenv . targetPlatform . isDarwin && stdenv . targetPlatform . isAarch64
66
66
67
- , useLdGold ?
67
+ , useLdGold ?
68
68
# might be better check to see if cc is clang/llvm?
69
69
# use gold as the linker on linux to improve link times
70
70
# do not use it on musl due to a ld.gold bug. See: <https://sourceware.org/bugzilla/show_bug.cgi?id=22266>.
71
- ( stdenv . targetPlatform . isLinux && ! stdenv . targetPlatform . isAndroid && ! stdenv . targetPlatform . isMusl )
71
+ ( stdenv . targetPlatform . isLinux && ! stdenv . targetPlatform . isAndroid && ! stdenv . targetPlatform . isMusl )
72
72
73
73
, ghc-version ? src-spec . version
74
74
, ghc-version-date ? null
311
311
# For cross compilers only the RTS should be built with -mno-outline-atomics
312
312
+ lib . optionalString ( ! hostPlatform . isAarch64 && targetPlatform . isLinux && targetPlatform . isAarch64 )
313
313
" '*.rts.ghc.c.opts += -optc-mno-outline-atomics'"
314
- # The following is required if we build on aarch64-darwin for aarch64-iOS. Otherwise older
314
+ + lib . optionalString enableRelocatedStaticLibs
315
+ " '*.*.ghc.*.opts += -fPIC' '*.*.cc.*.opts += -fPIC'"
316
+ + lib . optionalString ( enableRelocatedStaticLibs && targetPlatform . isx86_64 && ! targetPlatform . isWindows )
317
+ " '*.*.ghc.*.opts += -fexternal-dynamic-refs'"
318
+ # The following is required if we build on aarch64-darwin for aarch64-iOS. Otherwise older
315
319
# iPhones/iPads/... won't understand the compiled code, as the compiler will emit LDSETALH
316
320
# + lib.optionalString (targetPlatform.???) "'*.rts.ghc.c.opts += -optc-mcpu=apple-a7 -optc-march=armv8-a+norcpc'"
317
321
# For GHC versions in the 9.x range that don't support the +native_bignum flavour transformer yet
@@ -403,7 +407,7 @@ stdenv.mkDerivation (rec {
403
407
'' + lib . optionalString ( stdenv . targetPlatform . linker == "cctools" ) ''
404
408
export OTOOL="${ targetCC . bintools . bintools } /bin/${ targetCC . bintools . targetPrefix } otool"
405
409
export INSTALL_NAME_TOOL="${ bintoolsFor . install_name_tool } /bin/${ bintoolsFor . install_name_tool . targetPrefix } install_name_tool"
406
- '' ) + lib . optionalString ( targetPlatform == hostPlatform && useLdGold )
410
+ '' ) + lib . optionalString ( targetPlatform == hostPlatform && useLdGold )
407
411
# set LD explicitly if we want gold even if we aren't cross compiling
408
412
''
409
413
export LD="${ targetCC . bintools } /bin/ld.gold"
@@ -779,9 +783,9 @@ stdenv.mkDerivation (rec {
779
783
'' ;
780
784
781
785
# Hadrian's installation only works for native compilers, and is broken for cross compilers.
782
- # However Hadrian produces mostly relocatable installs anyway, so we can simply copy
786
+ # However Hadrian produces mostly relocatable installs anyway, so we can simply copy
783
787
# stage1/{bin, lib, share} into the destination as the copy phase.
784
-
788
+
785
789
installPhase =
786
790
if installStage1
787
791
then ''
0 commit comments