summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheng Shao <terrorjack@type.dance>2023-01-17 13:43:40 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-01-23 04:51:45 -0500
commit0900b58432c0e42263c62b0e151b0268129a290a (patch)
tree29a1a77c936cd942acb4b8caabfcaaaa9b8a4e39
parent3efd1e9934d9896e6c816e6cafb41b6872e3015b (diff)
downloadhaskell-0900b58432c0e42263c62b0e151b0268129a290a.tar.gz
hadrian: disable alloca for in-tree GMP on wasm32
When building in-tree GMP for wasm32, disable its alloca usage, since it may potentially cause stack overflow (e.g. #22602).
-rw-r--r--hadrian/src/Settings/Builders/Configure.hs10
1 files changed, 9 insertions, 1 deletions
diff --git a/hadrian/src/Settings/Builders/Configure.hs b/hadrian/src/Settings/Builders/Configure.hs
index 885f6a3f1f..e88a8bde4a 100644
--- a/hadrian/src/Settings/Builders/Configure.hs
+++ b/hadrian/src/Settings/Builders/Configure.hs
@@ -10,12 +10,20 @@ configureBuilderArgs = do
gmpPath <- expr (gmpBuildPath stage)
libffiPath <- expr (libffiBuildPath stage)
mconcat [ builder (Configure gmpPath) ? do
+ targetArch <- getSetting TargetArch
targetPlatform <- getSetting TargetPlatform
buildPlatform <- getSetting BuildPlatform
- pure [ "--enable-shared=no"
+ pure $ [ "--enable-shared=no"
, "--with-pic=yes"
, "--host=" ++ targetPlatform -- GMP's host is our target
, "--build=" ++ buildPlatform ]
+ -- Disable GMP's alloca usage on wasm32, it may
+ -- cause stack overflow (#22602) due to the
+ -- rather small 64KB default stack size. See
+ -- https://gmplib.org/manual/Build-Options for
+ -- more detailed explanation of this configure
+ -- option.
+ <> [ "--enable-alloca=malloc-reentrant" | targetArch == "wasm32" ]
, builder (Configure libffiPath) ? do
top <- expr topDirectory