summaryrefslogtreecommitdiff
path: root/compiler/GHC/Linker
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-09-16 16:17:44 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-09-22 08:24:23 -0400
commit92257abd4b64f0496204adb19462d05c1d6475e3 (patch)
tree906a64d411ff4116482742fdaeebd64fb24df570 /compiler/GHC/Linker
parentbb37026e3547af569db6dce021b59f4d0ac70910 (diff)
downloadhaskell-92257abd4b64f0496204adb19462d05c1d6475e3.tar.gz
Link with libm dynamically (#19877)
The compiler should be independent of the target.
Diffstat (limited to 'compiler/GHC/Linker')
-rw-r--r--compiler/GHC/Linker/Dynamic.hs16
-rw-r--r--compiler/GHC/Linker/Static.hs2
2 files changed, 8 insertions, 10 deletions
diff --git a/compiler/GHC/Linker/Dynamic.hs b/compiler/GHC/Linker/Dynamic.hs
index e8c31a1f20..3eca65c6cc 100644
--- a/compiler/GHC/Linker/Dynamic.hs
+++ b/compiler/GHC/Linker/Dynamic.hs
@@ -197,7 +197,8 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages
-------------------------------------------------------------------
let output_fn = case o_file of { Just s -> s; Nothing -> "a.out"; }
- unregisterised = platformUnregisterised (targetPlatform dflags)
+ platform = targetPlatform dflags
+ unregisterised = platformUnregisterised platform
let bsymbolicFlag = -- we need symbolic linking to resolve
-- non-PIC intra-package-relocations for
-- performance (where symbolic linking works)
@@ -206,7 +207,7 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages
runLink logger tmpfs dflags (
map Option verbFlags
- ++ libmLinkOpts
+ ++ libmLinkOpts platform
++ [ Option "-o"
, FileOption "" output_fn
]
@@ -224,13 +225,10 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages
-- | Some platforms require that we explicitly link against @libm@ if any
-- math-y things are used (which we assume to include all programs). See #14022.
-libmLinkOpts :: [Option]
-libmLinkOpts =
-#if defined(HAVE_LIBM)
- [Option "-lm"]
-#else
- []
-#endif
+libmLinkOpts :: Platform -> [Option]
+libmLinkOpts platform
+ | platformHasLibm platform = [Option "-lm"]
+ | otherwise = []
{-
Note [-Bsymbolic assumptions by GHC]
diff --git a/compiler/GHC/Linker/Static.hs b/compiler/GHC/Linker/Static.hs
index c4549d5274..ed67daa347 100644
--- a/compiler/GHC/Linker/Static.hs
+++ b/compiler/GHC/Linker/Static.hs
@@ -197,7 +197,7 @@ linkBinary' staticLink logger tmpfs dflags unit_env o_files dep_units = do
++ [ GHC.SysTools.Option "-o"
, GHC.SysTools.FileOption "" output_fn
]
- ++ libmLinkOpts
+ ++ libmLinkOpts platform
++ map GHC.SysTools.Option (
[]