diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2020-07-21 19:15:59 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-07-25 00:45:08 -0400 |
commit | 7721b923d53fb9eb93f80bb93b4c3bd976c05b4c (patch) | |
tree | edc61b1ed9885e442c7327460052f10d1ca589fa /compiler/GHC/Settings | |
parent | 73145d57f961c73b5853da7881d6a21e48e05909 (diff) | |
download | haskell-7721b923d53fb9eb93f80bb93b4c3bd976c05b4c.tar.gz |
Move GHC.Platform into the compiler
Previously it was in ghc-boot so that ghc-pkg could use it. However it
wasn't necessary because ghc-pkg only uses a subset of it: reading
target arch and OS from the settings file. This is now done via
GHC.Platform.ArchOS (was called PlatformMini before).
Diffstat (limited to 'compiler/GHC/Settings')
-rw-r--r-- | compiler/GHC/Settings/IO.hs | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/compiler/GHC/Settings/IO.hs b/compiler/GHC/Settings/IO.hs index c4e47618d2..d1ec388195 100644 --- a/compiler/GHC/Settings/IO.hs +++ b/compiler/GHC/Settings/IO.hs @@ -11,7 +11,6 @@ module GHC.Settings.IO import GHC.Prelude -import GHC.Settings.Platform import GHC.Settings.Utils import GHC.Settings.Config @@ -71,12 +70,12 @@ initSettings top_dir = do -- just partially applying those functions and throwing 'Left's; they're -- written in a very portable style to keep ghc-boot light. let getSetting key = either pgmError pure $ - getFilePathSetting0 top_dir settingsFile mySettings key + getRawFilePathSetting top_dir settingsFile mySettings key getToolSetting :: String -> ExceptT SettingsError m String getToolSetting key = expandToolDir mtool_dir <$> getSetting key getBooleanSetting :: String -> ExceptT SettingsError m Bool getBooleanSetting key = either pgmError pure $ - getBooleanSetting0 settingsFile mySettings key + getRawBooleanSetting settingsFile mySettings key targetPlatformString <- getSetting "target platform string" myExtraGccViaCFlags <- getSetting "GCC extra via C opts" -- On Windows, mingw is distributed with GHC, @@ -228,3 +227,39 @@ initSettings top_dir = do , sRawSettings = settingsList } + +getTargetPlatform + :: FilePath -- ^ Settings filepath (for error messages) + -> RawSettings -- ^ Raw settings file contents + -> PlatformConstants -- ^ Platform constants + -> Either String Platform +getTargetPlatform settingsFile settings constants = do + let + getBooleanSetting = getRawBooleanSetting settingsFile settings + readSetting :: (Show a, Read a) => String -> Either String a + readSetting = readRawSetting settingsFile settings + + targetArchOS <- getTargetArchOS settingsFile settings + targetWordSize <- readSetting "target word size" + targetWordBigEndian <- getBooleanSetting "target word big endian" + targetLeadingUnderscore <- getBooleanSetting "Leading underscore" + targetUnregisterised <- getBooleanSetting "Unregisterised" + targetHasGnuNonexecStack <- getBooleanSetting "target has GNU nonexec stack" + targetHasIdentDirective <- getBooleanSetting "target has .ident directive" + targetHasSubsectionsViaSymbols <- getBooleanSetting "target has subsections via symbols" + crossCompiling <- getBooleanSetting "cross compiling" + tablesNextToCode <- getBooleanSetting "Tables next to code" + + pure $ Platform + { platformArchOS = targetArchOS + , platformWordSize = targetWordSize + , platformByteOrder = if targetWordBigEndian then BigEndian else LittleEndian + , platformUnregisterised = targetUnregisterised + , platformHasGnuNonexecStack = targetHasGnuNonexecStack + , platformHasIdentDirective = targetHasIdentDirective + , platformHasSubsectionsViaSymbols = targetHasSubsectionsViaSymbols + , platformIsCrossCompiling = crossCompiling + , platformLeadingUnderscore = targetLeadingUnderscore + , platformTablesNextToCode = tablesNextToCode + , platformConstants = constants + } |