summaryrefslogtreecommitdiff
path: root/compiler/GHC/SysTools
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-08-01 11:34:32 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-08-05 04:00:39 -0400
commit53ce0db5a06598c88c6b8cb32043b878e7083dd4 (patch)
tree281c045c9f198c5bb046780881931b41de1f15d4 /compiler/GHC/SysTools
parent2bff2f87e43985e02bdde8c6fa39279df86cb617 (diff)
downloadhaskell-53ce0db5a06598c88c6b8cb32043b878e7083dd4.tar.gz
Refactor handling of object merging
Previously to merge a set of object files we would invoke the linker as usual, adding -r to the command-line. However, this can result in non-sensical command-lines which causes lld to balk (#17962). To avoid this we introduce a new tool setting into GHC, -pgmlm, which is the linker which we use to merge object files.
Diffstat (limited to 'compiler/GHC/SysTools')
-rw-r--r--compiler/GHC/SysTools/Tasks.hs15
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler/GHC/SysTools/Tasks.hs b/compiler/GHC/SysTools/Tasks.hs
index 794a12b913..f9962284f9 100644
--- a/compiler/GHC/SysTools/Tasks.hs
+++ b/compiler/GHC/SysTools/Tasks.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE CPP #-}
-----------------------------------------------------------------------------
--
-- Tasks running external programs for SysTools
@@ -299,6 +300,20 @@ ld: warning: symbol referencing errors
ld_postfix = tail . snd . ld_warn_break
ld_warning_found = not . null . snd . ld_warn_break
+-- See Note [Merging object files for GHCi] in GHC.Driver.Pipeline.
+runMergeObjects :: DynFlags -> [Option] -> IO ()
+runMergeObjects dflags args = traceToolCommand dflags "merge-objects" $ do
+ let (p,args0) = pgm_lm dflags
+ optl_args = map Option (getOpts dflags opt_lm)
+ args2 = args0 ++ args ++ optl_args
+ -- N.B. Darwin's ld64 doesn't support response files. Consequently we only
+ -- use them on Windows where they are truly necessary.
+#if defined(mingw32_HOST_OS)
+ mb_env <- getGccEnv args2
+ runSomethingResponseFile dflags id "Merge objects" p args2 mb_env
+#else
+ runSomething dflags "Merge objects" p args2
+#endif
runLibtool :: DynFlags -> [Option] -> IO ()
runLibtool dflags args = traceToolCommand dflags "libtool" $ do