summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-07-07 13:16:47 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-07-25 00:45:08 -0400
commit6333d7391068d8029eed3e8eff019b9e2c104c7b (patch)
treeed9c42bf6df586a976db83ff448b3efd16ef9764 /utils
parent342a01af624840ba94f22256079ff4f3cee09ca2 (diff)
downloadhaskell-6333d7391068d8029eed3e8eff019b9e2c104c7b.tar.gz
Put PlatformConstants into Platform
Diffstat (limited to 'utils')
-rw-r--r--utils/deriveConstants/Main.hs15
-rw-r--r--utils/ghc-pkg/Main.hs7
2 files changed, 15 insertions, 7 deletions
diff --git a/utils/deriveConstants/Main.hs b/utils/deriveConstants/Main.hs
index 1867d824b6..0b6247cf97 100644
--- a/utils/deriveConstants/Main.hs
+++ b/utils/deriveConstants/Main.hs
@@ -873,8 +873,10 @@ getWanted verbose os tmpdir gccProgram gccFlags nmProgram mobjdumpProgram
writeHaskellType :: FilePath -> [What Fst] -> IO ()
writeHaskellType fn ws = writeFile fn xs
where xs = unlines [header, body, footer]
- header = "data PlatformConstants = PlatformConstants {"
- footer = " } deriving Read"
+ header = "module GHC.Platform.Constants where\n\n\
+ \import Prelude\n\n\
+ \data PlatformConstants = PlatformConstants {"
+ footer = " } deriving (Show,Read,Eq)"
body = intercalate ",\n" (concatMap doWhat ws)
doWhat (GetClosureSize name _) = [" pc_" ++ name ++ " :: Int"]
@@ -909,16 +911,17 @@ writeHaskellWrappers :: FilePath -> [What Fst] -> IO ()
writeHaskellWrappers fn ws = writeFile fn xs
where xs = unlines body
body = concatMap doWhat ws
+ constants = " (platformConstants (targetPlatform dflags))"
doWhat (GetFieldType {}) = []
doWhat (GetClosureSize {}) = []
doWhat (GetWord name _) = [haskellise name ++ " :: DynFlags -> Int",
- haskellise name ++ " dflags = pc_" ++ name ++ " (platformConstants dflags)"]
+ haskellise name ++ " dflags = pc_" ++ name ++ constants]
doWhat (GetInt name _) = [haskellise name ++ " :: DynFlags -> Int",
- haskellise name ++ " dflags = pc_" ++ name ++ " (platformConstants dflags)"]
+ haskellise name ++ " dflags = pc_" ++ name ++ constants]
doWhat (GetNatural name _) = [haskellise name ++ " :: DynFlags -> Integer",
- haskellise name ++ " dflags = pc_" ++ name ++ " (platformConstants dflags)"]
+ haskellise name ++ " dflags = pc_" ++ name ++ constants]
doWhat (GetBool name _) = [haskellise name ++ " :: DynFlags -> Bool",
- haskellise name ++ " dflags = pc_" ++ name ++ " (platformConstants dflags)"]
+ haskellise name ++ " dflags = pc_" ++ name ++ constants]
doWhat (StructFieldMacro {}) = []
doWhat (ClosureFieldMacro {}) = []
doWhat (ClosurePayloadMacro {}) = []
diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs
index 37fd5ba566..91637f5fab 100644
--- a/utils/ghc-pkg/Main.hs
+++ b/utils/ghc-pkg/Main.hs
@@ -643,6 +643,7 @@ getPkgDatabases verbosity mode use_user use_cache expand_vars my_flags = do
Right appdir -> do
-- See Note [Settings File] about this file, and why we need GHC to share it with us.
let settingsFile = top_dir </> "settings"
+ let constantsFile = top_dir </> "platformConstants"
exists_settings_file <- doesFileExist settingsFile
targetPlatformMini <- case exists_settings_file of
False -> do
@@ -656,7 +657,11 @@ getPkgDatabases verbosity mode use_user use_cache expand_vars my_flags = do
-- It's excusable to not have a settings file (for now at
-- least) but completely inexcusable to have a malformed one.
Nothing -> die $ "Can't parse settings file " ++ show settingsFile
- case getTargetPlatform settingsFile mySettings of
+ constantsStr <- readFile constantsFile
+ constants <- case maybeReadFuzzy constantsStr of
+ Just s -> pure s
+ Nothing -> die $ "Can't parse platform constants file " ++ show constantsFile
+ case getTargetPlatform settingsFile mySettings constants of
Right platform -> pure $ platformMini platform
Left e -> die e
let subdir = uniqueSubdir targetPlatformMini