diff --git a/pkgs/development/compilers/ghc/9.2.4.nix b/pkgs/development/compilers/ghc/9.2.4.nix index 6b8efae06e5b1..d3c9e20e5d2c3 100644 --- a/pkgs/development/compilers/ghc/9.2.4.nix +++ b/pkgs/development/compilers/ghc/9.2.4.nix @@ -203,6 +203,15 @@ stdenv.mkDerivation (rec { extraPrefix = "libraries/Cabal/"; sha256 = "sha256-yRQ6YmMiwBwiYseC5BsrEtDgFbWvst+maGgDtdD0vAY="; }) + ] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [ + + # Prevent the paths module from emitting symbols that we don't use + # when building with separate outputs. + # + # These cause problems as they're not eliminated by GHC's dead code + # elimination on aarch64-darwin. (see + # https://github.com/NixOS/nixpkgs/issues/140774 for details). + ./cabal-paths-9.2.x.patch ]; postPatch = "patchShebangs ."; diff --git a/pkgs/development/compilers/ghc/9.2.5.nix b/pkgs/development/compilers/ghc/9.2.5.nix index e7c75fcaccf94..99d37c5a75c13 100644 --- a/pkgs/development/compilers/ghc/9.2.5.nix +++ b/pkgs/development/compilers/ghc/9.2.5.nix @@ -203,6 +203,15 @@ stdenv.mkDerivation (rec { extraPrefix = "libraries/Cabal/"; sha256 = "sha256-yRQ6YmMiwBwiYseC5BsrEtDgFbWvst+maGgDtdD0vAY="; }) + ] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [ + + # Prevent the paths module from emitting symbols that we don't use + # when building with separate outputs. + # + # These cause problems as they're not eliminated by GHC's dead code + # elimination on aarch64-darwin. (see + # https://github.com/NixOS/nixpkgs/issues/140774 for details). + ./cabal-paths-9.2.x.patch ]; postPatch = "patchShebangs ."; diff --git a/pkgs/development/compilers/ghc/cabal-paths-9.2.x.patch b/pkgs/development/compilers/ghc/cabal-paths-9.2.x.patch new file mode 100644 index 0000000000000..e4526da4e851d --- /dev/null +++ b/pkgs/development/compilers/ghc/cabal-paths-9.2.x.patch @@ -0,0 +1,278 @@ +diff --git a/Cabal/src/Distribution/Simple/Build/PathsModule.hs b/Cabal/src/Distribution/Simple/Build/PathsModule.hs +index b2be7e1a8..bf218dbc1 100644 +--- a/Cabal/src/Distribution/Simple/Build/PathsModule.hs ++++ b/Cabal/src/Distribution/Simple/Build/PathsModule.hs +@@ -25,16 +25,21 @@ import Distribution.Package + import Distribution.PackageDescription + import Distribution.Simple.Compiler + import Distribution.Simple.LocalBuildInfo +-import Distribution.Simple.Utils (shortRelativePath) ++import Distribution.Simple.Utils (shortRelativePath, unintersperse) + import Distribution.System + import Distribution.Version + + import qualified Distribution.Simple.Build.PathsModule.Z as Z + ++import System.FilePath ( pathSeparator ) ++ + -- ------------------------------------------------------------ + -- * Building Paths_.hs + -- ------------------------------------------------------------ + ++splitPath :: FilePath -> [ String ] ++splitPath = unintersperse pathSeparator ++ + generatePathsModule :: PackageDescription -> LocalBuildInfo -> ComponentLocalBuildInfo -> String + generatePathsModule pkg_descr lbi clbi = Z.render Z.Z + { Z.zPackageName = packageName pkg_descr +@@ -56,8 +61,41 @@ generatePathsModule pkg_descr lbi clbi = Z.render Z.Z + , Z.zDatadir = zDatadir + , Z.zLibexecdir = zLibexecdir + , Z.zSysconfdir = zSysconfdir ++ ++ , Z.zAbsBody = absBody ++ , Z.zWarnPragma = warnPragma ++ , Z.zImportList = importList ++ , Z.zShouldEmitDataDir = shouldEmitDataDir + } + where ++ dirs = [ (flat_libdir, "LibDir") ++ , (flat_dynlibdir, "DynLibDir") ++ , (flat_datadir, "DataDir") ++ , (flat_libexecdir, "LibexecDir") ++ , (flat_sysconfdir, "SysconfDir") ]; ++ shouldEmitPath p ++ | (splitPath flat_prefix) `isPrefixOf` (splitPath flat_bindir) = True ++ | (splitPath flat_prefix) `isPrefixOf` (splitPath p) = False ++ | otherwise = True ++ shouldEmitDataDir = shouldEmitPath flat_datadir ++ nixEmitPathFn (path, name) = let ++ varName = toLower <$> name ++ fnName = "get"++name ++ in if shouldEmitPath path then ++ varName ++ " :: FilePath\n"++ ++ varName ++ " = " ++ show path ++ ++ "\n" ++ fnName ++ " :: IO FilePath" ++ ++ "\n" ++ fnName ++ " = " ++ mkGetEnvOr varName ("return " ++ varName)++"\n" ++ else "" ++ mkGetEnvOr var expr = "catchIO (getEnv \""++var'++"\") (\\_ -> "++expr++")" ++ where var' = pkgPathEnvVar pkg_descr var ++ absBody = intercalate "\n" $ nixEmitPathFn <$> dirs ++ warnPragma = case filter (not . shouldEmitPath . fst) dirs of ++ [] -> "" ++ omittedDirs -> "{-# WARNING \"The functions: "++omittedFns++" Have been omitted by the Nix build system.\" #-}" ++ where omittedFns = intercalate ", " $ map snd omittedDirs ++ importList = intercalate ", " $ ("get" ++) . snd <$> filter (shouldEmitPath . fst) dirs ++ + supports_cpp = supports_language_pragma + supports_rebindable_syntax = ghc_newer_than (mkVersion [7,0,1]) + supports_language_pragma = ghc_newer_than (mkVersion [6,6,1]) +diff --git a/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs b/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs +index 6488ea061..b2b2c0e19 100644 +--- a/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs ++++ b/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs +@@ -19,7 +19,11 @@ data Z + zLibexecdir :: FilePath, + zSysconfdir :: FilePath, + zNot :: (Bool -> Bool), +- zManglePkgName :: (PackageName -> String)} ++ zManglePkgName :: (PackageName -> String), ++ zShouldEmitDataDir :: Bool, ++ zAbsBody :: String, ++ zWarnPragma :: String, ++ zImportList :: String} + deriving Generic + render :: Z -> String + render z_root = execWriter $ do +@@ -45,10 +49,23 @@ render z_root = execWriter $ do + tell "{-# OPTIONS_GHC -w #-}\n" + tell "module Paths_" + tell (zManglePkgName z_root (zPackageName z_root)) ++ tell " " ++ tell (zWarnPragma z_root) + tell " (\n" +- tell " version,\n" +- tell " getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,\n" +- tell " getDataFileName, getSysconfDir\n" ++ tell " version, getBinDir,\n" ++ tell " " ++ if (zShouldEmitDataDir z_root) ++ then do ++ tell "\n" ++ tell " getDataFileName,\n" ++ tell " " ++ return () ++ else do ++ return () ++ tell "\n" ++ tell " " ++ tell (zImportList z_root) ++ tell "\n" + tell " ) where\n" + tell "\n" + if (zNot z_root (zAbsolute z_root)) +@@ -97,12 +114,15 @@ render z_root = execWriter $ do + tell (zVersionDigits z_root) + tell " []\n" + tell "\n" +- tell "getDataFileName :: FilePath -> IO FilePath\n" +- tell "getDataFileName name = do\n" +- tell " dir <- getDataDir\n" +- tell " return (dir `joinFileName` name)\n" +- tell "\n" +- tell "getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n" ++ if (zShouldEmitDataDir z_root) ++ then do ++ tell "getDataFileName :: FilePath -> IO FilePath\n" ++ tell "getDataFileName name = do\n" ++ tell " dir <- getDataDir\n" ++ tell " return (dir `joinFileName` name)\n" ++ return () ++ else do ++ return () + tell "\n" + let + z_var0_function_defs = do +@@ -130,6 +150,8 @@ render z_root = execWriter $ do + tell "\n" + if (zRelocatable z_root) + then do ++ tell "\n" ++ tell "getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n" + tell "\n" + tell "getPrefixDirReloc :: FilePath -> IO FilePath\n" + tell "getPrefixDirReloc dirRel = do\n" +@@ -177,44 +199,17 @@ render z_root = execWriter $ do + if (zAbsolute z_root) + then do + tell "\n" +- tell "bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath\n" ++ tell "bindir :: FilePath\n" + tell "bindir = " + tell (zBindir z_root) + tell "\n" +- tell "libdir = " +- tell (zLibdir z_root) +- tell "\n" +- tell "dynlibdir = " +- tell (zDynlibdir z_root) +- tell "\n" +- tell "datadir = " +- tell (zDatadir z_root) +- tell "\n" +- tell "libexecdir = " +- tell (zLibexecdir z_root) +- tell "\n" +- tell "sysconfdir = " +- tell (zSysconfdir z_root) +- tell "\n" + tell "\n" ++ tell "getBinDir :: IO FilePath\n" + tell "getBinDir = catchIO (getEnv \"" + tell (zManglePkgName z_root (zPackageName z_root)) + tell "_bindir\") (\\_ -> return bindir)\n" +- tell "getLibDir = catchIO (getEnv \"" +- tell (zManglePkgName z_root (zPackageName z_root)) +- tell "_libdir\") (\\_ -> return libdir)\n" +- tell "getDynLibDir = catchIO (getEnv \"" +- tell (zManglePkgName z_root (zPackageName z_root)) +- tell "_dynlibdir\") (\\_ -> return dynlibdir)\n" +- tell "getDataDir = catchIO (getEnv \"" +- tell (zManglePkgName z_root (zPackageName z_root)) +- tell "_datadir\") (\\_ -> return datadir)\n" +- tell "getLibexecDir = catchIO (getEnv \"" +- tell (zManglePkgName z_root (zPackageName z_root)) +- tell "_libexecdir\") (\\_ -> return libexecdir)\n" +- tell "getSysconfDir = catchIO (getEnv \"" +- tell (zManglePkgName z_root (zPackageName z_root)) +- tell "_sysconfdir\") (\\_ -> return sysconfdir)\n" ++ tell (zAbsBody z_root) ++ tell "\n" + tell "\n" + return () + else do +diff --git a/cabal-dev-scripts/src/GenPathsModule.hs b/cabal-dev-scripts/src/GenPathsModule.hs +index e4b930635..b69a73191 100644 +--- a/cabal-dev-scripts/src/GenPathsModule.hs ++++ b/cabal-dev-scripts/src/GenPathsModule.hs +@@ -43,6 +43,11 @@ $(capture "decls" [d| + + , zNot :: Bool -> Bool + , zManglePkgName :: PackageName -> String ++ ++ , zShouldEmitDataDir :: Bool ++ , zAbsBody :: String ++ , zWarnPragma :: String ++ , zImportList :: String + } + deriving (Generic) + |]) +diff --git a/templates/Paths_pkg.template.hs b/templates/Paths_pkg.template.hs +index 6bc6b7875..f5489bea8 100644 +--- a/templates/Paths_pkg.template.hs ++++ b/templates/Paths_pkg.template.hs +@@ -9,10 +9,12 @@ + {% endif %} + {-# OPTIONS_GHC -fno-warn-missing-import-lists #-} + {-# OPTIONS_GHC -w #-} +-module Paths_{{ manglePkgName packageName }} ( +- version, +- getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, +- getDataFileName, getSysconfDir ++module Paths_{{ manglePkgName packageName }} {{ warnPragma }} ( ++ version, getBinDir, ++ {% if shouldEmitDataDir %} ++ getDataFileName, ++ {% endif %} ++ {{ importList }} + ) where + + {% if not absolute %} +@@ -51,12 +53,12 @@ catchIO = Exception.catch + version :: Version + version = Version {{ versionDigits }} [] + ++{% if shouldEmitDataDir %} + getDataFileName :: FilePath -> IO FilePath + getDataFileName name = do + dir <- getDataDir + return (dir `joinFileName` name) +- +-getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath ++{% endif %} + + {% defblock function_defs %} + minusFileName :: FilePath -> String -> FilePath +@@ -85,6 +87,8 @@ splitFileName p = (reverse (path2++drive), reverse fname) + + {% if relocatable %} + ++getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath ++ + getPrefixDirReloc :: FilePath -> IO FilePath + getPrefixDirReloc dirRel = do + exePath <- getExecutablePath +@@ -102,20 +106,12 @@ getSysconfDir = catchIO (getEnv "{{ manglePkgName packageName }}_sysconfdir") (\ + + {% elif absolute %} + +-bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath ++bindir :: FilePath + bindir = {{ bindir }} +-libdir = {{ libdir }} +-dynlibdir = {{ dynlibdir }} +-datadir = {{ datadir }} +-libexecdir = {{ libexecdir }} +-sysconfdir = {{ sysconfdir }} + ++getBinDir :: IO FilePath + getBinDir = catchIO (getEnv "{{ manglePkgName packageName }}_bindir") (\_ -> return bindir) +-getLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_libdir") (\_ -> return libdir) +-getDynLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_dynlibdir") (\_ -> return dynlibdir) +-getDataDir = catchIO (getEnv "{{ manglePkgName packageName }}_datadir") (\_ -> return datadir) +-getLibexecDir = catchIO (getEnv "{{ manglePkgName packageName }}_libexecdir") (\_ -> return libexecdir) +-getSysconfDir = catchIO (getEnv "{{ manglePkgName packageName }}_sysconfdir") (\_ -> return sysconfdir) ++{{ absBody }} + + {% elif isWindows %} + diff --git a/pkgs/development/haskell-modules/configuration-ghc-9.2.x.nix b/pkgs/development/haskell-modules/configuration-ghc-9.2.x.nix index c77a86913f618..856f9c25abb35 100644 --- a/pkgs/development/haskell-modules/configuration-ghc-9.2.x.nix +++ b/pkgs/development/haskell-modules/configuration-ghc-9.2.x.nix @@ -3,7 +3,7 @@ with haskellLib; let - inherit (pkgs.stdenv.hostPlatform) isDarwin; + inherit (pkgs.stdenv.hostPlatform) isAarch64 isDarwin; in self: super: { @@ -91,7 +91,9 @@ self: super: { bsb-http-chunked = dontCheck super.bsb-http-chunked; # need bytestring >= 0.11 which is only bundled with GHC >= 9.2 - regex-rure = doDistribute (markUnbroken super.regex-rure); + # broken on aarch64-darwin, failing with this error message: + # https://github.com/haskell/c2hs/issues/33 + regex-rure = doDistribute ((if isDarwin && isAarch64 then x: x else markUnbroken) super.regex-rure); jacinda = doDistribute super.jacinda; # 2022-08-01: Tests are broken on ghc 9.2.4: https://github.com/wz1000/HieDb/issues/46