diff options
author | Ben Gamari <ben@smart-cactus.org> | 2021-12-01 12:18:28 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2022-04-20 13:13:40 -0400 |
commit | 2b21c3fc992d5f860cdcf97642de6110c88e7809 (patch) | |
tree | 4ceb37a26b66b74afcb0ca602223bfcdd0b2a4c5 | |
parent | d8392f6a714b5646d43ed54eee0d028f714da717 (diff) | |
download | haskell-2b21c3fc992d5f860cdcf97642de6110c88e7809.tar.gz |
hadrian: Ensure that --extra-lib-dirs are used
Previously we only took `extraLibDirs` and friends from the package
description, ignoring any contribution from the `LocalBuildInfo`. Fix
this.
Fixes #20566.
-rw-r--r-- | hadrian/src/Hadrian/Haskell/Cabal/Parse.hs | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs b/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs index 2aad4d5de0..079f675b6e 100644 --- a/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs +++ b/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs @@ -33,7 +33,6 @@ import qualified Distribution.Simple.Program.Types as C import qualified Distribution.Simple.Configure as C (getPersistBuildConfig) import qualified Distribution.Simple.Build as C import qualified Distribution.Types.ComponentLocalBuildInfo as C -import qualified Distribution.Types.ComponentRequestedSpec as C import qualified Distribution.InstalledPackageInfo as Installed import qualified Distribution.Simple.PackageIndex as C import qualified Distribution.Text as C @@ -201,34 +200,13 @@ data MainSourceType = HsMain | CppMain | CMain -- | Parse the 'ContextData' of a given 'Context'. resolveContextData :: Context -> Action ContextData resolveContextData context@Context {..} = do - -- TODO: This is conceptually wrong! - -- We should use the gpd, the flagAssignment and compiler, hostPlatform, and - -- other information from the lbi. And then compute the finalised PD (flags, - -- satisfiable dependencies, platform, compiler info, deps, gpd). - -- - -- let (Right (pd,_)) = C.finalizePackageDescription flags (const True) platform (compilerInfo compiler) [] gpd - -- - -- However when using the new-build path's this might change. - - -- Read the package description from the Cabal file - gpd <- genericPackageDescription <$> readPackageData package - - -- Configure the package with the GHC for this stage - (compiler, platform) <- configurePackageGHC package stage - - cPath <- Context.contextPath context lbi <- liftIO $ C.getPersistBuildConfig cPath - let flags = C.flagAssignment lbi - - (Right (pd,_)) = C.finalizePD flags C.defaultComponentRequestedSpec - (const True) platform (C.compilerInfo compiler) [] gpd - -- Note: the @cPath@ is ignored. The path that's used is the 'buildDir' path -- from the local build info @lbi@. pdi <- liftIO $ getHookedBuildInfo [pkgPath package, cPath -/- "build"] - let pd' = C.updatePackageDescription pdi pd + let pd' = C.updatePackageDescription pdi (C.localPkgDescr lbi) lbi' = lbi { C.localPkgDescr = pd' } -- TODO: Get rid of deprecated 'externalPackageDeps' and drop -Wno-deprecations @@ -266,7 +244,7 @@ resolveContextData context@Context {..} = do -- @library-dirs@ here. _ -> error "No (or multiple) GHC rts package is registered!" - (buildInfo, modules, mainIs) = biModules pd' + (buildInfo, modules, mainIs) = biModules (C.localPkgDescr lbi') classifyMain :: FilePath -> MainSourceType classifyMain fp @@ -275,8 +253,7 @@ resolveContextData context@Context {..} = do | otherwise = CMain main_src = fmap (first C.display) mainIs - - in return $ ContextData + cdata = ContextData { dependencies = deps , componentId = C.localCompatPackageKey lbi' , mainIs = main_src @@ -316,6 +293,8 @@ resolveContextData context@Context {..} = do , frameworks = C.frameworks buildInfo , packageDescription = pd' } + in return cdata + -- | Build autogenerated files @autogen/cabal_macros.h@ and @autogen/Paths_*.hs@. buildAutogenFiles :: Context -> Action () buildAutogenFiles context = do |