Commit aecfddac authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Fix ghcEnableTablesNextToCode, refactor code.

parent 47c7ab17
module Oracles.Config.Flag (
Flag (..), flag, getFlag,
crossCompiling, gccIsClang, gccGe46,
platformSupportsSharedLibs, ghcWithSMP, ghcWithNativeCodeGen
crossCompiling, platformSupportsSharedLibs, ghcWithSMP,
ghcWithNativeCodeGen, supportsSplitObjects
) where
import Base
......@@ -12,6 +12,7 @@ data Flag = CrossCompiling
| GccIsClang
| GccLt46
| GhcUnregisterised
| LeadingUnderscore
| SolarisBrokenShld
| SplitObjectsBroken
| SupportsPackageKey
......@@ -25,6 +26,7 @@ flag f = do
GccIsClang -> "gcc-is-clang"
GccLt46 -> "gcc-lt-46"
GhcUnregisterised -> "ghc-unregisterised"
LeadingUnderscore -> "leading-underscore"
SolarisBrokenShld -> "solaris-broken-shld"
SplitObjectsBroken -> "split-objects-broken"
SupportsPackageKey -> "supports-package-key"
......@@ -41,30 +43,33 @@ getFlag = lift . flag
crossCompiling :: Action Bool
crossCompiling = flag CrossCompiling
gccIsClang :: Action Bool
gccIsClang = flag GccIsClang
gccGe46 :: Action Bool
gccGe46 = fmap not $ flag GccLt46
platformSupportsSharedLibs :: Action Bool
platformSupportsSharedLibs = do
badPlatform <- targetPlatforms [ "powerpc-unknown-linux"
, "x86_64-unknown-mingw32"
, "i386-unknown-mingw32" ]
solaris <- targetPlatform "i386-unknown-solaris2"
badPlatform <- anyTargetPlatform [ "powerpc-unknown-linux"
, "x86_64-unknown-mingw32"
, "i386-unknown-mingw32" ]
solaris <- anyTargetPlatform [ "i386-unknown-solaris2" ]
solarisBroken <- flag SolarisBrokenShld
return $ not (badPlatform || solaris && solarisBroken)
ghcWithSMP :: Action Bool
ghcWithSMP = do
goodArch <- targetArchs ["i386", "x86_64", "sparc", "powerpc", "arm"]
goodArch <- anyTargetArch ["i386", "x86_64", "sparc", "powerpc", "arm"]
ghcUnreg <- flag GhcUnregisterised
return $ goodArch && not ghcUnreg
ghcWithNativeCodeGen :: Action Bool
ghcWithNativeCodeGen = do
goodArch <- targetArchs ["i386", "x86_64", "sparc", "powerpc"]
badOs <- targetOss ["ios", "aix"]
goodArch <- anyTargetArch ["i386", "x86_64", "sparc", "powerpc"]
badOs <- anyTargetOs ["ios", "aix"]
ghcUnreg <- flag GhcUnregisterised
return $ goodArch && not badOs && not ghcUnreg
supportsSplitObjects :: Action Bool
supportsSplitObjects = do
broken <- flag SplitObjectsBroken
ghcUnreg <- flag GhcUnregisterised
goodArch <- anyTargetArch [ "i386", "x86_64", "powerpc", "sparc" ]
goodOs <- anyTargetOs [ "mingw32", "cygwin32", "linux", "darwin", "solaris2"
, "freebsd", "dragonfly", "netbsd", "openbsd" ]
return $ not broken && not ghcUnreg && goodArch && goodOs
module Oracles.Config.Setting (
Setting (..), SettingList (..),
setting, settingList, getSetting, getSettingList,
targetPlatform, targetPlatforms, targetOs, targetOss, notTargetOs,
targetArchs, windowsHost, notWindowsHost, ghcWithInterpreter,
ghcEnableTablesNextToCode, ghcCanonVersion, cmdLineLengthLimit
anyTargetPlatform, anyTargetOs, anyTargetArch, anyHostOs, windowsHost,
ghcWithInterpreter, ghcEnableTablesNextToCode, useLibFFIForAdjustors,
ghcCanonVersion, cmdLineLengthLimit
) where
import Base
......@@ -83,45 +83,37 @@ getSettingList :: SettingList -> ReaderT a Action [String]
getSettingList = lift . settingList
matchSetting :: Setting -> [String] -> Action Bool
matchSetting key values = do
value <- setting key
return $ value `elem` values
matchSetting key values = fmap (`elem` values) $ setting key
targetPlatforms :: [String] -> Action Bool
targetPlatforms = matchSetting TargetPlatformFull
anyTargetPlatform :: [String] -> Action Bool
anyTargetPlatform = matchSetting TargetPlatformFull
targetPlatform :: String -> Action Bool
targetPlatform s = targetPlatforms [s]
anyTargetOs :: [String] -> Action Bool
anyTargetOs = matchSetting TargetOs
targetOss :: [String] -> Action Bool
targetOss = matchSetting TargetOs
anyTargetArch :: [String] -> Action Bool
anyTargetArch = matchSetting TargetArch
targetOs :: String -> Action Bool
targetOs s = targetOss [s]
notTargetOs :: String -> Action Bool
notTargetOs = fmap not . targetOs
targetArchs :: [String] -> Action Bool
targetArchs = matchSetting TargetArch
anyHostOs :: [String] -> Action Bool
anyHostOs = matchSetting HostOs
windowsHost :: Action Bool
windowsHost = matchSetting HostOs ["mingw32", "cygwin32"]
notWindowsHost :: Action Bool
notWindowsHost = fmap not windowsHost
windowsHost = anyHostOs ["mingw32", "cygwin32"]
ghcWithInterpreter :: Action Bool
ghcWithInterpreter = do
goodOs <- targetOss [ "mingw32", "cygwin32", "linux", "solaris2"
, "freebsd", "dragonfly", "netbsd", "openbsd"
, "darwin", "kfreebsdgnu" ]
goodArch <- targetArchs [ "i386", "x86_64", "powerpc", "sparc"
, "sparc64", "arm" ]
goodOs <- anyTargetOs [ "mingw32", "cygwin32", "linux", "solaris2"
, "freebsd", "dragonfly", "netbsd", "openbsd"
, "darwin", "kfreebsdgnu" ]
goodArch <- anyTargetArch [ "i386", "x86_64", "powerpc", "sparc"
, "sparc64", "arm" ]
return $ goodOs && goodArch
ghcEnableTablesNextToCode :: Action Bool
ghcEnableTablesNextToCode = targetArchs ["ia64", "powerpc64"]
ghcEnableTablesNextToCode = notM $ anyTargetArch ["ia64", "powerpc64", "powerpc64le"]
useLibFFIForAdjustors :: Action Bool
useLibFFIForAdjustors = notM $ anyTargetArch ["i386", "x86_64"]
-- Canonicalised GHC version number, used for integer version comparisons. We
-- expand GhcMinorVersion to two digits by adding a leading zero if necessary.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment