import FastString
import LlvmCodeGen ( llvmFixupAsm )
import MonadUtils
+import Platform
--- import Data.Either
import Exception
import Data.IORef ( readIORef )
-import Distribution.System
--- import GHC.Exts ( Int(..) )
import System.Directory
import System.FilePath
import System.IO
-- than a double, which leads to unpredictable results.
-- By default, we turn this off with -ffloat-store unless
-- the user specified -fexcess-precision.
- (if cTargetArch == I386 &&
+ (if platformArch (targetPlatform dflags) == ArchX86 &&
not (dopt Opt_ExcessPrecision dflags)
then [ "-ffloat-store" ]
else []) ++
-- These symbols are imported into the stub.c file via RtsAPI.h, and the
-- way we do the import depends on whether we're currently compiling
-- the base package or not.
- ++ (if cTargetOS == Windows &&
+ ++ (if platformOS (targetPlatform dflags) == OSMinGW32 &&
thisPackage dflags == basePackageId
then [ "-DCOMPILING_BASE_PACKAGE" ]
else [])
-- regardless of the ordering.
--
-- This is a temporary hack.
- ++ (if cTargetArch == Sparc
+ ++ (if platformArch (targetPlatform dflags) == ArchSPARC
then ["-mcpu=v9"]
else [])
-- regardless of the ordering.
--
-- This is a temporary hack.
- ++ (if cTargetArch == Sparc
+ ++ (if platformArch (targetPlatform dflags) == ArchSPARC
then [SysTools.Option "-mcpu=v9"]
else [])
-- regardless of the ordering.
--
-- This is a temporary hack.
- (if cTargetArch == Sparc
+ (if platformArch (targetPlatform dflags) == ArchSPARC
then [SysTools.Option "-mcpu=v9"]
else []) ++
-- fix up some pretty big deficiencies in the code we generate
llvmOpts = ["-mem2reg", "-O1", "-O2"]
-
-----------------------------------------------------------------------------
-- LlvmLlc phase
runPhase LlvmLlc input_fn dflags
= do
let lc_opts = getOpts dflags opt_lc
- let opt_lvl = max 0 (min 2 $ optLevel dflags)
- let nphase = if cTargetOS == OSX
- then LlvmMangle
- else As
- let rmodel | opt_PIC = "pic"
+ opt_lvl = max 0 (min 2 $ optLevel dflags)
+ rmodel | opt_PIC = "pic"
| not opt_Static = "dynamic-no-pic"
| otherwise = "static"
- output_fn <- phaseOutputFilename nphase
+ output_fn <- phaseOutputFilename LlvmMangle
io $ SysTools.runLlvmLlc dflags
([ SysTools.Option (llvmOpts !! opt_lvl),
SysTools.Option "-o", SysTools.FileOption "" output_fn]
++ map SysTools.Option lc_opts)
- return (nphase, output_fn)
+ return (LlvmMangle, output_fn)
where
- llvmOpts = if cTargetOS == OSX
+ -- Bug in LLVM at O3 on OSX.
+ llvmOpts = if platformOS (targetPlatform dflags) == OSDarwin
then ["-O1", "-O2", "-O2"]
else ["-O1", "-O2", "-O3"]
-
-----------------------------------------------------------------------------
-- LlvmMangle phase
-- Permit the linker to auto link _symbol to _imp_symbol.
-- This lets us link against DLLs without needing an "import library".
- ++ (if cTargetOS == Windows
+ ++ (if platformOS (targetPlatform dflags) == OSMinGW32
then ["-Wl,--enable-auto-import"]
else [])
exeFileName :: DynFlags -> FilePath
exeFileName dflags
| Just s <- outputFile dflags =
- if cTargetOS == Windows
+ if platformOS (targetPlatform dflags) == OSMinGW32
then if null (takeExtension s)
then s <.> "exe"
else s
else s
| otherwise =
- if cTargetOS == Windows
+ if platformOS (targetPlatform dflags) == OSMinGW32
then "main.exe"
else "a.out"