From c61157bbe3f29b7cffe8f8f5505ed9d9a50b5f8f Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Fri, 10 Mar 2023 13:53:30 +0100 Subject: haskell.compiler.ghc{8107,902}: give cabal-paths.patch a better name --- pkgs/development/compilers/ghc/8.10.7.nix | 3 +- pkgs/development/compilers/ghc/9.0.2.nix | 3 +- ...al-3.2-3.4-paths-fix-cycle-aarch64-darwin.patch | 99 ++++++++++++++++++++++ pkgs/development/compilers/ghc/cabal-paths.patch | 99 ---------------------- 4 files changed, 101 insertions(+), 103 deletions(-) create mode 100644 pkgs/development/compilers/ghc/Cabal-3.2-3.4-paths-fix-cycle-aarch64-darwin.patch delete mode 100644 pkgs/development/compilers/ghc/cabal-paths.patch diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index afc06e09edb..4d220d97243 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -226,14 +226,13 @@ stdenv.mkDerivation (rec { sha256 = "0r4zjj0bv1x1m2dgxp3adsf2xkr94fjnyj1igsivd9ilbs5ja0b5"; }) ] ++ 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.patch + ./Cabal-3.2-3.4-paths-fix-cycle-aarch64-darwin.patch ]; postPatch = "patchShebangs ."; diff --git a/pkgs/development/compilers/ghc/9.0.2.nix b/pkgs/development/compilers/ghc/9.0.2.nix index f69e52701a9..783c7ae5025 100644 --- a/pkgs/development/compilers/ghc/9.0.2.nix +++ b/pkgs/development/compilers/ghc/9.0.2.nix @@ -205,14 +205,13 @@ stdenv.mkDerivation (rec { sha256 = "sha256-b4feGZIaKDj/UKjWTNY6/jH4s2iate0wAgMxG3rAbZI="; }) ] ++ 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.patch + ./Cabal-3.2-3.4-paths-fix-cycle-aarch64-darwin.patch ]; postPatch = "patchShebangs ."; diff --git a/pkgs/development/compilers/ghc/Cabal-3.2-3.4-paths-fix-cycle-aarch64-darwin.patch b/pkgs/development/compilers/ghc/Cabal-3.2-3.4-paths-fix-cycle-aarch64-darwin.patch new file mode 100644 index 00000000000..19adcf5388b --- /dev/null +++ b/pkgs/development/compilers/ghc/Cabal-3.2-3.4-paths-fix-cycle-aarch64-darwin.patch @@ -0,0 +1,99 @@ +diff --git a/Cabal/Distribution/Simple/Build/PathsModule.hs b/Cabal/Distribution/Simple/Build/PathsModule.hs +index 5e660e8d6..1ae603c94 100644 +--- a/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs ++++ b/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs +@@ -37,6 +37,9 @@ import System.FilePath ( pathSeparator ) + -- * Building Paths_.hs + -- ------------------------------------------------------------ + ++splitPath :: FilePath -> [ String ] ++splitPath = unintersperse pathSeparator ++ + generatePathsModule :: PackageDescription -> LocalBuildInfo -> ComponentLocalBuildInfo -> String + generatePathsModule pkg_descr lbi clbi = + let pragmas = +@@ -78,12 +81,44 @@ generatePathsModule pkg_descr lbi clbi = + "import System.Environment (getExecutablePath)\n" + | otherwise = "" + ++ 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 "" ++ ++ 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 ++ + header = + pragmas++ +- "module " ++ prettyShow paths_modulename ++ " (\n"++ +- " version,\n"++ +- " getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,\n"++ +- " getDataFileName, getSysconfDir\n"++ ++ "module " ++ prettyShow paths_modulename ++ " " ++ warnPragma ++ " (\n"++ ++ " version, getBinDir,\n"++ ++ (if shouldEmitDataDir then " getDataFileName, \n" else "\n")++ ++ " " ++ importList ++"\n"++ + " ) where\n"++ + "\n"++ + foreign_imports++ +@@ -136,26 +171,18 @@ generatePathsModule pkg_descr lbi clbi = + "\n"++ + filename_stuff + | absolute = +- "\nbindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath\n"++ ++ "\nbindir :: FilePath\n"++ + "\nbindir = " ++ show flat_bindir ++ +- "\nlibdir = " ++ show flat_libdir ++ +- "\ndynlibdir = " ++ show flat_dynlibdir ++ +- "\ndatadir = " ++ show flat_datadir ++ +- "\nlibexecdir = " ++ show flat_libexecdir ++ +- "\nsysconfdir = " ++ show flat_sysconfdir ++ + "\n"++ +- "\ngetBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n"++ ++ "\ngetBinDir :: IO FilePath\n"++ + "getBinDir = "++mkGetEnvOr "bindir" "return bindir"++"\n"++ +- "getLibDir = "++mkGetEnvOr "libdir" "return libdir"++"\n"++ +- "getDynLibDir = "++mkGetEnvOr "dynlibdir" "return dynlibdir"++"\n"++ +- "getDataDir = "++mkGetEnvOr "datadir" "return datadir"++"\n"++ +- "getLibexecDir = "++mkGetEnvOr "libexecdir" "return libexecdir"++"\n"++ +- "getSysconfDir = "++mkGetEnvOr "sysconfdir" "return sysconfdir"++"\n"++ +- "\n"++ +- "getDataFileName :: FilePath -> IO FilePath\n"++ +- "getDataFileName name = do\n"++ +- " dir <- getDataDir\n"++ +- " return (dir ++ "++path_sep++" ++ name)\n" ++ absBody ++ "\n"++ ++ (if shouldEmitDataDir then ++ "getDataFileName :: FilePath -> IO FilePath\n"++ ++ "getDataFileName name = do\n"++ ++ " dir <- getDataDir\n"++ ++ " return (dir ++ "++path_sep++" ++ name)\n" ++ else "\n") + | otherwise = + "\nprefix, bindirrel :: FilePath" ++ + "\nprefix = " ++ show flat_prefix ++ diff --git a/pkgs/development/compilers/ghc/cabal-paths.patch b/pkgs/development/compilers/ghc/cabal-paths.patch deleted file mode 100644 index 19adcf5388b..00000000000 --- a/pkgs/development/compilers/ghc/cabal-paths.patch +++ /dev/null @@ -1,99 +0,0 @@ -diff --git a/Cabal/Distribution/Simple/Build/PathsModule.hs b/Cabal/Distribution/Simple/Build/PathsModule.hs -index 5e660e8d6..1ae603c94 100644 ---- a/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs -+++ b/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs -@@ -37,6 +37,9 @@ import System.FilePath ( pathSeparator ) - -- * Building Paths_.hs - -- ------------------------------------------------------------ - -+splitPath :: FilePath -> [ String ] -+splitPath = unintersperse pathSeparator -+ - generatePathsModule :: PackageDescription -> LocalBuildInfo -> ComponentLocalBuildInfo -> String - generatePathsModule pkg_descr lbi clbi = - let pragmas = -@@ -78,12 +81,44 @@ generatePathsModule pkg_descr lbi clbi = - "import System.Environment (getExecutablePath)\n" - | otherwise = "" - -+ 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 "" -+ -+ 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 -+ - header = - pragmas++ -- "module " ++ prettyShow paths_modulename ++ " (\n"++ -- " version,\n"++ -- " getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,\n"++ -- " getDataFileName, getSysconfDir\n"++ -+ "module " ++ prettyShow paths_modulename ++ " " ++ warnPragma ++ " (\n"++ -+ " version, getBinDir,\n"++ -+ (if shouldEmitDataDir then " getDataFileName, \n" else "\n")++ -+ " " ++ importList ++"\n"++ - " ) where\n"++ - "\n"++ - foreign_imports++ -@@ -136,26 +171,18 @@ generatePathsModule pkg_descr lbi clbi = - "\n"++ - filename_stuff - | absolute = -- "\nbindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath\n"++ -+ "\nbindir :: FilePath\n"++ - "\nbindir = " ++ show flat_bindir ++ -- "\nlibdir = " ++ show flat_libdir ++ -- "\ndynlibdir = " ++ show flat_dynlibdir ++ -- "\ndatadir = " ++ show flat_datadir ++ -- "\nlibexecdir = " ++ show flat_libexecdir ++ -- "\nsysconfdir = " ++ show flat_sysconfdir ++ - "\n"++ -- "\ngetBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n"++ -+ "\ngetBinDir :: IO FilePath\n"++ - "getBinDir = "++mkGetEnvOr "bindir" "return bindir"++"\n"++ -- "getLibDir = "++mkGetEnvOr "libdir" "return libdir"++"\n"++ -- "getDynLibDir = "++mkGetEnvOr "dynlibdir" "return dynlibdir"++"\n"++ -- "getDataDir = "++mkGetEnvOr "datadir" "return datadir"++"\n"++ -- "getLibexecDir = "++mkGetEnvOr "libexecdir" "return libexecdir"++"\n"++ -- "getSysconfDir = "++mkGetEnvOr "sysconfdir" "return sysconfdir"++"\n"++ -- "\n"++ -- "getDataFileName :: FilePath -> IO FilePath\n"++ -- "getDataFileName name = do\n"++ -- " dir <- getDataDir\n"++ -- " return (dir ++ "++path_sep++" ++ name)\n" -+ absBody ++ "\n"++ -+ (if shouldEmitDataDir then -+ "getDataFileName :: FilePath -> IO FilePath\n"++ -+ "getDataFileName name = do\n"++ -+ " dir <- getDataDir\n"++ -+ " return (dir ++ "++path_sep++" ++ name)\n" -+ else "\n") - | otherwise = - "\nprefix, bindirrel :: FilePath" ++ - "\nprefix = " ++ show flat_prefix ++ -- cgit 1.4.1