Occurrrence analysis improvements for NOINLINE functions
[ghc.git] / hadrian / src / Settings / Builders / Hsc2Hs.hs
1 module Settings.Builders.Hsc2Hs (hsc2hsBuilderArgs) where
2
3 import Settings.Builders.Common
4
5 hsc2hsBuilderArgs :: Args
6 hsc2hsBuilderArgs = builder Hsc2Hs ? do
7 stage <- getStage
8 ccPath <- getBuilderPath $ Cc CompileC stage
9 gmpDir <- getSetting GmpIncludeDir
10 top <- expr topDirectory
11 hArch <- getSetting HostArch
12 hOs <- getSetting HostOs
13 tArch <- getSetting TargetArch
14 tOs <- getSetting TargetOs
15 version <- if stage == Stage0
16 then expr ghcCanonVersion
17 else getSetting ProjectVersionInt
18 mconcat [ arg $ "--cc=" ++ ccPath
19 , arg $ "--ld=" ++ ccPath
20 , notM windowsHost ? arg "--cross-safe"
21 , pure $ map ("-I" ++) (words gmpDir)
22 , map ("--cflag=" ++) <$> getCFlags
23 , map ("--lflag=" ++) <$> getLFlags
24 , notStage0 ? crossCompiling ? arg "--cross-compile"
25 , stage0 ? arg ("--cflag=-D" ++ hArch ++ "_HOST_ARCH=1")
26 , stage0 ? arg ("--cflag=-D" ++ hOs ++ "_HOST_OS=1" )
27 , notStage0 ? arg ("--cflag=-D" ++ tArch ++ "_HOST_ARCH=1")
28 , notStage0 ? arg ("--cflag=-D" ++ tOs ++ "_HOST_OS=1" )
29 , arg $ "--cflag=-D__GLASGOW_HASKELL__=" ++ version
30 , arg $ "--template=" ++ top -/- templateHscPath
31 , arg $ "-I" ++ top -/- "inplace/lib/include/"
32 , arg =<< getInput
33 , arg "-o", arg =<< getOutput ]
34
35 getCFlags :: Expr [String]
36 getCFlags = do
37 context <- getContext
38 autogen <- expr $ autogenPath context
39 mconcat [ remove ["-O"] (cArgs <> getStagedSettingList ConfCcArgs)
40 , getStagedSettingList ConfCppArgs
41 , cIncludeArgs
42 , getPkgDataList CppArgs
43 , getPkgDataList DepCcArgs
44 , cWarnings
45 , arg "-include", arg $ autogen -/- "cabal_macros.h" ]
46
47 getLFlags :: Expr [String]
48 getLFlags = do
49 libDirs <- getPkgDataList DepLibDirs
50 extraLibs <- getPkgDataList DepExtraLibs
51 mconcat [ getStagedSettingList ConfGccLinkerArgs
52 , ldArgs
53 , getPkgDataList LdArgs
54 , pure [ "-L" ++ unifyPath dir | dir <- libDirs ]
55 , pure [ "-l" ++ unifyPath dir | dir <- extraLibs ]
56 , getPkgDataList DepLdArgs ]