From d8bc902d05c6b0be6225771d70ad5a4472c4b15b Mon Sep 17 00:00:00 2001 From: Andrea Bedini Date: Sat, 4 Nov 2023 14:59:20 +0800 Subject: [PATCH] Revert #3639 (Don't pass -package-db and -package flags to --abi-hash) (#9384) * Revert #3639 (Don't pass -package-db and -package flags to --abi-hash) With ghc>=9.6 `ghc --abi-hash` initialises the plugins so it will fail if a cabal file specifies `ghc-options: -fplugin=Foo`. Closes: #9375 * Also revert in GHC.hs --------- Co-authored-by: Hamish Mackenzie Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 01cfac0e6608f7962e80e7cca67dd1b2b9285ecc) # Conflicts: # Cabal/src/Distribution/Simple/GHC.hs # Cabal/src/Distribution/Simple/GHCJS.hs --- Cabal/src/Distribution/Simple/GHC.hs | 38 ++++++++++++++++++++++++++ Cabal/src/Distribution/Simple/GHCJS.hs | 38 ++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/Cabal/src/Distribution/Simple/GHC.hs b/Cabal/src/Distribution/Simple/GHC.hs index 9d653f85829..25073f4cb7e 100644 --- a/Cabal/src/Distribution/Simple/GHC.hs +++ b/Cabal/src/Distribution/Simple/GHC.hs @@ -1858,6 +1858,7 @@ libAbiHash :: Verbosity -> PackageDescription -> LocalBuildInfo -> Library -> ComponentLocalBuildInfo -> IO String libAbiHash verbosity _pkg_descr lbi lib clbi = do let +<<<<<<< HEAD libBi = libBuildInfo lib comp = compiler lbi platform = hostPlatform lbi @@ -1893,6 +1894,43 @@ libAbiHash verbosity _pkg_descr lbi lib clbi = do | withSharedLib lbi = sharedArgs | withProfLib lbi = profArgs | otherwise = error "libAbiHash: Can't find an enabled library way" +======= + libBi = libBuildInfo lib + comp = compiler lbi + platform = hostPlatform lbi + vanillaArgs = + (componentGhcOptions verbosity lbi libBi clbi (componentBuildDir lbi clbi)) + `mappend` mempty + { ghcOptMode = toFlag GhcModeAbiHash + , ghcOptInputModules = toNubListR $ exposedModules lib + } + sharedArgs = + vanillaArgs + `mappend` mempty + { ghcOptDynLinkMode = toFlag GhcDynamicOnly + , ghcOptFPic = toFlag True + , ghcOptHiSuffix = toFlag "dyn_hi" + , ghcOptObjSuffix = toFlag "dyn_o" + , ghcOptExtra = hcSharedOptions GHC libBi + } + profArgs = + vanillaArgs + `mappend` mempty + { ghcOptProfilingMode = toFlag True + , ghcOptProfilingAuto = + Internal.profDetailLevelFlag + True + (withProfLibDetail lbi) + , ghcOptHiSuffix = toFlag "p_hi" + , ghcOptObjSuffix = toFlag "p_o" + , ghcOptExtra = hcProfOptions GHC libBi + } + ghcArgs + | withVanillaLib lbi = vanillaArgs + | withSharedLib lbi = sharedArgs + | withProfLib lbi = profArgs + | otherwise = error "libAbiHash: Can't find an enabled library way" +>>>>>>> 01cfac0e6 (Revert #3639 (Don't pass -package-db and -package flags to --abi-hash) (#9384)) (ghcProg, _) <- requireProgram verbosity ghcProgram (withPrograms lbi) hash <- getProgramInvocationOutput verbosity diff --git a/Cabal/src/Distribution/Simple/GHCJS.hs b/Cabal/src/Distribution/Simple/GHCJS.hs index c8721746a6a..fc9dbf84050 100644 --- a/Cabal/src/Distribution/Simple/GHCJS.hs +++ b/Cabal/src/Distribution/Simple/GHCJS.hs @@ -1570,6 +1570,7 @@ libAbiHash :: Verbosity -> PackageDescription -> LocalBuildInfo -> Library -> ComponentLocalBuildInfo -> IO String libAbiHash verbosity _pkg_descr lbi lib clbi = do let +<<<<<<< HEAD libBi = libBuildInfo lib comp = compiler lbi platform = hostPlatform lbi @@ -1605,6 +1606,43 @@ libAbiHash verbosity _pkg_descr lbi lib clbi = do | withSharedLib lbi = sharedArgs | withProfLib lbi = profArgs | otherwise = error "libAbiHash: Can't find an enabled library way" +======= + libBi = libBuildInfo lib + comp = compiler lbi + platform = hostPlatform lbi + vanillaArgs = + (componentGhcOptions verbosity lbi libBi clbi (componentBuildDir lbi clbi)) + `mappend` mempty + { ghcOptMode = toFlag GhcModeAbiHash + , ghcOptInputModules = toNubListR $ exposedModules lib + } + sharedArgs = + vanillaArgs + `mappend` mempty + { ghcOptDynLinkMode = toFlag GhcDynamicOnly + , ghcOptFPic = toFlag True + , ghcOptHiSuffix = toFlag "js_dyn_hi" + , ghcOptObjSuffix = toFlag "js_dyn_o" + , ghcOptExtra = hcSharedOptions GHC libBi + } + profArgs = + vanillaArgs + `mappend` mempty + { ghcOptProfilingMode = toFlag True + , ghcOptProfilingAuto = + Internal.profDetailLevelFlag + True + (withProfLibDetail lbi) + , ghcOptHiSuffix = toFlag "js_p_hi" + , ghcOptObjSuffix = toFlag "js_p_o" + , ghcOptExtra = hcProfOptions GHC libBi + } + ghcArgs + | withVanillaLib lbi = vanillaArgs + | withSharedLib lbi = sharedArgs + | withProfLib lbi = profArgs + | otherwise = error "libAbiHash: Can't find an enabled library way" +>>>>>>> 01cfac0e6 (Revert #3639 (Don't pass -package-db and -package flags to --abi-hash) (#9384)) (ghcjsProg, _) <- requireProgram verbosity ghcjsProgram (withPrograms lbi) hash <- getProgramInvocationOutput verbosity