Skip to content

Commit 5fe8d8d

Browse files
authored
Merge pull request #11949 from sheaf/T11619
Avoid writing setup-config twice
2 parents dd198a9 + 35da4ae commit 5fe8d8d

2 files changed

Lines changed: 27 additions & 8 deletions

File tree

Cabal/src/Distribution/Simple/Configure.hs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -459,13 +459,28 @@ findDistPrefOrDefault
459459
findDistPrefOrDefault = findDistPref defaultDistPref
460460

461461
-- | Perform the \"@.\/setup configure@\" action.
462-
-- Returns the @.setup-config@ file.
462+
--
463+
-- Returns the @LocalBuildInfo@, also writing it to the @setup-config@ file.
463464
configure
464465
:: (GenericPackageDescription, HookedBuildInfo)
465466
-> ConfigFlags
466467
-> IO LocalBuildInfo
467-
configure p = configure_setupHooks noConfigureHooks p defaultVerbosityHandles
468+
configure p cfg = do
469+
lbi <- configure_setupHooks noConfigureHooks p defaultVerbosityHandles cfg
470+
-- Write the 'LocalBuildInfo' to the @setup-config@ file.
471+
--
472+
-- NB: the shared 'configure_setupHooks'/'configureFinal' functions deliberately
473+
-- don't include this logic, as it is the responsibility of each top-level
474+
-- configure entry point.
475+
let distPref = fromFlag $ configDistPref cfg
476+
mbWorkDir = flagToMaybe $ configWorkingDir cfg
477+
writePersistBuildConfig mbWorkDir distPref lbi
478+
return lbi
468479

480+
-- | Run the @Cabal@ library configure phase.
481+
--
482+
-- NB: this function does /not/ persist the resulting 'LocalBuildInfo' to the
483+
-- @setup-config@ file; that is the responsibility of callers.
469484
configure_setupHooks
470485
:: ConfigureHooks
471486
-> (GenericPackageDescription, HookedBuildInfo)
@@ -546,8 +561,6 @@ configureFinal
546561
} =
547562
do
548563
let verbosity = mkVerbosity verbHandles (fromFlag (configVerbosity cfg))
549-
distPref = fromFlag $ configDistPref cfg
550-
mbWorkDir = flagToMaybe $ configWorkingDir cfg
551564

552565
-- Apply compiler capability checks to the incoming build options
553566
-- (idempotent).
@@ -608,10 +621,7 @@ configureFinal
608621
pkgInfo
609622
pkgDescr
610623
enabledComps
611-
lbi <- configureComponents verbHandles lbc2 pbd3 installedPkgSet promisedDeps externalPkgDeps
612-
writePersistBuildConfig mbWorkDir distPref lbi
613-
614-
return lbi
624+
configureComponents verbHandles lbc2 pbd3 installedPkgSet promisedDeps externalPkgDeps
615625

616626
runPreConfPackageHook
617627
:: ConfigFlags

changelog.d/T11619.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
synopsis: Only write setup-config once
3+
packages: [Cabal]
4+
prs: 11949
5+
issues: 11619
6+
---
7+
8+
We now ensure that the `setup-config` file, written by `writePersistBuildConfig`,
9+
is only ever written once in every code path.

0 commit comments

Comments
 (0)