Skip to content

Commit d6a562f

Browse files
authored
Merge branch 'master' into yt/fix-paths-windows
2 parents 5e003fa + e38a514 commit d6a562f

File tree

52 files changed

+432
-94
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+432
-94
lines changed

.github/workflows/validate.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,11 @@ jobs:
336336
apk add bash curl sudo jq pkgconfig \
337337
zlib-dev zlib-static binutils-gold curl \
338338
gcc g++ gmp-dev libc-dev libffi-dev make \
339-
musl-dev ncurses-dev perl tar xz
339+
musl-dev ncurses-dev perl tar xz git
340+
341+
# Apparently there's some permissions thing inside vs. outside the container
342+
# that Alpine's git doesn't like. Hack around it.
343+
- run: git config --global --add safe.directory $(pwd)
340344

341345
- uses: actions/checkout@v4
342346

CONTRIBUTING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,23 @@ If your PR is trivial you can omit this process (but explain in the PR why you
360360
think it does not warrant an issue). Feel free to open a new issue (or new
361361
issues) when appropriate.
362362
363+
### Pull request size
364+
365+
Keep your pull requests small, write one pull request per feature, let
366+
the content of the pull request match the title of the pull request.
367+
368+
To get merged, your pull request needs to be reviewed by two other
369+
contributors. Large pull requests are daunting to inspect, and the
370+
back-and-forth between the author and reviewer can get frustrating and
371+
difficult to follow.
372+
373+
Split your pull requests in multiple ones if possible (e.g. a refactor
374+
and a feature implementation should go in two different pull requests).
375+
This is *especially* important when we decide to backport a pull request
376+
(be it fix or a feature).
377+
378+
Thorough reviews mean less regressions, keeping your pull requests small
379+
will improve Cabal codebase quality.
363380
364381
## Changelog
365382

Cabal-hooks/Cabal-hooks.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ library
3030
, Cabal-syntax >= 3.15 && < 3.17
3131
, Cabal >= 3.15 && < 3.17
3232
, base >= 4.13 && < 5
33-
, containers >= 0.5.0.0 && < 0.8
33+
, containers >= 0.5.0.0 && < 0.9
3434
, transformers >= 0.5.6.0 && < 0.7
3535

3636
ghc-options: -Wall -fno-ignore-asserts -Wtabs -Wincomplete-uni-patterns -Wincomplete-record-updates

Cabal-syntax/Cabal-syntax.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ library
3232
, base >= 4.13 && < 5
3333
, binary >= 0.7 && < 0.9
3434
, bytestring >= 0.10.0.0 && < 0.13
35-
, containers >= 0.5.0.0 && < 0.8
35+
, containers >= 0.5.0.0 && < 0.9
3636
, deepseq >= 1.3.0.1 && < 1.7
3737
, directory >= 1.2 && < 1.4
3838
, filepath >= 1.3.0.1 && < 1.6

Cabal/Cabal.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ library
4343
, array >= 0.4.0.1 && < 0.6
4444
, base >= 4.13 && < 5
4545
, bytestring >= 0.10.0.0 && < 0.13
46-
, containers >= 0.5.0.0 && < 0.8
46+
, containers >= 0.5.0.0 && < 0.9
4747
, deepseq >= 1.3.0.1 && < 1.7
4848
, directory >= 1.2 && < 1.4
4949
, filepath >= 1.3.0.1 && < 1.6

Cabal/src/Distribution/PackageDescription/Check.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,6 @@ checkGenericPackageDescription
268268
checkP
269269
(not . null $ dups names)
270270
(PackageBuildImpossible $ DuplicateSections dupes)
271-
-- PackageDescription checks.
272-
checkPackageDescription packageDescription_
273271
-- Flag names.
274272
mapM_ checkFlagName genPackageFlags_
275273

Cabal/src/Distribution/Simple/Bench.hs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ module Distribution.Simple.Bench
2222
import Distribution.Compat.Prelude
2323
import Prelude ()
2424

25-
import Distribution.Compat.Environment
2625
import qualified Distribution.PackageDescription as PD
2726
import Distribution.Pretty
2827
import Distribution.Simple.Build (addInternalBuildTools)
@@ -89,15 +88,12 @@ bench args pkg_descr lbi flags = do
8988
dieWithException verbosity $
9089
NoBenchMarkProgram cmd
9190

92-
existingEnv <- getEnvironment
93-
9491
-- Compute the appropriate environment for running the benchmark
9592
let progDb = LBI.withPrograms lbiForBench
9693
pathVar = progSearchPath progDb
9794
envOverrides = progOverrideEnv progDb
9895
newPath <- programSearchPathAsPATHVar pathVar
99-
overrideEnv <- fromMaybe [] <$> getEffectiveEnvironment ([("PATH", Just newPath)] ++ envOverrides)
100-
let shellEnv = overrideEnv ++ existingEnv
96+
shellEnv <- getFullEnvironment ([("PATH", Just newPath)] ++ envOverrides)
10197

10298
-- Add (DY)LD_LIBRARY_PATH if needed
10399
shellEnv' <-

Cabal/src/Distribution/Simple/Program/Internal.hs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,28 @@ import Prelude ()
1717

1818
-- | Extract the version number from the output of 'strip --version'.
1919
--
20-
-- Invoking "strip --version" gives very inconsistent results. We ignore
21-
-- everything in parentheses (see #2497), look for the first word that starts
22-
-- with a number, and try parsing out the first two components of it. Non-GNU
23-
-- 'strip' doesn't appear to have a version flag.
20+
-- Invoking "strip --version" gives very inconsistent results. We
21+
-- ignore everything in parentheses (see #2497), look for the first
22+
-- word that starts with a number, and try parsing out the first two
23+
-- components of it. Non-GNU, non-LLVM 'strip' doesn't appear to have
24+
-- a version flag.
2425
stripExtractVersion :: String -> String
2526
stripExtractVersion str =
2627
let numeric "" = False
2728
numeric (x : _) = isDigit x
2829

30+
closingParentheses =
31+
[ ")"
32+
, -- LLVM strip outputs "llvm-strip, compatible with GNU strip\nLLVM (http://llvm.org/):\n..."
33+
"):"
34+
]
35+
2936
-- Filter out everything in parentheses.
3037
filterPar' :: Int -> [String] -> [String]
3138
filterPar' _ [] = []
3239
filterPar' n (x : xs)
3340
| n >= 0 && "(" `isPrefixOf` x = filterPar' (n + 1) ((safeTail x) : xs)
34-
| n > 0 && ")" `isSuffixOf` x = filterPar' (n - 1) xs
41+
| n > 0 && any (`isSuffixOf` x) closingParentheses = filterPar' (n - 1) xs
3542
| n > 0 = filterPar' n xs
3643
| otherwise = x : filterPar' n xs
3744

Cabal/src/Distribution/Simple/Program/Run.hs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module Distribution.Simple.Program.Run
2929
, getProgramInvocationOutputAndErrors
3030
, getProgramInvocationLBSAndErrors
3131
, getEffectiveEnvironment
32+
, getFullEnvironment
3233
) where
3334

3435
import Distribution.Compat.Prelude
@@ -237,6 +238,12 @@ getProgramInvocationIODataAndErrors
237238
-- | Return the current environment extended with the given overrides.
238239
-- If an entry is specified twice in @overrides@, the second entry takes
239240
-- precedence.
241+
--
242+
-- getEffectiveEnvironment returns 'Nothing' when there are no overrides.
243+
-- It returns an argument that is suitable to pass directly to 'CreateProcess' to
244+
-- override the environment.
245+
-- If you need the full environment to manipulate further, even when there are no overrides,
246+
-- then call 'getFullEnvironment'.
240247
getEffectiveEnvironment
241248
:: [(String, Maybe String)]
242249
-> IO (Maybe [(String, String)])
@@ -248,6 +255,17 @@ getEffectiveEnvironment overrides =
248255
update (var, Nothing) = Map.delete var
249256
update (var, Just val) = Map.insert var val
250257

258+
-- | Like 'getEffectiveEnvironment', but when no overrides are specified,
259+
-- returns the full environment instead of 'Nothing'.
260+
getFullEnvironment
261+
:: [(String, Maybe String)]
262+
-> IO [(String, String)]
263+
getFullEnvironment overrides = do
264+
menv <- getEffectiveEnvironment overrides
265+
case menv of
266+
Just env -> return env
267+
Nothing -> getEnvironment
268+
251269
-- | Like the unix xargs program. Useful for when we've got very long command
252270
-- lines that might overflow an OS limit on command line length and so you
253271
-- need to invoke a command multiple times to get all the args in.

Cabal/src/Distribution/Simple/Test/ExeV10.hs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ module Distribution.Simple.Test.ExeV10
88
import Distribution.Compat.Prelude
99
import Prelude ()
1010

11-
import Distribution.Compat.Environment
1211
import qualified Distribution.PackageDescription as PD
1312
import Distribution.Simple.BuildPaths
1413
import Distribution.Simple.Compiler
@@ -64,8 +63,6 @@ runTest pkg_descr lbi clbi hpcMarkupInfo flags suite = do
6463
way = guessWay lbi
6564
tixDir_ = i $ tixDir distPref way
6665

67-
existingEnv <- getEnvironment
68-
6966
let cmd =
7067
i (LBI.buildDir lbi)
7168
</> testName'
@@ -92,13 +89,18 @@ runTest pkg_descr lbi clbi hpcMarkupInfo flags suite = do
9289
pathVar = progSearchPath progDb
9390
envOverrides = progOverrideEnv progDb
9491
newPath <- programSearchPathAsPATHVar pathVar
95-
overrideEnv <- fromMaybe [] <$> getEffectiveEnvironment ([("PATH", Just newPath)] ++ envOverrides)
9692
let opts =
9793
map
9894
(testOption pkg_descr lbi suite)
9995
(testOptions flags)
10096
tixFile = packageRoot (testCommonFlags flags) </> getSymbolicPath (tixFilePath distPref way (testName'))
101-
shellEnv = [("HPCTIXFILE", tixFile) | isCoverageEnabled] ++ overrideEnv ++ existingEnv
97+
98+
shellEnv <-
99+
getFullEnvironment
100+
( [("PATH", Just newPath)]
101+
++ [("HPCTIXFILE", Just tixFile) | isCoverageEnabled]
102+
++ envOverrides
103+
)
102104

103105
-- Add (DY)LD_LIBRARY_PATH if needed
104106
shellEnv' <-

0 commit comments

Comments
 (0)