From 5f728fc4dd3121aa4d2809a68629a6422b53e95c Mon Sep 17 00:00:00 2001 From: Cheng Shao <terrorjack@type.dance> Date: Tue, 7 May 2024 20:35:47 +0000 Subject: [PATCH] hadrian: disable PIC for in-tree GMP on wasm32 This patch disables PIC for in-tree GMP on wasm32 target. Enabling PIC unconditionally adds undesired code size and runtime overhead for wasm32. (cherry picked from commit f9c1ae122ec642c0d9236dffc971bc2d1ca38fba) --- hadrian/src/Settings/Builders/Configure.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hadrian/src/Settings/Builders/Configure.hs b/hadrian/src/Settings/Builders/Configure.hs index 49f49767291..83d60306728 100644 --- a/hadrian/src/Settings/Builders/Configure.hs +++ b/hadrian/src/Settings/Builders/Configure.hs @@ -15,7 +15,6 @@ configureBuilderArgs = do targetPlatform <- queryTarget targetPlatformTriple buildPlatform <- queryBuild targetPlatformTriple 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 @@ -25,6 +24,10 @@ configureBuilderArgs = do -- more detailed explanation of this configure -- option. <> [ "--enable-alloca=malloc-reentrant" | targetArch == "wasm32" ] + -- Enable PIC unless target is wasm32, in which + -- case we don't want libgmp.a to be bloated due + -- to PIC overhead. + <> [ "--with-pic=yes" | targetArch /= "wasm32" ] , builder (Configure libffiPath) ? do top <- expr topDirectory -- GitLab