[Git][ghc/ghc][master] hadrian: disable alloca for in-tree GMP on wasm32

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Mon Jan 23 09:52:09 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
0900b584 by Cheng Shao at 2023-01-23T04:51:45-05:00
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).

- - - - -


1 changed file:

- hadrian/src/Settings/Builders/Configure.hs


Changes:

=====================================
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



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0900b58432c0e42263c62b0e151b0268129a290a

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0900b58432c0e42263c62b0e151b0268129a290a
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230123/44589139/attachment-0001.html>


More information about the ghc-commits mailing list