summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/ghc.mk6
-rw-r--r--compiler/main/DriverPipeline.hs20
-rw-r--r--compiler/main/DynFlags.hs3
-rw-r--r--compiler/main/SysTools.lhs11
-rw-r--r--configure.ac9
-rw-r--r--distrib/configure.ac.in3
-rw-r--r--settings.in3
7 files changed, 34 insertions, 21 deletions
diff --git a/compiler/ghc.mk b/compiler/ghc.mk
index 8ddf73a4e2..de191eaa10 100644
--- a/compiler/ghc.mk
+++ b/compiler/ghc.mk
@@ -99,12 +99,6 @@ endif
@echo 'cLeadingUnderscore = "$(LeadingUnderscore)"' >> $@
@echo 'cRAWCPP_FLAGS :: String' >> $@
@echo 'cRAWCPP_FLAGS = "$(RAWCPP_FLAGS)"' >> $@
- @echo 'cLdHasNoCompactUnwind :: String' >> $@
- @echo 'cLdHasNoCompactUnwind = "$(LdHasNoCompactUnwind)"' >> $@
- @echo 'cLdIsGNULd :: String' >> $@
- @echo 'cLdIsGNULd = "$(LdIsGNULd)"' >> $@
- @echo 'cLdHasBuildId :: String' >> $@
- @echo 'cLdHasBuildId = "$(LdHasBuildId)"' >> $@
@echo 'cGHC_DRIVER_DIR :: String' >> $@
@echo 'cGHC_DRIVER_DIR = "$(GHC_DRIVER_DIR)"' >> $@
@echo 'cGHC_UNLIT_PGM :: String' >> $@
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 3d6f68158d..5dd24c4fe2 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -1655,6 +1655,7 @@ getHCFilePackages filename =
linkBinary :: DynFlags -> [FilePath] -> [PackageId] -> IO ()
linkBinary dflags o_files dep_packages = do
let platform = targetPlatform dflags
+ mySettings = settings dflags
verbFlags = getVerbFlags dflags
output_fn = exeFileName dflags
@@ -1767,7 +1768,7 @@ linkBinary dflags o_files dep_packages = do
-- like
-- ld: warning: could not create compact unwind for .LFB3: non-standard register 5 being saved in prolog
-- on x86.
- ++ (if cLdHasNoCompactUnwind == "YES" &&
+ ++ (if sLdSupportsCompactUnwind mySettings &&
platformOS platform == OSDarwin &&
platformArch platform `elem` [ArchX86, ArchX86_64]
then ["-Wl,-no_compact_unwind"]
@@ -2089,7 +2090,8 @@ hsSourceCppOpts =
joinObjectFiles :: DynFlags -> [FilePath] -> FilePath -> IO ()
joinObjectFiles dflags o_files output_fn = do
- let ld_r args = SysTools.runLink dflags ([
+ let mySettings = settings dflags
+ ld_r args = SysTools.runLink dflags ([
SysTools.Option "-nostdlib",
SysTools.Option "-nodefaultlibs",
SysTools.Option "-Wl,-r"
@@ -2100,20 +2102,18 @@ joinObjectFiles dflags o_files output_fn = do
++ (if platformArch (targetPlatform dflags) == ArchSPARC
then [SysTools.Option "-Wl,-no-relax"]
else [])
- ++ [
- SysTools.Option ld_build_id,
- -- SysTools.Option ld_x_flag,
- SysTools.Option "-o",
- SysTools.FileOption "" output_fn ]
+ ++ map SysTools.Option ld_build_id
+ ++ [ SysTools.Option "-o",
+ SysTools.FileOption "" output_fn ]
++ args)
-- suppress the generation of the .note.gnu.build-id section,
-- which we don't need and sometimes causes ld to emit a
-- warning:
- ld_build_id | cLdHasBuildId == "YES" = "-Wl,--build-id=none"
- | otherwise = ""
+ ld_build_id | sLdSupportsBuildId mySettings = ["-Wl,--build-id=none"]
+ | otherwise = []
- if cLdIsGNULd == "YES"
+ if sLdIsGnuLd mySettings
then do
script <- newTempName dflags "ldscript"
writeFile script $ "INPUT(" ++ unwords o_files ++ ")"
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 67681fd3bc..c422980dd8 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -672,6 +672,9 @@ data Settings = Settings {
sRawSettings :: [(String, String)],
sExtraGccViaCFlags :: [String],
sSystemPackageConfig :: FilePath,
+ sLdSupportsCompactUnwind :: Bool,
+ sLdSupportsBuildId :: Bool,
+ sLdIsGnuLd :: Bool,
-- commands for particular phases
sPgm_L :: String,
sPgm_P :: (String,[Option]),
diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs
index 4bf63facf1..0928927888 100644
--- a/compiler/main/SysTools.lhs
+++ b/compiler/main/SysTools.lhs
@@ -192,6 +192,11 @@ initSysTools mbMinusB
_ ->
xs
Nothing -> pgmError ("No entry for " ++ show key ++ " in " ++ show settingsFile)
+ getBooleanSetting key = case lookup key mySettings of
+ Just "YES" -> return True
+ Just "NO" -> return False
+ Just xs -> pgmError ("Bad value for " ++ show key ++ ": " ++ show xs)
+ Nothing -> pgmError ("No entry for " ++ show key ++ " in " ++ show settingsFile)
readSetting key = case lookup key mySettings of
Just xs ->
case maybeRead xs of
@@ -213,6 +218,9 @@ initSysTools mbMinusB
gcc_prog <- getSetting "C compiler command"
gcc_args_str <- getSetting "C compiler flags"
let gcc_args = map Option (words gcc_args_str)
+ ldSupportsCompactUnwind <- getBooleanSetting "ld supports compact unwind"
+ ldSupportsBuildId <- getBooleanSetting "ld supports build-id"
+ ldIsGnuLd <- getBooleanSetting "ld is GNU ld"
perl_path <- getSetting "perl command"
let pkgconfig_path = installed "package.conf.d"
@@ -280,6 +288,9 @@ initSysTools mbMinusB
sRawSettings = mySettings,
sExtraGccViaCFlags = words myExtraGccViaCFlags,
sSystemPackageConfig = pkgconfig_path,
+ sLdSupportsCompactUnwind = ldSupportsCompactUnwind,
+ sLdSupportsBuildId = ldSupportsBuildId,
+ sLdIsGnuLd = ldIsGnuLd,
sPgm_L = unlit_path,
sPgm_P = (cpp_prog, cpp_args),
sPgm_F = "",
diff --git a/configure.ac b/configure.ac
index c8e6ea5e2e..397e8a5de0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -546,6 +546,10 @@ FP_CC_LLVM_BACKEND
FP_PROG_LD_HashSize31
FP_PROG_LD_ReduceMemoryOverheads
+FP_PROG_LD_IS_GNU
+FP_PROG_LD_BUILD_ID
+FP_PROG_LD_NO_COMPACT_UNWIND
+
FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_GCC_LINKER_OPTS_STAGE0],[CONF_LD_LINKER_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
@@ -830,11 +834,6 @@ FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN
dnl ** check for leading underscores in symbol names
FP_LEADING_UNDERSCORE
-dnl ** check for ld, whether it has an -x option, and if it is GNU ld
-FP_PROG_LD_IS_GNU
-FP_PROG_LD_BUILD_ID
-FP_PROG_LD_NO_COMPACT_UNWIND
-
FP_VISIBILITY_HIDDEN
dnl ** check for librt
diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in
index 8cb57c4509..d1ef5d592c 100644
--- a/distrib/configure.ac.in
+++ b/distrib/configure.ac.in
@@ -72,6 +72,9 @@ AC_PROG_CPP
FP_PROG_LD_HashSize31
FP_PROG_LD_ReduceMemoryOverheads
+FP_PROG_LD_IS_GNU
+FP_PROG_LD_BUILD_ID
+FP_PROG_LD_NO_COMPACT_UNWIND
#
dnl ** Check gcc version and flags we need to pass it **
diff --git a/settings.in b/settings.in
index d6245d6400..dbf15fd501 100644
--- a/settings.in
+++ b/settings.in
@@ -2,6 +2,9 @@
("C compiler command", "@SettingsCCompilerCommand@"),
("C compiler flags", "@SettingsCCompilerFlags@"),
("ld flags", "@SettingsLdFlags@"),
+ ("ld supports compact unwind", "@LdHasNoCompactUnwind@"),
+ ("ld supports build-id", "@LdHasBuildId@"),
+ ("ld is GNU ld", "@LdIsGNULd@"),
("ar command", "@SettingsArCommand@"),
("ar flags", "@ArArgs@"),
("ar supports at file", "@ArSupportsAtFile@"),