summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheng Shao <cheng.shao@tweag.io>2021-10-31 15:47:42 +0000
committerCheng Shao <astrohavoc@gmail.com>2022-07-25 20:41:55 +0000
commit96811ba491495b601ec7d6a32bef8563b0292109 (patch)
tree3b4109f216843ff38e84b53ee5ced474ef62a3b2
parent4a7256a75af2fc0318bef771a06949ffb3939d5a (diff)
downloadhaskell-96811ba491495b601ec7d6a32bef8563b0292109.tar.gz
Avoid as pipeline when compiling c
-rw-r--r--compiler/GHC/Driver/Phases.hs11
-rw-r--r--compiler/GHC/Driver/Pipeline.hs2
-rw-r--r--compiler/GHC/Driver/Pipeline/Execute.hs23
3 files changed, 22 insertions, 14 deletions
diff --git a/compiler/GHC/Driver/Phases.hs b/compiler/GHC/Driver/Phases.hs
index 31a1e45361..c4be206fbf 100644
--- a/compiler/GHC/Driver/Phases.hs
+++ b/compiler/GHC/Driver/Phases.hs
@@ -157,13 +157,13 @@ nextPhase platform p
LlvmLlc -> LlvmMangle
LlvmMangle -> As False
As _ -> MergeForeign
- Ccxx -> As False
- Cc -> As False
- Cobjc -> As False
- Cobjcxx -> As False
+ Ccxx -> MergeForeign
+ Cc -> MergeForeign
+ Cobjc -> MergeForeign
+ Cobjcxx -> MergeForeign
CmmCpp -> Cmm
Cmm -> maybeHCc
- HCc -> As False
+ HCc -> MergeForeign
MergeForeign -> StopLn
StopLn -> panic "nextPhase: nothing after StopLn"
where maybeHCc = if platformUnregisterised platform
@@ -320,4 +320,3 @@ phaseForeignLanguage phase = case phase of
As _ -> Just LangAsm
MergeForeign -> Just RawObject
_ -> Nothing
-
diff --git a/compiler/GHC/Driver/Pipeline.hs b/compiler/GHC/Driver/Pipeline.hs
index da7fd0b1f2..5871d534ba 100644
--- a/compiler/GHC/Driver/Pipeline.hs
+++ b/compiler/GHC/Driver/Pipeline.hs
@@ -777,7 +777,7 @@ viaCPipeline c_phase pipe_env hsc_env location input_fn = do
out_fn <- use (T_Cc c_phase pipe_env hsc_env location input_fn)
case stop_phase pipe_env of
StopC -> return Nothing
- _ -> asPipeline False pipe_env hsc_env location out_fn
+ _ -> return $ Just out_fn
llvmPipeline :: P m => PipeEnv -> HscEnv -> Maybe ModLocation -> FilePath -> m (Maybe FilePath)
llvmPipeline pipe_env hsc_env location fp = do
diff --git a/compiler/GHC/Driver/Pipeline/Execute.hs b/compiler/GHC/Driver/Pipeline/Execute.hs
index 6676747f21..b9da8f374c 100644
--- a/compiler/GHC/Driver/Pipeline/Execute.hs
+++ b/compiler/GHC/Driver/Pipeline/Execute.hs
@@ -427,9 +427,11 @@ runCcPhase cc_phase pipe_env hsc_env location input_fn = do
| llvmOptLevel dflags >= 1 = [ "-O" ]
| otherwise = []
- -- Decide next phase
- let next_phase = As False
- output_fn <- phaseOutputFilenameNew next_phase pipe_env hsc_env location
+ output_fn <- phaseOutputFilenameNew StopLn pipe_env hsc_env location
+
+ -- we create directories for the object file, because it
+ -- might be a hierarchical module.
+ createDirectoryIfMissing True (takeDirectory output_fn)
let
more_hcc_opts =
@@ -450,14 +452,22 @@ runCcPhase cc_phase pipe_env hsc_env location input_fn = do
ghcVersionH <- getGhcVersionPathName dflags unit_env
- GHC.SysTools.runCc (phaseForeignLanguage cc_phase) logger tmpfs dflags (
- [ GHC.SysTools.FileOption "" input_fn
+ withAtomicRename output_fn $ \temp_outputFilename ->
+ GHC.SysTools.runCc (phaseForeignLanguage cc_phase) logger tmpfs dflags (
+ [ GHC.SysTools.Option "-c"
+ , GHC.SysTools.FileOption "" input_fn
, GHC.SysTools.Option "-o"
- , GHC.SysTools.FileOption "" output_fn
+ , GHC.SysTools.FileOption "" temp_outputFilename
]
++ map GHC.SysTools.Option (
pic_c_flags
+ -- See Note [Produce big objects on Windows]
+ ++ [ "-Wa,-mbig-obj"
+ | platformOS (targetPlatform dflags) == OSMinGW32
+ , not $ target32Bit (targetPlatform dflags)
+ ]
+
-- Stub files generated for foreign exports references the runIO_closure
-- and runNonIO_closure symbols, which are defined in the base package.
-- These symbols are imported into the stub.c file via RtsAPI.h, and the
@@ -477,7 +487,6 @@ runCcPhase cc_phase pipe_env hsc_env location input_fn = do
then gcc_extra_viac_flags ++ more_hcc_opts
else [])
++ verbFlags
- ++ [ "-S" ]
++ cc_opt
++ [ "-include", ghcVersionH ]
++ framework_paths