Skip to content

Commit

Permalink
Address reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
Kleidukos committed Jul 14, 2023
1 parent e9f06f0 commit 25e00c3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
9 changes: 5 additions & 4 deletions Cabal/src/Distribution/Simple/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ build
-- ^ preprocessors to run before compiling
-> IO ()
build pkg_descr lbi flags suffixes = do
checkBuildProblems verbosity (compiler lbi) flags
checkSemaphoreSupport verbosity (compiler lbi) flags
targets <- readTargetInfos verbosity pkg_descr lbi (buildArgs flags)
let componentsToBuild = neededTargetsInBuildOrder' pkg_descr lbi (map nodeKey targets)
info verbosity $
Expand Down Expand Up @@ -175,10 +175,11 @@ build pkg_descr lbi flags suffixes = do
distPref = fromFlag (buildDistPref flags)
verbosity = fromFlag (buildVerbosity flags)

checkBuildProblems
-- | Check for conditions that would prevent the build from succeeding.
checkSemaphoreSupport
:: Verbosity -> Compiler -> BuildFlags -> IO ()
checkBuildProblems verbosity comp flags = do
unless (jsemSupported comp || not (isJust (flagToMaybe (buildUseSemaphore flags)))) $
checkSemaphoreSupport verbosity comp flags = do
unless (jsemSupported comp || (isNothing (flagToMaybe (buildUseSemaphore flags)))) $
die' verbosity $
"Your compiler does not support the -jsem flag. "
++ "To use this feature you must use GHC 9.8 or later."
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/Compiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ unitIdSupported = ghcSupported "Uses unit IDs"
backpackSupported :: Compiler -> Bool
backpackSupported = ghcSupported "Support Backpack"

-- | Does this compiler support the -jsem option
-- | Does this compiler support the -jsem option?
jsemSupported :: Compiler -> Bool
jsemSupported comp = case compilerFlavor comp of
GHC -> v >= mkVersion [9, 7]
Expand Down
8 changes: 5 additions & 3 deletions Cabal/src/Distribution/Types/ParStrat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ data ParStratX sem
Serial
deriving (Show)

-- Used by Cabal to indicate that we want to use this specific semaphore (created by cabal-install)
-- | Used by Cabal to indicate that we want to use this specific semaphore (created by cabal-install)
type ParStrat = ParStratX String

-- Used by cabal-install to say we want to create a semaphore with N slots.
-- | Used by cabal-install to say we want to create a semaphore with N slots.
type ParStratInstall = ParStratX Int

-- | Determine if the parallelism strategy enables parallel builds.
isParallelBuild :: ParStratX n -> Bool
isParallelBuild Serial = False
isParallelBuild NumJobs{} = True
isParallelBuild (NumJobs (Just 1)) = False
isParallelBuild (NumJobs _) = True
isParallelBuild UseSem{} = True
4 changes: 2 additions & 2 deletions changelog.d/pr-8557
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
synopsis: Add `--enable-semaphore` flag to enable interaction with GHC Job Server protocol
synopsis: Add `--semaphore` flag to enable interaction with GHC Job Server protocol
packages: cabal-install
prs: #8557

description: {

When cabal-install is passed the `--enable-semaphore` flag it will now act as a job server
When cabal-install is passed the `--semaphore` flag it will now act as a job server
according to the GHC Jobserver Protocol.

In particular this means that cabal-install will create a semaphore which it then
Expand Down

0 comments on commit 25e00c3

Please sign in to comment.