compileStub :: GhcMonad m => HscEnv -> Module -> ModLocation
-> m FilePath
compileStub hsc_env mod location = do
- let (o_base, o_ext) = splitExtension (ml_obj_file location)
- stub_o = (o_base ++ "_stub") <.> o_ext
-
-- compile the _stub.c file w/ gcc
- let (stub_c,_,_) = mkStubPaths (hsc_dflags hsc_env) (moduleName mod) location
+ let (stub_c,_,stub_o) = mkStubPaths (hsc_dflags hsc_env)
+ (moduleName mod) location
+
runPipeline StopLn hsc_env (stub_c,Nothing) Nothing
(SpecificFile stub_o) Nothing{-no ModLocation-}
= return Succeeded
link LinkBinary dflags batch_attempt_linking hpt
+ = link' dflags batch_attempt_linking hpt
+
+link LinkDynLib dflags batch_attempt_linking hpt
+ = link' dflags batch_attempt_linking hpt
+
+#ifndef GHCI
+-- warning suppression
+link other _ _ _ = panicBadLink other
+#endif
+
+panicBadLink :: GhcLink -> a
+panicBadLink other = panic ("link: GHC not built to link this way: " ++
+ show other)
+
+link' :: DynFlags -- dynamic flags
+ -> Bool -- attempt linking in batch mode?
+ -> HomePackageTable -- what to link
+ -> IO SuccessFlag
+
+link' dflags batch_attempt_linking hpt
| batch_attempt_linking
= do
let
text " Main.main not exported; not linking.")
return Succeeded
--- warning suppression
-link other _ _ _ = panicBadLink other
-
-panicBadLink :: GhcLink -> a
-panicBadLink other = panic ("link: GHC not built to link this way: " ++
- show other)
-
linkingNeeded :: DynFlags -> [Linkable] -> [PackageId] -> IO Bool
linkingNeeded dflags linkables pkg_deps = do
-- This is a temporary hack.
++ ["-mcpu=v9"]
#endif
+#if defined(darwin_TARGET_OS) && defined(i386_TARGET_ARCH)
+ -- By default, gcc on OS X will generate SSE
+ -- instructions, which need things 16-byte aligned,
+ -- but we don't 16-byte align things. Thus drop
+ -- back to generic i686 compatibility. Trac #2983.
+ ++ ["-march=i686"]
+#endif
++ (if hcc && mangle
then md_regd_c_flags
else [])
let assemble_file n
= SysTools.runAs dflags
(map SysTools.Option as_opts ++
+#ifdef sparc_TARGET_ARCH
+ -- We only support SparcV9 and better because V8 lacks an atomic CAS
+ -- instruction so we have to make sure that the assembler accepts the
+ -- instruction set. Note that the user can still override this
+ -- (e.g., -mcpu=ultrasparc). GCC picks the "best" -mcpu flag
+ -- regardless of the ordering.
+ --
+ -- This is a temporary hack.
+ [ SysTools.Option "-mcpu=v9" ] ++
+#endif
[ SysTools.Option "-c"
, SysTools.Option "-o"
, SysTools.FileOption "" (split_obj n)
-- no FileOptions here: windres doesn't like seeing
-- backslashes, apparently
+ removeFile manifest_filename
+
return [rc_obj_filename]
#endif