Skip to content

Commit 7d0d14a

Browse files
committed
Revert "cabal-install configureCompiler: configure progdb"
This reverts commit 8bdda9c. In configureCompiler the call to configureAllKnownPrograms was too eager. When called it selected the version of tools from PATH (such as alex), and then when a package was configured these tools were passed using `--with-alex` options to configure, which meant that the build-tool-depends versions were not used. (See #10692) Why was this call introduced in the first place? Because configureCompiler would a different result depending on whether: * It is run for the first time, the `ProgramDb` will contain unconfigured programs. * It is run subsequently, `ProgramDb` is read from disk, it does not contain unconfigured programs. Reverting this commit rexposes the bug that the serialised ProgramDb will not contain UnconfiguredPrograms (in the case where reconfiguring is avoided). However, there are no code paths which require this logic in `cabal-install` currently. The configuration phase happens again each time that `Cabal` is called, with a populated `ProgramDb`. We will fix this before the next major `cabal-install` release, but it would not be suitable to backport. In the future we will fix this properly by refactoring `configureCompiler` so that `ProgramDb` is not serialised. The general approach will be to make `configCompilerEx` return a pair of configured programs (`ghc` and `ghc-pkg`) and expose an additional function from `Cabal` which uses these two programs to perform the modifications to the `ProgramDb` which `configCompilerEx` performs. Also see #2238 and #9840 Fixes #10692
1 parent 529bd1f commit 7d0d14a

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

cabal-install/src/Distribution/Client/ProjectPlanning.hs

+6-6
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ configureCompiler
484484
let fileMonitorCompiler = newFileMonitor $ distProjectCacheFile "compiler"
485485

486486
progsearchpath <- liftIO $ getSystemSearchPath
487+
487488
rerunIfChanged
488489
verbosity
489490
fileMonitorCompiler
@@ -499,7 +500,7 @@ configureCompiler
499500
let extraPath = fromNubList packageConfigProgramPathExtra
500501
progdb <- liftIO $ prependProgramSearchPath verbosity extraPath [] defaultProgramDb
501502
let progdb' = userSpecifyPaths (Map.toList (getMapLast packageConfigProgramPaths)) progdb
502-
(comp, plat, progdb'') <-
503+
result@(_, _, progdb'') <-
503504
liftIO $
504505
Cabal.configCompilerEx
505506
hcFlavor
@@ -516,12 +517,11 @@ configureCompiler
516517
-- programs it cares about, and those are the ones we monitor here.
517518
monitorFiles (programsMonitorFiles progdb'')
518519

519-
-- Configure the unconfigured programs in the program database,
520-
-- as we can't serialise unconfigured programs.
521-
-- See also #2241 and #9840.
522-
finalProgDb <- liftIO $ configureAllKnownPrograms verbosity progdb''
520+
-- Note: There is current a bug here where if reconfiguring is avoided,
521+
-- the returned 'ProgramDb' will not contain `UnconfiguredPrograms` (but it will
522+
-- on the fresh run). See #9840 for the ticket which tracks the problem.
523523

524-
return (comp, plat, finalProgDb)
524+
return result
525525
where
526526
hcFlavor = flagToMaybe projectConfigHcFlavor
527527
hcPath = flagToMaybe projectConfigHcPath

cabal-testsuite/PackageTests/ExtraProgPath/setup.out

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# cabal v2-build
2-
Warning: cannot determine version of <ROOT>/pkg-config :
3-
""
42
Configuration is affected by the following files:
53
- cabal.project
4+
Warning: cannot determine version of <ROOT>/pkg-config :
5+
""
6+
Warning: cannot determine version of <ROOT>/pkg-config :
7+
""
68
Resolving dependencies...
79
Error: [Cabal-7107]
810
Could not resolve dependencies:

0 commit comments

Comments
 (0)