ghc: enable static RTS
This change allows loading statically compiled libreries into a running GHC, thus fixing the build of haskell packages that use TemplateHaskell. See [1] for the details. Fixes issue #61575, #124284. [1]: https://www.tweag.io/blog/2020-09-30-bazel-static-haskell/
This commit is contained in:
parent
0da85d3f77
commit
4884fcc0d2
2 changed files with 16 additions and 8 deletions
|
@ -33,7 +33,7 @@
|
|||
|
||||
, # Whether to build dynamic libs for the standard library (on the target
|
||||
# platform). Static libs are always built.
|
||||
enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt
|
||||
enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic
|
||||
|
||||
, # Whether to build terminfo.
|
||||
enableTerminfo ? !stdenv.targetPlatform.isWindows
|
||||
|
@ -105,9 +105,13 @@ let
|
|||
CrossCompilePrefix = ${targetPrefix}
|
||||
'' + lib.optionalString (!enableProfiledLibs) ''
|
||||
GhcLibWays = "v dyn"
|
||||
'' + lib.optionalString enableRelocatedStaticLibs ''
|
||||
GhcLibHcOpts += -fPIC
|
||||
GhcRtsHcOpts += -fPIC
|
||||
'' +
|
||||
# -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
|
||||
# makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
|
||||
# This solution was described in https://www.tweag.io/blog/2020-09-30-bazel-static-haskell
|
||||
lib.optionalString enableRelocatedStaticLibs ''
|
||||
GhcLibHcOpts += -fPIC -fexternal-dynamic-refs
|
||||
GhcRtsHcOpts += -fPIC -fexternal-dynamic-refs
|
||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
||||
EXTRA_CC_OPTS += -std=gnu99
|
||||
'';
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
, # Whether to build dynamic libs for the standard library (on the target
|
||||
# platform). Static libs are always built.
|
||||
enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt
|
||||
enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic
|
||||
|
||||
, # Whether to build terminfo.
|
||||
enableTerminfo ? !stdenv.targetPlatform.isWindows
|
||||
|
@ -106,9 +106,13 @@ let
|
|||
CrossCompilePrefix = ${targetPrefix}
|
||||
'' + lib.optionalString (!enableProfiledLibs) ''
|
||||
GhcLibWays = "v dyn"
|
||||
'' + lib.optionalString enableRelocatedStaticLibs ''
|
||||
GhcLibHcOpts += -fPIC
|
||||
GhcRtsHcOpts += -fPIC
|
||||
'' +
|
||||
# -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
|
||||
# makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
|
||||
# This solution was described in https://www.tweag.io/blog/2020-09-30-bazel-static-haskell
|
||||
lib.optionalString enableRelocatedStaticLibs ''
|
||||
GhcLibHcOpts += -fPIC -fexternal-dynamic-refs
|
||||
GhcRtsHcOpts += -fPIC -fexternal-dynamic-refs
|
||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
||||
EXTRA_CC_OPTS += -std=gnu99
|
||||
'';
|
||||
|
|
Loading…
Reference in a new issue