Skip to content

Commit 595d023

Browse files
authored
Merge pull request #10771 from alt-romes/wip/romes/10686
project planning: fix #10686 regression
2 parents 616ef9f + b817cb7 commit 595d023

File tree

7 files changed

+36
-22
lines changed

7 files changed

+36
-22
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ installAction flags@NixStyleFlags{extraFlags, configFlags, installFlags, project
467467
fetchAndReadSourcePackages
468468
verbosity
469469
distDirLayout
470-
compiler
470+
(Just compiler)
471471
(projectConfigShared config)
472472
(projectConfigBuildOnly config)
473473
[ProjectPackageRemoteTarball uri | uri <- uris]

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

+14-6
Original file line numberDiff line numberDiff line change
@@ -277,20 +277,28 @@ criticalSection (Lock lck) act = bracket_ (takeMVar lck) (putMVar lck ()) act
277277

278278
newJobControlFromParStrat
279279
:: Verbosity
280-
-> Compiler
280+
-> Maybe Compiler
281+
-- ^ The compiler, used to determine whether Jsem is supported.
282+
-- When Nothing, Jsem is assumed to be unsupported.
281283
-> ParStratInstall
282284
-- ^ The parallel strategy
283285
-> Maybe Int
284286
-- ^ A cap on the number of jobs (e.g. to force a maximum of 2 concurrent downloads despite a -j8 parallel strategy)
285287
-> IO (JobControl IO a)
286-
newJobControlFromParStrat verbosity compiler parStrat numJobsCap = case parStrat of
288+
newJobControlFromParStrat verbosity mcompiler parStrat numJobsCap = case parStrat of
287289
Serial -> newSerialJobControl
288290
NumJobs n -> newParallelJobControl (capJobs (fromMaybe numberOfProcessors n))
289291
UseSem n ->
290-
if jsemSupported compiler
291-
then newSemaphoreJobControl verbosity (capJobs n)
292-
else do
293-
warn verbosity "-jsem is not supported by the selected compiler, falling back to normal parallelism control."
292+
case mcompiler of
293+
Just compiler
294+
| jsemSupported compiler ->
295+
newSemaphoreJobControl verbosity (capJobs n)
296+
| otherwise ->
297+
do
298+
warn verbosity "-jsem is not supported by the selected compiler, falling back to normal parallelism control."
299+
newParallelJobControl (capJobs n)
300+
Nothing ->
301+
-- Don't warn in the Nothing case, as there isn't really a "selected" compiler.
294302
newParallelJobControl (capJobs n)
295303
where
296304
capJobs n = min (fromMaybe maxBound numJobsCap) n

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ rebuildTargets
369369

370370
-- Concurrency control: create the job controller and concurrency limits
371371
-- for downloading, building and installing.
372-
withJobControl (newJobControlFromParStrat verbosity compiler buildSettingNumJobs Nothing) $ \jobControl -> do
372+
withJobControl (newJobControlFromParStrat verbosity (Just compiler) buildSettingNumJobs Nothing) $ \jobControl -> do
373373
-- Before traversing the install plan, preemptively find all packages that
374374
-- will need to be downloaded and start downloading them.
375375
asyncDownloadPackages

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,7 @@ mplusMaybeT ma mb = do
12611261
fetchAndReadSourcePackages
12621262
:: Verbosity
12631263
-> DistDirLayout
1264-
-> Compiler
1264+
-> Maybe Compiler
12651265
-> ProjectConfigShared
12661266
-> ProjectConfigBuildOnly
12671267
-> [ProjectPackageLocation]
@@ -1425,7 +1425,7 @@ fetchAndReadSourcePackageRemoteTarball
14251425
syncAndReadSourcePackagesRemoteRepos
14261426
:: Verbosity
14271427
-> DistDirLayout
1428-
-> Compiler
1428+
-> Maybe Compiler
14291429
-> ProjectConfigShared
14301430
-> ProjectConfigBuildOnly
14311431
-> Bool

cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs

+10-5
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ import Distribution.PackageDescription
8484
)
8585
import Distribution.PackageDescription.Configuration (simplifyWithSysParams)
8686
import Distribution.Simple.Compiler
87-
( CompilerInfo (..)
87+
( Compiler (..)
88+
, CompilerInfo (..)
8889
, DebugInfoLevel (..)
8990
, OptimisationLevel (..)
91+
, compilerInfo
9092
, interpretPackageDB
9193
)
9294
import Distribution.Simple.InstallDirs (CopyDest (NoCopyDest))
@@ -216,10 +218,13 @@ type ProjectConfigSkeleton = CondTree ConfVar [ProjectConfigPath] ProjectConfig
216218
singletonProjectConfigSkeleton :: ProjectConfig -> ProjectConfigSkeleton
217219
singletonProjectConfigSkeleton x = CondNode x mempty mempty
218220

219-
instantiateProjectConfigSkeletonFetchingCompiler :: (OS, Arch, CompilerInfo) -> FlagAssignment -> ProjectConfigSkeleton -> ProjectConfig
220-
instantiateProjectConfigSkeletonFetchingCompiler (os, arch, impl) flags skel
221-
| null (toListOf traverseCondTreeV skel) = fst (ignoreConditions skel)
222-
| otherwise = instantiateProjectConfigSkeletonWithCompiler os arch impl flags skel
221+
instantiateProjectConfigSkeletonFetchingCompiler :: Monad m => m (OS, Arch, Compiler) -> FlagAssignment -> ProjectConfigSkeleton -> m (ProjectConfig, Maybe Compiler)
222+
instantiateProjectConfigSkeletonFetchingCompiler fetch flags skel
223+
| null (toListOf traverseCondTreeV skel) = pure (fst (ignoreConditions skel), Nothing)
224+
| otherwise = do
225+
(os, arch, comp) <- fetch
226+
let conf = instantiateProjectConfigSkeletonWithCompiler os arch (compilerInfo comp) flags skel
227+
pure (conf, Just comp)
223228

224229
instantiateProjectConfigSkeletonWithCompiler :: OS -> Arch -> CompilerInfo -> FlagAssignment -> ProjectConfigSkeleton -> ProjectConfig
225230
instantiateProjectConfigSkeletonWithCompiler os arch impl _flags skel = go $ mapTreeConds (fst . simplifyWithSysParams os arch impl) skel

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

+7-5
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,13 @@ rebuildProjectConfig
394394
liftIO $ info verbosity "Project settings changed, reconfiguring..."
395395
projectConfigSkeleton <- phaseReadProjectConfig
396396

397-
-- have to create the cache directory before configuring the compiler
398-
liftIO $ createDirectoryIfMissingVerbose verbosity True distProjectCacheDirectory
399-
(compiler, Platform arch os, _) <- configureCompiler verbosity distDirLayout (fst (PD.ignoreConditions projectConfigSkeleton) <> cliConfig)
397+
let fetchCompiler = do
398+
-- have to create the cache directory before configuring the compiler
399+
liftIO $ createDirectoryIfMissingVerbose verbosity True distProjectCacheDirectory
400+
(compiler, Platform arch os, _) <- configureCompiler verbosity distDirLayout (fst (PD.ignoreConditions projectConfigSkeleton) <> cliConfig)
401+
pure (os, arch, compiler)
400402

401-
let projectConfig = instantiateProjectConfigSkeletonFetchingCompiler (os, arch, compilerInfo compiler) mempty projectConfigSkeleton
403+
(projectConfig, compiler) <- instantiateProjectConfigSkeletonFetchingCompiler fetchCompiler mempty projectConfigSkeleton
402404
when (projectConfigDistDir (projectConfigShared $ projectConfig) /= NoFlag) $
403405
liftIO $
404406
warn verbosity "The builddir option is not supported in project and config files. It will be ignored."
@@ -434,7 +436,7 @@ rebuildProjectConfig
434436
-- NOTE: These are all packages mentioned in the project configuration.
435437
-- Whether or not they will be considered local to the project will be decided by `shouldBeLocal`.
436438
phaseReadLocalPackages
437-
:: Compiler
439+
:: Maybe Compiler
438440
-> ProjectConfig
439441
-> Rebuild [PackageSpecifier UnresolvedSourcePackage]
440442
phaseReadLocalPackages

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ import qualified Distribution.SPDX.License as SPDX
117117
import Distribution.Simple.Compiler
118118
( Compiler (..)
119119
, OptimisationLevel (..)
120-
, compilerInfo
121120
)
122121
import Distribution.Simple.Flag
123122
( flagToMaybe
@@ -381,7 +380,7 @@ withContextAndSelectors noTargets kind flags@NixStyleFlags{..} targetStrings glo
381380
createDirectoryIfMissingVerbose verbosity True (distProjectCacheDirectory $ distDirLayout ctx)
382381
(compiler, platform@(Platform arch os), _) <- runRebuild projectRoot $ configureCompiler verbosity (distDirLayout ctx) (fst (ignoreConditions projectCfgSkeleton) <> projectConfig ctx)
383382

384-
let projectCfg = instantiateProjectConfigSkeletonFetchingCompiler (os, arch, compilerInfo compiler) mempty projectCfgSkeleton
383+
(projectCfg, _) <- instantiateProjectConfigSkeletonFetchingCompiler (pure (os, arch, compiler)) mempty projectCfgSkeleton
385384

386385
let ctx' = ctx & lProjectConfig %~ (<> projectCfg)
387386

0 commit comments

Comments
 (0)