Skip to content
Snippets Groups Projects
Commit 18e53833 authored by Cheng Shao's avatar Cheng Shao
Browse files

hadrian: fix CFLAGS for gmp shared objs on wasm

This commit adds -fvisibility=default to CFLAGS of gmp when building
for wasm. This is required to generate the ghc-bignum shared library
without linking errors. Clang defaults to -fvisibility=hidden for wasm
targets, which will cause issues when a symbol is expected to be
exported in a shared library but without explicit visibility attribute
annotation.

(cherry picked from commit c247f2ee)
parent 37b3d585
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,7 @@ import Utilities ...@@ -12,6 +12,7 @@ import Utilities
import Hadrian.BuildPath import Hadrian.BuildPath
import Hadrian.Expression import Hadrian.Expression
import Settings.Builders.Common (cArgs, getStagedCCFlags) import Settings.Builders.Common (cArgs, getStagedCCFlags)
import GHC.Platform.ArchOS
-- | Build in-tree GMP library objects (if GmpInTree flag is set) and return -- | Build in-tree GMP library objects (if GmpInTree flag is set) and return
-- their paths. -- their paths.
...@@ -122,7 +123,13 @@ gmpRules = do ...@@ -122,7 +123,13 @@ gmpRules = do
let gmpBuildP = takeDirectory mk let gmpBuildP = takeDirectory mk
gmpP = takeDirectory gmpBuildP gmpP = takeDirectory gmpBuildP
ctx <- makeGmpPathContext gmpP ctx <- makeGmpPathContext gmpP
cFlags <- interpretInContext ctx $ mconcat [ cArgs, getStagedCCFlags ] cFlags <-
interpretInContext ctx $
mconcat
[ cArgs
, getStagedCCFlags
, anyTargetArch [ArchWasm32] ? arg "-fvisibility=default"
]
env <- sequence env <- sequence
[ builderEnvironment "CC" $ Cc CompileC (stage ctx) [ builderEnvironment "CC" $ Cc CompileC (stage ctx)
, return . AddEnv "CFLAGS" $ unwords cFlags , return . AddEnv "CFLAGS" $ unwords cFlags
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment