|
| 1 | +diff --git a/compiler/Setup.hs b/compiler/Setup.hs |
| 2 | +index c7c0850383..3ce6624307 100644 |
| 3 | +--- a/compiler/Setup.hs |
| 4 | ++++ b/compiler/Setup.hs |
| 5 | +@@ -1,3 +1,4 @@ |
| 6 | ++{-# LANGUAGE CPP #-} |
| 7 | + {-# LANGUAGE RecordWildCards #-} |
| 8 | + module Main where |
| 9 | + |
| 10 | +@@ -11,6 +12,10 @@ import Distribution.Verbosity |
| 11 | + import Distribution.Simple.Program |
| 12 | + import Distribution.Simple.Utils |
| 13 | + import Distribution.Simple.Setup |
| 14 | ++import Distribution.Simple.PackageIndex |
| 15 | ++#if MIN_VERSION_Cabal(3,14,0) |
| 16 | ++import Distribution.Utils.Path (interpretSymbolicPath) |
| 17 | ++#endif |
| 18 | + |
| 19 | + import System.IO |
| 20 | + import System.Process |
| 21 | +@@ -57,7 +62,11 @@ primopIncls = |
| 22 | + ghcAutogen :: Verbosity -> LocalBuildInfo -> IO () |
| 23 | + ghcAutogen verbosity lbi@LocalBuildInfo{..} = do |
| 24 | + -- Get compiler/ root directory from the cabal file |
| 25 | ++#if MIN_VERSION_Cabal(3,14,0) |
| 26 | ++ let Just compilerRoot = takeDirectory . interpretSymbolicPath Nothing <$> pkgDescrFile |
| 27 | ++#else |
| 28 | + let Just compilerRoot = takeDirectory <$> pkgDescrFile |
| 29 | ++#endif |
| 30 | + |
| 31 | + -- Require the necessary programs |
| 32 | + (gcc ,withPrograms) <- requireProgram normal gccProgram withPrograms |
| 33 | +@@ -77,10 +86,20 @@ ghcAutogen verbosity lbi@LocalBuildInfo{..} = do |
| 34 | + -- Call genprimopcode to generate *.hs-incl |
| 35 | + forM_ primopIncls $ \(file,command) -> do |
| 36 | + contents <- readProcess "genprimopcode" [command] primopsStr |
| 37 | ++#if MIN_VERSION_Cabal(3,14,0) |
| 38 | ++ rewriteFileEx verbosity (interpretSymbolicPath Nothing (buildDir lbi) </> file) contents |
| 39 | ++#elif MIN_VERSION_Cabal(3,11,0) |
| 40 | ++ rewriteFileEx verbosity (buildDir lbi </> file) contents |
| 41 | ++#else |
| 42 | + rewriteFileEx verbosity (buildDir </> file) contents |
| 43 | ++#endif |
| 44 | + |
| 45 | + -- Write GHC.Platform.Constants |
| 46 | ++#if MIN_VERSION_Cabal(3,14,0) |
| 47 | ++ let platformConstantsPath = interpretSymbolicPath Nothing (autogenPackageModulesDir lbi) </> "GHC/Platform/Constants.hs" |
| 48 | ++#else |
| 49 | + let platformConstantsPath = autogenPackageModulesDir lbi </> "GHC/Platform/Constants.hs" |
| 50 | ++#endif |
| 51 | + targetOS = case lookup "target os" settings of |
| 52 | + Nothing -> error "no target os in settings" |
| 53 | + Just os -> os |
| 54 | +@@ -95,7 +114,11 @@ ghcAutogen verbosity lbi@LocalBuildInfo{..} = do |
| 55 | + _ -> error "Couldn't find unique cabal library when building ghc" |
| 56 | + |
| 57 | + -- Write GHC.Settings.Config |
| 58 | ++#if MIN_VERSION_Cabal(3,14,0) |
| 59 | ++ configHsPath = interpretSymbolicPath Nothing (autogenPackageModulesDir lbi) </> "GHC/Settings/Config.hs" |
| 60 | ++#else |
| 61 | + configHsPath = autogenPackageModulesDir lbi </> "GHC/Settings/Config.hs" |
| 62 | ++#endif |
| 63 | + configHs = generateConfigHs cProjectUnitId settings |
| 64 | + createDirectoryIfMissingVerbose verbosity True (takeDirectory configHsPath) |
| 65 | + rewriteFileEx verbosity configHsPath configHs |
| 66 | +diff --git a/libraries/ghc-boot/Setup.hs b/libraries/ghc-boot/Setup.hs |
| 67 | +index 0995ee3f8f..73e6b3e5e7 100644 |
| 68 | +--- a/libraries/ghc-boot/Setup.hs |
| 69 | ++++ b/libraries/ghc-boot/Setup.hs |
| 70 | +@@ -1,3 +1,4 @@ |
| 71 | ++{-# LANGUAGE CPP #-} |
| 72 | + {-# LANGUAGE RecordWildCards #-} |
| 73 | + {-# LANGUAGE LambdaCase #-} |
| 74 | + {-# LANGUAGE LambdaCase #-} |
| 75 | +@@ -10,6 +11,9 @@ import Distribution.Verbosity |
| 76 | + import Distribution.Simple.Program |
| 77 | + import Distribution.Simple.Utils |
| 78 | + import Distribution.Simple.Setup |
| 79 | ++#if MIN_VERSION_Cabal(3,14,0) |
| 80 | ++import Distribution.Utils.Path (interpretSymbolicPath) |
| 81 | ++#endif |
| 82 | + |
| 83 | + import System.IO |
| 84 | + import System.Directory |
| 85 | +@@ -32,12 +36,24 @@ main = defaultMainWithHooks ghcHooks |
| 86 | + ghcAutogen :: Verbosity -> LocalBuildInfo -> IO () |
| 87 | + ghcAutogen verbosity lbi@LocalBuildInfo{..} = do |
| 88 | + -- Get compiler/ root directory from the cabal file |
| 89 | ++#if MIN_VERSION_Cabal(3,14,0) |
| 90 | ++ let Just compilerRoot = takeDirectory . interpretSymbolicPath Nothing <$> pkgDescrFile |
| 91 | ++#else |
| 92 | + let Just compilerRoot = takeDirectory <$> pkgDescrFile |
| 93 | ++#endif |
| 94 | + |
| 95 | + let platformHostFile = "GHC/Platform/Host.hs" |
| 96 | ++#if MIN_VERSION_Cabal(3,14,0) |
| 97 | ++ platformHostPath = interpretSymbolicPath Nothing (autogenPackageModulesDir lbi) </> platformHostFile |
| 98 | ++#else |
| 99 | + platformHostPath = autogenPackageModulesDir lbi </> platformHostFile |
| 100 | ++#endif |
| 101 | + ghcVersionFile = "GHC/Version.hs" |
| 102 | ++#if MIN_VERSION_Cabal(3,14,0) |
| 103 | ++ ghcVersionPath = interpretSymbolicPath Nothing (autogenPackageModulesDir lbi) </> ghcVersionFile |
| 104 | ++#else |
| 105 | + ghcVersionPath = autogenPackageModulesDir lbi </> ghcVersionFile |
| 106 | ++#endif |
| 107 | + |
| 108 | + -- Get compiler settings |
| 109 | + settings <- lookupEnv "HADRIAN_SETTINGS" >>= \case |
0 commit comments