diff options
author | Ian Lynagh <ian@well-typed.com> | 2012-08-05 21:28:20 +0100 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2012-08-05 21:28:20 +0100 |
commit | 668151c880f5662e59288a0884d8d3505c0ce7d7 (patch) | |
tree | fa20b117613c448c7e0c33f078c5c17a11fb7ede /compiler/main | |
parent | 1235c2742ee991d15e1db4e2b2ed8587951221ea (diff) | |
download | haskell-668151c880f5662e59288a0884d8d3505c0ce7d7.tar.gz |
More more ld-related settings into the settings file
Related to #4862
Diffstat (limited to 'compiler/main')
-rw-r--r-- | compiler/main/DriverPipeline.hs | 20 | ||||
-rw-r--r-- | compiler/main/DynFlags.hs | 3 | ||||
-rw-r--r-- | compiler/main/SysTools.lhs | 11 |
3 files changed, 24 insertions, 10 deletions
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 = "", |