MERGED: Fix building on Sparc/Solaris with non-GNU linker; fixes #5407
authorIan Lynagh <ian@well-typed.com>
Thu, 29 Nov 2012 13:33:05 +0000 (13:33 +0000)
committerIan Lynagh <ian@well-typed.com>
Thu, 29 Nov 2012 13:33:05 +0000 (13:33 +0000)
commit 9ef4d48e296d4b96492a839f9ee569f8f90c617b
Author: Ian Lynagh <ian@well-typed.com>
Date:   Fri Nov 23 16:54:15 2012 +0000

    Fix building on Sparc/Solaris with non-GNU linker; fixes #5407

    Patch from maeder.

compiler/main/DriverPipeline.hs

index 9f9f9da..6c35f71 100644 (file)
@@ -2097,7 +2097,8 @@ hsSourceCppOpts =
 
 joinObjectFiles :: DynFlags -> [FilePath] -> FilePath -> IO ()
 joinObjectFiles dflags o_files output_fn = do
-  let ld_r args = SysTools.runLink dflags ([
+  let ldIsGnuLd = cLdIsGNULd == "YES"
+      ld_r args = SysTools.runLink dflags ([
                             SysTools.Option "-nostdlib",
                             SysTools.Option "-nodefaultlibs",
                             SysTools.Option "-Wl,-r"
@@ -2106,6 +2107,7 @@ joinObjectFiles dflags o_files output_fn = do
                             -- -r and --relax are incompatible for ld, so
                             -- disable --relax explicitly.
                          ++ (if platformArch (targetPlatform dflags) == ArchSPARC
+                             && ldIsGnuLd
                                 then [SysTools.Option "-Wl,-no-relax"]
                                 else [])
                          ++ [
@@ -2129,7 +2131,7 @@ joinObjectFiles dflags o_files output_fn = do
       ld_build_id | cLdHasBuildId == "YES"  = "-Wl,--build-id=none"
                   | otherwise               = ""
 
-  if cLdIsGNULd == "YES"
+  if ldIsGnuLd
      then do
           script <- newTempName dflags "ldscript"
           writeFile script $ "INPUT(" ++ unwords o_files ++ ")"