diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2021-03-25 17:25:31 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-04-10 05:31:14 -0400 |
commit | 085983e63bfe6af23f8b85fbfcca8db4872d2f60 (patch) | |
tree | 0d41072c2830e5825f4e6f28c1ed528e29ca54dd /compiler/GHC/Settings | |
parent | 9c762f27d5468ab692e390b16420c9e304993993 (diff) | |
download | haskell-085983e63bfe6af23f8b85fbfcca8db4872d2f60.tar.gz |
Read constants header instead of global platformConstants
With this patch we switch from reading the globally installed
platformConstants file to reading the DerivedConstants.h header file
that is bundled in the RTS unit. When we build the RTS unit itself, we
get it from its includes directories.
The new parser is more efficient and strict than the Read instance for
PlatformConstants and we get about 2.2MB less allocations in every
cases. However it only really shows in tests that don't allocate much,
hence the following metric decreases.
Metric Decrease:
Naperian
T10421
T10547
T12150
T12234
T12425
T13035
T18304
T18923
T5837
T6048
T18140
Diffstat (limited to 'compiler/GHC/Settings')
-rw-r--r-- | compiler/GHC/Settings/IO.hs | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/compiler/GHC/Settings/IO.hs b/compiler/GHC/Settings/IO.hs index cd1c210ee7..51f101aaad 100644 --- a/compiler/GHC/Settings/IO.hs +++ b/compiler/GHC/Settings/IO.hs @@ -48,7 +48,6 @@ initSettings top_dir = do libexec :: FilePath -> FilePath libexec file = top_dir </> "bin" </> file settingsFile = installed "settings" - platformConstantsFile = installed "platformConstants" readFileSafe :: FilePath -> ExceptT SettingsError m String readFileSafe path = liftIO (doesFileExist path) >>= \case @@ -56,16 +55,11 @@ initSettings top_dir = do False -> throwE $ SettingsError_MissingData $ "Missing file: " ++ path settingsStr <- readFileSafe settingsFile - platformConstantsStr <- readFileSafe platformConstantsFile settingsList <- case maybeReadFuzzy settingsStr of Just s -> pure s Nothing -> throwE $ SettingsError_BadData $ "Can't parse " ++ show settingsFile let mySettings = Map.fromList settingsList - platformConstants <- case maybeReadFuzzy platformConstantsStr of - Just s -> pure s - Nothing -> throwE $ SettingsError_BadData $ - "Can't parse " ++ show platformConstantsFile -- See Note [Settings file] for a little more about this file. We're -- just partially applying those functions and throwing 'Left's; they're -- written in a very portable style to keep ghc-boot light. @@ -91,7 +85,7 @@ initSettings top_dir = do cpp_prog <- getToolSetting "Haskell CPP command" cpp_args_str <- getSetting "Haskell CPP flags" - platform <- either pgmError pure $ getTargetPlatform settingsFile mySettings platformConstants + platform <- either pgmError pure $ getTargetPlatform settingsFile mySettings let unreg_cc_args = if platformUnregisterised platform then ["-DNO_REGS", "-DUSE_MINIINTERPRETER"] @@ -227,17 +221,14 @@ initSettings top_dir = do , platformMisc_llvmTarget = llvmTarget } - , sPlatformConstants = platformConstants - , 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 +getTargetPlatform settingsFile settings = do let getBooleanSetting = getRawBooleanSetting settingsFile settings readSetting :: (Show a, Read a) => String -> Either String a @@ -265,5 +256,5 @@ getTargetPlatform settingsFile settings constants = do , platformIsCrossCompiling = crossCompiling , platformLeadingUnderscore = targetLeadingUnderscore , platformTablesNextToCode = tablesNextToCode - , platformConstants = constants + , platform_constants = Nothing -- will be filled later when loading (or building) the RTS unit } |