From 8bdda9c0b6231f05eda3e06f677ec5b71bfbb7cf Mon Sep 17 00:00:00 2001 From: sheaf Date: Mon, 25 Mar 2024 13:05:05 +0100 Subject: [PATCH] cabal-install configureCompiler: configure progdb We should configure unconfigured programs before serialising them (using the Binary ProgramDb instance) in Distribution.Client.ProjectPlanning.configureCompiler, as otherwise we can accidentally discard information. This isn't currently a live bug, because in practice we end up re-running configuration steps when interfacing with the Cabal library. However, in the bright future in which we avoid re-configuring things when building a Cabal package that we already determined when invoking cabal-install, this starts causing problems. --- cabal-install/src/Distribution/Client/ProjectPlanning.hs | 9 +++++++-- cabal-testsuite/PackageTests/ExtraProgPath/setup.out | 2 -- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning.hs b/cabal-install/src/Distribution/Client/ProjectPlanning.hs index 43c835f7a0d..6b77531b8a5 100644 --- a/cabal-install/src/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/src/Distribution/Client/ProjectPlanning.hs @@ -483,7 +483,7 @@ configureCompiler let extraPath = fromNubList packageConfigProgramPathExtra progdb <- liftIO $ prependProgramSearchPath verbosity extraPath [] defaultProgramDb let progdb' = userSpecifyPaths (Map.toList (getMapLast packageConfigProgramPaths)) progdb - result@(_, _, progdb'') <- + (comp, plat, progdb'') <- liftIO $ Cabal.configCompilerEx hcFlavor @@ -500,7 +500,12 @@ configureCompiler -- programs it cares about, and those are the ones we monitor here. monitorFiles (programsMonitorFiles progdb'') - return result + -- Configure the unconfigured programs in the program database, + -- as we can't serialise unconfigured programs. + -- See also #2241 and #9840. + finalProgDb <- liftIO $ configureAllKnownPrograms verbosity progdb'' + + return (comp, plat, finalProgDb) where hcFlavor = flagToMaybe projectConfigHcFlavor hcPath = flagToMaybe projectConfigHcPath diff --git a/cabal-testsuite/PackageTests/ExtraProgPath/setup.out b/cabal-testsuite/PackageTests/ExtraProgPath/setup.out index 1011c8899ed..c3755d7e8c7 100644 --- a/cabal-testsuite/PackageTests/ExtraProgPath/setup.out +++ b/cabal-testsuite/PackageTests/ExtraProgPath/setup.out @@ -1,8 +1,6 @@ # cabal v2-build Warning: cannot determine version of /pkg-config : "" -Warning: cannot determine version of /pkg-config : -"" Resolving dependencies... Error: [Cabal-7107] Could not resolve dependencies: