summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/GHC/Linker/Dynamic.hs16
-rw-r--r--compiler/GHC/Linker/Static.hs2
-rw-r--r--compiler/GHC/Platform.hs6
-rw-r--r--compiler/GHC/Settings/IO.hs2
-rw-r--r--configure.ac2
-rw-r--r--distrib/configure.ac.in3
-rw-r--r--hadrian/bindist/Makefile1
-rw-r--r--hadrian/cfg/system.config.in1
-rw-r--r--hadrian/src/Rules/Generate.hs1
-rw-r--r--mk/config.mk.in1
-rw-r--r--rts/include/ghc.mk1
11 files changed, 26 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 (
[]
diff --git a/compiler/GHC/Platform.hs b/compiler/GHC/Platform.hs
index b3f5bf830c..9bebcc5990 100644
--- a/compiler/GHC/Platform.hs
+++ b/compiler/GHC/Platform.hs
@@ -74,6 +74,11 @@ data Platform = Platform
-- ^ Determines whether we will be compiling info tables that reside just
-- before the entry code, or with an indirection to the entry code. See
-- TABLES_NEXT_TO_CODE in rts/include/rts/storage/InfoTables.h.
+ , platformHasLibm :: !Bool
+ -- ^ 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.
+
, platform_constants :: !(Maybe PlatformConstants)
-- ^ Constants such as structure offsets, type sizes, etc.
}
@@ -93,6 +98,7 @@ genericPlatform = Platform
, platformHasGnuNonexecStack = False
, platformHasIdentDirective = False
, platformHasSubsectionsViaSymbols= False
+ , platformHasLibm = False
, platformIsCrossCompiling = False
, platformLeadingUnderscore = False
, platformTablesNextToCode = True
diff --git a/compiler/GHC/Settings/IO.hs b/compiler/GHC/Settings/IO.hs
index 3c4e012675..49dd910d43 100644
--- a/compiler/GHC/Settings/IO.hs
+++ b/compiler/GHC/Settings/IO.hs
@@ -235,6 +235,7 @@ getTargetPlatform settingsFile settings = do
targetHasGnuNonexecStack <- getBooleanSetting "target has GNU nonexec stack"
targetHasIdentDirective <- getBooleanSetting "target has .ident directive"
targetHasSubsectionsViaSymbols <- getBooleanSetting "target has subsections via symbols"
+ targetHasLibm <- getBooleanSetting "target has libm"
crossCompiling <- getBooleanSetting "cross compiling"
tablesNextToCode <- getBooleanSetting "Tables next to code"
@@ -249,5 +250,6 @@ getTargetPlatform settingsFile settings = do
, platformIsCrossCompiling = crossCompiling
, platformLeadingUnderscore = targetLeadingUnderscore
, platformTablesNextToCode = tablesNextToCode
+ , platformHasLibm = targetHasLibm
, platform_constants = Nothing -- will be filled later when loading (or building) the RTS unit
}
diff --git a/configure.ac b/configure.ac
index da7598d621..a62f092877 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1092,6 +1092,8 @@ then
else
AC_SUBST([CabalHaveLibm],[False])
fi
+TargetHasLibm=$HaveLibM
+AC_SUBST(TargetHasLibm)
FP_BFD_SUPPORT
diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in
index 2a3425b1a6..dfc06e5a43 100644
--- a/distrib/configure.ac.in
+++ b/distrib/configure.ac.in
@@ -19,6 +19,9 @@ bootstrap_target=@TargetPlatform@
TargetHasRTSLinker=@TargetHasRTSLinker@
AC_SUBST(TargetHasRTSLinker)
+TargetHasLibm=@TargetHasLibm@
+AC_SUBST(TargetHasLibm)
+
FFIIncludeDir=@FFIIncludeDir@
FFILibDir=@FFILibDir@
AC_SUBST(FFILibDir)
diff --git a/hadrian/bindist/Makefile b/hadrian/bindist/Makefile
index c04e8a75bb..7221c89ab9 100644
--- a/hadrian/bindist/Makefile
+++ b/hadrian/bindist/Makefile
@@ -135,6 +135,7 @@ lib/settings :
@echo ',("target has .ident directive", "$(TargetHasIdentDirective)")' >> $@
@echo ',("target has subsections via symbols", "$(TargetHasSubsectionsViaSymbols)")' >> $@
@echo ',("target has RTS linker", "$(TargetHasRTSLinker)")' >> $@
+ @echo ',("target has libm", "$(TargetHasLibm)")' >> $@
@echo ',("Unregisterised", "$(GhcUnregisterised)")' >> $@
@echo ',("LLVM target", "$(LLVMTarget_CPP)")' >> $@
@echo ',("LLVM llc command", "$(SettingsLlcCommand)")' >> $@
diff --git a/hadrian/cfg/system.config.in b/hadrian/cfg/system.config.in
index e23c79a81d..2c341230cf 100644
--- a/hadrian/cfg/system.config.in
+++ b/hadrian/cfg/system.config.in
@@ -171,6 +171,7 @@ target-has-gnu-nonexec-stack = @TargetHasGnuNonexecStack@
target-has-ident-directive = @TargetHasIdentDirective@
target-has-subsections-via-symbols = @TargetHasSubsectionsViaSymbols@
target-has-rts-linker = @TargetHasRTSLinker@
+target-has-libm = @TargetHasLibm@
target-arm-version = @ARM_ISA@
# Include and library directories:
diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs
index 3eb100bae5..5247c8b4ae 100644
--- a/hadrian/src/Rules/Generate.hs
+++ b/hadrian/src/Rules/Generate.hs
@@ -329,6 +329,7 @@ generateSettings = do
, ("target has .ident directive", expr $ lookupValueOrError configFile "target-has-ident-directive")
, ("target has subsections via symbols", expr $ lookupValueOrError configFile "target-has-subsections-via-symbols")
, ("target has RTS linker", expr $ lookupValueOrError configFile "target-has-rts-linker")
+ , ("target has libm", expr $ lookupValueOrError configFile "target-has-libm")
, ("Unregisterised", expr $ yesNo <$> flag GhcUnregisterised)
, ("LLVM target", getSetting LlvmTarget)
, ("LLVM llc command", expr $ settingsFileSetting SettingsFileSetting_LlcCommand)
diff --git a/mk/config.mk.in b/mk/config.mk.in
index 95c9fe9378..18199bddd2 100644
--- a/mk/config.mk.in
+++ b/mk/config.mk.in
@@ -462,6 +462,7 @@ TargetHasGnuNonexecStack = @TargetHasGnuNonexecStack@
TargetHasIdentDirective = @TargetHasIdentDirective@
TargetHasSubsectionsViaSymbols = @TargetHasSubsectionsViaSymbols@
TargetHasRTSLinker = @TargetHasRTSLinker@
+TargetHasLibm = @TargetHasLibm@
TablesNextToCode = @TablesNextToCode@
SettingsCCompilerCommand = @SettingsCCompilerCommand@
diff --git a/rts/include/ghc.mk b/rts/include/ghc.mk
index 26275075bd..f44f970bb5 100644
--- a/rts/include/ghc.mk
+++ b/rts/include/ghc.mk
@@ -247,6 +247,7 @@ $(includes_SETTINGS) : rts/include/Makefile | $$(dir $$@)/.
@echo ',("target has .ident directive", "$(TargetHasIdentDirective)")' >> $@
@echo ',("target has subsections via symbols", "$(TargetHasSubsectionsViaSymbols)")' >> $@
@echo ',("target has RTS linker", "$(TargetHasRTSLinker)")' >> $@
+ @echo ',("target has libm", "$(TargetHasLibm)")' >> $@
@echo ',("Unregisterised", "$(GhcUnregisterised)")' >> $@
@echo ',("LLVM target", "$(LLVMTarget_CPP)")' >> $@
@echo ',("LLVM llc command", "$(SettingsLlcCommand)")' >> $@