Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions overlays/bootstrap.nix
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ in {
++ fromUntil "9.8.3" "9.8.4" ./patches/ghc/ghc-9.8.3-text-upper-bound.patch
++ fromUntil "9.10" "9.10.2" ./patches/ghc/ghc-9.10-containers-upper-bound.patch
++ fromUntil "9.10" "9.14" ./patches/ghc/ghc-9.10-merge-objects.patch
++ fromUntil "9.12" "9.14" ./patches/ghc/ghc-9.12-Cabal-3.14.patch
++ fromUntil "9.12" "9.14" ./patches/ghc/ghc-9.12-alex-3.5.2.0.patch

# This patch will make windows stop emitting absolute relocations. This is one way in which binutils 2.36+ (with ASLR enabled), will just choke on the
# assembly we generate because it's always absolute (32bit) addressing modes.
Expand Down
109 changes: 109 additions & 0 deletions overlays/patches/ghc/ghc-9.12-Cabal-3.14.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
diff --git a/compiler/Setup.hs b/compiler/Setup.hs
index c7c0850383..3ce6624307 100644
--- a/compiler/Setup.hs
+++ b/compiler/Setup.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
{-# LANGUAGE RecordWildCards #-}
module Main where

@@ -11,6 +12,10 @@ import Distribution.Verbosity
import Distribution.Simple.Program
import Distribution.Simple.Utils
import Distribution.Simple.Setup
+import Distribution.Simple.PackageIndex
+#if MIN_VERSION_Cabal(3,14,0)
+import Distribution.Utils.Path (interpretSymbolicPath)
+#endif

import System.IO
import System.Process
@@ -57,7 +62,11 @@ primopIncls =
ghcAutogen :: Verbosity -> LocalBuildInfo -> IO ()
ghcAutogen verbosity lbi@LocalBuildInfo{..} = do
-- Get compiler/ root directory from the cabal file
+#if MIN_VERSION_Cabal(3,14,0)
+ let Just compilerRoot = takeDirectory . interpretSymbolicPath Nothing <$> pkgDescrFile
+#else
let Just compilerRoot = takeDirectory <$> pkgDescrFile
+#endif

-- Require the necessary programs
(gcc ,withPrograms) <- requireProgram normal gccProgram withPrograms
@@ -77,10 +86,20 @@ ghcAutogen verbosity lbi@LocalBuildInfo{..} = do
-- Call genprimopcode to generate *.hs-incl
forM_ primopIncls $ \(file,command) -> do
contents <- readProcess "genprimopcode" [command] primopsStr
+#if MIN_VERSION_Cabal(3,14,0)
+ rewriteFileEx verbosity (interpretSymbolicPath Nothing (buildDir lbi) </> file) contents
+#elif MIN_VERSION_Cabal(3,11,0)
+ rewriteFileEx verbosity (buildDir lbi </> file) contents
+#else
rewriteFileEx verbosity (buildDir </> file) contents
+#endif

-- Write GHC.Platform.Constants
+#if MIN_VERSION_Cabal(3,14,0)
+ let platformConstantsPath = interpretSymbolicPath Nothing (autogenPackageModulesDir lbi) </> "GHC/Platform/Constants.hs"
+#else
let platformConstantsPath = autogenPackageModulesDir lbi </> "GHC/Platform/Constants.hs"
+#endif
targetOS = case lookup "target os" settings of
Nothing -> error "no target os in settings"
Just os -> os
@@ -95,7 +114,11 @@ ghcAutogen verbosity lbi@LocalBuildInfo{..} = do
_ -> error "Couldn't find unique cabal library when building ghc"

-- Write GHC.Settings.Config
+#if MIN_VERSION_Cabal(3,14,0)
+ configHsPath = interpretSymbolicPath Nothing (autogenPackageModulesDir lbi) </> "GHC/Settings/Config.hs"
+#else
configHsPath = autogenPackageModulesDir lbi </> "GHC/Settings/Config.hs"
+#endif
configHs = generateConfigHs cProjectUnitId settings
createDirectoryIfMissingVerbose verbosity True (takeDirectory configHsPath)
rewriteFileEx verbosity configHsPath configHs
diff --git a/libraries/ghc-boot/Setup.hs b/libraries/ghc-boot/Setup.hs
index 0995ee3f8f..73e6b3e5e7 100644
--- a/libraries/ghc-boot/Setup.hs
+++ b/libraries/ghc-boot/Setup.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE LambdaCase #-}
@@ -10,6 +11,9 @@ import Distribution.Verbosity
import Distribution.Simple.Program
import Distribution.Simple.Utils
import Distribution.Simple.Setup
+#if MIN_VERSION_Cabal(3,14,0)
+import Distribution.Utils.Path (interpretSymbolicPath)
+#endif

import System.IO
import System.Directory
@@ -32,12 +36,24 @@ main = defaultMainWithHooks ghcHooks
ghcAutogen :: Verbosity -> LocalBuildInfo -> IO ()
ghcAutogen verbosity lbi@LocalBuildInfo{..} = do
-- Get compiler/ root directory from the cabal file
+#if MIN_VERSION_Cabal(3,14,0)
+ let Just compilerRoot = takeDirectory . interpretSymbolicPath Nothing <$> pkgDescrFile
+#else
let Just compilerRoot = takeDirectory <$> pkgDescrFile
+#endif

let platformHostFile = "GHC/Platform/Host.hs"
+#if MIN_VERSION_Cabal(3,14,0)
+ platformHostPath = interpretSymbolicPath Nothing (autogenPackageModulesDir lbi) </> platformHostFile
+#else
platformHostPath = autogenPackageModulesDir lbi </> platformHostFile
+#endif
ghcVersionFile = "GHC/Version.hs"
+#if MIN_VERSION_Cabal(3,14,0)
+ ghcVersionPath = interpretSymbolicPath Nothing (autogenPackageModulesDir lbi) </> ghcVersionFile
+#else
ghcVersionPath = autogenPackageModulesDir lbi </> ghcVersionFile
+#endif

-- Get compiler settings
settings <- lookupEnv "HADRIAN_SETTINGS" >>= \case
27 changes: 27 additions & 0 deletions overlays/patches/ghc/ghc-9.12-alex-3.5.2.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff --git a/compiler/GHC/Parser/Lexer.x b/compiler/GHC/Parser/Lexer.x
index fe08dc69cd..57157cd8bb 100644
--- a/compiler/GHC/Parser/Lexer.x
+++ b/compiler/GHC/Parser/Lexer.x
@@ -41,6 +41,7 @@
-- Alex "Haskell code fragment top"

{
+{-# LANGUAGE CPP #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
@@ -3471,10 +3472,14 @@ topNoLayoutContainsCommas [] = False
topNoLayoutContainsCommas (ALRLayout _ _ : ls) = topNoLayoutContainsCommas ls
topNoLayoutContainsCommas (ALRNoLayout b _ : _) = b

+#ifdef MIN_TOOL_VERSION_alex
+#if !MIN_TOOL_VERSION_alex(3,5,2)
-- If the generated alexScan/alexScanUser functions are called multiple times
-- in this file, alexScanUser gets broken out into a separate function and
-- increases memory usage. Make sure GHC inlines this function and optimizes it.
{-# INLINE alexScanUser #-}
+#endif
+#endif

lexToken :: P (PsLocated Token)
lexToken = do
Loading