[Git][ghc/ghc][wip/andreask/add_mul_lea] 832 commits: Make T20214 terminate promptly be setting input to /dev/null

Andreas Klebinger (@AndreasK) gitlab at gitlab.haskell.org
Mon Aug 8 12:43:06 UTC 2022



Andreas Klebinger pushed to branch wip/andreask/add_mul_lea at Glasgow Haskell Compiler / GHC


Commits:
706deee0 by Greg Steuck at 2022-03-05T17:44:10-08:00
Make T20214 terminate promptly be setting input to /dev/null

It was hanging and timing out on OpenBSD before.

- - - - -
14e90098 by Simon Peyton Jones at 2022-03-07T14:05:41-05:00
Always generalise top-level bindings

Fix #21023 by always generalising top-level binding; change
the documentation of -XMonoLocalBinds to match.

- - - - -
c9c31c3c by Matthew Pickering at 2022-03-07T14:06:16-05:00
hadrian: Add little flavour transformer to build stage2 with assertions

This can be useful to build a `perf+assertions` build or even better
`default+no_profiled_libs+omit_pragmas+assertions`.

- - - - -
89c14a6c by Matthew Pickering at 2022-03-07T14:06:16-05:00
ci: Convert all deb10 make jobs into hadrian jobs

This is the first step in converting all the CI configs to use hadrian
rather than make. (#21129)

The metrics increase due to hadrian using --hyperlinked-source for
haddock builds. (See #21156)

-------------------------
Metric Increase:
    haddock.Cabal
    haddock.base
    haddock.compiler
-------------------------

- - - - -
7bfae2ee by Matthew Pickering at 2022-03-07T14:06:16-05:00
Replace use of BIN_DIST_PREP_TAR_COMP with BIN_DIST_NAME

And adds a check to make sure we are not accidently settings
BIN_DIST_PREP_TAR_COMP when using hadrian.

- - - - -
5b35ca58 by Matthew Pickering at 2022-03-07T14:06:16-05:00
Fix gen_contents_index logic for hadrian bindist

- - - - -
273bc133 by Krzysztof Gogolewski at 2022-03-07T14:06:52-05:00
Fix reporting constraints in pprTcSolverReportMsg

'no_instance_msg' and 'no_deduce_msg' were omitting the first wanted.

- - - - -
5874a30a by Simon Jakobi at 2022-03-07T14:07:28-05:00
Improve setBit for Natural

Previously the default definition was used, which involved allocating
intermediate Natural values.

Fixes #21173.

- - - - -
7a02aeb8 by Matthew Pickering at 2022-03-07T14:08:03-05:00
Remove leftover trace in testsuite

- - - - -
6ce6c250 by Andreas Klebinger at 2022-03-07T23:48:56-05:00
Expand and improve the Note [Strict Worker Ids].

I've added an explicit mention of the invariants surrounding those. As well as adding
more direct cross references to the Strict Field Invariant.

- - - - -
d0f892fe by Ryan Scott at 2022-03-07T23:49:32-05:00
Delete GenericKind_ in favor of GenericKind_DC

When deriving a `Generic1` instance, we need to know what the last type
variable of a data type is. Previously, there were two mechanisms to determine
this information:

* `GenericKind_`, where `Gen1_` stored the last type variable of a data type
   constructor (i.e., the `tyConTyVars`).
* `GenericKind_DC`, where `Gen1_DC` stored the last universally quantified
  type variable in a data constructor (i.e., the `dataConUnivTyVars`).

These had different use cases, as `GenericKind_` was used for generating
`Rep(1)` instances, while `GenericKind_DC` was used for generating `from(1)`
and `to(1)` implementations. This was already a bit confusing, but things went
from confusing to outright wrong after !6976. This is because after !6976,
the `deriving` machinery stopped using `tyConTyVars` in favor of
`dataConUnivTyVars`. Well, everywhere with the sole exception of
`GenericKind_`, which still continued to use `tyConTyVars`. This lead to
disaster when deriving a `Generic1` instance for a GADT family instance, as
the `tyConTyVars` do not match the `dataConUnivTyVars`. (See #21185.)

The fix is to stop using `GenericKind_` and replace it with `GenericKind_DC`.
For the most part, this proves relatively straightforward. Some highlights:

* The `forgetArgVar` function was deleted entirely, as it no longer proved
  necessary after `GenericKind_`'s demise.
* The substitution that maps from the last type variable to `Any` (see
  `Note [Generating a correctly typed Rep instance]`) had to be moved from
  `tc_mkRepTy` to `tc_mkRepFamInsts`, as `tc_mkRepTy` no longer has access to
  the last type variable.

Fixes #21185.

- - - - -
a60ddffd by Matthew Pickering at 2022-03-08T22:51:37+00:00
Move bootstrap and cabal-reinstall test jobs to nightly

CI is creaking under the pressure of too many jobs so attempt to reduce
the strain by removing a couple of jobs.

- - - - -
7abe3288 by Matthew Pickering at 2022-03-09T10:24:15+00:00
Add 10 minute timeout to linters job

- - - - -
3cf75ede by Matthew Pickering at 2022-03-09T10:24:16+00:00
Revert "hadrian: Correctly set whether we have a debug compiler when running tests"

Needing the arguments for "GHC/Utils/Constant.hs" implies a dependency
on the previous stage compiler. Whilst we work out how to get around
this I will just revert this commit (as it only affects running the
testsuite in debug way).

This reverts commit ce65d0cceda4a028f30deafa3c39d40a250acc6a.

- - - - -
18b9ba56 by Matthew Pickering at 2022-03-09T11:07:23+00:00
ci: Fix save_cache function

Each interation of saving the cache would copy the whole `cabal` store
into a subfolder in the CACHE_DIR rather than copying the contents of
the cabal store into the cache dir. This resulted in a cache which
looked like:

```
/builds/ghc/ghc/cabal-cache/cabal/cabal/cabal/cabal/cabal/cabal/cabal/cabal/cabal/cabal/
```

So it would get one layer deeper every CI run and take longer and longer
to compress.

- - - - -
bc684dfb by Ben Gamari at 2022-03-10T03:20:07-05:00
mr-template: Mention timeframe for review
- - - - -
7f5f4ede by Vladislav Zavialov at 2022-03-10T03:20:43-05:00
Bump submodules: containers, exceptions

GHC Proposal #371 requires TypeOperators to use type equality a~b.
This submodule update pulls in the appropriate forward-compatibility
changes in 'libraries/containers' and 'libraries/exceptions'

- - - - -
8532b8a9 by Matthew Pickering at 2022-03-10T03:20:43-05:00
Add an inline pragma to lookupVarEnv

The containers bump reduced the size of the Data.IntMap.Internal.lookup
function so that it no longer experienced W/W. This means that the size
of lookupVarEnv increased over the inlining threshold and it wasn't
inlined into the hot code path in substTyVar.

See containers#821, #21159 and !7638 for some more explanation.

-------------------------
Metric Decrease:
    LargeRecord
    T12227
    T13386
    T15703
    T18223
    T5030
    T8095
    T9872a
    T9872b
    T9872c
    TcPlugin_RewritePerf
-------------------------

- - - - -
844cf1e1 by Matthew Pickering at 2022-03-10T03:20:43-05:00
Normalise output of T10970 test

The output of this test changes each time the containers submodule
version updates. It's easier to apply the version normaliser so that
the test checks that there is a version number, but not which one it is.

- - - - -
24b6af26 by Ryan Scott at 2022-03-11T19:56:28-05:00
Refactor tcDeriving to generate tyfam insts before any bindings

Previously, there was an awful hack in `genInst` (now called `genInstBinds`
after this patch) where we had to return a continutation rather than directly
returning the bindings for a derived instance. This was done for staging
purposes, as we had to first infer the instance contexts for derived instances
and then feed these contexts into the continuations to ensure the generated
instance bindings had accurate instance contexts.
`Note [Staging of tcDeriving]` in `GHC.Tc.Deriving` described this confusing
state of affairs.

The root cause of this confusing design was the fact that `genInst` was trying
to generate instance bindings and associated type family instances for derived
instances simultaneously. This really isn't possible, however: as
`Note [Staging of tcDeriving]` explains, one needs to have access to the
associated type family instances before one can properly infer the instance
contexts for derived instances. The use of continuation-returning style was an
attempt to circumvent this dependency, but it did so in an awkward way.

This patch detangles this awkwardness by splitting up `genInst` into two
functions: `genFamInsts` (for associated type family instances) and
`genInstBinds` (for instance bindings). Now, the `tcDeriving` function calls
`genFamInsts` and brings all the family instances into scope before calling
`genInstBinds`. This removes the need for the awkward continuation-returning
style seen in the previous version of `genInst`, making the code easier to
understand.

There are some knock-on changes as well:

1. `hasStockDeriving` now needs to return two separate functions: one that
   describes how to generate family instances for a stock-derived instance,
   and another that describes how to generate the instance bindings. I factored
   out this pattern into a new `StockGenFns` data type.
2. While documenting `StockGenFns`, I realized that there was some
   inconsistency regarding which `StockGenFns` functions needed which
   arguments. In particular, the function in `GHC.Tc.Deriv.Generics` which
   generates `Rep(1)` instances did not take a `SrcSpan` like other `gen_*`
   functions did, and it included an extra `[Type]` argument that was entirely
   redundant. As a consequence, I refactored the code in
   `GHC.Tc.Deriv.Generics` to more closely resemble other `gen_*` functions.
   A happy result of all this is that all `StockGenFns` functions now take
   exactly the same arguments, which makes everything more uniform.

This is purely a refactoring that should not have any effect on user-observable
behavior. The new design paves the way for an eventual fix for #20719.

- - - - -
62caaa9b by Ben Gamari at 2022-03-11T19:57:03-05:00
gitlab-ci: Use the linters image in hlint job

As the `hlint` executable is only available in the linters image.

Fixes #21146.

- - - - -
4abd7eb0 by Matthew Pickering at 2022-03-11T19:57:38-05:00
Remove partOfGhci check in the loader

This special logic has been part of GHC ever since template haskell was
introduced in 9af77fa423926fbda946b31e174173d0ec5ebac8.

It's hard to believe in any case that this special logic pays its way at
all. Given

* The list is out-of-date, which has potential to lead to miscompilation
  when using "editline", which was removed in 2010 (46aed8a4).
* The performance benefit seems negligable as each load only happens
  once anyway and packages specified by package flags are preloaded into
  the linker state at the start of compilation.

Therefore we just remove this logic.

Fixes #19791

- - - - -
c40cbaa2 by Andreas Klebinger at 2022-03-11T19:58:14-05:00
Improve -dtag-inference-checks checks.

FUN closures don't get tagged when evaluated. So no point in checking their
tags.

- - - - -
ab00d23b by Simon Jakobi at 2022-03-11T19:58:49-05:00
Improve clearBit and complementBit for Natural

Also optimize bigNatComplementBit#.

Fixes #21175, #21181, #21194.

- - - - -
a6d8facb by Sebastian Graf at 2022-03-11T19:59:24-05:00
gitignore all (build) directories headed by _

- - - - -
524795fe by Sebastian Graf at 2022-03-11T19:59:24-05:00
Demand: Document why we need three additional equations of multSubDmd

- - - - -
6bdcd557 by Cheng Shao at 2022-03-11T20:00:01-05:00
CmmToC: make 64-bit word splitting for 32-bit targets respect target endianness

This used to been broken for little-endian targets.

- - - - -
9e67c69e by Cheng Shao at 2022-03-11T20:00:01-05:00
CmmToC: fix Double# literal payload for 32-bit targets

Contrary to the legacy comment, the splitting didn't happen and we
ended up with a single StgWord64 literal in the output code! Let's
just do the splitting here.

- - - - -
1eee2e28 by Cheng Shao at 2022-03-11T20:00:01-05:00
CmmToC: use __builtin versions of memcpyish functions to fix type mismatch

Our memcpyish primop's type signatures doesn't match the C type
signatures. It's not a problem for typical archs, since their C ABI
permits dropping the result, but it doesn't work for wasm. The
previous logic would cast the memcpyish function pointer to an
incorrect type and perform an indirect call, which results in a
runtime trap on wasm.

The most straightforward fix is: don't emit EFF_ for memcpyish
functions. Since we don't want to include extra headers in .hc to
bring in their prototypes, we can just use the __builtin versions.

- - - - -
9d8d4837 by Cheng Shao at 2022-03-11T20:00:01-05:00
CmmToC: emit __builtin_unreachable() when CmmSwitch doesn't contain fallback case

Otherwise the C compiler may complain "warning: non-void function does
not return a value in all control paths [-Wreturn-type]".

- - - - -
27da5540 by Cheng Shao at 2022-03-11T20:00:01-05:00
CmmToC: make floatToWord32/doubleToWord64 faster

Use castFloatToWord32/castDoubleToWord64 in base to perform the
reinterpret cast.

- - - - -
c98e8332 by Cheng Shao at 2022-03-11T20:00:01-05:00
CmmToC: fix -Wunused-value warning in ASSIGN_BaseReg

When ASSIGN_BaseReg is a no-op, we shouldn't generate any C code,
otherwise C compiler complains a bunch of -Wunused-value warnings when
doing unregisterised codegen.

- - - - -
5932247c by Ben Gamari at 2022-03-11T20:00:36-05:00
users guide: Eliminate spurious \spxentry mentions

We were failing to pass the style file to `makeindex`, as is done by
the mklatex configuration generated by Sphinx.

Fixes #20913.

- - - - -
e40cf4ef by Simon Jakobi at 2022-03-11T20:01:11-05:00
ghc-bignum: Tweak integerOr

The result of ORing two BigNats is always greater or equal to the
larger of the two. Therefore it is safe to skip the magnitude checks of
integerFromBigNat#.

- - - - -
cf081476 by Vladislav Zavialov at 2022-03-12T07:02:40-05:00
checkUnboxedLitPat: use non-fatal addError

This enables GHC to report more parse errors in a single pass.

- - - - -
7fe07143 by Andreas Klebinger at 2022-03-12T07:03:16-05:00
Rename -fprof-late-ccs to -fprof-late

- - - - -
88a94541 by Sylvain Henry at 2022-03-12T07:03:56-05:00
Hadrian: avoid useless allocations in trackArgument

Cf ticky report before the change:

    Entries      Alloc    Alloc'd  Non-void Arguments      STG Name
--------------------------------------------------------------------------------
     696987   29044128          0   1 L                    main:Target.trackArgument_go5{v r24kY} (fun)

- - - - -
2509d676 by Sylvain Henry at 2022-03-12T07:04:36-05:00
Hadrian: avoid allocating in stageString (#19209)

- - - - -
c062fac0 by Sylvain Henry at 2022-03-12T07:04:36-05:00
Hadrian: remove useless imports

Added for no reason in 7ce1b694f7be7fbf6e2d7b7eb0639e61fbe358c6

- - - - -
c82fb934 by Sylvain Henry at 2022-03-12T07:05:16-05:00
Hadrian: avoid allocations in WayUnit's Read instance (#19209)

- - - - -
ed04aed2 by Sylvain Henry at 2022-03-12T07:05:16-05:00
Hadrian: use IntSet Binary instance for Way (#19209)

- - - - -
ad835531 by Simon Peyton Jones at 2022-03-13T18:12:12-04:00
Fix bug in weak loop-breakers in OccurAnal

Note [Weak loop breakers] explains why we need to track variables free
in RHS of rules.  But we need to do this for /inactive/ rules as well
as active ones, unlike the rhs_fv_env stuff.

So we now have two fields in node Details, one for free vars of
active rules, and one for free vars of all rules.

This was shown up by #20820, which is now fixed.

- - - - -
76b94b72 by Sebastian Graf at 2022-03-13T18:12:48-04:00
Worker/wrapper: Preserve float barriers (#21150)

Issue #21150 shows that worker/wrapper allocated a worker function for a
function with multiple calls that said "called at most once" when the first
argument was absent. That's bad!

This patch makes it so that WW preserves at least one non-one-shot value lambda
(see `Note [Preserving float barriers]`) by passing around `void#` in place of
absent arguments.

Fixes #21150.

Since the fix is pretty similar to `Note [Protecting the last value argument]`,
I put the logic in `mkWorkerArgs`. There I realised (#21204) that
`-ffun-to-thunk` is basically useless with `-ffull-laziness`, so I deprecated
the flag, simplified and split into `needsVoidWorkerArg`/`addVoidWorkerArg`.
SpecConstr is another client of that API.

Fixes #21204.

Metric Decrease:
    T14683

- - - - -
97db789e by romes at 2022-03-14T11:36:39-04:00
Fix up Note [Bind free vars]

Move GHC-specific comments from Language.Haskell.Syntax.Binds to
GHC.Hs.Binds

It looks like the Note was deleted but there were actually two copies of
it. L.H.S.B no longer references it, and GHC.Hs.Binds keeps an updated
copy. (See #19252)

There are other duplicated notes -- they will be fixed in the next
commit

- - - - -
135888dd by romes at 2022-03-14T11:36:39-04:00
TTG Pull AbsBinds and ABExport out of the main AST

AbsBinds and ABExport both depended on the typechecker, and were thus
removed from the main AST Expr.

CollectPass now has a new function `collectXXHsBindsLR` used for the new
HsBinds extension point

Bumped haddock submodule to work with AST changes.

The removed Notes from Language.Haskell.Syntax.Binds were duplicated
(and not referenced) and the copies in GHC.Hs.Binds are kept (and
referenced there). (See #19252)

- - - - -
106413f0 by sheaf at 2022-03-14T11:37:21-04:00
Add two coercion optimisation perf tests

- - - - -
8eadea67 by sheaf at 2022-03-14T15:08:24-04:00
Fix isLiftedType_maybe and handle fallout

As #20837 pointed out, `isLiftedType_maybe` returned `Just False` in
many situations where it should return `Nothing`, because it didn't
take into account type families or type variables.

In this patch, we fix this issue. We rename `isLiftedType_maybe` to
`typeLevity_maybe`, which now returns a `Levity` instead of a boolean.
We now return `Nothing` for types with kinds of the form
`TYPE (F a1 ... an)` for a type family `F`, as well as
`TYPE (BoxedRep l)` where `l` is a type variable.

This fix caused several other problems, as other parts of the compiler
were relying on `isLiftedType_maybe` returning a `Just` value, and were
now panicking after the above fix. There were two main situations in
which panics occurred:

  1. Issues involving the let/app invariant. To uphold that invariant,
     we need to know whether something is lifted or not. If we get an
     answer of `Nothing` from `isLiftedType_maybe`, then we don't know
     what to do. As this invariant isn't particularly invariant, we
     can change the affected functions to not panic, e.g. by behaving
     the same in the `Just False` case and in the `Nothing` case
     (meaning: no observable change in behaviour compared to before).

  2. Typechecking of data (/newtype) constructor patterns. Some programs
     involving patterns with unknown representations were accepted, such
     as T20363. Now that we are stricter, this caused further issues,
     culminating in Core Lint errors. However, the behaviour was
     incorrect the whole time; the incorrectness only being revealed by
     this change, not triggered by it.

     This patch fixes this by overhauling where the representation
     polymorphism involving pattern matching are done. Instead of doing
     it in `tcMatches`, we instead ensure that the `matchExpected`
     functions such as `matchExpectedFunTys`, `matchActualFunTySigma`,
     `matchActualFunTysRho` allow return argument pattern types which
     have a fixed RuntimeRep (as defined in Note [Fixed RuntimeRep]).
     This ensures that the pattern matching code only ever handles types
     with a known runtime representation. One exception was that
     patterns with an unknown representation type could sneak in via
     `tcConPat`, which points to a missing representation-polymorphism
     check, which this patch now adds.

     This means that we now reject the program in #20363, at least until
     we implement PHASE 2 of FixedRuntimeRep (allowing type families in
     RuntimeRep positions). The aforementioned refactoring, in which
     checks have been moved to `matchExpected` functions, is a first
     step in implementing PHASE 2 for patterns.

Fixes #20837

- - - - -
8ff32124 by Sebastian Graf at 2022-03-14T15:09:01-04:00
DmdAnal: Don't unbox recursive data types (#11545)

As `Note [Demand analysis for recursive data constructors]` describes, we now
refrain from unboxing recursive data type arguments, for two reasons:

 1. Relating to run/alloc perf: Similar to
    `Note [CPR for recursive data constructors]`, it seldomly improves run/alloc
    performance if we just unbox a finite number of layers of a potentially huge
    data structure.
 2. Relating to ghc/alloc perf: Inductive definitions on single-product
    recursive data types like the one in T11545 will (diverge, and) have very
    deep demand signatures before any other abortion mechanism in Demand
    analysis is triggered. That leads to great and unnecessary churn on Demand
    analysis when ultimately we will never make use of any nested strictness
    information anyway.

Conclusion: Discard nested demand and boxity information on such recursive types
with the help of `Note [Detecting recursive data constructors]`.

I also implemented `GHC.Types.Unique.MemoFun.memoiseUniqueFun` in order to avoid
the overhead of repeated calls to `GHC.Core.Opt.WorkWrap.Utils.isRecDataCon`.
It's nice and simple and guards against some smaller regressions in T9233 and
T16577.

ghc/alloc performance-wise, this patch is a very clear win:

                               Test    Metric          value      New value Change
---------------------------------------------------------------------------------------
                LargeRecord(normal) ghc/alloc  6,141,071,720  6,099,871,216  -0.7%
MultiLayerModulesTH_OneShot(normal) ghc/alloc  2,740,973,040  2,705,146,640  -1.3%
                     T11545(normal) ghc/alloc    945,475,492     85,768,928 -90.9% GOOD
                     T13056(optasm) ghc/alloc    370,245,880    326,980,632 -11.7% GOOD
                     T18304(normal) ghc/alloc     90,933,944     76,998,064 -15.3% GOOD
                     T9872a(normal) ghc/alloc  1,800,576,840  1,792,348,760  -0.5%
                     T9872b(normal) ghc/alloc  2,086,492,432  2,073,991,848  -0.6%
                     T9872c(normal) ghc/alloc  1,750,491,240  1,737,797,832  -0.7%
       TcPlugin_RewritePerf(normal) ghc/alloc  2,286,813,400  2,270,957,896  -0.7%

                          geo. mean                                          -2.9%

No noteworthy change in run/alloc either.

NoFib results show slight wins, too:

--------------------------------------------------------------------------------
        Program         Allocs    Instrs
--------------------------------------------------------------------------------
    constraints          -1.9%     -1.4%
          fasta          -3.6%     -2.7%
reverse-complem          -0.3%     -0.9%
       treejoin          -0.0%     -0.3%
--------------------------------------------------------------------------------
            Min          -3.6%     -2.7%
            Max          +0.1%     +0.1%
 Geometric Mean          -0.1%     -0.1%

Metric Decrease:
    T11545
    T13056
    T18304

- - - - -
ab618309 by Vladislav Zavialov at 2022-03-15T18:34:38+03:00
Export (~) from Data.Type.Equality (#18862)

* Users can define their own (~) type operator
* Haddock can display documentation for the built-in (~)
* New transitional warnings implemented:
    -Wtype-equality-out-of-scope
    -Wtype-equality-requires-operators

Updates the haddock submodule.

- - - - -
577135bf by Aaron Allen at 2022-03-16T02:27:48-04:00
Convert Diagnostics in GHC.Tc.Gen.Foreign

Converts all uses of 'TcRnUnknownMessage' to proper diagnostics.

- - - - -
c1fed9da by Aaron Allen at 2022-03-16T02:27:48-04:00
Suggest FFI extensions as hints (#20116)

- Use extension suggestion hints instead of suggesting extensions in the
error message body for several FFI errors.
- Adds a test case for `TcRnForeignImportPrimExtNotSet`

- - - - -
a33d1045 by Zubin Duggal at 2022-03-16T02:28:24-04:00
TH: allow negative patterns in quotes (#20711)

We still don't allow negative overloaded patterns. Earler all negative patterns
were treated as negative overloaded patterns. Now, we expliclty check the
extension field to see if the pattern is actually a negative overloaded pattern

- - - - -
1575c4a5 by Sebastian Graf at 2022-03-16T02:29:03-04:00
Demand: Let `Boxed` win in `lubBoxity` (#21119)

Previously, we let `Unboxed` win in `lubBoxity`, which is unsoundly optimistic
in terms ob Boxity analysis. "Unsoundly" in the sense that we sometimes unbox
parameters that we better shouldn't unbox. Examples are #18907 and T19871.absent.

Until now, we thought that this hack pulled its weight becuase it worked around
some shortcomings of the phase separation between Boxity analysis and CPR
analysis. But it is a gross hack which caused regressions itself that needed all
kinds of fixes and workarounds. See for example #20767. It became impossible to
work with in !7599, so I want to remove it.

For example, at the moment, `lubDmd B dmd` will not unbox `dmd`,
but `lubDmd A dmd` will. Given that `B` is supposed to be the bottom element of
the lattice, it's hardly justifiable to get a better demand when `lub`bing with
`A`.

The consequence of letting `Boxed` win in `lubBoxity` is that we *would* regress
 #2387, #16040 and parts of #5075 and T19871.sumIO, until Boxity and CPR
are able to communicate better. Fortunately, that is not the case since I could
tweak the other source of optimism in Boxity analysis that is described in
`Note [Unboxed demand on function bodies returning small products]` so that
we *recursively* assume unboxed demands on function bodies returning small
products. See the updated Note.

`Note [Boxity for bottoming functions]` describes why we need bottoming
functions to have signatures that say that they deeply unbox their arguments.
In so doing, I had to tweak `finaliseArgBoxities` so that it will never unbox
recursive data constructors. This is in line with our handling of them in CPR.
I updated `Note [Which types are unboxed?]` to reflect that.

In turn we fix #21119, #20767, #18907, T19871.absent and get a much simpler
implementation (at least to think about). We can also drop the very ad-hoc
definition of `deferAfterPreciseException` and its Note in favor of the
simple, intuitive definition we used to have.

Metric Decrease:
    T16875
    T18223
    T18698a
    T18698b
    hard_hole_fits
Metric Increase:
    LargeRecord
    MultiComponentModulesRecomp
    T15703
    T8095
    T9872d

Out of all the regresions, only the one in T9872d doesn't vanish in a perf
build, where the compiler is bootstrapped with -O2 and thus SpecConstr.
Reason for regressions:

  * T9872d is due to `ty_co_subst` taking its `LiftingContext` boxed.
    That is because the context is passed to a function argument, for
    example in `liftCoSubstTyVarBndrUsing`.
  * In T15703, LargeRecord and T8095, we get a bit more allocations in
    `expand_syn` and `piResultTys`, because a `TCvSubst` isn't unboxed.
    In both cases that guards against reboxing in some code paths.
  * The same is true for MultiComponentModulesRecomp, where we get less unboxing
    in `GHC.Unit.Finder.$wfindInstalledHomeModule`. In a perf build, allocations
    actually *improve* by over 4%!

Results on NoFib:

--------------------------------------------------------------------------------
        Program         Allocs    Instrs
--------------------------------------------------------------------------------
         awards          -0.4%     +0.3%
      cacheprof          -0.3%     +2.4%
            fft          -1.5%     -5.1%
       fibheaps          +1.2%     +0.8%
          fluid          -0.3%     -0.1%
            ida          +0.4%     +0.9%
   k-nucleotide          +0.4%     -0.1%
     last-piece         +10.5%    +13.9%
           lift          -4.4%     +3.5%
        mandel2         -99.7%    -99.8%
           mate          -0.4%     +3.6%
         parser          -1.0%     +0.1%
         puzzle         -11.6%     +6.5%
reverse-complem          -3.0%     +2.0%
            scs          -0.5%     +0.1%
         sphere          -0.4%     -0.2%
      wave4main          -8.2%     -0.3%
--------------------------------------------------------------------------------
Summary excludes mandel2 because of excessive bias
            Min         -11.6%     -5.1%
            Max         +10.5%    +13.9%
 Geometric Mean          -0.2%     +0.3%
--------------------------------------------------------------------------------

Not bad for a bug fix.

The regression in `last-piece` could become a win if SpecConstr would work on
non-recursive functions. The regression in `fibheaps` is due to
`Note [Reboxed crud for bottoming calls]`, e.g., #21128.

- - - - -
bb779b90 by sheaf at 2022-03-16T02:29:42-04:00
Add a regression test for #21130

This problem was due to a bug in cloneWanted, which was incorrectly
creating a coercion hole to hold an evidence variable.

This bug was introduced by 8bb52d91 and fixed in 81740ce8.

Fixes #21130

- - - - -
0f0e2394 by Tamar Christina at 2022-03-17T10:16:37-04:00
linker: Initial Windows C++ exception unwinding support

- - - - -
36d20d4d by Tamar Christina at 2022-03-17T10:16:37-04:00
linker: Fix ADDR32NB relocations on Windows

- - - - -
8a516527 by Tamar Christina at 2022-03-17T10:16:37-04:00
testsuite: properly escape string paths

- - - - -
1a0dd008 by sheaf at 2022-03-17T10:17:13-04:00
Hadrian: account for change in late-ccs flag

The late cost centre flag was renamed from -fprof-late-ccs
to -fprof-late in 7fe07143, but this change hadn't been
propagated to Hadrian.

- - - - -
8561c1af by romes at 2022-03-18T05:10:58-04:00
TTG: Refactor HsBracket

- - - - -
19163397 by romes at 2022-03-18T05:10:58-04:00
Type-checking untyped brackets

When HsExpr GhcTc, the HsBracket constructor should hold a HsBracket
GhcRn, rather than an HsBracket GhcTc.

We make use of the HsBracket p extension constructor (XBracket
(XXBracket p)) to hold an HsBracket GhcRn when the pass is GhcTc

See !4782 https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782

- - - - -
310890a5 by romes at 2022-03-18T05:10:58-04:00
Separate constructors for typed and untyped brackets

Split HsBracket into HsTypedBracket and HsUntypedBracket.

Unfortunately, we still cannot get rid of

    instance XXTypedBracket GhcTc = HsTypedBracket GhcRn

despite no longer requiring it for typechecking, but rather because the
TH desugarer works on GhcRn rather than GhcTc (See GHC.HsToCore.Quote)

- - - - -
4a2567f5 by romes at 2022-03-18T05:10:58-04:00
TTG: Refactor bracket for desugaring during tc

When desugaring a bracket we want to desugar /renamed/ rather than
/typechecked/ code; So in (HsExpr GhcTc) tree, we must
have a (HsExpr GhcRn) for the quotation itself.

This commit reworks the TTG refactor on typed and untyped brackets by
storing the /renamed/ code in the bracket field extension rather than in
the constructor extension in `HsQuote` (previously called
`HsUntypedBracket`)

See Note [The life cycle of a TH quotation] and https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782

- - - - -
b056adc8 by romes at 2022-03-18T05:10:58-04:00
TTG: Make HsQuote GhcTc isomorphic to NoExtField

An untyped bracket `HsQuote p` can never be constructed with
`p ~ GhcTc`. This is because we don't typecheck `HsQuote` at all.

That's OK, because we also never use `HsQuote GhcTc`.

To enforce this at the type level we make `HsQuote GhcTc` isomorphic
to `NoExtField` and impossible to construct otherwise, by using TTG field
extensions to make all constructors, except for `XQuote` (which takes `NoExtField`),
unconstructable, with `DataConCantHappen`

This is explained more in detail in Note [The life cycle of a TH quotation]

Related discussion: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782

- - - - -
ac3b2e7d by romes at 2022-03-18T05:10:58-04:00
TTG: TH brackets finishing touches

Rewrite the critical notes and fix outdated ones,

use `HsQuote GhcRn` (in `HsBracketTc`) for desugaring regardless of the
bracket being typed or untyped,

remove unused `EpAnn` from `Hs*Bracket GhcRn`,

zonkExpr factor out common brackets code,

ppr_expr factor out common brackets code,

and fix tests,

to finish MR https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782.

-------------------------
Metric Decrease:
    hard_hole_fits
-------------------------

- - - - -
d147428a by Ben Gamari at 2022-03-18T05:11:35-04:00
codeGen: Fix signedness of jump table indexing

Previously while constructing the jump table index we would
zero-extend the discriminant before subtracting the start of the
jump-table. This goes subtly wrong in the case of a sub-word, signed
discriminant, as described in the included Note. Fix this in both the
PPC and X86 NCGs.

Fixes #21186.

- - - - -
435a3d5d by Ben Gamari at 2022-03-18T05:11:35-04:00
testsuite: Add test for #21186

- - - - -
e9d8de93 by Zubin Duggal at 2022-03-19T07:35:49-04:00
TH: Fix pretty printing of newtypes with operators and GADT syntax (#20868)

The pretty printer for regular data types already accounted for these,
and had some duplication with the newtype pretty printer.

Factoring the logic out into a common function and using it for both
newtypes and data declarations is enough to fix the bug.

- - - - -
244da9eb by sheaf at 2022-03-19T07:36:24-04:00
List GHC.Event.Internal in base.cabal on Windows

GHC.Event.Internal was not listed in base.cabal on Windows. This caused
undefined reference errors. This patch adds it back, by moving it out
of the OS-specific logic in base.cabal.

Fixes #21245.
- - - - -
d1c03719 by Andreas Klebinger at 2022-03-19T07:37:00-04:00
Compact regions: Maintain tags properly

Fixes #21251

- - - - -
d45bb701 by romes at 2022-03-19T07:37:36-04:00
Remove dead code HsDoRn

- - - - -
c842611f by nineonine at 2022-03-20T21:16:06-04:00
Revamp derived Eq instance code generation (#17240)

This patch improves code generation for derived Eq instances.
The idea is to use 'dataToTag' to evaluate both arguments.
This allows to 'short-circuit' when tags do not match.
Unfortunately, inner evals are still present when we branch
on tags. This is due to the way 'dataToTag#' primop
evaluates its argument in the code generator. #21207 was
created to explore further optimizations.

Metric Decrease:
    LargeRecord

- - - - -
52ffd38c by Sylvain Henry at 2022-03-20T21:16:46-04:00
Avoid some SOURCE imports

- - - - -
b91798be by Zubin Duggal at 2022-03-23T13:39:39-04:00
hi haddock: Lex and store haddock docs in interface files

Names appearing in Haddock docstrings are lexed and renamed like any other names
appearing in the AST. We currently rename names irrespective of the namespace,
so both type and constructor names corresponding to an identifier will appear in
the docstring. Haddock will select a given name as the link destination based on
its own heuristics.

This patch also restricts the limitation of `-haddock` being incompatible with
`Opt_KeepRawTokenStream`.

The export and documenation structure is now computed in GHC and serialised in
.hi files. This can be used by haddock to directly generate doc pages without
reparsing or renaming the source. At the moment the operation of haddock
is not modified, that's left to a future patch.

Updates the haddock submodule with the minimum changes needed.

- - - - -
78db231f by Cheng Shao at 2022-03-23T13:40:17-04:00
configure: bump LlvmMaxVersion to 14

LLVM 13.0.0 is released in Oct 2021, and latest head validates against
LLVM 13 just fine if LlvmMaxVersion is bumped.

- - - - -
b06e5dd8 by Adam Sandberg Ericsson at 2022-03-23T13:40:54-04:00
docs: clarify the eventlog format documentation a little bit

- - - - -
4dc62498 by Matthew Pickering at 2022-03-23T13:41:31-04:00
Fix behaviour of -Wunused-packages in ghci

Ticket #21110 points out that -Wunused-packages behaves a bit unusually
in GHCi. Now we define the semantics for -Wunused-packages in
interactive mode as follows:

* If you use -Wunused-packages on an initial load then the warning is reported.
* If you explicitly set -Wunused-packages on the command line then the
  warning is displayed (until it is disabled)
* If you then subsequently modify the set of available targets by using
  :load or :cd (:cd unloads everything) then the warning is (silently)
  turned off.

This means that every :r the warning is printed if it's turned on (but you did ask for it).

Fixes #21110

- - - - -
fed05347 by Ben Gamari at 2022-03-23T13:42:07-04:00
rts/adjustor: Place adjustor templates in data section on all OSs

In !7604 we started placing adjustor templates in the data section on
Linux as some toolchains there reject relocations in the text section.
However, it turns out that OpenBSD also exhibits this restriction.

Fix this by *always* placing adjustor templates in the data section.

Fixes #21155.

- - - - -
db32bb8c by Zubin Duggal at 2022-03-23T13:42:44-04:00
Improve error message when warning about unsupported LLVM version (#20958)

Change the wording to make it clear that the upper bound is non-inclusive.

- - - - -
f214349a by Ben Gamari at 2022-03-23T13:43:20-04:00
rts: Untag function field in scavenge_PAP_payload

Previously we failed to untag the function closure when scavenging the
payload of a PAP, resulting in an invalid closure pointer being passed
to scavenge_large_bitmap and consequently #21254. Fix this.

Fixes #21254

- - - - -
e6d0e287 by Ben Gamari at 2022-03-23T13:43:20-04:00
rts: Don't mark object code in markCAFs unless necessary

Previously `markCAFs` would call `markObjectCode` even in non-major GCs.
This is problematic since `prepareUnloadCheck` is not called in such
GCs, meaning that the section index has not been updated.

Fixes #21254

- - - - -
1a7cf096 by Sylvain Henry at 2022-03-23T13:44:05-04:00
Avoid redundant imports of GHC.Driver.Session

Remove GHC.Driver.Session imports that weren't considered as redundant
because of the reexport of PlatformConstants. Also remove this reexport
as modules using this datatype should import GHC.Platform instead.

- - - - -
e3f60577 by Sylvain Henry at 2022-03-23T13:44:05-04:00
Reverse dependency between StgToCmm and Runtime.Heap.Layout

- - - - -
e6585ca1 by Sylvain Henry at 2022-03-23T13:44:46-04:00
Define filterOut with filter

filter has fusion rules that filterOut lacks

- - - - -
c58d008c by Ryan Scott at 2022-03-24T06:10:43-04:00
Fix and simplify DeriveAnyClass's context inference using SubTypePredSpec

As explained in `Note [Gathering and simplifying constraints for DeriveAnyClass]`
in `GHC.Tc.Deriv.Infer`, `DeriveAnyClass` infers instance contexts by emitting
implication constraints. Previously, these implication constraints were
constructed by hand. This is a terribly trick thing to get right, as it
involves a delicate interplay of skolemisation, metavariable instantiation, and
`TcLevel` bumping. Despite much effort, we discovered in #20719 that the
implementation was subtly incorrect, leading to valid programs being rejected.

While we could scrutinize the code that manually constructs implication
constraints and repair it, there is a better, less error-prone way to do
things. After all, the heart of `DeriveAnyClass` is generating code which
fills in each class method with defaults, e.g., `foo = $gdm_foo`. Typechecking
this sort of code is tantamount to calling `tcSubTypeSigma`, as we much ensure
that the type of `$gdm_foo` is a subtype of (i.e., more polymorphic than) the
type of `foo`. As an added bonus, `tcSubTypeSigma` is a battle-tested function
that handles skolemisation, metvariable instantiation, `TcLevel` bumping, and
all other means of tricky bookkeeping correctly.

With this insight, the solution to the problems uncovered in #20719 is simple:
use `tcSubTypeSigma` to check if `$gdm_foo`'s type is a subtype of `foo`'s
type. As a side effect, `tcSubTypeSigma` will emit exactly the implication
constraint that we were attempting to construct by hand previously. Moreover,
it does so correctly, fixing #20719 as a consequence.

This patch implements the solution thusly:

* The `PredSpec` data type (previously named `PredOrigin`) is now split into
  `SimplePredSpec`, which directly stores a `PredType`, and `SubTypePredSpec`,
  which stores the actual and expected types in a subtype check.
  `SubTypePredSpec` is only used for `DeriveAnyClass`; all other deriving
  strategies use `SimplePredSpec`.
* Because `tcSubTypeSigma` manages the finer details of type variable
  instantiation and constraint solving under the hood, there is no longer any
  need to delicately split apart the method type signatures in
  `inferConstraintsAnyclass`. This greatly simplifies the implementation of
  `inferConstraintsAnyclass` and obviates the need to store skolems,
  metavariables, or given constraints in a `ThetaSpec` (previously named
  `ThetaOrigin`). As a bonus, this means that `ThetaSpec` now simply becomes a
  synonym for a list of `PredSpec`s, which is conceptually much simpler than it
  was before.
* In `simplifyDeriv`, each `SubTypePredSpec` results in a call to
  `tcSubTypeSigma`. This is only performed for its side effect of emitting
  an implication constraint, which is fed to the rest of the constraint solving
  machinery in `simplifyDeriv`. I have updated
  `Note [Gathering and simplifying constraints for DeriveAnyClass]` to explain
  this in more detail.

To make the changes in `simplifyDeriv` more manageable, I also performed some
auxiliary refactoring:

* Previously, every iteration of `simplifyDeriv` was skolemising the type
  variables at the start, simplifying, and then performing a reverse
  substitution at the end to un-skolemise the type variables. This is not
  necessary, however, since we can just as well skolemise once at the
  beginning of the `deriving` pipeline and zonk the `TcTyVar`s after
  `simplifyDeriv` is finished. This patch does just that, having been made
  possible by prior work in !7613. I have updated `Note [Overlap and deriving]`
  in `GHC.Tc.Deriv.Infer` to explain this, and I have also left comments on
  the relevant data structures (e.g., `DerivEnv` and `DerivSpec`) to explain
  when things might be `TcTyVar`s or `TyVar`s.
* All of the aforementioned cleanup allowed me to remove an ad hoc
  deriving-related in `checkImplicationInvariants`, as all of the skolems in
  a `tcSubTypeSigma`–produced implication constraint should now be `TcTyVar`
  at the time the implication is created.
* Since `simplifyDeriv` now needs a `SkolemInfo` and `UserTypeCtxt`, I have
  added `ds_skol_info` and `ds_user_ctxt` fields to `DerivSpec` to store these.
  Similarly, I have also added a `denv_skol_info` field to `DerivEnv`, which
  ultimately gets used to initialize the `ds_skol_info` in a `DerivSpec`.

Fixes #20719.

- - - - -
21680fb0 by Sebastian Graf at 2022-03-24T06:11:19-04:00
WorkWrap: Handle partial FUN apps in `isRecDataCon` (#21265)

Partial FUN apps like `(->) Bool` aren't detected by `splitFunTy_maybe`.
A silly oversight that is easily fixed by replacing `splitFunTy_maybe` with a
guard in the `splitTyConApp_maybe` case.

But fortunately, Simon nudged me into rewriting the whole `isRecDataCon`
function in a way that makes it much shorter and hence clearer which DataCons
are actually considered as recursive.

Fixes #21265.

- - - - -
a2937e2b by Matthew Pickering at 2022-03-24T17:13:22-04:00
Add test for T21035

This test checks that you are allowed to explicitly supply object files
for dependencies even if you haven't got the shared object for that
library yet.

Fixes #21035

- - - - -
1756d547 by Matthew Pickering at 2022-03-24T17:13:58-04:00
Add check to ensure we are not building validate jobs for releases

- - - - -
99623358 by Matthew Pickering at 2022-03-24T17:13:58-04:00
hadrian: Correct generation of hsc2hs wrapper

If you inspect the inside of a wrapper script for hsc2hs you will see
that the cflag and lflag values are concatenated incorrectly.

```
HSC2HS_EXTRA="--cflag=-U__i686--lflag=-fuse-ld=gold"
```

It should instead be

```
HSC2HS_EXTRA="--cflag=-U__i686 --lflag=-fuse-ld=gold"
```

Fixes #21221

- - - - -
fefd4e31 by Matthew Pickering at 2022-03-24T17:13:59-04:00
testsuite: Remove library dependenices from T21119

These dependencies would affect the demand signature depending on
various rules and so on.

Fixes #21271

- - - - -
5ff690b8 by Matthew Pickering at 2022-03-24T17:13:59-04:00
ci: Generate jobs for all normal builds and use hadrian for all builds

This commit introduces a new script (.gitlab/gen_ci.hs) which generates
a yaml file (.gitlab/jobs.yaml) which contains explicit descriptions for
all the jobs we want to run. The jobs are separated into three
categories:

* validate - jobs run on every MR
* nightly  - jobs run once per day on the master branch
* release  - jobs for producing release artifacts

The generation script is a Haskell program which includes a DSL for
specifying the different jobs. The hope is that it's easier to reason
about the different jobs and how the variables are merged together
rather than the unclear and opaque yaml syntax. The goal is to fix
issues like #21190 once and for all..

The `.gitlab/jobs.yaml` can be generated by running the `.gitlab/generate_jobs`
script. You have to do this manually.

Another consequence of this patch is that we use hadrian for all the
validate, nightly and release builds on all platforms.

- - - - -
1d673aa2 by Christiaan Baaij at 2022-03-25T11:35:49-04:00
Add the OPAQUE pragma

A new pragma, `OPAQUE`, that ensures that every call of a named
function annotated with an `OPAQUE` pragma remains a call of that
named function, not some name-mangled variant.

Implements GHC proposal 0415:
https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0415-opaque-pragma.rst

This commit also updates the haddock submodule to handle the newly
introduced lexer tokens corresponding to the OPAQUE pragma.

- - - - -
83f5841b by Bodigrim at 2022-03-25T11:36:31-04:00
Add instance Lift ByteArray

- - - - -
7cc1184a by Matthew Pickering at 2022-03-25T11:37:07-04:00
Make -ddump-rn-ast and -ddump-tc-ast work in GHCi

Fixes #17830

- - - - -
940feaf3 by Sylvain Henry at 2022-03-25T11:37:47-04:00
Modularize Tidy (#17957)

- Factorize Tidy options into TidyOpts datatype. Initialize it in
  GHC.Driver.Config.Tidy
- Same thing for StaticPtrOpts
- Perform lookups of unpackCString[Utf8]# once in initStaticPtrOpts
  instead of for every use of mkStringExprWithFS

- - - - -
25101813 by Takenobu Tani at 2022-03-28T01:16:02-04:00
users-guide: Correct markdown for profiling

This patch corrects some markdown.

[skip ci]

- - - - -
c832ae93 by Matthew Pickering at 2022-03-28T01:16:38-04:00
hadrian: Flag cabal flag handling

This patch basically deletes some ad-hoc handling of Cabal Flags and
replaces it with a correct query of the LocalBuildInfo. The flags in the
local build info can be modified by users by passing hadrian options

For example (!4331)

```
*.genapply.cabal.configure.opts += --flags=unregisterised
```

And all the flags specified by the `Cabal Flags` builder were already
passed to configure properly using `--flags`.

- - - - -
a9f3a5c6 by Ben Gamari at 2022-03-28T01:16:38-04:00
Disable text's dependency on simdutf by default

Unfortunately we are simply not currently in a good position to robustly
ship binary distributions which link against C++ code like simdutf.

Fixes #20724.

- - - - -
eff86e8a by Richard Eisenberg at 2022-03-28T01:17:14-04:00
Add Red Herring to Note [What might equal later?]

Close #21208.

- - - - -
12653be9 by jberryman at 2022-03-28T01:17:55-04:00
Document typed splices inhibiting unused bind detection (#16524)
- - - - -
4aeade15 by Adam Sandberg Ericsson at 2022-03-28T01:18:31-04:00
users-guide: group ticky-ticky profiling under one heading

- - - - -
cc59648a by Sylvain Henry at 2022-03-28T01:19:12-04:00
Hadrian: allow testsuite to run with cross-compilers (#21292)

- - - - -
89cb1315 by Matthew Pickering at 2022-03-28T01:19:48-04:00
hadrian: Add show target to bindist makefile

Some build systems use "make show" to query facts about the bindist, for
example:

```
make show VALUE=ProjectVersion > version
```

to determine the ProjectVersion

- - - - -
8229885c by Alan Zimmerman at 2022-03-28T19:23:28-04:00
EPA: let stmt with semicolon has wrong anchor

The code

   let ;x =1

Captures the semicolon annotation, but did not widen the anchor in the
ValBinds.

Fix that.

Closes #20247

- - - - -
2c12627c by Ryan Scott at 2022-03-28T19:24:04-04:00
Consistently attach SrcSpans to sub-expressions in TH splices

Before, `GHC.ThToHs` was very inconsistent about where various sub-expressions
would get the same `SrcSpan` from the original TH splice location or just a
generic `noLoc` `SrcSpan`. I have ripped out all uses of `noLoc` in favor of
the former instead, and I have added a
`Note [Source locations within TH splices]` to officially enshrine this
design choice.

Fixes #21299.

- - - - -
789add55 by Zubin Duggal at 2022-03-29T13:07:22-04:00
Fix all invalid haddock comments in the compiler

Fixes #20935 and #20924

- - - - -
967dad03 by Zubin Duggal at 2022-03-29T13:07:22-04:00
hadrian: Build lib:GHC with -haddock and -Winvalid-haddock (#21273)

- - - - -
ad09a5f7 by sheaf at 2022-03-29T13:08:05-04:00
Hadrian: make DDEBUG separate from debugged RTS

This patchs separates whether -DDEBUG is enabled (i.e. whether debug
assertions are enabled) from whether we are using the debugged RTS
(i.e. GhcDebugged = YES).

This means that we properly skip tests which have been marked with
`when(compiler_debugged(), skip)`.

Fixes #21113, #21153 and #21234

- - - - -
840a6811 by Matthew Pickering at 2022-03-29T13:08:42-04:00
RTS: Zero gc_cpu_start and gc_cpu_end after accounting

When passed a combination of `-N` and `-qn` options the cpu time for
garbage collection was being vastly overcounted because the counters
were not being zeroed appropiately.

When -qn1 is passed, only 1 of the N avaiable GC threads is chosen to
perform work, the rest are idle. At the end of the GC period, stat_endGC
traverses all the GC threads and adds up the elapsed time from each of
them. For threads which didn't participate in this GC, the value of the
cpu time should be zero, but before this patch, the counters were not
zeroed and hence we would count the same elapsed time on many subsequent
iterations (until the thread participated in a GC again).

The most direct way to zero these fields is to do so immediately after
the value is added into the global counter, after which point they are
never used again.

We also tried another approach where we would zero the counter in
yieldCapability but there are some (undiagnosed) siations where a
capbility would not pass through yieldCapability before the GC ended and
the same double counting problem would occur.

Fixes #21082

- - - - -
dda46e2d by Matthew Pickering at 2022-03-29T13:09:18-04:00
Add test for T21306

Fixes #21306

- - - - -
f07c7766 by Jakob Brünker at 2022-03-30T03:10:33-04:00
Give parsing plugins access to errors

Previously, when the parser produced non-fatal errors (i.e. it produced
errors but the 'PState' is 'POk'), compilation would be aborted before
the 'parsedResultAction' of any plugin was invoked. This commit changes
that, so that such that 'parsedResultAction' gets collections of
warnings and errors as argument, and must return them after potentially
modifying them.

Closes #20803

- - - - -
e5dfde75 by Ben Gamari at 2022-03-30T03:11:10-04:00
Fix reference to Note [FunBind vs PatBind]

This Note was renamed in 2535a6716202253df74d8190b028f85cc6d21b72 yet
this occurrence was not updated.

- - - - -
21894a63 by Krzysztof Gogolewski at 2022-03-30T03:11:45-04:00
Refactor: make primtypes independent of PrimReps

Previously, 'pcPrimTyCon', the function used to define a primitive type,
was taking a PrimRep, only to convert it to a RuntimeRep. Now it takes
a RuntimeRep directly.

Moved primRepToRuntimeRep to GHC.Types.RepType. It is now
located next to its inverse function runtimeRepPrimRep.
Now GHC.Builtin.Types.Prim no longer mentions PrimRep, and GHC.Types.RepType
no longer imports GHC.Builtin.Types.Prim.

Removed unused functions `primRepsToRuntimeRep` and `mkTupleRep`.

Removed Note [PrimRep and kindPrimRep] - it was never referenced,
didn't belong to Types.Prim, and Note [Getting from RuntimeRep to
PrimRep] is more comprehensive.

- - - - -
43da2963 by Matthew Pickering at 2022-03-30T09:55:49+01:00
Fix mention of non-existent "rehydrateIface" function [skip ci]

Fixes #21303

- - - - -
6793a20f by gershomb at 2022-04-01T10:33:46+01:00
Remove wrong claim about naturality law.

This docs change removes a longstanding confusion in the Traversable
docs. The docs say "(The naturality law is implied by parametricity and
thus so is the purity law [1, p15].)". However if one reads the
reference a different "natural" law is implied by parametricity. The
naturality law given as a law here is imposed. Further, the reference
gives examples which violate both laws -- so they cannot be implied by
parametricity. This PR just removes the wrong claim.

- - - - -
5beeff46 by Ben Gamari at 2022-04-01T10:34:39+01:00
Refactor handling of global initializers

GHC uses global initializers for a number of things including
cost-center registration, info-table provenance registration, and setup
of foreign exports. Previously, the global initializer arrays which
referenced these initializers would live in the object file of the C
stub, which would then be merged into the main object file of the
module.

Unfortunately, this approach is no longer tenable with the move to
Clang/LLVM on Windows (see #21019). Specifically, lld's PE backend does
not support object merging (that is, the -r flag). Instead we are now
rather packaging a module's object files into a static library. However,
this is problematic in the case of initializers as there are no
references to the C stub object in the archive, meaning that the linker
may drop the object from the final link.

This patch refactors our handling of global initializers to instead
place initializer arrays within the object file of the module to which
they belong. We do this by introducing a Cmm data declaration containing
the initializer array in the module's Cmm stream. While the initializer
functions themselves remain in separate C stub objects, the reference
from the module's object ensures that they are not dropped from the
final link.

In service of #21068.

- - - - -
3e6fe71b by Matthew Pickering at 2022-04-01T10:35:41+01:00
Fix remaining issues in eventlog types (gen_event_types.py)

*  The size of End concurrent mark phase looks wrong and, it used to be 4 and now it's 0.
*  The size of Task create is wrong, used to be 18 and now 14.
*  The event ticky-ticky entry counter begin sample has the wrong name
*  The event ticky-ticky entry counter being sample has the wrong size, was 0 now 32.

Closes #21070

- - - - -
7847f47a by Ben Gamari at 2022-04-01T10:35:41+01:00
users-guide: Fix a few small issues in eventlog format descriptions

The CONC_MARK_END event description didn't mention its payload.
Clarify the meaning of the CREATE_TASK's payload.

- - - - -
acfd5a4c by Matthew Pickering at 2022-04-01T10:35:53+01:00
ci: Regenerate jobs.yaml

It seems I forgot to update this to reflect the current state of
gen_ci.hs

- - - - -
a952dd80 by Matthew Pickering at 2022-04-01T10:35:59+01:00
ci: Attempt to fix windows cache issues

It appears that running the script directly does nothing (no info is
printed about saving the cache).

- - - - -
fb65e6e3 by Adrian Ratiu at 2022-04-01T10:49:52+01:00
fp_prog_ar.m4: take AR var into consideration

In ChromeOS and Gentoo we want the ability to use LLVM ar
instead of GNU ar even though both are installed, thus we
pass (for eg) AR=llvm-ar to configure.

Unfortunately GNU ar always gets picked regardless of the
AR setting because the check does not consider the AR var
when setting fp_prog_ar, hence this fix.

- - - - -
1daaefdf by Greg Steuck at 2022-04-01T10:50:16+01:00
T13366 requires c++ & c++abi libraries on OpenBSD

Fixes this failure:

=====> 1 of 1 [0, 0, 0]
T13366(normal) 1 of 1 [0, 0, 0] Compile failed (exit code 1) errors were:

<no location info>: error:
    user specified .o/.so/.DLL could not be loaded (File not found)
Whilst trying to load:  (dynamic) stdc++
Additional directories searched: (none)

*** unexpected failure for T13366(normal)

- - - - -
18e6c85b by Jakob Bruenker at 2022-04-01T10:54:28+01:00
new datatypes for parsedResultAction

Previously, the warnings and errors were given and returned as a tuple
(Messages PsWarnings, Messages PsErrors). Now, it's just PsMessages.

This, together with the HsParsedModule the parser plugin gets and
returns, has been wrapped up as ParsedResult.

- - - - -
9727e592 by Morrow at 2022-04-01T10:55:12+01:00
Clarify that runghc interprets the input program

- - - - -
f589dea3 by sheaf at 2022-04-01T10:59:58+01:00
Unify RuntimeRep arguments in ty_co_match

The `ty_co_match` function ignored the implicit RuntimeRep coercions
that occur in a `FunCo`. Even though a comment explained that this
should be fine, #21205 showed that it could result in discarding a
RuntimeRep coercion, and thus discarding an important cast entirely.

With this patch, we first match the kinds in `ty_co_match`.

Fixes #21205

-------------------------
Metric Increase:
    T12227
    T18223
-------------------------

- - - - -
6f4dc372 by Andreas Klebinger at 2022-04-01T11:01:35+01:00
Export MutableByteArray from Data.Array.Byte

This implements CLC proposal #49

- - - - -
5df9f5e7 by ARATA Mizuki at 2022-04-01T11:02:35+01:00
Add test cases for #20640

Closes #20640

- - - - -
8334ff9e by Krzysztof Gogolewski at 2022-04-01T11:03:16+01:00
Minor cleanup

- Remove unused functions exprToCoercion_maybe, applyTypeToArg,
  typeMonoPrimRep_maybe, runtimeRepMonoPrimRep_maybe.
- Replace orValid with a simpler check
- Use splitAtList in applyTysX
- Remove calls to extra_clean in the testsuite; it does not do anything.

Metric Decrease:
    T18223

- - - - -
b2785cfc by Eric Lindblad at 2022-04-01T11:04:07+01:00
hadrian typos

- - - - -
418e6fab by Eric Lindblad at 2022-04-01T11:04:12+01:00
two typos

- - - - -
dd7c7c99 by Phil de Joux at 2022-04-01T11:04:56+01:00
Add tests and docs on plugin args and order.

- - - - -
3e209a62 by MaxHearnden at 2022-04-01T11:05:19+01:00
Change may not to might not
- - - - -
b84380d3 by Matthew Pickering at 2022-04-01T11:07:27+01:00
hadrian: Remove linters-common from bindist

Zubin observed that the bindists contains the utility library
linters-common. There are two options:

1. Make sure only the right files are added into the bindist.. a bit
   tricky due to the non-trivial structure of the lib directory.
2. Remove the bad files once they get copied in.. a bit easier

So I went for option 2 but we perhaps should go for option 1 in the
future.

Fixes #21203

- - - - -
ba9904c1 by Zubin Duggal at 2022-04-01T11:07:31+01:00
hadrian: allow testing linters with out of tree compilers

- - - - -
26547759 by Matthew Pickering at 2022-04-01T11:07:35+01:00
hadrian: Introduce CheckProgram datatype to replace a 7-tuple

- - - - -
df65d732 by Jakob Bruenker at 2022-04-01T11:08:28+01:00
Fix panic when pretty printing HsCmdLam

When pretty printing a HsCmdLam with more than one argument, GHC
panicked because of a missing case. This fixes that.

Closes #21300

- - - - -
ad6cd165 by John Ericson at 2022-04-01T11:10:06+01:00
hadrian: Remove vestigial -this-unit-id support check

This has been dead code since 400ead81e80f66ad7b1260b11b2a92f25ccc3e5a.

- - - - -
8ca7ab81 by Matthew Pickering at 2022-04-01T11:10:23+01:00
hadrian: Fix race involving empty package databases

There was a small chance of a race occuring between the small window of

1. The first package (.conf) file get written into the database
2. hadrian calling "ghc-pkg recache" to refresh the package.conf file

In this window the package database would contain rts.conf but not a
package.cache file, and therefore if ghc was invoked it would error
because it was missing.

To solve this we call "ghc-pkg recache" at when the database is created
by shake by writing the stamp file into the database folder. This also
creates the package.cache file and so avoids the possibility of this
race.

- - - - -
cc4ec64b by Matthew Pickering at 2022-04-01T11:11:05+01:00
hadrian: Add assertion that in/out tree args are the same

There have been a few instances where this calculation was incorrect, so
we add a non-terminal assertion when now checks they the two
computations indeed compute the same thing.

Fixes #21285

- - - - -
691508d8 by Matthew Pickering at 2022-04-01T11:13:10+01:00
hlint: Ignore suggestions in generated HaddockLex file

With the make build system this file ends up in the compiler/
subdirectory so is linted. With hadrian, the file ends up in _build so
it's not linted.

Fixes #21313

- - - - -
f8f152e7 by Krzysztof Gogolewski at 2022-04-01T11:14:08+01:00
Change GHC.Prim to GHC.Exts in docs and tests

Users are supposed to import GHC.Exts rather than GHC.Prim.
Part of #18749.

- - - - -
f8fc6d2e by Matthew Pickering at 2022-04-01T11:15:24+01:00
driver: Improve -Wunused-packages error message (and simplify implementation)

In the past I improved the part of -Wunused-packages which found which
packages were used. Now I improve the part which detects which ones were
specified. The key innovation is to use the explicitUnits field from
UnitState which has the result of resolving the package flags, so we
don't need to mess about with the flag arguments from DynFlags anymore.

The output now always includes the package name and version (and the
flag which exposed it).

```
    The following packages were specified via -package or -package-id flags,
    but were not needed for compilation:
      - bytestring-0.11.2.0 (exposed by flag -package bytestring)
      - ghc-9.3 (exposed by flag -package ghc)
      - process-1.6.13.2 (exposed by flag -package process)
```

Fixes #21307

- - - - -
5e5a12d9 by Matthew Pickering at 2022-04-01T11:15:32+01:00
driver: In oneshot mode, look for interface files in hidir

How things should work:

*  -i is the search path for source files
*  -hidir explicitly sets the search path for interface files and the output location for interface files.
*  -odir sets the search path and output location for object files.

Before in one shot mode we would look for the interface file in the
search locations given by `-i`, but then set the path to be in the
`hidir`, so in unusual situations the finder could find an interface
file in the `-i` dir but later fail because it tried to read the
interface file from the `-hidir`.

A bug identified by #20569

- - - - -
950f58e7 by Matthew Pickering at 2022-04-01T11:15:36+01:00
docs: Update documentation interaction of search path, -hidir and -c mode.

As noted in #20569 the documentation for search path was wrong because
it seemed to indicate that `-i` dirs were important when looking for
interface files in `-c` mode, but they are not important if `-hidir` is
set.

Fixes #20569

- - - - -
d85c7dcb by sheaf at 2022-04-01T11:17:56+01:00
Keep track of promotion ticks in HsOpTy

This patch adds a PromotionFlag field to HsOpTy, which is used
in pretty-printing and when determining whether to emit warnings
with -fwarn-unticked-promoted-constructors.

This allows us to correctly report tick-related warnings for things
like:

  type A = Int : '[]
  type B = [Int, Bool]

Updates haddock submodule

Fixes #19984

- - - - -
32070e6c by Jakob Bruenker at 2022-04-01T20:31:08+02:00
Implement \cases (Proposal 302)

This commit implements proposal 302: \cases - Multi-way lambda
expressions.

This adds a new expression heralded by \cases, which works exactly like
\case, but can match multiple apats instead of a single pat.

Updates submodule haddock to support the ITlcases token.

Closes #20768

- - - - -
c6f77f39 by sheaf at 2022-04-01T20:33:05+02:00
Add a regression test for #21323

This bug was fixed at some point between GHC 9.0 and GHC 9.2;
this patch simply adds a regression test.

- - - - -
3596684e by Jakob Bruenker at 2022-04-01T20:33:05+02:00
Fix error when using empty case in arrow notation

It was previously not possible to use -XEmptyCase in Arrow notation,
since GHC would print "Exception: foldb of empty list".

This is now fixed.

Closes #21301

- - - - -
9a325b59 by Ben Gamari at 2022-04-01T20:33:05+02:00
users-guide: Fix various markup issues

- - - - -
aefb1e6d by sheaf at 2022-04-01T20:36:01+02:00
Ensure implicit parameters are lifted

`tcExpr` typechecked implicit parameters by introducing a metavariable
of kind `TYPE kappa`, without enforcing that `kappa ~ LiftedRep`.
This patch instead creates a metavariable of kind `Type`.

Fixes #21327

- - - - -
ed62dc66 by Ben Gamari at 2022-04-05T11:44:51-04:00
gitlab-ci: Disable cabal-install store caching on Windows

For reasons that remain a mystery, cabal-install seems to consistently
corrupt its cache on Windows. Disable caching for now.

Works around #21347.

- - - - -
5ece5c5a by Ryan Scott at 2022-04-06T13:00:51-04:00
Add /linters/*/dist-install/ to .gitignore

Fixes #21335.

[ci skip]

- - - - -
410c76ee by Ben Gamari at 2022-04-06T13:01:28-04:00
Use static archives as an alternative to object merging

Unfortunately, `lld`'s COFF backend does not currently support object
merging. With ld.bfd having broken support for high image-load base
addresses, it's necessary to find an alternative. Here I introduce
support in the driver for generating static archives, which we use on
Windows instead of object merging.

Closes #21068.

- - - - -
400666c8 by Ben Gamari at 2022-04-06T13:01:28-04:00
rts/linker: Catch archives masquerading as object files

Check the file's header to catch static archive bearing the `.o`
extension, as may happen on Windows after the Clang refactoring.

See #21068

- - - - -
694d39f0 by Ben Gamari at 2022-04-06T13:01:28-04:00
driver: Make object merging optional

On Windows we don't have a linker which supports object joining (i.e.
the `-r` flag). Consequently, `-pgmlm` is now a `Maybe`.

See #21068.

- - - - -
41fcb5cd by Ben Gamari at 2022-04-06T13:01:28-04:00
hadrian: Refactor handling of ar flags

Previously the setup was quite fragile as it had to assume which
arguments were file arguments and which were flags.

- - - - -
3ac80a86 by Ben Gamari at 2022-04-06T13:01:28-04:00
hadrian: Produce ar archives with L modifier on Windows

Since object files may in fact be archive files, we must ensure that
their contents are merged rather than constructing an
archive-of-an-archive.

See #21068.

- - - - -
295c35c5 by Ben Gamari at 2022-04-06T13:01:28-04:00
Add a Note describing lack of object merging on Windows

See #21068.

- - - - -
d2ae0a3a by Ben Gamari at 2022-04-06T13:01:28-04:00
Build ar archives with -L when "joining" objects

Since there may be .o files which are in fact archives.

- - - - -
babb47d2 by Zubin Duggal at 2022-04-06T13:02:04-04:00
Add warnings for file header pragmas that appear in the body of a module (#20385)

Once we are done parsing the header of a module to obtain the options, we
look through the rest of the tokens in order to determine if they contain any
misplaced file header pragmas that would usually be ignored, potentially
resulting in bad error messages.

The warnings are reported immediately so that later errors don't shadow
over potentially helpful warnings.

Metric Increase:
  T13719

- - - - -
3f31825b by Ben Gamari at 2022-04-06T13:02:40-04:00
rts/AdjustorPool: Generalize to allow arbitrary contexts

Unfortunately the i386 adjustor logic needs this.

- - - - -
9b645ee1 by Ben Gamari at 2022-04-06T13:02:40-04:00
adjustors/i386: Use AdjustorPool

In !7511 (closed) I introduced a new allocator for adjustors,
AdjustorPool, which eliminates the address space fragmentation issues
which adjustors can introduce. In that work I focused on amd64 since
that was the platform where I observed issues.

However, in #21132 we noted that the size of adjustors is also a cause
of CI fragility on i386. In this MR I port i386 to use AdjustorPool.
Sadly the complexity of the i386 adjustor code does cause require a bit
of generalization which makes the code a bit more opaque but such is the
world.

Closes #21132.

- - - - -
c657a616 by Ben Gamari at 2022-04-06T13:03:16-04:00
hadrian: Clean up flavour transformer definitions

Previously the `ipe` and `omit_pragmas` transformers were hackily
defined using the textual key-value syntax. Fix this.

- - - - -
9ce273b9 by Ben Gamari at 2022-04-06T13:03:16-04:00
gitlab-ci: Drop dead HACKAGE_INDEX_STATE variable

- - - - -
01845375 by Ben Gamari at 2022-04-06T13:03:16-04:00
gitlab/darwin: Factor out bindists

This makes it a bit easier to bump them.

- - - - -
c41c478e by Ben Gamari at 2022-04-06T13:03:16-04:00
Fix a few new warnings when booting with GHC 9.2.2

-Wuni-incomplete-patterns and apparent improvements in the pattern match
checker surfaced these.

- - - - -
6563cd24 by Ben Gamari at 2022-04-06T13:03:16-04:00
gitlab-ci: Bump bootstrap compiler to 9.2.2

This is necessary to build recent `text` commits.

Bumps Hackage index state for a hashable which builds with GHC 9.2.

- - - - -
a62e983e by Ben Gamari at 2022-04-06T13:03:16-04:00
Bump text submodule to current `master`

Addresses #21295.

- - - - -
88d61031 by Vladislav Zavialov at 2022-04-06T13:03:53-04:00
Refactor OutputableBndrFlag instances

The matching on GhcPass introduced by 95275a5f25a is not necessary.
This patch reverts it to make the code simpler.

- - - - -
f601f002 by GHC GitLab CI at 2022-04-06T15:18:26-04:00
rts: Eliminate use of nested functions

This is a gcc-specific extension.

- - - - -
d4c5f29c by Ben Gamari at 2022-04-06T15:18:26-04:00
driver: Drop hacks surrounding windres invocation

Drop hack for #1828, among others as they appear to be unnecessary when
using `llvm-windres`.

- - - - -
6be2c5a7 by Ben Gamari at 2022-04-06T15:18:26-04:00
Windows/Clang: Build system adaptation

* Bump win32-tarballs to 0.7
* Move Windows toolchain autoconf logic into separate file
* Use clang and LLVM utilities as described in #21019
* Disable object merging as lld doesn't support -r
* Drop --oformat=pe-bigobj-x86-64 arguments from ld flags as LLD detects
  that the output is large on its own.
* Drop gcc wrapper since Clang finds its root fine on its own.

- - - - -
c6fb7aff by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Test that we can build bigobj PE objects

- - - - -
79851c07 by Ben Gamari at 2022-04-06T15:18:26-04:00
Drop -static-libgcc

This flag is not applicable when Clang is used.

- - - - -
1f8a8264 by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Port T16514 to C

Previously this test was C++ which made it a bit of a portability
problem.

- - - - -
d7e650d1 by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Mark Windows as a libc++ platform

- - - - -
d7886c46 by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Mark T9405 as fixed on Windows

I have not seen it fail since moving to clang.

Closes #12714.

- - - - -
4c3fbb4e by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Mark FloatFnInverses as fixed

The new toolchain has fixed it.

Closes #15670.

- - - - -
402c36ba by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Rework T13606 to avoid gcc dependence

Previously we used libgcc_s's import library in T13606. However, now that
we ship with clang we no longer have this library. Instead we now use gdi32.

- - - - -
9934ad54 by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Clean up tests depending on C++ std lib

- - - - -
12fcdef2 by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Split T13366 into two tests

Split up the C and C++ uses since the latter is significantly more
platform-dependent.

- - - - -
3c08a198 by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Fix mk-big-obj

I'm a bit unclear on how this previously worked as it attempted
to build an executable without defining `main`.

- - - - -
7e97cc23 by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Provide module definitions in T10955dyn

Otherwise the linker will export all symbols, including those provided
by the RTS, from the produced shared object. Consequently, attempting
to link against multiple objects simultaneously will cause the linker
to complain that RTS symbols are multiply defined. Avoid this
by limiting the DLL exports with a module definition file.

- - - - -
9a248afa by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Mark test-defaulting-plugin as fragile on Windows

Currently llvm-ar does not handle long file paths, resulting in
occassional failures of these tests and #21293.

- - - - -
39371aa4 by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite/driver: Treat framework failures of fragile tests as non-fatal

Previously we would report framework failures of tests marked as fragile
as failures. Now we rather treat them as fragile test failures, which
are not fatal to the testsuite run. Noticed while investigating #21293.

- - - - -
a1e6661d by Ben Gamari at 2022-04-06T15:18:32-04:00
Bump Cabal submodule

- Disable support for library-for-ghci on Windows as described
  in #21068.
- Teach Cabal to use `ar -L` when available

- - - - -
f7b0f63c by Ben Gamari at 2022-04-06T15:18:37-04:00
Bump process submodule

Fixes missing TEST_CC_OPTS in testsuite tests.

- - - - -
109cee19 by Ben Gamari at 2022-04-06T15:18:37-04:00
hadrian: Disable ghci libraries when object merging is not available

- - - - -
c22fba5c by Ben Gamari at 2022-04-06T15:18:37-04:00
Bump bytestring submodule

- - - - -
6e2744cc by Ben Gamari at 2022-04-06T15:18:37-04:00
Bump text submodule

- - - - -
32333747 by Ben Gamari at 2022-04-06T15:18:37-04:00
hadrian: Build wrappers using ghc rather than cc

- - - - -
59787ba5 by Ben Gamari at 2022-04-06T15:18:37-04:00
linker/PEi386: More descriptive error message

- - - - -
5e3c3c4f by Ben Gamari at 2022-04-06T15:18:37-04:00
testsuite: Mark TH_spliceE5_prof as unbroken on Windows

It was previously failing due to #18721 and now passes with the new
toolchain.

Closes #18721.

- - - - -
9eb0a9d9 by GHC GitLab CI at 2022-04-06T15:23:48-04:00
rts/PEi386: Move some debugging output to -DL

- - - - -
ce874595 by Ben Gamari at 2022-04-06T15:24:01-04:00
nativeGen/x86: Use %rip-relative addressing

On Windows with high-entropy ASLR we must use %rip-relative addressing
to avoid overflowing the signed 32-bit immediate size of x86-64.
Since %rip-relative addressing comes essentially for free and can make
linking significantly easier, we use it on all platforms.

- - - - -
52deee64 by Ben Gamari at 2022-04-06T15:24:01-04:00
Generate LEA for label expressions

- - - - -
105a0056 by Ben Gamari at 2022-04-06T15:24:01-04:00
Refactor is32BitLit to take Platform rather than Bool

- - - - -
ec4526b5 by Ben Gamari at 2022-04-06T15:24:01-04:00
Don't assume that labels are 32-bit on Windows

- - - - -
ffdbe457 by Ben Gamari at 2022-04-06T15:24:01-04:00
nativeGen: Note signed-extended nature of MOV

- - - - -
bfb79697 by Ben Gamari at 2022-04-06T15:30:56-04:00
rts: Move __USE_MINGW_ANSI_STDIO definition to PosixSource.h

It's easier to ensure that this is included first than Rts.h

- - - - -
5ad143fd by Ben Gamari at 2022-04-06T15:30:56-04:00
rts: Fix various #include issues

This fixes various violations of the newly-added RTS includes linter.

- - - - -
a59a66a8 by Ben Gamari at 2022-04-06T15:30:56-04:00
testsuite: Lint RTS #includes

Verifies two important properties of #includes in the RTS:

 * That system headers don't appear inside of a `<BeginPrivate.h>` block
   as this can hide system library symbols, resulting in very
   hard-to-diagnose linker errors

 * That no headers precede `Rts.h`, ensuring that __USE_MINGW_ANSI_STDIO
   is set correctly before system headers are included.

- - - - -
42bf7528 by GHC GitLab CI at 2022-04-06T16:25:04-04:00
rts/PEi386: Fix memory leak

Previously we would leak the section information of the `.bss`
section.

- - - - -
d286a55c by Ben Gamari at 2022-04-06T16:25:25-04:00
rts/linker: Preserve information about symbol types

As noted in #20978, the linker would previously handle overflowed
relocations by creating a jump island. While this is fine in the case of
code symbols, it's very much not okay in the case of data symbols. To
fix this we must keep track of whether each symbol is code or data and
relocate them appropriately. This patch takes the first step in this
direction, adding a symbol type field to the linker's symbol table. It
doesn't yet change relocation behavior to take advantage of this
knowledge.

Fixes #20978.

- - - - -
e689e9d5 by Ben Gamari at 2022-04-06T16:25:25-04:00
rts/PEi386: Fix relocation overflow behavior

This fixes handling of overflowed relocations on PEi386 targets:

 * Refuse to create jump islands for relocations of data symbols
 * Correctly handle the `__imp___acrt_iob_func` symbol, which is an new
   type of symbol: `SYM_TYPE_INDIRECT_DATA`

- - - - -
655e7d8f by GHC GitLab CI at 2022-04-06T16:25:25-04:00
rts: Mark anything that might have an info table as data

Tables-next-to-code mandates that we treat symbols with info tables like
data since we cannot relocate them using a jump island.

See #20983.

- - - - -
7e8cc293 by Ben Gamari at 2022-04-06T16:25:25-04:00
rts/PEi386: Rework linker

This is a significant rework of the PEi386 linker, making the linker
compatible with high image base addresses. Specifically, we now use the
m32 allocator instead of `HeapAllocate`.

In addition I found a number of latent bugs in our handling of import
libraries and relocations. I've added quite a few comments describing
what I've learned about Windows import libraries while fixing these.

Thanks to Tamar Christina (@Phyx) for providing the address space search
logic, countless hours of help while debugging, and his boundless
Windows knowledge.

Co-Authored-By: Tamar Christina <tamar at zhox.com>

- - - - -
ff625218 by Ben Gamari at 2022-04-06T16:25:25-04:00
rts/PEi386: Move allocateBytes to MMap.c

- - - - -
f562b5ca by Ben Gamari at 2022-04-06T16:25:25-04:00
rts/PEi386: Avoid accidentally-quadratic allocation cost

We now preserve the address that we last mapped, allowing us to resume
our search and avoiding quadratic allocation costs. This fixes the
runtime of T10296a, which allocates many adjustors.

- - - - -
3247b7db by Ben Gamari at 2022-04-06T16:25:25-04:00
Move msvcrt dep out of base

- - - - -
fa404335 by Ben Gamari at 2022-04-06T16:25:25-04:00
rts/linker: More descriptive debug output

- - - - -
140f338f by Ben Gamari at 2022-04-06T16:25:25-04:00
rts/PathUtils: Define pathprintf in terms of snwprintf on Windows

swprintf deviates from usual `snprintf` semantics in that it does not
guarantee reasonable behavior when the buffer is NULL (that is,
returning the number of bytes that would have been emitted).

- - - - -
eb60565b by Ben Gamari at 2022-04-06T16:25:25-04:00
rts/linker: Report archive member index

- - - - -
209fd61b by Ben Gamari at 2022-04-06T16:25:25-04:00
rts/linker: Split up object resolution and initialization

Previously the RTS linker would call initializers during the
"resolve" phase of linking. However, this is problematic in the
case of cyclic dependencies between objects. In particular, consider
the case where we have a situation where a static library
contains a set of recursive objects:

 * object A has depends upon symbols in object B
 * object B has an initializer that depends upon object A
 * we try to load object A

The linker would previously:

 1. start resolving object A
 2. encounter the reference to object B, loading it resolve object B
 3. run object B's initializer
 4. the initializer will attempt to call into object A,
    which hasn't been fully resolved (and therefore protected)

Fix this by moving constructor execution to a new linking
phase, which follows resolution.

Fix #21253.

- - - - -
8e8a1021 by Ben Gamari at 2022-04-06T16:25:25-04:00
rts/linker/LoadArchive: Fix leaking file handle

Previously `isArchive` could leak a `FILE` handle if the `fread`
returned a short read.

- - - - -
429ea5d9 by sheaf at 2022-04-07T07:55:52-04:00
Remove Fun pattern from Typeable COMPLETE set

GHC merge request !963 improved warnings in the presence of
COMPLETE annotations. This allows the removal of the Fun pattern
from the complete set.

Doing so expectedly causes some redundant pattern match warnings,
in particular in GHC.Utils.Binary.Typeable and Data.Binary.Class
from the binary library; this commit addresses that.

Updates binary submodule

Fixes #20230

- - - - -
54b18824 by Alan Zimmerman at 2022-04-07T07:56:28-04:00
EPA: handling of con_bndrs in mkGadtDecl

Get rid of unnnecessary case clause that always matched.

Closes #20558

- - - - -
9c838429 by Ben Gamari at 2022-04-07T09:38:53-04:00
testsuite: Mark T10420 as broken on Windows

Due to #21322.

- - - - -
50739d2b by Ben Gamari at 2022-04-07T09:42:42-04:00
rts: Refactor and fix printf attributes on clang

Clang on Windows does not understand the `gnu_printf` attribute; use
`printf` instead.

- - - - -
9eeaeca4 by Ben Gamari at 2022-04-07T09:42:42-04:00
rts: Add missing newline in error message

- - - - -
fcef9a17 by Ben Gamari at 2022-04-07T09:42:42-04:00
configure: Make environ decl check more robust

Some platforms (e.g. Windows/clang64) declare `environ` in `<stdlib.h>`,
not `<unistd.h>`

- - - - -
8162b4f3 by Ben Gamari at 2022-04-07T09:42:42-04:00
rts: Adjust RTS symbol table on Windows for ucrt

- - - - -
633280d7 by Ben Gamari at 2022-04-07T09:43:21-04:00
testsuite: Fix exit code of bounds checking tests on Windows

`abort` exits with 255, not 134, on Windows.

- - - - -
cab4dc01 by Ben Gamari at 2022-04-07T09:43:31-04:00
testsuite: Update expected output from T5435 tests on Windows

I'll admit, I don't currently see *why* this output is reordered
but it is a fairly benign difference and I'm out of time to investigate.

- - - - -
edf5134e by Ben Gamari at 2022-04-07T09:43:35-04:00
testsuite: Mark T20918 as broken on Windows

Our toolchain on Windows doesn't currently have Windows support.

- - - - -
d0ddeff3 by Ben Gamari at 2022-04-07T09:43:39-04:00
testsuite: Mark linker unloading tests as broken on Windows

Due to #20354.

We will need to investigate this prior the release.

- - - - -
5a86da2b by Ben Gamari at 2022-04-07T09:43:43-04:00
testsuite: Mark T9405 as broken on Windows

Due to #21361.

- - - - -
4aa86dcf by Ben Gamari at 2022-04-07T09:44:18-04:00
Merge branches 'wip/windows-high-codegen', 'wip/windows-high-linker', 'wip/windows-clang-2' and 'wip/lint-rts-includes' into wip/windows-clang-join

- - - - -
7206f055 by Ben Gamari at 2022-04-07T09:45:07-04:00
rts/CloneStack: Ensure that Rts.h is #included first

As is necessary on Windows.

- - - - -
9cfcb27b by Ben Gamari at 2022-04-07T09:45:07-04:00
rts: Fallback to ucrtbase not msvcrt

Since we have switched to Clang the toolchain now links against
ucrt rather than msvcrt.

- - - - -
d6665d85 by Ben Gamari at 2022-04-07T09:46:25-04:00
Accept spurious perf test shifts on Windows

Metric Decrease:
    T16875
Metric Increase:
    T12707
    T13379
    T3294
    T4801
    T5321FD
    T5321Fun
    T783

- - - - -
83363c8b by Simon Peyton Jones at 2022-04-07T12:57:21-04:00
Use prepareBinding in tryCastWorkerWrapper

As #21144 showed, tryCastWorkerWrapper was calling prepareRhs, and
then unconditionally floating the bindings, without the checks of
doFloatFromRhs.   That led to floating an unlifted binding into
a Rec group.

This patch refactors prepareBinding to make these checks,
and do them uniformly across all calls.  A nice improvement.

Other changes
* Instead of passing around a RecFlag and a TopLevelFlag; and sometimes
  a (Maybe SimplCont) for join points, define a new Simplifier-specific
  data type BindContext:
      data BindContext = BC_Let  TopLevelFlag RecFlag
                       | BC_Join SimplCont
  and use it consistently.

* Kill off completeNonRecX by inlining it.  It was only called in
  one place.

* Add a wrapper simplImpRules for simplRules.

Compile time on T9630 drops by 4.7%; little else changes.

Metric Decrease:
    T9630

- - - - -
02279a9c by Vladislav Zavialov at 2022-04-07T12:57:59-04:00
Rename [] to List (#21294)

This patch implements a small part of GHC Proposal #475.
The key change is in GHC.Types:

	- data [] a = [] | a : [a]
	+ data List a = [] | a : List a

And the rest of the patch makes sure that List is pretty-printed as []
in various contexts.

Updates the haddock submodule.

- - - - -
08480d2a by Simon Peyton Jones at 2022-04-07T12:58:36-04:00
Fix the free-var test in validDerivPred

The free-var test (now documented as (VD3)) was too narrow,
affecting only class predicates.  #21302 demonstrated that
this wasn't enough!

Fixes #21302.

Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com>

- - - - -
b3d6d23d by Andreas Klebinger at 2022-04-07T12:59:12-04:00
Properly explain where INLINE pragmas can appear.

Fixes #20676

- - - - -
23ef62b3 by Ben Gamari at 2022-04-07T14:28:28-04:00
rts: Fix off-by-one in snwprintf usage

- - - - -
b2dbcc7d by Simon Jakobi at 2022-04-08T03:00:38-04:00
Improve seq[D]VarSet

Previously, the use of size[D]VarSet would involve a traversal of the
entire underlying IntMap. Since IntMaps are already spine-strict,
this is unnecessary.

- - - - -
64ac20a7 by sheaf at 2022-04-08T03:01:16-04:00
Add test for #21338

This no-skolem-info bug was fixed by the no-skolem-info patch
that will be part of GHC 9.4. This patch adds a regression test for
the issue reported in issue #21338.

Fixes #21338.

- - - - -
c32c4db6 by Ben Gamari at 2022-04-08T03:01:53-04:00
rts: Move __USE_MINGW_ANSI_STDIO definition to PosixSource.h

It's easier to ensure that this is included first than Rts.h

- - - - -
56f85d62 by Ben Gamari at 2022-04-08T03:01:53-04:00
rts: Fix various #include issues

This fixes various violations of the newly-added RTS includes linter.

- - - - -
cb1f31f5 by Ben Gamari at 2022-04-08T03:01:53-04:00
testsuite: Lint RTS #includes

Verifies two important properties of #includes in the RTS:

 * That system headers don't appear inside of a `<BeginPrivate.h>` block
   as this can hide system library symbols, resulting in very
   hard-to-diagnose linker errors

 * That no headers precede `Rts.h`, ensuring that __USE_MINGW_ANSI_STDIO
   is set correctly before system headers are included.

- - - - -
c44432db by Krzysztof Gogolewski at 2022-04-08T03:02:29-04:00
Fixes to 9.4 release notes

- Mention -Wforall-identifier
- Improve description of withDict
- Fix formatting

- - - - -
777365f1 by sheaf at 2022-04-08T09:43:35-04:00
Correctly report SrcLoc of redundant constraints

We were accidentally dropping the source location information in
certain circumstances when reporting redundant constraints. This patch
makes sure that we set the TcLclEnv correctly before reporting the
warning.

Fixes #21315

- - - - -
af300a43 by Vladislav Zavialov at 2022-04-08T09:44:11-04:00
Reject illegal quote mark in data con declarations (#17865)

* Non-fatal (i.e. recoverable) parse error
* Checking infix constructors
* Extended the regression test

- - - - -
56254e6b by Ben Gamari at 2022-04-08T09:59:46-04:00
Merge remote-tracking branch 'origin/master'

- - - - -
6e2c3b7c by Matthew Pickering at 2022-04-08T13:55:15-04:00
driver: Introduce HomeModInfoCache abstraction

The HomeModInfoCache is a mutable cache which is updated incrementally
as the driver completes, this makes it robust to exceptions including
(SIGINT)

The interface for the cache is described by the `HomeMOdInfoCache` data
type:

```
data HomeModInfoCache = HomeModInfoCache { hmi_clearCache :: IO [HomeModInfo]
                                         , hmi_addToCache :: HomeModInfo -> IO () }
```

The first operation clears the cache and returns its contents. This is
designed so it's harder to end up in situations where the cache is
retained throughout the execution of upsweep.

The second operation allows a module to be added to the cache.

The one slightly nasty part is in `interpretBuildPlan` where we have to
be careful to ensure that the cache writes happen:

1. In parralel
2. Before the executation continues after upsweep.

This requires some simple, localised MVar wrangling.

Fixes #20780

- - - - -
85f4a3c9 by Andreas Klebinger at 2022-04-08T13:55:50-04:00
Add flag -fprof-manual which controls if GHC should honour manual cost centres.

This allows disabling of manual control centres in code a user doesn't control like
libraries.

Fixes #18867

- - - - -
3415981c by Vladislav Zavialov at 2022-04-08T13:56:27-04:00
HsUniToken for :: in GADT constructors (#19623)

One more step towards the new design of EPA.

Updates the haddock submodule.

- - - - -
23f95735 by sheaf at 2022-04-08T13:57:07-04:00
Docs: datacon eta-expansion, rep-poly checks

The existing notes weren't very clear on how the eta-expansion of
data constructors that occurs in tcInferDataCon/dsConLike interacts
with the representation polymorphism invariants. So we explain with
a few more details how we ensure that the representation-polymorphic
lambdas introduced by tcInferDataCon/dsConLike don't end up causing
problems, by checking they are properly instantiated and then relying
on the simple optimiser to perform beta reduction.

A few additional changes:

  - ConLikeTc just take type variables instead of binders, as we
    never actually used the binders.
  - Removed the FRRApp constructor of FRROrigin; it was no longer used
    now that we use ExpectedFunTyOrigin.
  - Adds a bit of documentation to the constructors
    of ExpectedFunTyOrigin.

- - - - -
d4480490 by Matthew Pickering at 2022-04-08T13:57:43-04:00
ci: Replace "always" with "on_success" to stop build jobs running before hadrian-ghci has finished

See https://docs.gitlab.com/ee/ci/yaml/#when

* always means, always run not matter what
* on_success means, run if the dependencies have built successfully

- - - - -
0736e949 by Vladislav Zavialov at 2022-04-08T13:58:19-04:00
Disallow (->) as a data constructor name (#16999)

The code was misusing isLexCon, which was never meant for validation.
In fact, its documentation states the following:

	Use these functions to figure what kind of name a 'FastString'
	represents; these functions do /not/ check that the identifier
	is valid.

Ha! This sign can't stop me because I can't read.

The fix is to use okConOcc instead. The other checks (isTcOcc or
isDataOcc) seem superfluous, so I also removed those.

- - - - -
e58d5eeb by Simon Peyton Jones at 2022-04-08T13:58:55-04:00
Tiny documentation wibble

This commit
   commit 83363c8b04837ee871a304cf85207cf79b299fb0
   Author: Simon Peyton Jones <simon.peytonjones at gmail.com>
   Date:   Fri Mar 11 16:55:38 2022 +0000

       Use prepareBinding in tryCastWorkerWrapper

refactored completeNonRecX away, but left a Note referring to it.
This MR fixes that Note.

- - - - -
4bb00839 by Matthew Pickering at 2022-04-09T07:40:28-04:00
ci: Fix nightly head.hackage pipelines

This also needs a corresponding commit to head.hackage, I also made the
job explicitly depend on the fedora33 job so that it isn't blocked by a
failing windows job, which causes docs-tarball to fail.

- - - - -
3c48e12a by Matthew Pickering at 2022-04-09T07:40:28-04:00
ci: Remove doc-tarball dependency from perf and perf-nofib jobs

These don't depend on the contents of the tarball so we can run them
straight after the fedora33 job finishes.

- - - - -
27362265 by Matthew Pickering at 2022-04-09T07:41:04-04:00
Bump deepseq to 1.4.7.0

Updates deepseq submodule

Fixes #20653

- - - - -
dcf30da8 by Joachim Breitner at 2022-04-09T13:02:19-04:00
Drop the app invariant

previously, GHC had the "let/app-invariant" which said that the RHS of a
let or the argument of an application must be of lifted type or ok for
speculation. We want this on let to freely float them around, and we
wanted that on app to freely convert between the two (e.g. in
beta-reduction or inlining).

However, the app invariant meant that simple code didn't stay simple and
this got in the way of rules matching. By removing the app invariant,
this thus fixes #20554.

The new invariant is now called "let-can-float invariant", which is
hopefully easier to guess its meaning correctly.

Dropping the app invariant means that everywhere where we effectively do
beta-reduction (in the two simplifiers, but also in `exprIsConApp_maybe`
and other innocent looking places) we now have to check if the argument
must be evaluated (unlifted and side-effecting), and analyses have to be
adjusted to the new semantics of `App`.

Also, `LetFloats` in the simplifier can now also carry such non-floating
bindings.

The fix for DmdAnal, refine by Sebastian, makes functions with unlifted
arguments strict in these arguments, which changes some signatures.

This causes some extra calls to `exprType` and `exprOkForSpeculation`,
so some perf benchmarks regress a bit (while others improve).

Metric Decrease:
    T9020
Metric Increase:
    LargeRecord
    T12545
    T15164
    T16577
    T18223
    T5642
    T9961

Co-authored-by: Sebastian Graf <sebastian.graf at kit.edu>

- - - - -
6c6c5379 by Philip Hazelden at 2022-04-09T13:02:59-04:00
Add functions traceWith, traceShowWith, traceEventWith.

As discussed at
https://github.com/haskell/core-libraries-committee/issues/36

- - - - -
8fafacf7 by Philip Hazelden at 2022-04-09T13:02:59-04:00
Add tests for several trace functions.

- - - - -
20bbf3ac by Philip Hazelden at 2022-04-09T13:02:59-04:00
Update changelog.

- - - - -
47d18b0b by Andreas Klebinger at 2022-04-09T13:03:35-04:00
Add regression test for #19569

- - - - -
5f8d6e65 by sheaf at 2022-04-09T13:04:14-04:00
Fix missing SymCo in pushCoercionIntoLambda

There was a missing SymCo in pushCoercionIntoLambda. Currently
this codepath is only used with rewrite rules, so this bug managed
to slip by, but trying to use pushCoercionIntoLambda in other contexts
revealed the bug.

- - - - -
20eca489 by Vladislav Zavialov at 2022-04-09T13:04:50-04:00
Refactor: simplify lexing of the dot

Before this patch, the lexer did a truly roundabout thing with the dot:

1. look up the varsym in reservedSymsFM and turn it into ITdot
2. under OverloadedRecordDot, turn it into ITvarsym
3. in varsym_(prefix|suffix|...) turn it into ITvarsym, ITdot, or
   ITproj, depending on extensions and whitespace

Turns out, the last step is sufficient to handle the dot correctly.
This patch removes the first two steps.

- - - - -
5440f63e by Hécate Moonlight at 2022-04-12T11:11:06-04:00
Document that DuplicateRecordFields doesn't tolerates ambiguous fields

Fix #19891

- - - - -
0090ad7b by Sebastian Graf at 2022-04-12T11:11:42-04:00
Eta reduction based on evaluation context (#21261)

I completely rewrote our Notes surrounding eta-reduction. The new entry point is
`Note [Eta reduction makes sense]`.

Then I went on to extend the Simplifier to maintain an evaluation context in the
form of a `SubDemand` inside a `SimplCont`. That `SubDemand` is useful for doing
eta reduction according to `Note [Eta reduction based on evaluation context]`,
which describes how Demand analysis, Simplifier and `tryEtaReduce` interact to
facilitate eta reduction in more scenarios.

Thus we fix #21261.

ghc/alloc perf marginally improves (-0.0%). A medium-sized win is when compiling
T3064 (-3%). It seems that haddock improves by 0.6% to 1.0%, too.

Metric Decrease:
    T3064

- - - - -
4d2ee313 by Sebastian Graf at 2022-04-12T17:54:57+02:00
Specialising through specialised method calls (#19644)

In #19644, we discovered that the ClassOp/DFun rules from
Note [ClassOp/DFun selection] inhibit transitive specialisation in a scenario
like
```
class C a where m :: Show b => a -> b -> ...; n :: ...
instance C Int where m = ... -- $cm :: Show b => Int -> b -> ...
f :: forall a b. (C a, Show b) => ...
f $dC $dShow = ... m @a $dC @b $dShow ...
main = ... f @Int @Bool ...
```
After we specialise `f` for `Int`, we'll see `m @a $dC @b $dShow` in the body of
`$sf`. But before this patch, Specialise doesn't apply the ClassOp/DFun rule to
rewrite to a call of the instance method for `C Int`, e.g., `$cm @Bool $dShow`.
As a result, Specialise couldn't further specialise `$cm` for `Bool`.

There's a better example in `Note [Specialisation modulo dictionary selectors]`.

This patch enables proper Specialisation, as follows:

1. In the App case of `specExpr`, try to apply the CalssOp/DictSel rule on the
   head of the application
2. Attach an unfolding to freshly-bound dictionary ids such as `$dC` and
   `$dShow` in `bindAuxiliaryDict`

NB: Without (2), (1) would be pointless, because `lookupRule` wouldn't be able
to look into the RHS of `$dC` to see the DFun.

(2) triggered #21332, because the Specialiser floats around dictionaries without
accounting for them in the `SpecEnv`'s `InScopeSet`, triggering a panic when
rewriting dictionary unfoldings.

Fixes #19644 and #21332.

- - - - -
b06f4f47 by Sebastian Graf at 2022-04-12T17:54:58+02:00
Specialise: Check `typeDeterminesValue` before specialising on an interesting dictionary

I extracted the checks from `Note [Type determines value]` into its own
function, so that we share the logic properly. Then I made sure that we
actually call `typeDeterminesValue` everywhere we check for `interestingDict`.

- - - - -
a42dbc55 by Matthew Pickering at 2022-04-13T06:24:52-04:00
Refine warning about defining rules in SAFE modules

This change makes it clear that it's the definition rather than any
usage which is a problem, and that rules defined in other modules will
still be  used to do rewrites.

Fixes #20923

- - - - -
df893f66 by Andreas Klebinger at 2022-04-14T08:18:37-04:00
StgLint: Lint constructor applications and strict workers for arity.

This will mean T9208 when run with lint will return a lint error instead
of resulting in a panic.

Fixes #21117

- - - - -
426ec446 by sheaf at 2022-04-14T08:19:16-04:00
Hadrian: use a set to keep track of ways

The order in which ways are provided doesn't matter,
so we use a data structure with the appropriate semantics to
represent ways.

Fixes #21378

- - - - -
7c639b9a by Dylan Yudaken at 2022-04-15T13:55:59-04:00
Only enable PROF_SPIN in DEBUG

- - - - -
96b9e5ea by Ben Gamari at 2022-04-15T13:56:34-04:00
testsuite: Add test for #21390

- - - - -
d8392f6a by Ben Gamari at 2022-04-15T13:56:34-04:00
rts: Ensure that the interpreter doesn't disregard tags

Previously the interpreter's handling of `RET_BCO` stack frames would
throw away the tag of the returned closure. This resulted in #21390.

- - - - -
83c67f76 by Alan Zimmerman at 2022-04-20T11:49:28-04:00
Add -dkeep-comments flag to keep comments in the parser

This provides a way to set the Opt_KeepRawTokenStream from the command
line, allowing exact print annotation users to see exactly what is
produced for a given parsed file, when used in conjunction with
-ddump-parsed-ast

Discussed in #19706, but this commit does not close the issue.

- - - - -
a5ea65c9 by Krzysztof Gogolewski at 2022-04-20T11:50:04-04:00
Remove LevityInfo

Every Id was storing a boolean whether it could be levity-polymorphic.
This information is no longer needed since representation-checking
has been moved to the typechecker.

- - - - -
49bd7584 by Andreas Klebinger at 2022-04-20T11:50:39-04:00
Fix a shadowing issue in StgUnarise.

For I assume performance reasons we don't record no-op replacements
during unarise. This lead to problems with code like this:

    f = \(Eta_B0 :: VoidType) x1 x2 ->
       ... let foo = \(Eta_B0 :: LiftedType) -> g x y Eta_B0
           in ...

Here we would record the outer Eta_B0 as void rep, but would not
shadow Eta_B0 inside `foo` because this arg is single-rep and so
doesn't need to replaced. But this means when looking at occurence
sites we would check the env and assume it's void rep based on the
entry we made for the (no longer in scope) outer `Eta_B0`.

Fixes #21396 and the ticket has a few more details.

- - - - -
0c02c919 by Simon Peyton Jones at 2022-04-20T11:51:15-04:00
Fix substitution in bindAuxiliaryDict

In GHC.Core.Opt.Specialise.bindAuxiliaryDict we were unnecessarily
calling `extendInScope` to bring into scope variables that were
/already/ in scope.  Worse, GHC.Core.Subst.extendInScope strangely
deleted the newly-in-scope variables from the substitution -- and that
was fatal in #21391.

I removed the redundant calls to extendInScope.

More ambitiously, I changed GHC.Core.Subst.extendInScope (and cousins)
to stop deleting variables from the substitution.  I even changed the
names of the function to extendSubstInScope (and cousins) and audited
all the calls to check that deleting from the substitution was wrong.
In fact there are very few such calls, and they are all about
introducing a fresh non-in-scope variable.  These are "OutIds"; it is
utterly wrong to mess with the "InId" substitution.

I have not added a Note, because I'm deleting wrong code, and it'd be
distracting to document a bug.

- - - - -
0481a6af by Cheng Shao at 2022-04-21T11:06:06+00:00
[ci skip] Drop outdated TODO in RtsAPI.c

- - - - -
1e062a8a by Ben Gamari at 2022-04-22T02:12:59-04:00
rts: Introduce ip_STACK_FRAME

While debugging it is very useful to be able to determine whether a
given info table is a stack frame or not. We have spare bits in the
closure flags array anyways, use one for this information.

- - - - -
08a6a2ee by Ben Gamari at 2022-04-22T02:12:59-04:00
rts: Mark closureFlags array as const

- - - - -
8f9b8282 by Krzysztof Gogolewski at 2022-04-22T02:13:35-04:00
Check for zero-bit types in sizeExpr

Fixes #20940

Metric Decrease:
    T18698a

- - - - -
fcf22883 by Andreas Klebinger at 2022-04-22T02:14:10-04:00
Include the way string in the file name for dump files.

This can be disabled by `-fno-dump-with-ways` if not desired.
Finally we will be able to look at both profiled and non-profiled dumps
when compiling with dump flags and we compile in both ways.

- - - - -
252394ce by Bodigrim at 2022-04-22T02:14:48-04:00
Improve error messages from GHC.IO.Encoding.Failure

- - - - -
250f57c1 by Bodigrim at 2022-04-22T02:14:48-04:00
Update test baselines to match new error messages from GHC.IO.Encoding.Failure

- - - - -
5ac9b321 by Ben Gamari at 2022-04-22T02:15:25-04:00
get-win32-tarballs: Drop i686 architecture

As of #18487 we no longer support 32-bit Windows.

Fixes #21372.

- - - - -
dd5fecb0 by Ben Gamari at 2022-04-22T02:16:00-04:00
hadrian: Don't rely on xxx not being present in installation path

Previously Hadrian's installation makefile would assume that the string
`xxx` did not appear in the installation path. This would of course
break for some users.

Fixes #21402.

- - - - -
09e98859 by Ben Gamari at 2022-04-22T02:16:35-04:00
testsuite: Ensure that GHC doesn't pick up environment files

Here we set GHC_ENVIRONMENT="-" to ensure that GHC invocations of tests
don't pick up a user's local package environment.

Fixes #21365.

Metric Decrease:
    T10421
    T12234
    T12425
    T13035
    T16875
    T9198

- - - - -
76bb8cb3 by Ben Gamari at 2022-04-22T02:17:11-04:00
hadrian: Enable -dlint in devel2 flavour

Previously only -dcore-lint was enabled.

- - - - -
f435d55f by Krzysztof Gogolewski at 2022-04-22T08:00:18-04:00
Fixes to rubbish literals

* In CoreToStg, the application 'RUBBISH[rep] x' was simplified
  to 'RUBBISH[rep]'. But it is possible that the result of the function
  is represented differently than the function.
* In Unarise, 'LitRubbish (primRepToType prep)'
  is incorrect: LitRubbish takes a RuntimeRep such as IntRep,
  while primRepToType returns a type such as Any @(TYPE IntRep). Use
  primRepToRuntimeRep instead.
  This code is never run in the testsuite.
* In StgToByteCode, all rubbish literals were assumed to be boxed.
  This code predates representation-polymorphic RubbishLit and I think
  it was not updated.

I don't have a testcase for any of those issues, but the code looks
wrong.

- - - - -
93c16b94 by sheaf at 2022-04-22T08:00:57-04:00
Relax "suppressing errors" assert in reportWanteds

The assertion in reportWanteds that we aren't suppressing all the
Wanted constraints was too strong: it might be the case that we are
inside an implication, and have already reported an unsolved Wanted
from outside the implication. It is possible that all Wanteds inside
the implication have been rewritten by the outer Wanted, so we shouldn't
throw an assertion failure in that case.

Fixes #21405

- - - - -
78ec692d by Andreas Klebinger at 2022-04-22T08:01:33-04:00
Mention new MutableByteArray# wrapper in base changelog.

- - - - -
56d7cb53 by Eric Lindblad at 2022-04-22T14:13:32-04:00
unlist announce

- - - - -
1e4dcf23 by sheaf at 2022-04-22T14:14:12-04:00
decideMonoTyVars: account for CoVars in candidates

The "candidates" passed to decideMonoTyVars can contain coercion holes.
This is because we might well decide to quantify over some unsolved
equality constraints, as long as they are not definitely insoluble.

In that situation, decideMonoTyVars was passing a set of type variables
that was not closed over kinds to closeWrtFunDeps, which was tripping
up an assertion failure.

Fixes #21404

- - - - -
2c541f99 by Simon Peyton Jones at 2022-04-22T14:14:47-04:00
Improve floated dicts in Specialise

Second fix to #21391.  It turned out that we missed calling
bringFloatedDictsIntoScope when specialising imports, which
led to the same bug as before.

I refactored to move that call to a single place, in specCalls,
so we can't forget it.

This meant making `FloatedDictBinds` into its own type, pairing
the dictionary bindings themselves with the set of their binders.
Nicer this way.

- - - - -
0950e2c4 by Ben Gamari at 2022-04-25T10:18:17-04:00
hadrian: Ensure that --extra-lib-dirs are used

Previously we only took `extraLibDirs` and friends from the package
description, ignoring any contribution from the `LocalBuildInfo`. Fix
this.

Fixes #20566.

- - - - -
53cc93ae by Ben Gamari at 2022-04-25T10:18:17-04:00
hadrian: Drop redundant include directories

The package-specific include directories in
Settings.Builders.Common.cIncludeDirs are now redundant since they now
come from Cabal.

Closes #20566.

- - - - -
b2721819 by Ben Gamari at 2022-04-25T10:18:17-04:00
hadrian: Clean up handling of libffi dependencies

- - - - -
18e5103f by Ben Gamari at 2022-04-25T10:18:17-04:00
testsuite: More robust library way detection

Previously `test.mk` would try to determine whether the dynamic,
profiling, and vanilla library ways are available by searching for
`PrimOpWrappers.{,dyn_,p_}hi` in directory reported by `ghc-pkg field
ghc-prim library-dirs`. However, this is extremely fragile as
there is no guarantee that there is only one library directory. To
handle the case of multiple `library-dirs` correct we would
have to carry out the delicate task of tokenising the directory list (in
shell, no less).

Since this isn't a task that I am eager to solve, I have rather moved
the detection logic into the testsuite driver and instead perform a test
compilation in each of the ways. This should be more robust than the
previous approach.

I stumbled upon this while fixing #20579.

- - - - -
6c7a4913 by Ben Gamari at 2022-04-25T10:18:17-04:00
testsuite: Cabalify ghc-config

To ensure that the build benefits from Hadrian's usual logic for building
packages, avoiding #21409.

Closes #21409.

- - - - -
9af091f7 by Ben Gamari at 2022-04-25T10:18:53-04:00
rts: Factor out built-in GC roots

- - - - -
e7c4719d by Ben Gamari at 2022-04-25T10:18:54-04:00
Ensure that wired-in exception closures aren't GC'd

As described in Note [Wired-in exceptions are not CAFfy], a small set of
built-in exception closures get special treatment in the code generator,
being declared as non-CAFfy despite potentially containing CAF
references. The original intent of this treatment for the RTS to then
add StablePtrs for each of the closures, ensuring that they are not
GC'd. However, this logic was not applied consistently and eventually
removed entirely in 951c1fb0. This lead to #21141.

Here we fix this bug by reintroducing the StablePtrs and document the
status quo.

Closes #21141.

- - - - -
9587726f by Ben Gamari at 2022-04-25T10:18:54-04:00
testsuite: Add testcase for #21141

- - - - -
cb71226f by Ben Gamari at 2022-04-25T10:19:29-04:00
Drop dead code in GHC.Linker.Static.linkBinary'

Previously we supported building statically-linked executables using
libtool. However, this was dropped in
91262e75dd1d80f8f28a3922934ec7e59290e28c in favor of using ar/ranlib
directly. Consequently we can drop this logic.

Fixes #18826.

- - - - -
9420d26b by Ben Gamari at 2022-04-25T10:19:29-04:00
Drop libtool path from settings file

GHC no longers uses libtool for linking and therefore this is no longer
necessary.

- - - - -
41cf758b by Ben Gamari at 2022-04-25T10:19:29-04:00
Drop remaining vestiges of libtool

Drop libtool logic from gen-dll, allowing us to drop the remaining logic
from the `configure` script.

Strangely, this appears to reliably reduce compiler allocations of
T16875 on Windows.

Closes #18826.

Metric Decrease:
    T16875

- - - - -
e09afbf2 by Ben Gamari at 2022-04-25T10:20:05-04:00
rts: Refactor handling of dead threads' stacks

This fixes a bug that @JunmingZhao42 and I noticed while working on her
MMTK port. Specifically, in stg_stop_thread we used stg_enter_info as a
sentinel at the tail of a stack after a thread has completed. However,
stg_enter_info expects to have a two-field payload, which we do not
push. Consequently, if the GC ends up somehow the stack it will attempt
to interpret data past the end of the stack as the frame's fields,
resulting in unsound behavior.

To fix this I eliminate this hacky use of `stg_stop_thread` and instead
introduce a new stack frame type, `stg_dead_thread_info`. Not only does
this eliminate the potential for the previously mentioned memory
unsoundness but it also more clearly captures the intended structure of
the dead threads' stacks.

- - - - -
e76705cf by Ben Gamari at 2022-04-25T10:20:05-04:00
rts: Improve documentation of closure types

Also drops the unused TREC_COMMITTED transaction state.

- - - - -
f2c08124 by Bodigrim at 2022-04-25T10:20:44-04:00
Document behaviour of RULES with KnownNat

- - - - -
360dc2bc by Li-yao Xia at 2022-04-25T19:13:06+00:00
Fix rendering of liftA haddock

- - - - -
16df6058 by Ben Gamari at 2022-04-27T10:02:25-04:00
testsuite: Report minimum and maximum stat changes

As suggested in #20733.

- - - - -
e39cab62 by Fabian Thorand at 2022-04-27T10:03:03-04:00
Defer freeing of mega block groups

Solves the quadratic worst case performance of freeing megablocks that
was described in issue #19897.

During GC runs, we now keep a secondary free list for megablocks that is
neither sorted, nor coalesced. That way, free becomes an O(1) operation
at the expense of not being able to reuse memory for larger allocations.
At the end of a GC run, the secondary free list is sorted and then
merged into the actual free list in a single pass.

That way, our worst case performance is O(n log(n)) rather than O(n^2).

We postulate that temporarily losing coalescense during a single GC run
won't have any adverse effects in practice because:

- We would need to release enough memory during the GC, and then after
  that (but within the same GC run) allocate a megablock group of more
  than one megablock. This seems unlikely, as large objects are not
  copied during GC, and so we shouldn't need such large allocations
  during a GC run.
- Allocations of megablock groups of more than one megablock are rare.
  They only happen when a single heap object is large enough to require
  that amount of space. Any allocation areas that are supposed to hold
  more than one heap object cannot use megablock groups, because only
  the first megablock of a megablock group has valid `bdescr`s. Thus,
  heap object can only start in the first megablock of a group, not in
  later ones.

- - - - -
5de6be0c by Fabian Thorand at 2022-04-27T10:03:03-04:00
Add note about inefficiency in returnMemoryToOS

- - - - -
8bef471a by sheaf at 2022-04-27T10:03:43-04:00
Ensure that Any is Boxed in FFI imports/exports

We should only accept the type `Any` in foreign import/export
declarations when it has type `Type` or `UnliftedType`.
This patch adds a kind check, and a special error message triggered by
occurrences of `Any` in foreign import/export declarations at other
kinds.

Fixes #21305

- - - - -
ba3d4e1c by Ben Gamari at 2022-04-27T10:04:19-04:00
Basic response file support

Here we introduce support into our command-line parsing infrastructure
and driver for handling gnu-style response file arguments,
typically used to work around platform command-line length limitations.

Fixes #16476.

- - - - -
3b6061be by Ben Gamari at 2022-04-27T10:04:19-04:00
testsuite: Add test for #16476

- - - - -
75bf1337 by Matthew Pickering at 2022-04-27T10:04:55-04:00
ci: Fix cabal-reinstall job

It's quite nice we can do this by mostly deleting code

Fixes #21373

- - - - -
2c00d904 by Matthew Pickering at 2022-04-27T10:04:55-04:00
ci: Add test to check that release jobs have profiled libs

- - - - -
50d78d3b by Matthew Pickering at 2022-04-27T10:04:55-04:00
ci: Explicitly handle failures in test_hadrian

We also disable the stage1 testing which is broken.

Related to #21072

- - - - -
2dcdf091 by Matthew Pickering at 2022-04-27T10:04:55-04:00
ci: Fix shell command

- - - - -
55c84123 by Matthew Pickering at 2022-04-27T10:04:55-04:00
bootstrap: Add bootstrapping files for ghc-9_2_2

Fixes #21373

- - - - -
c7ee0be6 by Matthew Pickering at 2022-04-27T10:04:55-04:00
ci: Add linting job which checks authors are not GHC CI

- - - - -
23aad124 by Adam Sandberg Ericsson at 2022-04-27T10:05:31-04:00
rts: state explicitly what evacuate and scavange mean in the copying gc

- - - - -
318e0005 by Ben Gamari at 2022-04-27T10:06:07-04:00
rts/eventlog: Don't attempt to flush if there is no writer

If the user has not configured a writer then there is nothing to flush.

- - - - -
ee11d043 by Ben Gamari at 2022-04-27T10:06:07-04:00
Enable eventlog support in all ways by default

Here we deprecate the eventlogging RTS ways and instead enable eventlog
support in the remaining ways. This simplifies packaging and reduces GHC
compilation times (as we can eliminate two whole compilations of the RTS)
while simplifying the end-user story. The trade-off is a small increase
in binary sizes in the case that the user does not want eventlogging
support, but we think that this is a fine trade-off.

This also revealed a latent RTS bug: some files which included `Cmm.h`
also assumed that it defined various macros which were in fact defined
by `Config.h`, which `Cmm.h` did not include. Fixing this in turn
revealed that `StgMiscClosures.cmm` failed to import various spinlock
statistics counters, as evidenced by the failed unregisterised build.

Closes #18948.

- - - - -
a2e5ab70 by Andreas Klebinger at 2022-04-27T10:06:43-04:00
Change `-dsuppress-ticks` to only suppress non-code ticks.

This means cost centres and coverage ticks will still be present in
output. Makes using -dsuppress-all more convenient when looking at
profiled builds.

- - - - -
ec9d7e04 by Ben Gamari at 2022-04-27T10:07:21-04:00
Bump text submodule.

This should fix #21352

- - - - -
c3105be4 by Bodigrim at 2022-04-27T10:08:01-04:00
Documentation for setLocaleEncoding

- - - - -
7f618fd3 by sheaf at 2022-04-27T10:08:40-04:00
Update docs for change to type-checking plugins

There was no mention of the changes to type-checking plugins
in the 9.4.1 notes, and the extending_ghc documentation contained
a reference to an outdated type.

- - - - -
4419dd3a by Adam Sandberg Ericsson at 2022-04-27T10:09:18-04:00
rts: add some more documentation to StgWeak closure type

- - - - -
5a7f0dee by Matthew Pickering at 2022-04-27T10:09:54-04:00
Give Cmm files fake ModuleNames which include full filepath

This fixes the initialisation functions when using -prof or
-finfo-table-map.

Fixes #21370

- - - - -
81cf52bb by sheaf at 2022-04-27T10:10:33-04:00
Mark GHC.Prim.PtrEq as Unsafe

This module exports unsafe pointer equality operations,
so we accordingly mark it as Unsafe.

Fixes #21433

- - - - -
f6a8185d by Ben Gamari at 2022-04-28T09:10:31+00:00
testsuite: Add performance test for #14766

This distills the essence of the Sigs.hs program found in the ticket.

- - - - -
c7a3dc29 by Douglas Wilson at 2022-04-28T18:54:44-04:00
hadrian: Add Monoid instance to Way

- - - - -
654bafea by Douglas Wilson at 2022-04-28T18:54:44-04:00
hadrian: Enrich flavours to build profiled/debugged/threaded ghcs per stage

- - - - -
4ad559c8 by Douglas Wilson at 2022-04-28T18:54:44-04:00
hadrian: add debug_ghc and debug_stage1_ghc flavour transformers

- - - - -
f9728fdb by Douglas Wilson at 2022-04-28T18:54:44-04:00
hadrian: Don't pass -rtsopts when building libraries

- - - - -
769279e6 by Matthew Pickering at 2022-04-28T18:54:44-04:00
testsuite: Fix calculation about whether to pass -dynamic to compiler

- - - - -
da8ae7f2 by Ben Gamari at 2022-04-28T18:55:20-04:00
hadrian: Clean up flavour transformer definitions

Previously the `ipe` and `omit_pragmas` transformers were hackily
defined using the textual key-value syntax. Fix this.

- - - - -
61305184 by Ben Gamari at 2022-04-28T18:55:56-04:00
Bump process submodule

- - - - -
a8c99391 by sheaf at 2022-04-28T18:56:37-04:00
Fix unification of ConcreteTvs, removing IsRefl#

This patch fixes the unification of concrete type variables.
The subtlety was that unifying concrete metavariables is more subtle
than other metavariables, as decomposition is possible. See the Note
[Unifying concrete metavariables], which explains how we unify a
concrete type variable with a type 'ty' by concretising 'ty', using
the function 'GHC.Tc.Utils.Concrete.concretise'.

This can be used to perform an eager syntactic check for concreteness,
allowing us to remove the IsRefl# special predicate. Instead of emitting
two constraints `rr ~# concrete_tv` and `IsRefl# rr concrete_tv`, we
instead concretise 'rr'. If this succeeds we can fill 'concrete_tv',
and otherwise we directly emit an error message to the typechecker
environment instead of deferring. We still need the error message
to be passed on (instead of directly thrown), as we might benefit from
further unification in which case we will need to zonk the stored types.
To achieve this, we change the 'wc_holes' field of 'WantedConstraints'
to 'wc_errors', which stores general delayed errors. For the moement,
a delayed error is either a hole, or a syntactic equality error.

hasFixedRuntimeRep_MustBeRefl is now hasFixedRuntimeRep_syntactic, and
hasFixedRuntimeRep has been refactored to directly return the most
useful coercion for PHASE 2 of FixedRuntimeRep.

This patch also adds a field ir_frr to the InferResult datatype,
holding a value of type Maybe FRROrigin. When this value is not
Nothing, this means that we must fill the ir_ref field with a type
which has a fixed RuntimeRep.
When it comes time to fill such an ExpType, we ensure that the type
has a fixed RuntimeRep by performing a representation-polymorphism
check with the given FRROrigin
This is similar to what we already do to ensure we fill an Infer
ExpType with a type of the correct TcLevel.
This allows us to properly perform representation-polymorphism checks
on 'Infer' 'ExpTypes'.

The fillInferResult function had to be moved to GHC.Tc.Utils.Unify
to avoid a cyclic import now that it calls hasFixedRuntimeRep.

This patch also changes the code in matchExpectedFunTys to make use
of the coercions, which is now possible thanks to the previous change.
This implements PHASE 2 of FixedRuntimeRep in some situations.
For example, the test cases T13105 and T17536b are now both accepted.

Fixes #21239 and #21325

-------------------------
Metric Decrease:
    T18223
    T5631
-------------------------

- - - - -
43bd897d by Simon Peyton Jones at 2022-04-28T18:57:13-04:00
Add INLINE pragmas for Enum helper methods

As #21343 showed, we need to be super-certain that the "helper
methods" for Enum instances are actually inlined or specialised.

I also tripped over this when I discovered that numericEnumFromTo
and friends had no pragmas at all, so their performance was very
fragile.  If they weren't inlined, all bets were off.  So I've added
INLINE pragmas for them too.

See new Note [Inline Enum method helpers] in GHC.Enum.

I also expanded Note [Checking for INLINE loop breakers] in
GHC.Core.Lint to explain why an INLINE function might temporarily
be a loop breaker -- this was the initial bug report in #21343.

Strangely we get a 16% runtime allocation decrease in
perf/should_run/T15185, but only on i386.  Since it moves in the right
direction I'm disinclined to investigate, so I'll accept it.

Metric Decrease:
    T15185

- - - - -
ca1434e3 by Ben Gamari at 2022-04-28T18:57:49-04:00
configure: Bump GHC version to 9.5

Bumps haddock submodule.

- - - - -
292e3971 by Teo Camarasu at 2022-04-28T18:58:28-04:00
add since annotation for GHC.Stack.CCS.whereFrom

- - - - -
905206d6 by Tamar Christina at 2022-04-28T22:19:34-04:00
winio: add support to iserv.

- - - - -
d182897e by Tamar Christina at 2022-04-28T22:19:34-04:00
Remove unused line
- - - - -
22cf4698 by Matthew Pickering at 2022-04-28T22:20:10-04:00
Revert "rts: Refactor handling of dead threads' stacks"

This reverts commit e09afbf2a998beea7783e3de5dce5dd3c6ff23db.

- - - - -
8ed57135 by Matthew Pickering at 2022-04-29T04:11:29-04:00
Provide efficient unionMG function for combining two module graphs.

This function is used by API clients (hls).

This supercedes !6922

- - - - -
0235ff02 by Ben Gamari at 2022-04-29T04:12:05-04:00
Bump bytestring submodule

Update to current `master`.

- - - - -
01988418 by Matthew Pickering at 2022-04-29T04:12:05-04:00
testsuite: Normalise package versions in UnusedPackages test

- - - - -
724d0dc0 by Matthew Pickering at 2022-04-29T08:59:42+00:00
testsuite: Deduplicate ways correctly

This was leading to a bug where we would run a profasm test twice which
led to invalid junit.xml which meant the test results database was not
being populated for the fedora33-perf job.

- - - - -
5630dde6 by Ben Gamari at 2022-04-29T13:06:20-04:00
rts: Refactor handling of dead threads' stacks

This fixes a bug that @JunmingZhao42 and I noticed while working on her
MMTK port. Specifically, in stg_stop_thread we used stg_enter_info as a
sentinel at the tail of a stack after a thread has completed. However,
stg_enter_info expects to have a two-field payload, which we do not
push. Consequently, if the GC ends up somehow the stack it will attempt
to interpret data past the end of the stack as the frame's fields,
resulting in unsound behavior.

To fix this I eliminate this hacky use of `stg_stop_thread` and instead
introduce a new stack frame type, `stg_dead_thread_info`. Not only does
this eliminate the potential for the previously mentioned memory
unsoundness but it also more clearly captures the intended structure of
the dead threads' stacks.

- - - - -
0cdef807 by parsonsmatt at 2022-04-30T16:51:12-04:00
Add a note about instance visibility across component boundaries

In principle, the *visible* instances are
* all instances defined in a prior top-level declaration group
  (see docs on `newDeclarationGroup`), or
* all instances defined in any module transitively imported by the
  module being compiled

However, actually searching all modules transitively below the one being
compiled is unreasonably expensive, so `reifyInstances` will report only the
instance for modules that GHC has had some cause to visit during this
compilation.  This is a shortcoming: `reifyInstances` might fail to report
instances for a type that is otherwise unusued, or instances defined in a
different component.  You can work around this shortcoming by explicitly importing the modules
whose instances you want to be visible. GHC issue #20529
has some discussion around this.

Fixes #20529

- - - - -
e2dd884a by Ryan Scott at 2022-04-30T16:51:47-04:00
Make mkFunCo take AnonArgFlags into account

Previously, whenever `mkFunCo` would produce reflexive coercions, it would
use `mkVisFunTy` to produce the kind of the coercion. However, `mkFunCo` is
also used to produce coercions between types of the form `ty1 => ty2` in
certain places. This has the unfortunate side effect of causing the type of
the coercion to appear as `ty1 -> ty2` in certain error messages, as spotted
in #21328.

This patch address this by changing replacing the use of `mkVisFunTy` with
`mkFunctionType` in `mkFunCo`. `mkFunctionType` checks the kind of `ty1` and
makes the function arrow `=>` instead of `->` if `ty1` has kind `Constraint`,
so this should always produce the correct `AnonArgFlag`. As a result, this
patch fixes part (2) of #21328.

This is not the only possible way to fix #21328, as the discussion on that
issue lists some possible alternatives. Ultimately, it was concluded that the
alternatives would be difficult to maintain, and since we already use
`mkFunctionType` in `coercionLKind` and `coercionRKind`, using `mkFunctionType`
in `mkFunCo` is consistent with this choice. Moreover, using `mkFunctionType`
does not regress the performance of any test case we have in GHC's test suite.

- - - - -
170da54f by Ben Gamari at 2022-04-30T16:52:27-04:00
Convert More Diagnostics (#20116)

Replaces uses of `TcRnUnknownMessage` with proper diagnostics
constructors.

- - - - -
39edc7b4 by Marius Ghita at 2022-04-30T16:53:06-04:00
Update user guide example rewrite rules formatting

Change the rewrite rule examples to include a space between the
composition of `f` and `g` in the map rewrite rule examples.

Without this change, if the user has locally enabled the extension
OverloadedRecordDot the copied example will result in a compile time
error that `g` is not a field of `f`.

```
    • Could not deduce (GHC.Records.HasField "g" (a -> b) (a1 -> b))
        arising from selecting the field ‘g’
```

- - - - -
2e951e48 by Adam Sandberg Ericsson at 2022-04-30T16:53:42-04:00
ghc-boot: export typesynonyms from GHC.Utils.Encoding

This makes the Haddocks easier to understand.

- - - - -
d8cbc77e by Adam Sandberg Ericsson at 2022-04-30T16:54:18-04:00
users guide: add categories to some flags

- - - - -
d0f14fad by Chris Martin at 2022-04-30T16:54:57-04:00
hacking guide: mention the core libraries committee

- - - - -
34b28200 by Matthew Pickering at 2022-04-30T16:55:32-04:00
Revert "Make the specialiser handle polymorphic specialisation"

This reverts commit ef0135934fe32da5b5bb730dbce74262e23e72e8.

See ticket #21229

-------------------------
Metric Decrease:
    T15164
Metric Increase:
    T13056
-------------------------

- - - - -
ee891c1e by Matthew Pickering at 2022-04-30T16:55:32-04:00
Add test for T21229

- - - - -
ab677cc8 by Matthew Pickering at 2022-04-30T16:56:08-04:00
Hadrian: Update README about the flavour/testsuite contract

There have been a number of tickets about non-tested flavours not
passing the testsuite.. this is expected and now noted in the
documentation. You use other flavours to run the testsuite at your own
risk.

Fixes #21418

- - - - -
b57b5b92 by Ben Gamari at 2022-04-30T16:56:44-04:00
rts/m32: Fix assertion failure

This fixes an assertion failure in the m32 allocator due to the
imprecisely specified preconditions of `m32_allocator_push_filled_list`.
Specifically, the caller must ensure that the page type is set to filled
prior to calling `m32_allocator_push_filled_list`.

While this issue did result in an assertion failure in the debug RTS,
the issue is in fact benign.

- - - - -
a7053a6c by sheaf at 2022-04-30T16:57:23-04:00
Testsuite driver: don't crash on empty metrics

The testsuite driver crashed when trying to display minimum/maximum
performance changes when there are no metrics (i.e. there is
no baseline available). This patch fixes that.

- - - - -
636f7c62 by Andreas Klebinger at 2022-05-01T22:21:17-04:00
StgLint: Check that functions are applied to compatible runtime reps

We use compatibleRep to compare reps, and avoid checking functions with
levity polymorphic types because of #21399.

- - - - -
60071076 by Hécate Moonlight at 2022-05-01T22:21:55-04:00
Add documentation to the ByteArray# primetype.

close #21417

- - - - -
2b2e3020 by Andreas Klebinger at 2022-05-01T22:22:31-04:00
exprIsDeadEnd: Use isDeadEndAppSig to check if a function appliction is bottoming.

We used to check the divergence and that the number of arguments > arity.
But arity zero represents unknown arity so this was subtly broken for a long time!

We would check if the saturated function diverges, and if we applied >=arity arguments.
But for unknown arity functions any number of arguments is >=idArity.

This fixes #21440.

- - - - -
4eaf0f33 by Eric Lindblad at 2022-05-01T22:23:11-04:00
typos
- - - - -
fc58df90 by Niklas Hambüchen at 2022-05-02T08:59:27+00:00
libraries/base: docs: Explain relationshipt between `finalizeForeignPtr` and `*Conc*` creation

Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/21420

- - - - -
3e400f20 by Krzysztof Gogolewski at 2022-05-02T18:29:23-04:00
Remove obsolete code in CoreToStg

Note [Nullary unboxed tuple] was removed in e9e61f18a548b70693f4.
This codepath is tested by T15696_3.

- - - - -
4a780928 by Krzysztof Gogolewski at 2022-05-02T18:29:24-04:00
Fix several note references

- - - - -
15ffe2b0 by Sebastian Graf at 2022-05-03T20:11:51+02:00
Assume at least one evaluation for nested SubDemands (#21081, #21133)

See the new `Note [SubDemand denotes at least one evaluation]`.

A demand `n :* sd` on a let binder `x=e` now means

> "`x` was evaluated `n` times and in any program trace it is evaluated, `e` is
>  evaluated deeply in sub-demand `sd`."

The "any time it is evaluated" premise is what this patch adds. As a result,
we get better nested strictness. For example (T21081)
```hs
f :: (Bool, Bool) -> (Bool, Bool)
f pr = (case pr of (a,b) -> a /= b, True)
-- before: <MP(L,L)>
-- after:  <MP(SL,SL)>

g :: Int -> (Bool, Bool)
g x = let y = let z = odd x in (z,z) in f y
```
The change in demand signature "before" to "after" allows us to case-bind `z`
here.

Similarly good things happen for the `sd` in call sub-demands `Cn(sd)`, which
allows for more eta-reduction (which is only sound with `-fno-pedantic-bottoms`,
albeit).

We also fix #21085, a surprising inconsistency with `Poly` to `Call` sub-demand
expansion.

In an attempt to fix a regression caused by less inlining due to eta-reduction
in T15426, I eta-expanded the definition of `elemIndex` and `elemIndices`, thus
fixing #21345 on the go.

The main point of this patch is that it fixes #21081 and #21133.

Annoyingly, I discovered that more precise demand signatures for join points can
transform a program into a lazier program if that join point gets floated to the
top-level, see #21392. There is no simple fix at the moment, but !5349 might.
Thus, we accept a ~5% regression in `MultiLayerModulesTH_OneShot`, where #21392
bites us in `addListToUniqDSet`. T21392 reliably reproduces the issue.

Surprisingly, ghc/alloc perf on Windows improves much more than on other jobs, by
0.4% in the geometric mean and by 2% in T16875.

Metric Increase:
    MultiLayerModulesTH_OneShot
Metric Decrease:
    T16875

- - - - -
948c7e40 by Andreas Klebinger at 2022-05-04T09:57:34-04:00
CoreLint - When checking for levity polymorphism look through more ticks.

For expressions like `(scc<cc_name> primOp#) arg1` we should also look
at arg1 to determine if we call primOp# at a fixed runtime rep.

This is what corePrep already does but CoreLint didn't yet. This patch
will bring them in sync in this regard.

It also uses tickishFloatable in CorePrep instead of CorePrep having
it's own slightly differing definition of when a tick is floatable.

- - - - -
85bc73bd by Alexis King at 2022-05-04T09:58:14-04:00
genprimopcode: Support Unicode properly

- - - - -
063d485e by Alexis King at 2022-05-04T09:58:14-04:00
genprimopcode: Replace LaTeX documentation syntax with Haddock

The LaTeX documentation generator does not seem to have been used for
quite some time, so the LaTeX-to-Haddock preprocessing step has become a
pointless complication that makes documenting the contents of GHC.Prim
needlessly difficult. This commit replaces the LaTeX syntax with the
Haddock it would have been converted into, anyway, though with an
additional distinction: it uses single quotes in places to instruct
Haddock to generate hyperlinks to bindings. This improves the quality of
the generated output.

- - - - -
d61f7428 by Ben Gamari at 2022-05-04T09:58:50-04:00
rts/ghc.mk: Only build StgCRunAsm.S when it is needed

Previously the make build system unconditionally included StgCRunAsm.S
in the link, meaning that the RTS would require an execstack
unnecessarily.

Fixes #21478.

- - - - -
934a90dd by Simon Peyton Jones at 2022-05-04T16:15:34-04:00
Improve error reporting in generated code

Our error reporting in generated code (via desugaring before
typechecking) only worked when the generated code was just a simple
call. This commit makes it work in nested cases.

- - - - -
445d3657 by sheaf at 2022-05-04T16:16:12-04:00
Ensure Any is not levity-polymorphic in FFI

The previous patch forgot to account for a type such as

  Any @(TYPE (BoxedRep l))

for a quantified levity variable l.

- - - - -
ddd2591c by Ben Gamari at 2022-05-04T16:16:48-04:00
Update supported LLVM versions

Pull forward minimum version to match 9.2.

(cherry picked from commit c26faa54c5fbe902ccb74e79d87e3fa705e270d1)

- - - - -
f9698d79 by Ben Gamari at 2022-05-04T16:16:48-04:00
testsuite/T7275: Use sed -r

Darwin requires the `-r` flag to be compatible with GNU sed.

(cherry picked from commit 512338c8feec96c38ef0cf799f3a01b77c967c56)

- - - - -
8635323b by Ben Gamari at 2022-05-04T16:16:48-04:00
gitlab-ci: Use ld.lld on ARMv7/Linux

Due to #16177.

Also cleanup some code style issues.

(cherry picked from commit cc1c3861e2372f464bf9e3c9c4d4bd83f275a1a6)

- - - - -
4f6370c7 by Ben Gamari at 2022-05-04T16:16:48-04:00
gitlab-ci: Always preserve artifacts, even in failed jobs

(cherry picked from commit fd08b0c91ea3cab39184f1b1b1aafcd63ce6973f)

- - - - -
6f662754 by Ben Gamari at 2022-05-04T16:16:48-04:00
configure: Make sphinx version check more robust

It appears that the version of sphinx shipped on CentOS 7
reports a version string of `Sphinx v1...`. Accept the `v`.

(cherry picked from commit a9197a292fd4b13308dc6664c01351c7239357ed)

- - - - -
0032dc38 by Ben Gamari at 2022-05-04T16:16:48-04:00
gitlab-ci: Don't run make job in release pipelines

(cherry picked from commit 16d6a8ff011f2194485387dcca1c00f8ddcdbdeb)

- - - - -
27f9aab3 by Ben Gamari at 2022-05-04T16:16:48-04:00
gitlab/ci: Fix name of bootstrap compiler directory

Windows binary distributions built with Hadrian have a target platform
suffix in the name of their root directory. Teach `ci.sh` about this
fact.

(cherry picked from commit df5752f39671f6d04d8cd743003469ae5eb67235)

- - - - -
b528f0f6 by Krzysztof Gogolewski at 2022-05-05T09:05:43-04:00
Fix several note references, part 2

- - - - -
691aacf6 by Adam Sandberg Ericsson at 2022-05-05T09:06:19-04:00
adjustors: align comment about number of integer like arguments with implementation for Amd4+MinGW implementation

- - - - -
f050557e by Simon Jakobi at 2022-05-05T12:47:32-04:00
Remove two uses of IntMap.size

IntMap.size is O(n). The new code should be slightly more efficient.

The transformation of GHC.CmmToAsm.CFG.calcFreqs.nodeCount can be
described formally as the transformation:

    (\sum_{0}^{n-1} \sum_{0}^{k-1} i_nk) + n
    ==>
    (\sum_{0}^{n-1} 1 + \sum_{0}^{k-1} i_nk)

- - - - -
7da90ae3 by Tom Ellis at 2022-05-05T12:48:09-04:00
Explain that 'fail s' should run in the monad itself

- - - - -
610d0283 by Matthew Craven at 2022-05-05T12:48:47-04:00
Add a test for the bracketing in rules for (^)

- - - - -
016f9ca6 by Matthew Craven at 2022-05-05T12:48:47-04:00
Fix broken rules for (^) with known small powers

- - - - -
9372aaab by Matthew Craven at 2022-05-05T12:48:47-04:00
Give the two T19569 tests different names

- - - - -
61901b32 by Andreas Klebinger at 2022-05-05T12:49:23-04:00
SpecConstr: Properly create rules for call patterns representing partial applications

The main fix is that in addVoidWorkerArg we now add the argument to the front.

This fixes #21448.

-------------------------
Metric Decrease:
    T16875
-------------------------

- - - - -
71278dc7 by Teo Camarasu at 2022-05-05T12:50:03-04:00
add since annotations for instances of ByteArray

- - - - -
962ff90b by sheaf at 2022-05-05T12:50:42-04:00
Start 9.6.1-notes

Updates the documentation notes to start tracking changes for
the 9.6.1 release (instead of 9.4).

- - - - -
aacb15a3 by Matthew Pickering at 2022-05-05T20:24:01-04:00
ci: Add job to check that jobs.yaml is up-to-date

There have been quite a few situations where jobs.yaml has been out of
date. It's better to add a CI job which checks that it's right.

We don't want to use a staged pipeline because it obfuscates the
structure of the pipeline.

- - - - -
be7102e5 by Ben Gamari at 2022-05-05T20:24:37-04:00
rts: Ensure that XMM registers are preserved on Win64

Previously we only preserved the bottom 64-bits of the callee-saved
128-bit XMM registers, in violation of the Win64 calling convention.
Fix this.

Fixes #21465.

- - - - -
73b22ff1 by Ben Gamari at 2022-05-05T20:24:37-04:00
testsuite: Add test for #21465

- - - - -
e2ae9518 by Ziyang Liu at 2022-05-06T19:22:22-04:00
Allow `let` just before pure/return in ApplicativeDo

The following is currently rejected:

```haskell
-- F is an Applicative but not a Monad
x :: F (Int, Int)
x = do
  a <- pure 0
  let b = 1
  pure (a, b)
```

This has bitten me multiple times. This MR contains a simple fix:
only allow a "let only" segment to be merged with the next (and not
the previous) segment. As a result, when the last one or more
statements before pure/return are `LetStmt`s, there will be one
more segment containing only those `LetStmt`s.

Note that if the `let` statement mentions a name bound previously, then
the program is still rejected, for example

```haskell
x = do
  a <- pure 0
  let b = a + 1
  pure (a, b)
```

or the example in #18559. To support this would require a more
complex approach, but this is IME much less common than the
previous case.

- - - - -
0415449a by Matthew Pickering at 2022-05-06T19:22:58-04:00
template-haskell: Fix representation of OPAQUE pragmas

There is a mis-match between the TH representation of OPAQUE pragmas and
GHC's internal representation due to how OPAQUE pragmas disallow phase
annotations. It seemed most in keeping to just fix the wired in name
issue by adding a special case to the desugaring of INLINE pragmas
rather than making TH/GHC agree with how the representation should look.

Fixes #21463

- - - - -
4de887e2 by Simon Peyton Jones at 2022-05-06T19:23:34-04:00
Comments only: Note [AppCtxt]

- - - - -
6e69964d by Matthew Pickering at 2022-05-06T19:24:10-04:00
Fix name of windows release bindist in doc-tarball job

- - - - -
ced4689e by Matthew Pickering at 2022-05-06T19:24:46-04:00
ci: Generate source-tarball in release jobs

We need to distribute the source tarball so we should generate it in the
CI pipeline.

- - - - -
3c91de21 by Rob at 2022-05-08T13:40:53+02:00
Change Specialise to use OrdList.

Fixes #21362

Metric Decrease:
    T16875

- - - - -
67072c31 by Simon Jakobi at 2022-05-08T12:23:43-04:00
Tweak GHC.CmmToAsm.CFG.delEdge

mapAdjust is more efficient than mapAlter.

- - - - -
374554bb by Teo Camarasu at 2022-05-09T16:24:37-04:00
Respect -po when heap profiling (#21446)

- - - - -
1ea414b6 by Teo Camarasu at 2022-05-09T16:24:37-04:00
add test case for #21446

- - - - -
c7902078 by Jens Petersen at 2022-05-09T16:25:17-04:00
avoid hadrian/bindist/Makefile install_docs error when --docs=none

When docs are disabled the bindist does not have docs/ and hence docs-utils/ is not generated.
Here we just test that docs-utils exists before attempting to install prologue.txt and gen_contents_index
to avoid the error:

/usr/bin/install: cannot stat 'docs-utils/prologue.txt': No such file or directory
make: *** [Makefile:195: install_docs] Error 1

- - - - -
158bd659 by Hécate Moonlight at 2022-05-09T16:25:56-04:00
Correct base's changelog for 4.16.1.0

This commit reaffects the new Ix instances of the foreign integral
types from base 4.17 to 4.16.1.0

closes #21529

- - - - -
a4fbb589 by Sylvain Henry at 2022-05-09T16:26:36-04:00
STG: only print cost-center if asked to

- - - - -
50347ded by Gergo ERDI at 2022-05-10T11:43:33+00:00
Improve "Glomming" note

Add a paragraph that clarifies that `occurAnalysePgm` finding out-of-order
references, and thus needing to glom, is not a cause for concern when its
root cause is rewrite rules.

- - - - -
df2e3373 by Eric Lindblad at 2022-05-10T20:45:41-04:00
update INSTALL
- - - - -
dcac3833 by Matthew Pickering at 2022-05-10T20:46:16-04:00
driver: Make -no-keep-o-files -no-keep-hi-files work in --make mode

It seems like it was just an oversight to use the incorrect DynFlags
(global rather than local) when implementing these two options. Using
the local flags allows users to request these intermediate files get
cleaned up, which works fine in --make mode because

1. Interface files are stored in memory
2. Object files are only cleaned at the end of session (after link)

Fixes #21349

- - - - -
35da81f8 by Ben Gamari at 2022-05-10T20:46:52-04:00
configure: Check for ffi.h

As noted in #21485, we checked for ffi.h yet then failed to throw an
error if it is missing.

Fixes #21485.

- - - - -
bdc99cc2 by Simon Peyton Jones at 2022-05-10T20:47:28-04:00
Check for uninferrable variables in tcInferPatSynDecl

This fixes #21479

See Note [Unquantified tyvars in a pattern synonym]

While doing this, I found that some error messages pointed at the
pattern synonym /name/, rather than the /declaration/ so I widened the
SrcSpan to encompass the declaration.

- - - - -
142a73d9 by Matthew Pickering at 2022-05-10T20:48:04-04:00
hadrian: Fix split-sections transformer

The splitSections transformer has been broken since -dynamic-too support
was implemented in hadrian. This is because we actually build the
dynamic way when building the dynamic way, so the predicate would always
fail.

The fix is to just always pass `split-sections` even if it doesn't do
anything for a particular way.

Fixes #21138

- - - - -
699f5935 by Matthew Pickering at 2022-05-10T20:48:04-04:00
packaging: Build perf builds with -split-sections

In 8f71d958 the make build system was made to use split-sections on
linux systems but it appears this logic never made it to hadrian.
There is the split_sections flavour transformer but this doesn't appear
to be used for perf builds on linux.

Closes #21135

- - - - -
21feece2 by Simon Peyton Jones at 2022-05-10T20:48:39-04:00
Use the wrapper for an unlifted binding

We assumed the wrapper for an unlifted binding is the identity,
but as #21516 showed, that is no always true.

Solution is simple: use it.

- - - - -
68d1ea5f by Matthew Pickering at 2022-05-10T20:49:15-04:00
docs: Fix path to GHC API docs in index.html

In the make bindists we generate documentation in docs/ghc-<VER> but the
hadrian bindists generate docs/ghc/ so the path to the GHC API docs was
wrong in the index.html file.

Rather than make the hadrian and make bindists the same it was easier to
assume that if you're using the mkDocs script that you're using hadrian
bindists.

Fixes #21509

- - - - -
9d8f44a9 by Matthew Pickering at 2022-05-10T20:49:51-04:00
hadrian: Don't pass -j to haddock

This has high potential for oversubcribing as many haddock jobs can be
spawned in parralel which will each request the given number of
capabilities.

Once -jsem is implemented (#19416, !5176) we can expose that haddock via
haddock and use that to pass a semaphore.

Ticket #21136

- - - - -
fec3e7aa by Matthew Pickering at 2022-05-10T20:50:27-04:00
hadrian: Only copy and install libffi headers when using in-tree libffi

When passed `--use-system-libffi` then we shouldn't copy and install the
headers from the system package. Instead the headers are expected to be
available as a runtime dependency on the users system.

Fixes #21485 #21487

- - - - -
5b791ed3 by mikael at 2022-05-11T08:22:13-04:00
FIND_LLVM_PROG: Recognize llvm suffix used by FreeBSD, ie llc10.

- - - - -
8500206e by ARATA Mizuki at 2022-05-11T08:22:57-04:00
Make floating-point abs IEEE 754 compliant

The old code used by via-C backend didn't handle the sign bit of NaN.

See #21043.

- - - - -
4a4c77ed by Alan Zimmerman at 2022-05-11T08:23:33-04:00
EPA: do statement with leading semicolon has wrong anchor

The code

    do; a <- doAsync; b

Generated an incorrect Anchor for the statement list that starts after
the first semicolon.

This commit fixes it.

Closes #20256

- - - - -
e3ca8dac by Simon Peyton Jones at 2022-05-11T08:24:08-04:00
Specialiser: saturate DFuns correctly

Ticket #21489 showed that the saturation mechanism for
DFuns (see Note Specialising DFuns) should use both
UnspecType and UnspecArg.

We weren't doing that; but this MR fixes that problem.

No test case because it's hard to tickle, but it showed up in
Gergo's work with GHC-as-a-library.

- - - - -
fcc7dc4c by Ben Gamari at 2022-05-11T20:05:41-04:00
gitlab-ci: Check for dynamic msys2 dependencies

Both #20878 and #21196 were caused by unwanted dynamic dependencies
being introduced by boot libraries. Ensure that we catch this in CI by
attempting to run GHC in an environment with a minimal PATH.

- - - - -
3c998f0d by Matthew Pickering at 2022-05-11T20:06:16-04:00
Add back Debian9 CI jobs

We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19
not being at EOL until April 2023 and they still need tinfo5.

Fixes #21469

- - - - -
dea9a3d9 by Ben Gamari at 2022-05-11T20:06:51-04:00
rts: Drop setExecutable

Since f6e366c058b136f0789a42222b8189510a3693d1 setExecutable has been
dead code. Drop it.

- - - - -
32cdf62d by Simon Peyton Jones at 2022-05-11T20:07:27-04:00
Add a missing guard in GHC.HsToCore.Utils.is_flat_prod_pat

This missing guard gave rise to #21519.

- - - - -
2c00a8d0 by Matthew Pickering at 2022-05-11T20:08:02-04:00
Add mention of -hi to RTS --help

Fixes #21546

- - - - -
a2dcad4e by Andre Marianiello at 2022-05-12T02:15:48+00:00
Decouple dynflags in Cmm parser (related to #17957)

- - - - -
3a022baa by Andre Marianiello at 2022-05-12T02:15:48+00:00
Remove Module argument from initCmmParserConfig

- - - - -
2fc8d76b by Andre Marianiello at 2022-05-12T02:15:48+00:00
Move CmmParserConfig and PDConfig into GHC.Cmm.Parser.Config

- - - - -
b8c5ffab by Andre Marianiello at 2022-05-12T18:13:55-04:00
Decouple dynflags in GHC.Core.Opt.Arity (related to #17957)

Metric Decrease:
    T16875

- - - - -
3bf938b6 by sheaf at 2022-05-12T18:14:34-04:00
Update extending_ghc for TcPlugin changes

The documentation still mentioned Derived constraints and
an outdated datatype TcPluginResult.

- - - - -
668a9ef4 by jackohughes at 2022-05-13T12:10:34-04:00
Fix printing of brackets in multiplicities (#20315)

Change mulArrow to allow for printing of correct application precedence
where necessary and update callers of mulArrow to reflect this.

As part of this, move mulArrow from GHC/Utils/Outputtable to GHC/Iface/Type.

Fixes #20315

- - - - -
30b8b7f1 by Ben Gamari at 2022-05-13T12:11:09-04:00
rts: Add debug output on ocResolve failure

This makes it easier to see how resolution failures nest.

- - - - -
53b3fa1c by Ben Gamari at 2022-05-13T12:11:09-04:00
rts/PEi386: Fix handling of weak symbols

Previously we would flag the symbol as weak but failed
to set its address, which must be computed from an "auxiliary"
symbol entry the follows the weak symbol.

Fixes #21556.

- - - - -
5678f017 by Ben Gamari at 2022-05-13T12:11:09-04:00
testsuite: Add tests for #21556

- - - - -
49af0e52 by Ben Gamari at 2022-05-13T22:23:26-04:00
Re-export augment and build from GHC.List

Resolves https://gitlab.haskell.org/ghc/ghc/-/issues/19127

- - - - -
aed356e1 by Simon Peyton Jones at 2022-05-13T22:24:02-04:00
Comments only around HsWrapper

- - - - -
27b90409 by Ben Gamari at 2022-05-16T08:30:44-04:00
hadrian: Introduce linting flavour transformer (+lint)

The linting flavour enables -dlint uniformly across anything build by
the stage1 compiler.

-dcmm-lint is not currently enabled because it fails on i386 (see #21563)

- - - - -
3f316776 by Matthew Pickering at 2022-05-16T08:30:44-04:00
hadrian: Uniformly enable -dlint with enableLinting transformer

This fixes some bugs where

* -dcore-lint was being passed when building stage1 libraries with the
  boot compiler
* -dcore-lint was not being passed when building executables.

Fixes #20135

- - - - -
3d74cfca by Andreas Klebinger at 2022-05-16T08:31:20-04:00
Make closure macros EXTERN_INLINE to make debugging easier

Implements #21424.

The RTS macros get_itbl and friends are extremely helpful during debugging.
However only a select few of those were available in the compiled RTS as actual symbols
as the rest were INLINE macros.

This commit marks all of them as EXTERN_INLINE. This will still inline them at use sites
but allow us to use their compiled counterparts during debugging.

This allows us to use things like `p get_fun_itbl(ptr)` in the gdb shell
since `get_fun_itbl` will now be available as symbol!

- - - - -
93153aab by Matthew Pickering at 2022-05-16T08:31:55-04:00
packaging: Introduce CI job for generating hackage documentation

This adds a CI job (hackage-doc-tarball) which generates the necessary
tarballs for uploading libraries and documentation to hackage. The
release script knows to download this folder and the upload script will
also upload the release to hackage as part of the release.

The `ghc_upload_libs` script is moved from ghc-utils into .gitlab/ghc_upload_libs

There are two modes, preparation and upload.

* The `prepare` mode takes a link to a bindist and creates a folder containing the
  source and doc tarballs ready to upload to hackage.
* The `upload` mode takes the folder created by prepare and performs the upload to
  hackage.

Fixes #21493

Related to #21512

- - - - -
65d31d05 by Simon Peyton Jones at 2022-05-16T15:32:50-04:00
Add arity to the INLINE pragmas for pattern synonyms

The lack of INLNE arity was exposed by #21531.  The fix is
simple enough, if a bit clumsy.

- - - - -
43c018aa by Krzysztof Gogolewski at 2022-05-16T15:33:25-04:00
Misc cleanup

- Remove groupWithName (unused)
- Use the RuntimeRepType synonym where possible
- Replace getUniqueM + mkSysLocalOrCoVar with mkSysLocalOrCoVarM

No functional changes.

- - - - -
8dfea078 by Pavol Vargovcik at 2022-05-16T15:34:04-04:00
TcPlugin: access to irreducible givens + fix passed ev_binds_var

- - - - -
fb579e15 by Ben Gamari at 2022-05-17T00:25:02-04:00
driver: Introduce pgmcxx

Here we introduce proper support for compilation of C++ objects. This
includes:

 * logic in `configure` to detect the C++ toolchain and propagating this
   information into the `settings` file
 * logic in the driver to use the C++ toolchain when compiling C++
   sources

- - - - -
43628ed4 by Ben Gamari at 2022-05-17T00:25:02-04:00
testsuite: Build T20918 with HC, not CXX

- - - - -
0ef249aa by Ben Gamari at 2022-05-17T00:25:02-04:00
Introduce package to capture dependency on C++ stdlib

Here we introduce a new "virtual" package into the initial package
database, `system-cxx-std-lib`. This gives users a convenient, platform
agnostic way to link against C++ libraries, addressing #20010.

Fixes #20010.

- - - - -
03efe283 by Ben Gamari at 2022-05-17T00:25:02-04:00
testsuite: Add tests for system-cxx-std-lib package

Test that we can successfully link against C++ code both in GHCi and
batch compilation.

See #20010

- - - - -
5f6527e0 by nineonine at 2022-05-17T00:25:38-04:00
OverloadedRecordFields: mention parent name in 'ambiguous occurrence' error for better disambiguation (#17420)

- - - - -
eccdb208 by Simon Peyton Jones at 2022-05-17T07:16:39-04:00
Adjust flags for pprTrace

We were using defaultSDocContext for pprTrace, which suppresses
lots of useful infomation. This small MR adds

   GHC.Utils.Outputable.traceSDocContext

and uses it for pprTrace and pprTraceUserWarning.

traceSDocContext is a global, and hence not influenced by flags,
but that seems unavoidable.  But I made the sdocPprDebug bit
controlled by unsafeHasPprDebug, since we have the latter for
exactly this purpose.

Fixes #21569

- - - - -
d2284c4c by Simon Peyton Jones at 2022-05-17T07:17:15-04:00
Fix bad interaction between withDict and the Specialiser

This MR fixes a bad bug, where the withDict was inlined too
vigorously, which in turn made the type-class Specialiser generate
a bogus specialisation, because it saw the same overloaded function
applied to two /different/ dictionaries.

Solution: inline `withDict` later.  See (WD8) of Note [withDict]
in GHC.HsToCore.Expr

See #21575, which is fixed by this change.

- - - - -
70f52443 by Matthew Pickering at 2022-05-17T07:17:50-04:00
Bump time submodule to 1.12.2

This bumps the time submodule to the 1.12.2 release.

Fixes #21571

- - - - -
2343457d by Vladislav Zavialov at 2022-05-17T07:18:26-04:00
Remove unused test files (#21582)

Those files were moved to the perf/ subtree in 11c9a469, and then
accidentally reintroduced in 680ef2c8.

- - - - -
cb52b4ae by Ben Gamari at 2022-05-17T16:00:14-04:00
CafAnal: Improve code clarity

Here we implement a few measures to improve the clarity of the CAF
analysis implementation. Specifically:

* Use CafInfo instead of Bool since the former is more descriptive
* Rename CAFLabel to CAFfyLabel, since not all CAFfyLabels are in fact
  CAFs
* Add numerous comments

- - - - -
b048a9f4 by Ben Gamari at 2022-05-17T16:00:14-04:00
codeGen: Ensure that static datacon apps are included in SRTs

When generating an SRT for a recursive group, GHC.Cmm.Info.Build.oneSRT
filters out recursive references, as described in Note [recursive SRTs].
However, doing so for static functions would be unsound, for the reason
described in Note [Invalid optimisation: shortcutting].

However, the same argument applies to static data constructor
applications, as we discovered in #20959. Fix this by ensuring that
static data constructor applications are included in recursive SRTs.

The approach here is not entirely satisfactory, but it is a starting
point.

Fixes #20959.

- - - - -
0e2d16eb by Matthew Pickering at 2022-05-17T16:00:50-04:00
Add test for #21558

This is now fixed on master and 9.2 branch.

Closes #21558

- - - - -
ef3c8d9e by Sylvain Henry at 2022-05-17T20:22:02-04:00
Don't store LlvmConfig into DynFlags

LlvmConfig contains information read from llvm-passes and llvm-targets
files in GHC's top directory. Reading these files is done only when
needed (i.e. when the LLVM backend is used) and cached for the whole
compiler session. This patch changes the way this is done:

- Split LlvmConfig into LlvmConfig and LlvmConfigCache

- Store LlvmConfigCache in HscEnv instead of DynFlags: there is no
  good reason to store it in DynFlags. As it is fixed per session, we
  store it in the session state instead (HscEnv).

- Initializing LlvmConfigCache required some changes to driver functions
  such as newHscEnv. I've used the opportunity to untangle initHscEnv
  from initGhcMonad (in top-level GHC module) and to move it to
  GHC.Driver.Main, close to newHscEnv.

- I've also made `cmmPipeline` independent of HscEnv in order to remove
  the call to newHscEnv in regalloc_unit_tests.

- - - - -
828fbd8a by Andreas Klebinger at 2022-05-17T20:22:38-04:00
Give all EXTERN_INLINE closure macros prototypes

- - - - -
cfc8e2e2 by Ben Gamari at 2022-05-19T04:57:51-04:00
base: Introduce [sg]etFinalizerExceptionHandler

This introduces a global hook which is called when an exception is
thrown during finalization.

- - - - -
372cf730 by Ben Gamari at 2022-05-19T04:57:51-04:00
base: Throw exceptions raised while closing finalized Handles

Fixes #21336.

- - - - -
3dd2f944 by Ben Gamari at 2022-05-19T04:57:51-04:00
testsuite: Add tests for #21336

- - - - -
297156e0 by Matthew Pickering at 2022-05-19T04:58:27-04:00
Add release flavour and use it for the release jobs

The release flavour is essentially the same as the perf flavour
currently but also enables `-haddock`. I have hopefully updated all the
relevant places where the `-perf` flavour was hardcoded.

Fixes #21486

- - - - -
a05b6293 by Matthew Pickering at 2022-05-19T04:58:27-04:00
ci: Don't build sphinx documentation on centos

The centos docker image lacks the sphinx builder so we disable building
sphinx docs for these jobs.

Fixes #21580

- - - - -
209d7c69 by Matthew Pickering at 2022-05-19T04:58:27-04:00
ci: Use correct syntax when args list is empty

This seems to fail on the ancient version of bash present on CentOS

- - - - -
02d16334 by Matthew Pickering at 2022-05-19T04:59:03-04:00
hadrian: Don't attempt to build dynamic profiling libraries

We only support building static profiling libraries, the transformer was
requesting things like a dynamic, threaded, debug, profiling RTS, which
we have never produced nor distributed.

Fixes #21567

- - - - -
35bdab1c by Ben Gamari at 2022-05-19T04:59:39-04:00
configure: Check CC_STAGE0 for --target support

We previously only checked the stage 1/2 compiler
for --target support. We got away with this for quite a while but it
eventually caught up with us in #21579, where `bytestring`'s new NEON
implementation was unbuildable on Darwin due to Rosetta's seemingly
random logic for determining which executable image to execute. This
lead to a confusing failure to build `bytestring`'s cbits, when `clang`
tried to compile NEON builtins while targetting x86-64.

Fix this by checking CC_STAGE0 for --target support.

Fixes #21579.

- - - - -
0ccca94b by Norman Ramsey at 2022-05-20T05:32:32-04:00
add dominator analysis of `CmmGraph`

This commit adds module `GHC.Cmm.Dominators`, which provides a wrapper
around two existing algorithms in GHC: the Lengauer-Tarjan dominator
analysis from the X86 back end and the reverse postorder ordering from
the Cmm Dataflow framework.  Issue #20726 proposes that we evaluate
some alternatives for dominator analysis, but for the time being, the
best path forward is simply to use the existing analysis on
`CmmGraph`s.

This commit addresses a bullet in #21200.

- - - - -
54f0b578 by Norman Ramsey at 2022-05-20T05:32:32-04:00
add dominator-tree function

- - - - -
05ed917b by Norman Ramsey at 2022-05-20T05:32:32-04:00
add HasDebugCallStack; remove unneeded extensions

- - - - -
0b848136 by Andreas Klebinger at 2022-05-20T05:32:32-04:00
document fields of `DominatorSet`
- - - - -
8a26e8d6 by Ben Gamari at 2022-05-20T05:33:08-04:00
nonmoving: Fix documentation of GC statistics fields

These were previously incorrect.

Fixes #21553.

- - - - -
c1e24e61 by Matthew Pickering at 2022-05-20T05:33:44-04:00
Remove pprTrace from pushCoercionIntoLambda (#21555)

This firstly caused spurious output to be emitted (as evidenced by
 #21555) but even worse caused a massive coercion to be attempted to be
 printed (> 200k terms) which would invariably eats up all the memory of
 your computer.

The good news is that removing this trace allows the program to compile
to completion, the bad news is that the program exhibits a core lint
error (on 9.0.2) but not any other releases it seems.

Fixes #21577 and #21555

- - - - -
a36d12ee by Zubin Duggal at 2022-05-20T10:44:35-04:00
docs: Fix LlvmVersion in manpage (#21280)

- - - - -
36b8a57c by Matthew Pickering at 2022-05-20T10:45:10-04:00
validate: Use $make rather than make

In the validate script we are careful to use the $make variable as this
stores whether we are using gmake, make, quiet mode etc. There was just
this one place where we failed to use it.

Fixes #21598

- - - - -
4aa3c5bd by Norman Ramsey at 2022-05-21T03:11:04+00:00
Change `Backend` type and remove direct dependencies

With this change, `Backend` becomes an abstract type
(there are no more exposed value constructors).
Decisions that were formerly made by asking "is the
current back end equal to (or different from) this named value
constructor?" are now made by interrogating the back end about
its properties, which are functions exported by `GHC.Driver.Backend`.

There is a description of how to migrate code using `Backend` in the
user guide.

Clients using the GHC API can find a backdoor to access the Backend
datatype in GHC.Driver.Backend.Internal.

Bumps haddock submodule.

Fixes #20927

- - - - -
ecf5f363 by Julian Ospald at 2022-05-21T12:51:16-04:00
Respect DESTDIR in hadrian bindist Makefile, fixes #19646

- - - - -
7edd991e by Julian Ospald at 2022-05-21T12:51:16-04:00
Test DESTDIR in test_hadrian()

- - - - -
ea895b94 by Matthew Pickering at 2022-05-22T21:57:47-04:00
Consider the stage of typeable evidence when checking stage restriction

We were considering all Typeable evidence to be "BuiltinInstance"s which
meant the stage restriction was going unchecked. In-fact, typeable has
evidence and so we need to apply the stage restriction.

This is
complicated by the fact we don't generate typeable evidence and the
corresponding DFunIds until after typechecking is concluded so we
introcue a new `InstanceWhat` constructor, BuiltinTypeableInstance which
records whether the evidence is going to be local or not.

Fixes #21547

- - - - -
ffbe28e5 by Dominik Peteler at 2022-05-22T21:58:23-04:00
Modularize GHC.Core.Opt.LiberateCase

Progress towards #17957

- - - - -
bc723ac2 by Simon Peyton Jones at 2022-05-23T17:09:34+01:00
Improve FloatOut and SpecConstr

This patch addresses a relatively obscure situation that arose
when chasing perf regressions in !7847, which itself is fixing

It does two things:

* SpecConstr can specialise on ($df d1 d2) dictionary arguments
* FloatOut no longer checks argument strictness

See Note [Specialising on dictionaries] in GHC.Core.Opt.SpecConstr.

A test case is difficult to construct, but it makes a big difference
in nofib/real/eff/VSM, at least when we have the patch for #21286
installed. (The latter stops worker/wrapper for dictionary arguments).

There is a spectacular, but slightly illusory, improvement in
runtime perf on T15426.  I have documented the specifics in
T15426 itself.

Metric Decrease:
    T15426

- - - - -
1a4195b0 by John Ericson at 2022-05-23T17:33:59-04:00
Make debug a `Bool` not an `Int` in `StgToCmmConfig`

We don't need any more resolution than this.

Rename the field to `stgToCmmEmitDebugInfo` to indicate it is no longer
conveying any "level" information.

- - - - -
e9fff12b by Alan Zimmerman at 2022-05-23T21:04:49-04:00
EPA : Remove duplicate comments in DataFamInstD

The code

  data instance Method PGMigration = MigrationQuery Query
                                   -- ^ Run a query against the database
                                   | MigrationCode (Connection -> IO (Either String ()))
                                   -- ^ Run any arbitrary IO code

Resulted in two instances of the "-- ^ Run a query against the database"
comment appearing in the Exact Print Annotations when it was parsed.

Ensure only one is kept.

Closes #20239

- - - - -
e2520df3 by Alan Zimmerman at 2022-05-23T21:05:27-04:00
EPA: Comment Order Reversed

Make sure comments captured in the exact print annotations are in
order of increasing location

Closes #20718

- - - - -
4b45fd72 by Teo Camarasu at 2022-05-24T10:49:13-04:00
Add test for T21455

- - - - -
e2cd1d43 by Teo Camarasu at 2022-05-24T10:49:13-04:00
Allow passing -po outside profiling way

Resolves #21455

- - - - -
3b8c413a by Greg Steuck at 2022-05-24T10:49:52-04:00
Fix haddock_*_perf tests on non-GNU-grep systems

Using regexp pattern requires `egrep` and straight up `+`.  The
haddock_parser_perf and haddock_renamer_perf tests now pass on
OpenBSD. They previously incorrectly parsed the files and awk
complained about invalid syntax.

- - - - -
1db877a3 by Ben Gamari at 2022-05-24T10:50:28-04:00
hadrian/bindist: Drop redundant include of install.mk

`install.mk` is already included by `config.mk`. Moreover, `install.mk`
depends upon `config.mk` to set `RelocatableBuild`, making this first
include incorrect.

- - - - -
f485d267 by Greg Steuck at 2022-05-24T10:51:08-04:00
Remove -z wxneeded for OpenBSD

With all the recent W^X fixes in the loader this workaround is not
necessary any longer. I verified that the only tests failing for me on
OpenBSD 7.1-current are the same (libc++ related) before and after
this commit (with --fast).

- - - - -
7c51177d by Andreas Klebinger at 2022-05-24T22:13:19-04:00
Use UnionListsOrd instead of UnionLists in most places.

This should get rid of most, if not all "Overlong lists" errors and fix #20016

- - - - -
81b3741f by Andreas Klebinger at 2022-05-24T22:13:55-04:00
Fix #21563 by using Word64 for 64bit shift code.

We use the 64bit shifts only on 64bit platforms. But we
compile the code always so compiling it on 32bit caused a
lint error. So use Word64 instead.

- - - - -
2c25fff6 by Zubin Duggal at 2022-05-24T22:14:30-04:00
Fix compilation with -haddock on GHC <= 8.10

-haddock on GHC < 9.0 is quite fragile and can result in obtuse parse errors
when it encounters invalid haddock syntax.

This has started to affect users since 297156e0b8053a28a860e7a18e1816207a59547b
enabled -haddock by default on many flavours.

Furthermore, since we don't test bootstrapping with 8.10 on CI, this problem
managed to slip throught the cracks.

- - - - -
cfb9faff by sheaf at 2022-05-24T22:15:12-04:00
Hadrian: don't add "lib" for relocatable builds

The conditional in hadrian/bindist/Makefile depended on the target OS,
but it makes more sense to use whether we are using a relocatable build.
(Currently this only gets set to true on Windows, but this ensures
that the logic stays correctly coupled.)

- - - - -
9973c016 by Andre Marianiello at 2022-05-25T01:36:09-04:00
Remove HscEnv from GHC.HsToCore.Usage (related to #17957)

Metric Decrease:
    T16875

- - - - -
2ff18e39 by sheaf at 2022-05-25T01:36:48-04:00
SimpleOpt: beta-reduce through casts

The simple optimiser would sometimes fail to
beta-reduce a lambda when there were casts
in between the lambda and its arguments.
This can cause problems because we rely on
representation-polymorphic lambdas getting
beta-reduced away (for example, those
that arise from newtype constructors with
representation-polymorphic arguments, with
UnliftedNewtypes).

- - - - -
e74fc066 by CarrieMY at 2022-05-25T16:43:03+02:00
Desugar RecordUpd in `tcExpr`

This patch typechecks record updates by desugaring them inside
the typechecker using the HsExpansion mechanism, and then typechecking
this desugared result.

Example:

    data T p q = T1 { x :: Int, y :: Bool, z :: Char }
               | T2 { v :: Char }
               | T3 { x :: Int }
               | T4 { p :: Float, y :: Bool, x :: Int }
               | T5

The record update `e { x=e1, y=e2 }` desugars as follows

  e { x=e1, y=e2 }
    ===>
  let { x' = e1; y' = e2 } in
  case e of
     T1 _ _ z -> T1 x' y' z
     T4 p _ _ -> T4 p y' x'

The desugared expression is put into an HsExpansion, and we typecheck
that.

The full details are given in Note [Record Updates] in GHC.Tc.Gen.Expr.

Fixes #2595 #3632 #10808 #10856 #16501 #18311 #18802 #21158 #21289

Updates haddock submodule

- - - - -
2b8bdab8 by Eric Lindblad at 2022-05-26T03:21:58-04:00
update README
- - - - -
3d7e7e84 by BinderDavid at 2022-05-26T03:22:38-04:00
Replace dead link in Haddock documentation of Control.Monad.Fail (fixes #21602)

- - - - -
ee61c7f9 by John Ericson at 2022-05-26T03:23:13-04:00
Add Haddocks for `WwOpts`

- - - - -
da5ccf0e by Dominik Peteler at 2022-05-26T03:23:13-04:00
Avoid global compiler state for `GHC.Core.Opt.WorkWrap`

Progress towards #17957

- - - - -
3bd975b4 by sheaf at 2022-05-26T03:23:52-04:00
Optimiser: avoid introducing bad rep-poly

The functions `pushCoValArg` and `pushCoercionIntoLambda` could
introduce bad representation-polymorphism. Example:

  type RR :: RuntimeRep
  type family RR where { RR = IntRep }
  type F :: TYPE RR
  type family F where  { F  = Int# }

  co = GRefl F (TYPE RR[0])
    :: (F :: TYPE RR)
    ~# (F |> TYPE RR[0] :: TYPE IntRep)

  f :: F -> ()

`pushCoValArg` would transform the unproblematic application

  (f |> (co -> <()>)) (arg :: F |> TYPE RR[0])

into an application in which the argument does not have a fixed
`RuntimeRep`:

  f ((arg |> sym co) :: (F :: TYPE RR))

- - - - -
b22979fb by Fraser Tweedale at 2022-05-26T06:14:51-04:00
executablePath test: fix file extension treatment

The executablePath test strips the file extension (if any) when
comparing the query result with the expected value.  This is to
handle platforms where GHC adds a file extension to the output
program file (e.g. .exe on Windows).

After the initial check, the file gets deleted (if supported).
However, it tries to delete the *stripped* filename, which is
incorrect.  The test currently passes only because Windows does not
allow deleting the program while any process created from it is
alive.

Make the test program correct in general by deleting the
*non-stripped* executable filename.

- - - - -
afde4276 by Fraser Tweedale at 2022-05-26T06:14:51-04:00
fix executablePath test for NetBSD

executablePath support for NetBSD was added in
a172be07e3dce758a2325104a3a37fc8b1d20c9c, but the test was not
updated.

Update the test so that it works for NetBSD.  This requires handling
some quirks:

- The result of getExecutablePath could include "./" segments.
  Therefore use System.FilePath.equalFilePath to compare paths.

- The sysctl(2) call returns the original executable name even after
  it was deleted.  Add `canQueryAfterDelete :: [FilePath]` and
  adjust expectations for the post-delete query accordingly.

Also add a note to the `executablePath` haddock to advise that
NetBSD behaves differently from other OSes when the file has been
deleted.

Also accept a decrease in memory usage for T16875.  On Windows, the
metric is -2.2% of baseline, just outside the allowed ±2%.  I don't
see how this commit could have influenced this metric, so I suppose
it's something in the CI environment.

Metric Decrease:
    T16875

- - - - -
d0e4355a by John Ericson at 2022-05-26T06:15:30-04:00
Factor out `initArityOps` to `GHC.Driver.Config.*` module

We want `DynFlags` only mentioned in `GHC.Driver`.

- - - - -
44bb7111 by romes at 2022-05-26T16:27:57+00:00
TTG: Move MatchGroup Origin field and MatchGroupTc to GHC.Hs

- - - - -
88e58600 by sheaf at 2022-05-26T17:38:43-04:00
Add tests for eta-expansion of data constructors

This patch adds several tests relating to the eta-expansion of
data constructors, including UnliftedNewtypes and DataTypeContexts.

- - - - -
d87530bb by Richard Eisenberg at 2022-05-26T23:20:14-04:00
Generalize breakTyVarCycle to work with TyFamLHS

The function breakTyVarCycle_maybe has been installed
in a dark corner of GHC to catch some gremlins (a.k.a.
occurs-check failures) who lurk
there. But it previously only caught gremlins of the
form (a ~ ... F a ...), where some of our intrepid users
have spawned gremlins of the form (G a ~ ... F (G a) ...).
This commit improves breakTyVarCycle_maybe (and renames
it to breakTyEqCycle_maybe) to catch the new gremlins.

Happily, the change is remarkably small.

The gory details are in Note [Type equality cycles].

Test cases: typecheck/should_compile/{T21515,T21473}.

- - - - -
ed37027f by Hécate Moonlight at 2022-05-26T23:20:52-04:00
[base] Fix the links in the Data.Data module

fix #21658
fix #21657
fix #21657

- - - - -
3bd7d5d6 by Krzysztof Gogolewski at 2022-05-27T16:44:48+02:00
Use a class to check validity of withDict

This moves handling of the magic 'withDict' function from the desugarer
to the typechecker. Details in Note [withDict].

I've extracted a part of T16646Fail to a separate file T16646Fail2,
because the new error in 'reify' hides the errors from 'f' and 'g'.

WithDict now works with casts, this fixes #21328.

Part of #19915

- - - - -
b54f6c4f by sheaf at 2022-05-28T21:00:09-04:00
Fix FreeVars computation for mdo

Commit acb188e0 introduced a regression in the computation of free
variables in mdo statements, as the logic in
GHC.Rename.Expr.segmentRecStmts was slightly different depending on
whether the recursive do block corresponded to an mdo statement or
a rec statment.

This patch restores the previous computation for mdo blocks.

Fixes #21654

- - - - -
0704295c by Matthew Pickering at 2022-05-28T21:00:45-04:00
T16875: Stabilise (temporarily) by increasing acceptance threshold

The theory is that on windows there is some difference in the
environment between pipelines on master and merge requests which affects
all tests equally but because T16875 barely allocates anything it is the
test which is affected the most.

See #21557

- - - - -
6341c8ed by Matthew Pickering at 2022-05-28T21:01:20-04:00
make: Fix make maintainer-clean deleting a file tracked by source control

Fixes #21659

- - - - -
fbf2f254 by Bodigrim at 2022-05-28T21:01:58-04:00
Expand documentation of hIsTerminalDevice

- - - - -
0092c67c by Teo Camarasu at 2022-05-29T12:25:39+00:00
export IsList from GHC.IsList

it is still re-exported from GHC.Exts

- - - - -
91396327 by Sylvain Henry at 2022-05-30T09:40:55-04:00
MachO linker: fix handling of ARM64_RELOC_SUBTRACTOR

ARM64_RELOC_SUBTRACTOR relocations are paired with an
AMR64_RELOC_UNSIGNED relocation to implement: addend + sym1 - sym2
The linker was doing it in two steps, basically:
  *addend <- *addend - sym2
  *addend <- *addend + sym1
The first operation was likely to overflow. For example when the
relocation target was 32-bit and both sym1/sym2 were 64-bit addresses.
With the small memory model, (sym1-sym2) would fit in 32 bits but
(*addend-sym2) may not.

Now the linker does it in one step:
  *addend <- *addend + sym1 - sym2

- - - - -
acc26806 by Sylvain Henry at 2022-05-30T09:40:55-04:00
Some fixes to SRT documentation

- reordered the 3 SRT implementation cases from the most general to the
  most specific one:
    USE_SRT_POINTER -> USE_SRT_OFFSET -> USE_INLINE_SRT_FIELD
- added requirements for each
- found and documented a confusion about "SRT inlining" not supported
  with MachO. (It is fixed in the following commit)

- - - - -
5878f439 by Sylvain Henry at 2022-05-30T09:40:55-04:00
Enable USE_INLINE_SRT_FIELD on ARM64

It was previously disabled because of:
- a confusion about "SRT inlining" (see removed comment in this commit)
- a linker bug (overflow) in the handling of ARM64_RELOC_SUBTRACTOR
  relocation: fixed by a previous commit.

- - - - -
59bd6159 by Matthew Pickering at 2022-05-30T09:41:39-04:00
ci: Make sure to exit promptly if `make install` fails.

Due to the vageries of bash, you have to explicitly handle the failure
and exit when in a function.

This failed to exit promptly when !8247 was failing.

See #21358 for the general issue

- - - - -
5a5a28da by Sylvain Henry at 2022-05-30T09:42:23-04:00
Split GHC.HsToCore.Foreign.Decl

This is preliminary work for JavaScript support. It's better to put the
code handling the desugaring of Prim, C and JavaScript declarations into
separate modules.

- - - - -
6f5ff4fa by Sylvain Henry at 2022-05-30T09:43:05-04:00
Bump hadrian to LTS-19.8 (GHC 9.0.2)

- - - - -
f2e70707 by Sylvain Henry at 2022-05-30T09:43:05-04:00
Hadrian: remove unused code

- - - - -
2f215b9f by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
Eta reduction with casted function

We want to be able to eta-reduce
   \x y. ((f x) |> co) y
by pushing 'co' inwards.  A very small change accommodates this
See Note [Eta reduction with casted function]

- - - - -
f4f6a87a by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
Do arity trimming at bindings, rather than in exprArity

Sometimes there are very large casts, and coercionRKind
can be slow.

- - - - -
610a2b83 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
Make findRhsArity take RecFlag

This avoids a fixpoint iteration for the common case of
non-recursive bindings.

- - - - -
80ba50c7 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
Comments and white space

- - - - -
0079171b by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
Make PrimOpId record levity

This patch concerns #20155, part (1)

The general idea is that since primops have curried bindings
(currently in PrimOpWrappers.hs) we don't need to eta-expand
them.  But we /do/ need to eta-expand the levity-polymorphic ones,
because they /don't/ have bindings.

This patch makes a start in that direction, by identifying the
levity-polymophic primops in the PrimOpId IdDetails constructor.

For the moment, I'm still eta-expanding all primops (by saying
that hasNoBinding returns True for all primops), because of the
bug reported in #20155.  But I hope that before long we can
tidy that up too, and remove the TEMPORARILY stuff in hasNoBinding.

- - - - -
6656f016 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
A bunch of changes related to eta reduction

This is a large collection of changes all relating to eta
reduction, originally triggered by #18993, but there followed
a long saga.

Specifics:

* Move state-hack stuff from GHC.Types.Id (where it never belonged)
  to GHC.Core.Opt.Arity (which seems much more appropriate).

* Add a crucial mkCast in the Cast case of
  GHC.Core.Opt.Arity.eta_expand; helps with T18223

* Add clarifying notes about eta-reducing to PAPs.
  See Note [Do not eta reduce PAPs]

* I moved tryEtaReduce from GHC.Core.Utils to GHC.Core.Opt.Arity,
  where it properly belongs.  See Note [Eta reduce PAPs]

* In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, pull out the code for
  when eta-expansion is wanted, to make wantEtaExpansion, and all that
  same function in GHC.Core.Opt.Simplify.simplStableUnfolding.  It was
  previously inconsistent, but it's doing the same thing.

* I did a substantial refactor of ArityType; see Note [ArityType].
  This allowed me to do away with the somewhat mysterious takeOneShots;
  more generally it allows arityType to describe the function, leaving
  its clients to decide how to use that information.

  I made ArityType abstract, so that clients have to use functions
  to access it.

* Make GHC.Core.Opt.Simplify.Utils.rebuildLam (was stupidly called
  mkLam before) aware of the floats that the simplifier builds up, so
  that it can still do eta-reduction even if there are some floats.
  (Previously that would not happen.)  That means passing the floats
  to rebuildLam, and an extra check when eta-reducting (etaFloatOk).

* In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, make use of call-info
  in the idDemandInfo of the binder, as well as the CallArity info. The
  occurrence analyser did this but we were failing to take advantage here.

  In the end I moved the heavy lifting to GHC.Core.Opt.Arity.findRhsArity;
  see Note [Combining arityType with demand info], and functions
  idDemandOneShots and combineWithDemandOneShots.

  (These changes partly drove my refactoring of ArityType.)

* In GHC.Core.Opt.Arity.findRhsArity
  * I'm now taking account of the demand on the binder to give
    extra one-shot info.  E.g. if the fn is always called with two
    args, we can give better one-shot info on the binders
    than if we just look at the RHS.

  * Don't do any fixpointing in the non-recursive
    case -- simple short cut.

  * Trim arity inside the loop. See Note [Trim arity inside the loop]

* Make SimpleOpt respect the eta-reduction flag
  (Some associated refactoring here.)

* I made the CallCtxt which the Simplifier uses distinguish between
  recursive and non-recursive right-hand sides.
     data CallCtxt = ... | RhsCtxt RecFlag | ...
  It affects only one thing:
     - We call an RHS context interesting only if it is non-recursive
       see Note [RHS of lets] in GHC.Core.Unfold

* Remove eta-reduction in GHC.CoreToStg.Prep, a welcome simplification.
  See Note [No eta reduction needed in rhsToBody] in GHC.CoreToStg.Prep.

Other incidental changes

* Fix a fairly long-standing outright bug in the ApplyToVal case of
  GHC.Core.Opt.Simplify.mkDupableContWithDmds. I was failing to take the
  tail of 'dmds' in the recursive call, which meant the demands were All
  Wrong.  I have no idea why this has not caused problems before now.

* Delete dead function GHC.Core.Opt.Simplify.Utils.contIsRhsOrArg

Metrics: compile_time/bytes allocated
                               Test    Metric       Baseline      New value Change
---------------------------------------------------------------------------------------
MultiLayerModulesTH_OneShot(normal) ghc/alloc  2,743,297,692  2,619,762,992  -4.5% GOOD
                     T18223(normal) ghc/alloc  1,103,161,360    972,415,992 -11.9% GOOD
                      T3064(normal) ghc/alloc    201,222,500    184,085,360  -8.5% GOOD
                      T8095(normal) ghc/alloc  3,216,292,528  3,254,416,960  +1.2%
                      T9630(normal) ghc/alloc  1,514,131,032  1,557,719,312  +2.9%  BAD
                 parsing001(normal) ghc/alloc    530,409,812    525,077,696  -1.0%

geo. mean                                 -0.1%

Nofib:
       Program           Size    Allocs   Runtime   Elapsed  TotalMem
--------------------------------------------------------------------------------
         banner          +0.0%     +0.4%     -8.9%     -8.7%      0.0%
    exact-reals          +0.0%     -7.4%    -36.3%    -37.4%      0.0%
 fannkuch-redux          +0.0%     -0.1%     -1.0%     -1.0%      0.0%
           fft2          -0.1%     -0.2%    -17.8%    -19.2%      0.0%
          fluid          +0.0%     -1.3%     -2.1%     -2.1%      0.0%
             gg          -0.0%     +2.2%     -0.2%     -0.1%      0.0%
  spectral-norm          +0.1%     -0.2%      0.0%      0.0%      0.0%
            tak          +0.0%     -0.3%     -9.8%     -9.8%      0.0%
           x2n1          +0.0%     -0.2%     -3.2%     -3.2%      0.0%
--------------------------------------------------------------------------------
            Min          -3.5%     -7.4%    -58.7%    -59.9%      0.0%
            Max          +0.1%     +2.2%    +32.9%    +32.9%      0.0%
 Geometric Mean          -0.0%     -0.1%    -14.2%    -14.8%     -0.0%

Metric Decrease:
    MultiLayerModulesTH_OneShot
    T18223
    T3064
    T15185
    T14766
Metric Increase:
    T9630

- - - - -
cac8c7bb by Matthew Pickering at 2022-05-30T13:44:50-04:00
hadrian: Fix building from source-dist without alex/happy

This fixes two bugs which were adding dependencies on alex/happy when
building from a source dist.

* When we try to pass `--with-alex` and `--with-happy` to cabal when
  configuring but the builders are not set. This is fixed by making them
  optional.
* When we configure, cabal requires alex/happy because of the
  build-tool-depends fields. These are now made optional with a cabal
  flag (build-tool-depends) for compiler/hpc-bin/genprimopcode.

Fixes #21627

- - - - -
a96dccfe by Matthew Pickering at 2022-05-30T13:44:50-04:00
ci: Test the bootstrap without ALEX/HAPPY on path

- - - - -
0e5bb3a8 by Matthew Pickering at 2022-05-30T13:44:50-04:00
ci: Test bootstrapping in release jobs

- - - - -
d8901469 by Matthew Pickering at 2022-05-30T13:44:50-04:00
ci: Allow testing bootstrapping on MRs using the "test-bootstrap" label

- - - - -
18326ad2 by Matthew Pickering at 2022-05-30T13:45:25-04:00
rts: Remove explicit timescale for deprecating -h flag

We originally planned to remove the flag in 9.4 but there's actually no
great rush to do so and it's probably less confusing (forever) to keep
the message around suggesting an explicit profiling option.

Fixes #21545

- - - - -
eaaa1389 by Matthew Pickering at 2022-05-30T13:46:01-04:00
Enable -dlint in hadrian lint transformer

Now #21563 is fixed we can properly enable `-dlint` in CI rather than a
subset of the flags.

- - - - -
0544f114 by Ben Gamari at 2022-05-30T19:16:55-04:00
upload-ghc-libs: Allow candidate-only upload

- - - - -
83467435 by Sylvain Henry at 2022-05-30T19:17:35-04:00
Avoid using DynFlags in GHC.Linker.Unit (#17957)

- - - - -
5c4421b1 by Matthew Pickering at 2022-05-31T08:35:17-04:00
hadrian: Introduce new package database for executables needed to build stage0

These executables (such as hsc2hs) are built using the boot compiler and
crucially, most libraries from the global package database.

We also move other build-time executables to be built in this stage such
as linters which also cleans up which libraries end up in the global
package database. This allows us to remove hacks where linters-common is
removed from the package database when a bindist is created.

This fixes issues caused by infinite recursion due to bytestring adding
a dependency on template-haskell.

Fixes #21634

- - - - -
0dafd3e7 by Matthew Pickering at 2022-05-31T08:35:17-04:00
Build stage1 with -V as well

This helps tracing errors which happen when building stage1

- - - - -
15d42a7a by Matthew Pickering at 2022-05-31T08:35:52-04:00
Revert "packaging: Build perf builds with -split-sections"

This reverts commit 699f593532a3cd5ca1c2fab6e6e4ce9d53be2c1f.

Split sections causes segfaults in profiling way with old toolchains
(deb9) and on windows (#21670)

Fixes #21670

- - - - -
d4c71f09 by John Ericson at 2022-05-31T16:26:28+00:00
Purge `DynFlags` and `HscEnv` from some `GHC.Core` modules where it's not too hard

Progress towards #17957

Because of `CoreM`, I did not move the `DynFlags` and `HscEnv` to other
modules as thoroughly as I usually do. This does mean that risk of
`DynFlags` "creeping back in" is higher than it usually is.

After we do the same process to the other Core passes, and then figure
out what we want to do about `CoreM`, we can finish the job started
here.

That is a good deal more work, however, so it certainly makes sense to
land this now.

- - - - -
a720322f by romes at 2022-06-01T07:44:44-04:00
Restore Note [Quasi-quote overview]

- - - - -
392ce3fc by romes at 2022-06-01T07:44:44-04:00
Move UntypedSpliceFlavour from L.H.S to GHC.Hs

UntypedSpliceFlavour was only used in the client-specific `GHC.Hs.Expr`
but was defined in the client-independent L.H.S.Expr.

- - - - -
7975202b by romes at 2022-06-01T07:44:44-04:00
TTG: Rework and improve splices

This commit redefines the structure of Splices in the AST.

We get rid of `HsSplice` which used to represent typed and untyped
splices, quasi quotes, and the result of splicing either an expression,
a type or a pattern.

Instead we have `HsUntypedSplice` which models an untyped splice or a
quasi quoter, which works in practice just like untyped splices.

The `HsExpr` constructor `HsSpliceE` which used to be constructed with
an `HsSplice` is split into `HsTypedSplice` and `HsUntypedSplice`. The
former is directly constructed with an `HsExpr` and the latter now takes
an `HsUntypedSplice`.

Both `HsType` and `Pat` constructors `HsSpliceTy` and `SplicePat` now
take an `HsUntypedSplice` instead of a `HsSplice` (remember only
/untyped splices/ can be spliced as types or patterns).

The result of splicing an expression, type, or pattern is now
comfortably stored in the extension fields `XSpliceTy`, `XSplicePat`,
`XUntypedSplice` as, respectively, `HsUntypedSpliceResult (HsType
GhcRn)`, `HsUntypedSpliceResult (Pat GhcRn)`, and `HsUntypedSpliceResult
(HsExpr GhcRn)`

Overall the TTG extension points are now better used to
make invalid states unrepresentable and model the progression between
stages better.

See Note [Lifecycle of an untyped splice, and PendingRnSplice]
and Note [Lifecycle of an typed splice, and PendingTcSplice] for more
details.

Updates haddock submodule

Fixes #21263

-------------------------
Metric Decrease:
    hard_hole_fits
-------------------------

- - - - -
320270c2 by Matthew Pickering at 2022-06-01T07:44:44-04:00
Add test for #21619

Fixes #21619

- - - - -
ef7ddd73 by Pierre Le Marre at 2022-06-01T07:44:47-04:00
Pure Haskell implementation of GHC.Unicode

Switch to a pure Haskell implementation of base:GHC.Unicode, based on the implementation of the package unicode-data (https://github.com/composewell/unicode-data/).

Approved by CLC as per https://github.com/haskell/core-libraries-committee/issues/59#issuecomment-1132106691.

- Remove current Unicode cbits.
- Add generator for Unicode property files from Unicode Character Database.
- Generate internal modules.
- Update GHC.Unicode.
- Add unicode003 test for general categories and case mappings.
- Add Python scripts to check 'base' Unicode tests outputs and characters properties.

Fixes #21375

-------------------------
Metric Decrease:
    T16875
Metric Increase:
    T4029
    T18304
    haddock.base
-------------------------

- - - - -
514a6a28 by Eric Lindblad at 2022-06-01T07:44:51-04:00
typos

- - - - -
9004be3c by Matthew Pickering at 2022-06-01T07:44:52-04:00
source-dist: Copy in files created by ./boot

Since we started producing source dists with hadrian we stopped copying
in the files created by ./boot which adds a dependency on python3 and
autoreconf. This adds back in the files which were created by running
configure.

Fixes #21673 #21672 and #21626

- - - - -
a12a3cab by Matthew Pickering at 2022-06-01T07:44:52-04:00
ci: Don't try to run ./boot when testing bootstrap of source dist

- - - - -
e07f9059 by Shlomo Shuck at 2022-06-01T07:44:55-04:00
Language.Haskell.Syntax: Fix docs for PromotedConsT etc.

Fixes ghc/ghc#21675.

- - - - -
87295e6d by Ben Gamari at 2022-06-01T07:44:56-04:00
Bump bytestring, process, and text submodules

Metric Decrease:
    T5631
Metric Increase:
    T18223

(cherry picked from commit 55fcee30cb3281a66f792e8673967d64619643af)

- - - - -
24b5bb61 by Ben Gamari at 2022-06-01T07:44:56-04:00
Bump Cabal submodule

To current `master`.

(cherry picked from commit fbb59c212415188486aafd970eafef170516356a)

- - - - -
5433a35e by Matthew Pickering at 2022-06-01T22:26:30-04:00
hadrian/tool-args: Write output to intermediate file rather than via stdout

This allows us to see the output of hadrian while it is doing the setup.

- - - - -
468f919b by Matthew Pickering at 2022-06-01T22:27:10-04:00
Make -fcompact-unwind the default

This is a follow-up to !7247 (closed) making the inclusion of compact unwinding
sections the default.

Also a slight refactoring/simplification of the flag handling to add
-fno-compact-unwind.

- - - - -
819fdc61 by Zubin Duggal at 2022-06-01T22:27:47-04:00
hadrian bootstrap: add plans for 9.0.2 and 9.2.3

- - - - -
9fa790b4 by Zubin Duggal at 2022-06-01T22:27:47-04:00
ci: Add matrix for bootstrap sources

- - - - -
ce9f986b by John Ericson at 2022-06-02T15:42:59+00:00
HsToCore.Coverage: Improve haddocks

- - - - -
f065804e by John Ericson at 2022-06-02T15:42:59+00:00
Hoist auto `mkModBreaks` and `writeMixEntries` conditions to caller

No need to inline traversing a maybe for `mkModBreaks`. And better to
make each function do one thing and let the caller deside when than
scatter the decision making and make the caller seem more imperative.

- - - - -
d550d907 by John Ericson at 2022-06-02T15:42:59+00:00
Rename `HsToCore.{Coverage -> Ticks}`

The old name made it confusing why disabling HPC didn't disable the
entire pass. The name makes it clear --- there are other reasons to add
ticks in addition.

- - - - -
6520da95 by John Ericson at 2022-06-02T15:42:59+00:00
Split out `GHC.HsToCore.{Breakpoints,Coverage}` and use `SizedSeq`

As proposed in
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7508#note_432877 and
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7508#note_434676,
`GHC.HsToCore.Ticks` is about ticks, breakpoints are separate and
backend-specific (only for the bytecode interpreter), and mix entry
writing is just for HPC.

With this split we separate out those interpreter- and HPC-specific
its, and keep the main `GHC.HsToCore.Ticks` agnostic.

Also, instead of passing the reversed list and count around, we use
`SizedSeq` which abstracts over the algorithm. This is much nicer to
avoid noise and prevents bugs.

(The bugs are not just hypothetical! I missed up the reverses on an
earlier draft of this commit.)

- - - - -
1838c3d8 by Sylvain Henry at 2022-06-02T15:43:14+00:00
GHC.HsToCore.Breakpoints: Slightly improve perf

We have the length already, so we might as well use that rather than
O(n) recomputing it.

- - - - -
5a3fdcfd by John Ericson at 2022-06-02T15:43:59+00:00
HsToCore.Coverage: Purge DynFlags

Finishes what !7467 (closed) started.

Progress towards #17957

- - - - -
9ce9ea50 by HaskellMouse at 2022-06-06T09:50:00-04:00
Deprecate TypeInType extension

This commit fixes #20312
It deprecates "TypeInType" extension
according to the following proposal:
https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0083-no-type-in-type.rst

It has been already implemented.

The migration strategy:
 1. Disable TypeInType
 2. Enable both DataKinds and PolyKinds extensions

Metric Decrease:
    T16875

- - - - -
f2e037fd by Aaron Allen at 2022-06-06T09:50:39-04:00
Diagnostics conversions, part 6 (#20116)

Replaces uses of `TcRnUnknownMessage` with proper diagnostics
constructors in `GHC.Tc.Gen.Match`, `GHC.Tc.Gen.Pat`, and
`GHC.Tc.Gen.Sig`.

- - - - -
04209f2a by Simon Peyton Jones at 2022-06-06T09:51:15-04:00
Ensure floated dictionaries are in scope (again)

In the Specialiser, we missed one more call to
bringFloatedDictsIntoScope (see #21391).

This omission led to #21689. The problem is that the call
to `rewriteClassOps` needs to have in scope any dictionaries
floated out of the arguments we have just specialised.

Easy fix.

- - - - -
a7fece19 by John Ericson at 2022-06-07T05:04:22+00:00
Don't print the number of deps in count-deps tests

It is redundant information and a source of needless version control
conflicts when multiple MRs are changing the deps list.

Just printing the list and not also its length is fine.

- - - - -
a1651a3a by John Ericson at 2022-06-07T05:06:38+00:00
Core.Lint: Reduce `DynFlags` and `HscEnv`

Co-Authored-By: Andre Marianiello <andremarianiello at users.noreply.github.com>

- - - - -
56ebf9a5 by Andreas Klebinger at 2022-06-09T09:11:43-04:00
Fix a CSE shadowing bug.

We used to process the rhs of non-recursive bindings and their body
using the same env. If we had something like
    let x = ... x ...
this caused trouble because the two xs refer to different binders
but we would substitute both for a new binder x2 causing out of scope
errors.

We now simply use two different envs for the rhs and body in cse_bind.
It's all explained in the Note [Separate envs for let rhs and body]

Fixes #21685

- - - - -
28880828 by sheaf at 2022-06-09T09:12:19-04:00
Typecheck remaining ValArgs in rebuildHsApps

This patch refactors hasFixedRuntimeRep_remainingValArgs, renaming it
to tcRemainingValArgs. The logic is moved to rebuildHsApps, which
ensures consistent behaviour across tcApp and quickLookArg1/tcEValArg.

This patch also refactors the treatment of stupid theta for data
constructors, changing the place we drop stupid theta arguments
from dsConLike to mkDataConRep (now the datacon wrapper drops these
arguments).

We decided not to implement PHASE 2 of the FixedRuntimeRep plan for
these remaining ValArgs. Future directions are outlined on the wiki:
  https://gitlab.haskell.org/ghc/ghc/-/wikis/Remaining-ValArgs

Fixes #21544 and #21650

- - - - -
1fbba97b by Matthew Pickering at 2022-06-09T09:12:54-04:00
Add test for T21682

Fixes #21682

- - - - -
8727be73 by Andreas Klebinger at 2022-06-09T09:13:29-04:00
Document dataToTag# primop

- - - - -
7eab75bb by uhbif19 at 2022-06-09T20:22:47+03:00
Remove TcRnUnknownMessage usage from GHC.Rename.Env #20115

- - - - -
46d2fc65 by uhbif19 at 2022-06-09T20:24:40+03:00
Fix TcRnPragmaWarning meaning

- - - - -
69e72ecd by Matthew Pickering at 2022-06-09T19:07:01-04:00
getProcessCPUTime: Fix the getrusage fallback to account for system CPU time

clock_gettime reports the combined total or user AND system time so in
order to replicate it with getrusage we need to add both system and user
time together.

See https://stackoverflow.com/questions/7622371/getrusage-vs-clock-gettime

Some sample measurements when building Cabal with this patch

t1: rusage
t2: clock_gettime

t1: 62347518000; t2: 62347520873
t1: 62395687000; t2: 62395690171
t1: 62432435000; t2: 62432437313
t1: 62478489000; t2: 62478492465
t1: 62514990000; t2: 62514992534
t1: 62515479000; t2: 62515480327
t1: 62515485000; t2: 62515486344

Fixes #21656

- - - - -
722814ba by Yiyun Liu at 2022-06-10T21:23:03-04:00
Use <br> instead of newline character

- - - - -
dc202080 by Matthew Craven at 2022-06-13T14:07:12-04:00
Use (fixed_lev = True) in mkDataTyConRhs

- - - - -
ad70c621 by Matthew Pickering at 2022-06-14T08:40:53-04:00
hadrian: Fix testing stage1 compiler

There were various issues with testing the stage1 compiler..

1. The wrapper was not being built
2. The wrapper was picking up the stage0 package database and trying to
   load prelude from that.
3. The wrappers never worked on windows so just don't support that for
   now.

Fixes #21072

- - - - -
ac83899d by Ben Gamari at 2022-06-14T08:41:30-04:00
validate: Ensure that $make variable is set

Currently the `$make` variable is used without being set in `validate`'s
Hadrian path, which uses make to install the binary distribution. Fix
this.

Fixes #21687.

- - - - -
59bc6008 by John Ericson at 2022-06-15T18:05:35+00:00
CoreToStg.Prep: Get rid of `DynFlags` and `HscEnv`

The call sites in `Driver.Main` are duplicative, but this is good,
because the next step is to remove `InteractiveContext` from `Core.Lint`
into `Core.Lint.Interactive`.

Also further clean up `Core.Lint` to use a better configuration record
than the one we initially added.

- - - - -
aa9d9381 by Ben Gamari at 2022-06-15T20:33:04-04:00
hadrian: Run xattr -rc . on bindist tarball

Fixes #21506.

- - - - -
cdc75a1f by Ben Gamari at 2022-06-15T20:33:04-04:00
configure: Hide spurious warning from ld

Previously the check_for_gold_t22266 configure check could result in
spurious warnings coming from the linker being blurted to stderr.
Suppress these by piping stderr to /dev/null.

- - - - -
e128b7b8 by Ben Gamari at 2022-06-15T20:33:40-04:00
cmm: Add surface syntax for MO_MulMayOflo

- - - - -
bde65ea9 by Ben Gamari at 2022-06-15T20:34:16-04:00
configure: Don't attempt to override linker on Darwin

Configure's --enable-ld-override functionality is intended to ensure
that we don't rely on ld.bfd, which tends to be slow and buggy, on
Linux and Windows. However, on Darwin the lack of sensible package
management makes it extremely easy for users to have awkward mixtures of
toolchain components from, e.g., XCode, the Apple Command-Line Tools
package, and homebrew. This leads to extremely confusing problems
like #21712.

Here we avoid this by simply giving up on linker selection on Darwin
altogether. This isn't so bad since the Apple ld64 linker has decent
performance and AFAICT fairly reliable.

Closes #21712.

- - - - -
25b510c3 by Torsten Schmits at 2022-06-16T12:37:45-04:00
replace quadratic nub to fight byte code gen perf explosion

Despite this code having been present in the core-to-bytecode
implementation, I have observed it in the wild starting with 9.2,
causing enormous slowdown in certain situations.

My test case produces the following profiles:

Before:

```
	total time  =      559.77 secs   (559766 ticks @ 1000 us, 1 processor)
	total alloc = 513,985,665,640 bytes  (excludes profiling overheads)

COST CENTRE MODULE         SRC                                         %time %alloc  ticks     bytes

elem_by     Data.OldList   libraries/base/Data/OldList.hs:429:1-7       67.6   92.9  378282 477447404296
eqInt       GHC.Classes    libraries/ghc-prim/GHC/Classes.hs:275:8-14   12.4    0.0  69333        32
$c>>=       GHC.Data.IOEnv <no location info>                            6.9    0.6  38475 3020371232
```

After:

```
	total time  =       89.83 secs   (89833 ticks @ 1000 us, 1 processor)
	total alloc = 39,365,306,360 bytes  (excludes profiling overheads)

COST CENTRE           MODULE                SRC                                                                  %time %alloc  ticks     bytes

$c>>=                 GHC.Data.IOEnv        <no location info>                                                    43.6    7.7  39156 3020403424
doCase                GHC.StgToByteCode     compiler/GHC/StgToByteCode.hs:(805,1)-(1054,53)                        2.5    7.4   2246 2920777088

```

- - - - -
aa7e1f20 by Matthew Pickering at 2022-06-16T12:38:21-04:00
hadrian: Don't install `include/` directory in bindist.

The install_includes for the RTS package used to be put in the top-level
./include folder but this would lead to confusing things happening if
you installed multiple GHC versions side-by-side.

We don't need this folder anymore because install-includes
is honoured properly by cabal and the relevant header files already
copied in by the cabal installation process.

If you want to depend on the header files for the RTS in a Haskell
project then you just have to depend on the `rts` package and the
correct include directories will be provided for you.

If you want to depend on the header files in a standard C project then
you should query ghc-pkg to get the right paths.

```
ghc-pkg field rts include-dirs  --simple-output
```

Fixes #21609

- - - - -
03172116 by Bryan Richter at 2022-06-16T12:38:57-04:00
Enable eventlogs on nightly perf job

- - - - -
ecbf8685 by Hécate Moonlight at 2022-06-16T16:30:00-04:00
Repair dead link in TH haddocks

Closes #21724

- - - - -
99ff3818 by sheaf at 2022-06-16T16:30:39-04:00
Hadrian: allow configuring Hsc2Hs

This patch adds the ability to pass options to Hsc2Hs as Hadrian
key/value settings, in the same way as cabal configure options,
using the syntax:

  *.*.hsc2hs.run.opts += ...

- - - - -
9c575f24 by sheaf at 2022-06-16T16:30:39-04:00
Hadrian bootstrap: look up hsc2hs

Hadrian bootstrapping looks up where to find ghc_pkg, but the same
logic was not in place for hsc2hs which meant we could fail to
find the appropriate hsc2hs executabe when bootstrapping Hadrian.
This patch adds that missing logic.

- - - - -
229d741f by Ben Gamari at 2022-06-18T10:42:54-04:00
ghc-heap: Add (broken) test for #21622

- - - - -
cadd7753 by Ben Gamari at 2022-06-18T10:42:54-04:00
ghc-heap: Don't Box NULL pointers

Previously we could construct a `Box` of a NULL pointer from the `link`
field of `StgWeak`. Now we take care to avoid ever introducing such
pointers in `collect_pointers` and ensure that the `link` field is
represented as a `Maybe` in the `Closure` type.

Fixes #21622

- - - - -
31c214cc by Tamar Christina at 2022-06-18T10:43:34-04:00
winio: Add support to console handles to handleToHANDLE

- - - - -
711cb417 by Ben Gamari at 2022-06-18T10:44:11-04:00
CmmToAsm/AArch64: Add SMUL[LH] instructions

These will be needed to fix #21624.

- - - - -
d05d90d2 by Ben Gamari at 2022-06-18T10:44:11-04:00
CmmToAsm/AArch64: Fix syntax of OpRegShift operands

Previously this produced invalid assembly containing a redundant comma.

- - - - -
a1e1d8ee by Ben Gamari at 2022-06-18T10:44:11-04:00
ncg/aarch64: Fix implementation of IntMulMayOflo

The code generated for IntMulMayOflo was previously wrong as it
depended upon the overflow flag, which the AArch64 MUL instruction does
not set. Fix this.

Fixes #21624.

- - - - -
26745006 by Ben Gamari at 2022-06-18T10:44:11-04:00
testsuite: Add test for #21624

Ensuring that mulIntMayOflo# behaves as expected.

- - - - -
94f2e92a by Sebastian Graf at 2022-06-20T09:40:58+02:00
CprAnal: Set signatures of DFuns to top

The recursive DFun in the reproducer for #20836 also triggered a bug in CprAnal
that is observable in a debug build. The CPR signature of a recursive DFunId
was never updated and hence the optimistic arity 0 bottom signature triggered a
mismatch with the arity 1 of the binding in WorkWrap. We never miscompiled any
code because WW doesn't exploit bottom CPR signatures.

- - - - -
b570da84 by Sebastian Graf at 2022-06-20T09:43:29+02:00
CorePrep: Don't speculatively evaluate recursive calls (#20836)

In #20836 we have optimised a terminating program into an endless loop,
because we speculated the self-recursive call of a recursive DFun.
Now we track the set of enclosing recursive binders in CorePrep to prevent
speculation of such self-recursive calls.

See the updates to Note [Speculative evaluation] for details.

Fixes #20836.

- - - - -
49fb2f9b by Sebastian Graf at 2022-06-20T09:43:32+02:00
Simplify: Take care with eta reduction in recursive RHSs (#21652)

Similar to the fix to #20836 in CorePrep, we now track the set of enclosing
recursive binders in the SimplEnv and SimpleOptEnv.
See Note [Eta reduction in recursive RHSs] for details.

I also updated Note [Arity robustness] with the insights Simon and I had in a
call discussing the issue.

Fixes #21652.

Unfortunately, we get a 5% ghc/alloc regression in T16577. That is due to
additional eta reduction in GHC.Read.choose1 and the resulting ANF-isation
of a large list literal at the top-level that didn't happen before (presumably
because it was too interesting to float to the top-level). There's not much we
can do about that.

Metric Increase:
    T16577

- - - - -
2563b95c by Sebastian Graf at 2022-06-20T09:45:09+02:00
Ignore .hie-bios

- - - - -
e4e44d8d by Simon Peyton Jones at 2022-06-20T12:31:45-04:00
Instantiate top level foralls in partial type signatures

The main fix for #21667 is the new call to tcInstTypeBnders
in tcHsPartialSigType. It was really a simple omission before.

I also moved the decision about whether we need to apply the
Monomorphism Restriction, from `decideGeneralisationPlan` to
`tcPolyInfer`.  That removes a flag from the InferGen constructor,
which is good.

But more importantly, it allows the new function,
   checkMonomorphismRestriction
called from `tcPolyInfer`, to "see" the `Types` involved rather than
the `HsTypes`.  And that in turn matters because we invoke the MR for
partial signatures if none of the partial signatures in the group have
any overloading context; and we can't answer that question for HsTypes.
See Note [Partial type signatures and the monomorphism restriction]
in GHC.Tc.Gen.Bind.

This latter is really a pre-existing bug.

- - - - -
262a9f93 by Winston Hartnett at 2022-06-20T12:32:23-04:00
Make Outputable instance for InlineSig print the InlineSpec

Fix ghc/ghc#21739

Squash fix ghc/ghc#21739

- - - - -
b5590fff by Matthew Pickering at 2022-06-20T12:32:59-04:00
Add NO_BOOT to hackage_doc_tarball job

We were attempting to boot a src-tarball which doesn't work as ./boot is
not included in the source tarball. This slipped through as the job is
only run on nightly.

- - - - -
d24afd9d by Vladislav Zavialov at 2022-06-20T17:34:44-04:00
HsToken for @-patterns and TypeApplications (#19623)

One more step towards the new design of EPA.

- - - - -
159b7628 by Tamar Christina at 2022-06-20T17:35:23-04:00
linker: only keep rtl exception tables if they have been relocated

- - - - -
da5ff105 by Andreas Klebinger at 2022-06-21T17:04:12+02:00
Ticky:Make json info a separate field.

- - - - -
1a4ce4b2 by Matthew Pickering at 2022-06-22T09:49:22+01:00
Revert "Ticky:Make json info a separate field."

This reverts commit da5ff10503e683e2148c62e36f8fe2f819328862.

This was pushed directly without review.

- - - - -
f89bf85f by Vanessa McHale at 2022-06-22T08:21:32-04:00
Flags to disable local let-floating; -flocal-float-out, -flocal-float-out-top-level CLI flags

These flags affect the behaviour of local let floating.

If `-flocal-float-out` is disabled (the default) then we disable all
local floating.

```
…(let x = let y = e in (a,b) in body)...
===>
…(let y = e; x = (a,b) in body)...

```

Further to this, top-level local floating can be disabled on it's own by
passing -fno-local-float-out-top-level.

```
x = let y = e in (a,b)
===>
y = e; x = (a,b)
```

Note that this is only about local floating, ie, floating two adjacent
lets past each other and doesn't say anything about the global floating
pass which is controlled by `-fno-float`.

Fixes #13663

- - - - -
4ccefc6e by Matthew Craven at 2022-06-22T08:22:12-04:00
Check for Int overflows in Data.Array.Byte

- - - - -
2004e3c8 by Matthew Craven at 2022-06-22T08:22:12-04:00
Add a basic test for ByteArray's Monoid instance

- - - - -
fb36770c by Matthew Craven at 2022-06-22T08:22:12-04:00
Rename `copyByteArray` to `unsafeCopyByteArray`

- - - - -
ecc9aedc by Ben Gamari at 2022-06-22T08:22:48-04:00
testsuite: Add test for #21719

Happily, this has been fixed since 9.2.

- - - - -
19606c42 by Brandon Chinn at 2022-06-22T08:23:28-04:00
Use lookupNameCache instead of lookupOrigIO

- - - - -
4c9dfd69 by Brandon Chinn at 2022-06-22T08:23:28-04:00
Break out thNameToGhcNameIO (ref. #21730)

- - - - -
eb4fb849 by Michael Peyton Jones at 2022-06-22T08:24:07-04:00
Add laws for 'toInteger' and 'toRational'

CLC discussion here:
https://github.com/haskell/core-libraries-committee/issues/58

- - - - -
c1a950c1 by Alexander Esgen at 2022-06-22T12:36:13+00:00
Correct documentation of defaults of the `-V` RTS option

- - - - -
b7b7d90d by Matthew Pickering at 2022-06-22T21:58:12-04:00
Transcribe discussion from #21483 into a Note

In #21483 I had a discussion with Simon Marlow about the memory
retention behaviour of -Fd. I have just transcribed that conversation
here as it elucidates the potentially subtle assumptions which led to
the design of the memory retention behaviours of -Fd.

Fixes #21483

- - - - -
980d1954 by Ben Gamari at 2022-06-22T21:58:48-04:00
eventlog: Don't leave dangling pointers hanging around

Previously we failed to reset pointers to various eventlog buffers to
NULL after freeing them. In principle we shouldn't look at them after
they are freed but nevertheless it is good practice to set them to a
well-defined value.

- - - - -
575ec846 by Eric Lindblad at 2022-06-22T21:59:28-04:00
runhaskell
- - - - -
e6a69337 by Artem Pelenitsyn at 2022-06-22T22:00:07-04:00
re-export GHC.Natural.minusNaturalMaybe from Numeric.Natural

CLC proposal: https://github.com/haskell/core-libraries-committee/issues/45

- - - - -
5d45aa97 by Gergo ERDI at 2022-06-22T22:00:46-04:00
When specialising, look through floatable ticks.

Fixes #21697.

- - - - -
531205ac by Andreas Klebinger at 2022-06-22T22:01:22-04:00
TagCheck.hs: Properly check if arguments are boxed types.

For one by mistake I had been checking against the kind of runtime rep
instead of the boxity.

This uncovered another bug, namely that we tried to generate the
checking code before we had associated the function arguments with
a register, so this could never have worked to begin with.

This fixes #21729 and both of the above issues.

- - - - -
c7f9f6b5 by Gleb Popov at 2022-06-22T22:02:00-04:00
Use correct arch for the FreeBSD triple in gen-data-layout.sh

Downstream bug for reference: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261798
Relevant upstream issue: #15718

- - - - -
75f0091b by Andreas Klebinger at 2022-06-22T22:02:35-04:00
Bump nofib submodule.

Allows the shake runner to build with 9.2.3 among other things.

Fixes #21772

- - - - -
0aa0ce69 by Ben Gamari at 2022-06-27T08:01:03-04:00
Bump ghc-prim and base versions

To 0.9.0 and 4.17.0 respectively.

Bumps array, deepseq, directory, filepath, haskeline, hpc, parsec, stm,
terminfo, text, unix, haddock, and hsc2hs submodules.

(cherry picked from commit ba47b95122b7b336ce1cc00896a47b584ad24095)

- - - - -
4713abc2 by Ben Gamari at 2022-06-27T08:01:03-04:00
testsuite: Use normalise_version more consistently

Previously several tests' output were unnecessarily dependent on version
numbers, particularly of `base`. Fix this.

- - - - -
d7b0642b by Matthew Pickering at 2022-06-27T08:01:03-04:00
linters: Fix lint-submodule-refs when crashing trying to find plausible branches

- - - - -
38378be3 by Andreas Klebinger at 2022-06-27T08:01:39-04:00
hadrian: Improve haddocks for ghcDebugAssertions

- - - - -
ac7a7fc8 by Andreas Klebinger at 2022-06-27T08:01:39-04:00
Don't mark lambda binders as OtherCon

We used to put OtherCon unfoldings on lambda binders of workers
and sometimes also join points/specializations with with the
assumption that since the wrapper would force these arguments
once we execute the RHS they would indeed be in WHNF.

This was wrong for reasons detailed in #21472. So now we purge
evaluated unfoldings from *all* lambda binders.

This fixes #21472, but at the cost of sometimes not using as efficient a
calling convention. It can also change inlining behaviour as some
occurances will no longer look like value arguments when they did
before.

As consequence we also change how we compute CBV information for
arguments slightly. We now *always* determine the CBV convention
for arguments during tidy. Earlier in the pipeline we merely mark
functions as candidates for having their arguments treated as CBV.

As before the process is described in the relevant notes:
Note [CBV Function Ids]
Note [Attaching CBV Marks to ids]
Note [Never put `OtherCon` unfoldigns on lambda binders]

-------------------------
Metric Decrease:
    T12425
    T13035
    T18223
    T18223
    T18923
    MultiLayerModulesTH_OneShot
Metric Increase:
    WWRec
-------------------------

- - - - -
06cf6f4a by Tony Zorman at 2022-06-27T08:02:18-04:00
Add suggestions for unrecognised pragmas (#21589)

In case of a misspelled pragma, offer possible corrections as to what
the user could have meant.

Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/21589

- - - - -
3fbab757 by Greg Steuck at 2022-06-27T08:02:56-04:00
Remove the traces of i386-*-openbsd, long live amd64

OpenBSD will not ship any ghc packages on i386 starting with 7.2
release.  This means there will not be a bootstrap compiler easily
available.  The last available binaries are ghc-8.10.6 which is
already not supported as bootstrap for HEAD.

See here for more information:

https://marc.info/?l=openbsd-ports&m=165060700222580&w=2

- - - - -
58530271 by Bodigrim at 2022-06-27T08:03:34-04:00
Add Foldable1 and Bifoldable1 type classes

Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/9

Instances roughly follow
https://hackage.haskell.org/package/semigroupoids-5.3.7/docs/Data-Semigroup-Foldable-Class.html#t:Foldable1
but the API of `Foldable1` was expanded in comparison to `semigroupoids`.

Compatibility shim is available from https://github.com/phadej/foldable1 (to be released).

Closes #13573.

- - - - -
a51f4ecc by Naomi Liu at 2022-06-27T08:04:13-04:00
add levity polymorphism to addrToAny#

- - - - -
f4edcdc4 by Naomi Liu at 2022-06-27T08:04:13-04:00
add tests for addrToAny# levity

- - - - -
07016fc9 by Matthew Pickering at 2022-06-27T08:04:49-04:00
hadrian: Update main README page

This README had some quite out-of-date content about the build system so
I did a complete pass deleting old material. I also made the section
about flavours more prominent and mentioned flavour transformers.

- - - - -
79ae2d89 by Ben Gamari at 2022-06-27T08:05:24-04:00
testsuite: Hide output from test compilations with verbosity==2

Previously the output from test compilations used to determine whether,
e.g., profiling libraries are available was shown with verbosity
levels >= 2. However, the default level is 2, meaning that most users
were often spammed with confusing errors. Fix this by bumping the
verbosity threshold for this output to >=3.

Fixes #21760.
- - - - -
995ea44d by Ben Gamari at 2022-06-27T08:06:00-04:00
configure: Only probe for LD in FIND_LD

Since 6be2c5a7e9187fc14d51e1ec32ca235143bb0d8b we would probe for LD
rather early in `configure`. However, it turns out that this breaks
`configure`'s `ld`-override logic, which assumes that `LD` was set by
the user and aborts.

Fixes #21778.

- - - - -
b43d140b by Sergei Trofimovich at 2022-06-27T08:06:39-04:00
`.hs-boot` make rules: add missing order-only dependency on target directory

Noticed missing target directory dependency as a build failure in
`make --shuffle` mode (added in https://savannah.gnu.org/bugs/index.php?62100):

    "cp" libraries/base/./GHC/Stack/CCS.hs-boot libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot
    cp: cannot create regular file 'libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot': No such file or directory
    libraries/haskeline/ghc.mk:4: libraries/haskeline/dist-install/build/.depend-v-p-dyn.haskell: No such file or directory
    make[1]: *** [libraries/base/ghc.mk:4: libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot] Error 1 shuffle=1656129254
    make: *** [Makefile:128: all] Error 2 shuffle=1656129254

Note that `cp` complains about inability to create target file.

The change adds order-only dependency on a target directory (similar to
the rest of rules in that file).

The bug is lurking there since 2009 commit 34cc75e1a (`GHC new build
system megapatch`.) where upfront directory creation was never added to
`.hs-boot` files.

- - - - -
57a5f88c by Ben Gamari at 2022-06-28T03:24:24-04:00
Mark AArch64/Darwin as requiring sign-extension

Apple's AArch64 ABI requires that the caller sign-extend small integer
arguments. Set platformCConvNeedsExtension to reflect this fact.

Fixes #21773.

- - - - -
df762ae9 by Ben Gamari at 2022-06-28T03:24:24-04:00
-ddump-llvm shouldn't imply -fllvm

Previously -ddump-llvm would change the backend used, which contrasts
with all other dump flags. This is quite surprising and cost me quite
a bit of time. Dump flags should not change compiler behavior.

Fixes #21776.

- - - - -
70f0c1f8 by Ben Gamari at 2022-06-28T03:24:24-04:00
CmmToAsm/AArch64: Re-format argument handling logic

Previously there were very long, hard to parse lines. Fix this.

- - - - -
696d64c3 by Ben Gamari at 2022-06-28T03:24:24-04:00
CmmToAsm/AArch64: Sign-extend narrow C arguments

The AArch64/Darwin ABI requires that function arguments narrower
than 32-bits must be sign-extended by the caller. We neglected to
do this, resulting in #20735.

Fixes #20735.

- - - - -
c006ac0d by Ben Gamari at 2022-06-28T03:24:24-04:00
testsuite: Add test for #20735

- - - - -
16b9100c by Ben Gamari at 2022-06-28T03:24:59-04:00
integer-gmp: Fix cabal file

Evidently fields may not come after sections in a cabal file.

- - - - -
03cc5d02 by Sergei Trofimovich at 2022-06-28T15:20:45-04:00
ghc.mk: fix 'make install' (`mk/system-cxx-std-lib-1.0.conf.install` does not exist)

before the change `make install` was failing as:

```
"mv" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc-stage2" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc"
make[1]: *** No rule to make target 'mk/system-cxx-std-lib-1.0.conf.install', needed by 'install_packages'.  Stop.
```

I think it's a recent regression caused by 0ef249aa where `system-cxx-std-lib-1.0.conf`
is created (somewhat manually), but not the .install varianlt of it.

The fix is to consistently use `mk/system-cxx-std-lib-1.0.conf` everywhere.

Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/21784

- - - - -
eecab8f9 by Simon Peyton Jones at 2022-06-28T15:21:21-04:00
Comments only, about join points

This MR just adds some documentation about why casts
destroy join points, following #21716.

- - - - -
251471e7 by Matthew Pickering at 2022-06-28T19:02:41-04:00
Cleanup BuiltInSyntax vs UserSyntax

There was some confusion about whether FUN/TYPE/One/Many should be
BuiltInSyntax or UserSyntax. The answer is certainly UserSyntax as
BuiltInSyntax is for things which are directly constructed by the parser
rather than going through normal renaming channels.

I fixed all the obviously wrong places I could find and added a test for
the original bug which was caused by this (#21752)

Fixes #21752 #20695 #18302

- - - - -
0e22f16c by Ben Gamari at 2022-06-28T19:03:16-04:00
template-haskell: Bump version to 2.19.0.0

Bumps text and exceptions submodules due to bounds.

- - - - -
bbe6f10e by Emily Bourke at 2022-06-29T08:23:13+00:00
Tiny tweak to `IOPort#` documentation

The exclamation mark and bracket don’t seem to make sense here. I’ve
looked through the history, and I don’t think they’re deliberate – possibly
a copy-and-paste error.
- - - - -
70e47489 by Dominik Peteler at 2022-06-29T19:26:31-04:00
Remove `CoreOccurAnal` constructor of the `CoreToDo` type

It was dead code since the last occurence in an expression context got
removed in 71916e1c018dded2e68d6769a2dbb8777da12664.

- - - - -
d0722170 by nineonine at 2022-07-01T08:15:56-04:00
Fix panic with UnliftedFFITypes+CApiFFI (#14624)

When declaring foreign import using CAPI calling convention, using
unlifted unboxed types would result in compiler panic. There was
an attempt to fix the situation in #9274, however it only addressed
some of the ByteArray cases.

This patch fixes other missed cases for all prims that may be used
as basic foreign types.

- - - - -
eb043148 by Douglas Wilson at 2022-07-01T08:16:32-04:00
rts: gc stats: account properly for copied bytes in sequential collections

We were not updating the [copied,any_work,scav_find_work, max_n_todo_overflow]
counters during sequential collections. As well, we were double counting for
parallel collections.

To fix this we add an `else` clause to the `if (is_par_gc())`.

The par_* counters do not need to be updated in the sequential case
because they must be 0.

- - - - -
f95edea9 by Matthew Pickering at 2022-07-01T19:21:55-04:00
desugar: Look through ticks when warning about possible literal overflow

Enabling `-fhpc` or `-finfo-table-map` would case a tick to end up
between the appliation of `neg` to its argument. This defeated the
special logic which looks for `NegApp ... (HsOverLit` to warn about
possible overflow if a user writes a negative literal (without out
NegativeLiterals) in their code.

Fixes #21701

- - - - -
f25c8d03 by Matthew Pickering at 2022-07-01T19:22:31-04:00
ci: Fix definition of slow-validate flavour (so that -dlint) is passed

In this embarassing sequence of events we were running slow-validate
without -dlint.

- - - - -
bf7991b0 by Mike Pilgrem at 2022-07-02T10:12:04-04:00
Identify the extistence of the `runhaskell` command and that it is equivalent to the `runghc` command. Add an entry to the index for `runhaskell`. See https://gitlab.haskell.org/ghc/ghc/-/issues/21411
- - - - -
9e79f6d0 by Simon Jakobi at 2022-07-02T10:12:39-04:00
Data.Foldable1: Remove references to Foldable-specific note

...as discussed in
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8495#note_439455.

- - - - -
3a8970ac by romes at 2022-07-03T14:11:31-04:00
TTG: Move HsModule to L.H.S

Move the definition of HsModule defined in GHC.Hs to
Language.Haskell.Syntax with an added TTG parameter and corresponding
extension fields.

This is progress towards having the haskell-syntax package, as described
in #21592

- - - - -
f9f80995 by romes at 2022-07-03T14:11:31-04:00
TTG: Move ImpExp client-independent bits to L.H.S.ImpExp

Move the GHC-independent definitions from GHC.Hs.ImpExp to
Language.Haskell.Syntax.ImpExp with the required TTG extension fields
such as to keep the AST independent from GHC.

This is progress towards having the haskell-syntax package, as described
in #21592

Bumps haddock submodule

- - - - -
c43dbac0 by romes at 2022-07-03T14:11:31-04:00
Refactor ModuleName to L.H.S.Module.Name

ModuleName used to live in GHC.Unit.Module.Name. In this commit, the
definition of ModuleName and its associated functions are moved to
Language.Haskell.Syntax.Module.Name according to the current plan
towards making the AST GHC-independent.

The instances for ModuleName for Outputable, Uniquable and Binary were
moved to the module in which the class is defined because these instances
depend on GHC.

The instance of Eq for ModuleName is slightly changed to no longer
depend on unique explicitly and instead uses FastString's instance of
Eq.

- - - - -
2635c6f2 by konsumlamm at 2022-07-03T14:12:11-04:00
Expand `Ord` instance for `Down`

Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/23#issuecomment-1172932610

- - - - -
36fba0df by Anselm Schüler at 2022-07-04T05:06:42+00:00
Add applyWhen to Data.Function per CLC prop

Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/71#issuecomment-1165830233

- - - - -
3b13aab1 by Matthew Pickering at 2022-07-04T15:15:00-04:00
hadrian: Don't read package environments in ghc-stage1 wrapper

The stage1 compiler may be on the brink of existence and not have even a
working base library. You may have installed packages globally with a
similar stage2 compiler which will then lead to arguments such as
--show-iface not even working because you are passing too many package
flags. The solution is simple, don't read these implicit files.

Fixes #21803

- - - - -
aba482ea by Andreas Klebinger at 2022-07-04T17:55:55-04:00
Ticky:Make json info a separate field.

Fixes #21233

- - - - -
74f3867d by Matthew Pickering at 2022-07-04T17:56:30-04:00
Add docs:<pkg> command to hadrian to build docs for just one package

- - - - -
418afaf1 by Matthew Pickering at 2022-07-04T17:56:30-04:00
upload-docs: propagate publish correctly in upload_sdist

- - - - -
ed793d7a by Matthew Pickering at 2022-07-04T17:56:30-04:00
docs-upload: Fix upload script when no packages are listed

- - - - -
d002c6e0 by Matthew Pickering at 2022-07-04T17:56:30-04:00
hadrian: Add --haddock-base-url option for specifying base-url when generating docs

The motiviation for this flag is to be able to produce documentation
which is suitable for uploading for hackage, ie, the cross-package links
work correctly.

There are basically three values you want to set this to:

* off - default, base_url = ../%pkg% which works for local browsing
* on - no argument , base_url = https:://hackage.haskell.org/package/%pkg%/docs - for hackage docs upload
* on - argument, for example, base_url = http://localhost:8080/package/%pkg%/docs for testing the documentation.

The `%pkg%` string is a template variable which is replaced with the
package identifier for the relevant package.

This is one step towards fixing #21749

- - - - -
41eb749a by Matthew Pickering at 2022-07-04T17:56:31-04:00
Add nightly job for generating docs suitable for hackage upload

- - - - -
620ee7ed by Matthew Pickering at 2022-07-04T17:57:05-04:00
ghci: Support :set prompt in multi repl

This adds supports for various :set commands apart from `:set <FLAG>` in
multi repl, this includes `:set prompt` and so-on.

Fixes #21796

- - - - -
b151b65e by Matthew Pickering at 2022-07-05T16:32:31-04:00
Vendor filepath inside template-haskell

Adding filepath as a dependency of template-haskell means that it can't
be reinstalled if any build-plan depends on template-haskell.

This is a temporary solution for the 9.4 release.

A longer term solution is to split-up the template-haskell package into
the wired-in part and a non-wired-in part which can be reinstalled. This
was deemed quite risky on the 9.4 release timescale.

Fixes #21738

- - - - -
c9347ecf by John Ericson at 2022-07-05T16:33:07-04:00
Factor fields of `CoreDoSimplify` into separate data type

This avoids some partiality. The work @mmhat is doing cleaning up and
modularizing `Core.Opt` will build on this nicely.

- - - - -
d0e74992 by Eric Lindblad at 2022-07-06T01:35:48-04:00
https urls
- - - - -
803e965c by Eric Lindblad at 2022-07-06T01:35:48-04:00
options and typos
- - - - -
5519baa5 by Eric Lindblad at 2022-07-06T01:35:48-04:00
grammar
- - - - -
4ddc1d3e by Eric Lindblad at 2022-07-06T01:35:48-04:00
sources
- - - - -
c95c2026 by Matthew Pickering at 2022-07-06T01:35:48-04:00
Fix lint warnings in bootstrap.py

- - - - -
86ced2ad by romes at 2022-07-06T01:36:23-04:00
Restore Eq instance of ImportDeclQualifiedStyle

Fixes #21819

- - - - -
3547e264 by romes at 2022-07-06T13:50:27-04:00
Prune L.H.S modules of GHC dependencies

Move around datatypes, functions and instances that are GHC-specific out
of the `Language.Haskell.Syntax.*` modules to reduce the GHC
dependencies in them -- progressing towards #21592

Creates a module `Language.Haskell.Syntax.Basic` to hold basic
definitions required by the other L.H.S modules (and don't belong in any
of them)

- - - - -
e4eea07b by romes at 2022-07-06T13:50:27-04:00
TTG: Move CoreTickish out of LHS.Binds

Remove the `[CoreTickish]` fields from datatype `HsBindLR idL idR` and
move them to the extension point instance, according to the plan
outlined in #21592 to separate the base AST from the GHC specific bits.

- - - - -
acc1816b by romes at 2022-07-06T13:50:27-04:00
TTG for ForeignImport/Export

Add a TTG parameter to both `ForeignImport` and `ForeignExport` and,
according to #21592, move the GHC-specific bits in them and in the other
AST data types related to foreign imports and exports to the TTG
extension point.

- - - - -
371c5ecf by romes at 2022-07-06T13:50:27-04:00
TTG for HsTyLit

Add TTG parameter to `HsTyLit` to move the GHC-specific `SourceText`
fields to the extension point and out of the base AST.

Progress towards #21592

- - - - -
fd379d1b by romes at 2022-07-06T13:50:27-04:00
Remove many GHC dependencies from L.H.S

Continue to prune the `Language.Haskell.Syntax.*` modules out of GHC
imports according to the plan in the linked issue.

Moves more GHC-specific declarations to `GHC.*` and brings more required
GHC-independent declarations to `Language.Haskell.Syntax.*` (extending
e.g. `Language.Haskell.Syntax.Basic`).

Progress towards #21592

Bump haddock submodule for !8308

-------------------------
Metric Decrease:
    hard_hole_fits
-------------------------

- - - - -
c5415bc5 by Alan Zimmerman at 2022-07-06T13:50:27-04:00
Fix exact printing of the HsRule name

Prior to this branch, the HsRule name was

    XRec pass (SourceText,RuleName)

and there is an ExactPrint instance for (SourceText, RuleName).

The SourceText has moved to a different location, so synthesise the
original to trigger the correct instance when printing.

We need both the SourceText and RuleName when exact printing, as it is
possible to have a NoSourceText variant, in which case we fall back to
the FastString.

- - - - -
665fa5a7 by Matthew Pickering at 2022-07-06T13:51:03-04:00
driver: Fix issue with module loops and multiple home units

We were attempting to rehydrate all dependencies of a particular module,
but we actually only needed to rehydrate those of the current package
(as those are the ones participating in the loop).

This fixes loading GHC into a multi-unit session.

Fixes #21814

- - - - -
bbcaba6a by Andreas Klebinger at 2022-07-06T13:51:39-04:00
Remove a bogus #define from ClosureMacros.h

- - - - -
fa59223b by Tamar Christina at 2022-07-07T23:23:57-04:00
winio: make consoleReadNonBlocking not wait for any events at all.

- - - - -
42c917df by Adam Sandberg Ericsson at 2022-07-07T23:24:34-04:00
rts: allow NULL to be used as an invalid StgStablePtr

- - - - -
3739e565 by Andreas Schwab at 2022-07-07T23:25:10-04:00
RTS: Add stack marker to StgCRunAsm.S

Every object file must be properly marked for non-executable stack, even if it
contains no code.

- - - - -
a889bc05 by Ben Gamari at 2022-07-07T23:25:45-04:00
Bump unix submodule

Adds `config.sub` to unix's `.gitignore`, fixing #19574.

- - - - -
3609a478 by Matthew Pickering at 2022-07-09T11:11:58-04:00
ghci: Fix most calls to isLoaded to work in multi-mode

The most egrarious thing this fixes is the report about the total number
of loaded modules after starting a session.

Ticket #20889

- - - - -
fc183c90 by Matthew Pickering at 2022-07-09T11:11:58-04:00
Enable :edit command in ghci multi-mode.

This works after the last change to isLoaded.

Ticket #20888

- - - - -
46050534 by Simon Peyton Jones at 2022-07-09T11:12:34-04:00
Fix a scoping bug in the Specialiser

In the call to `specLookupRule` in `already_covered`, in `specCalls`,
we need an in-scope set that includes the free vars of the arguments.
But we simply were not guaranteeing that: did not include the
`rule_bndrs`.

Easily fixed.  I'm not sure how how this bug has lain for quite
so long without biting us.

Fixes #21828.

- - - - -
6e8d9056 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00
Edit Note [idArity varies independently of dmdTypeDepth]

...and refer to it in GHC.Core.Lint.lintLetBind.

Fixes #21452

- - - - -
89ba4655 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00
Tiny documentation wibbles (comments only)

- - - - -
61a46c6d by Eric Lindblad at 2022-07-13T08:28:29-04:00
fix readme
- - - - -
61babb5e by Eric Lindblad at 2022-07-13T08:28:29-04:00
fix bootstrap
- - - - -
8b417ad5 by Eric Lindblad at 2022-07-13T08:28:29-04:00
tarball
- - - - -
e9d9f078 by Zubin Duggal at 2022-07-13T14:00:18-04:00
hie-files: Fix scopes for deriving clauses and instance signatures (#18425)

- - - - -
c4989131 by Zubin Duggal at 2022-07-13T14:00:18-04:00
hie-files: Record location of filled in default method bindings

This is useful for hie files to reconstruct the evidence that default methods
depend on.

- - - - -
9c52e7fc by Zubin Duggal at 2022-07-13T14:00:18-04:00
testsuite: Factor out common parts from hiefile tests

- - - - -
6a9e4493 by sheaf at 2022-07-13T14:00:56-04:00
Hadrian: update documentation of settings

The documentation for key-value settings was a bit out of date.
This patch updates it to account for `cabal.configure.opts` and
`hsc2hs.run.opts`.

The user-settings document was also re-arranged, to make the key-value
settings more prominent (as it doesn't involve changing the Hadrian
source code, and thus doesn't require any recompilation of Hadrian).

- - - - -
a2f142f8 by Zubin Duggal at 2022-07-13T20:43:32-04:00
Fix potential space leak that arise from ModuleGraphs retaining references
to previous ModuleGraphs, in particular the lazy `mg_non_boot` field.
This manifests in `extendMG`.

Solution: Delete `mg_non_boot` as it is only used for `mgLookupModule`, which
is only called in two places in the compiler, and should only be called at most
once for every home unit:

GHC.Driver.Make:
      mainModuleSrcPath :: Maybe String
      mainModuleSrcPath = do
        ms <- mgLookupModule mod_graph (mainModIs hue)
        ml_hs_file (ms_location ms)

GHCI.UI:
listModuleLine modl line = do
   graph <- GHC.getModuleGraph
   let this = GHC.mgLookupModule graph modl

Instead `mgLookupModule` can be a linear function that looks through the entire
list of `ModuleGraphNodes`

Fixes #21816

- - - - -
dcf8b30a by Ben Gamari at 2022-07-13T20:44:08-04:00
rts: Fix AdjustorPool bitmap manipulation

Previously the implementation of bitmap_first_unset assumed that
`__builtin_clz` would accept `uint8_t` however it apparently rather
extends its argument to `unsigned int`.

To fix this we simply revert to a naive implementation since handling
the various corner cases with `clz` is quite tricky. This should be
fine given that AdjustorPool isn't particularly hot. Ideally we would
have a single, optimised bitmap implementation in the RTS but I'll leave
this for future work.

Fixes #21838.

- - - - -
ad8f3e15 by Luite Stegeman at 2022-07-16T07:20:36-04:00
Change GHCi bytecode return convention for unlifted datatypes.

This changes the bytecode return convention for unlifted
algebraic datatypes to be the same as for lifted
types, i.e. ENTER/PUSH_ALTS instead of
RETURN_UNLIFTED/PUSH_ALTS_UNLIFTED

Fixes #20849

- - - - -
5434d1a3 by Colten Webb at 2022-07-16T07:21:15-04:00
Compute record-dot-syntax types
Ensures type information for record-dot-syntax
is included in HieASTs. See #21797

- - - - -
89d169ec by Colten Webb at 2022-07-16T07:21:15-04:00
Add record-dot-syntax test

- - - - -
4beb9f3c by Ben Gamari at 2022-07-16T07:21:51-04:00
Document RuntimeRep polymorphism limitations of catch#, et al

As noted in #21868, several primops accepting continuations producing
RuntimeRep-polymorphic results aren't nearly as polymorphic as their
types suggest. Document this limitation and adapt the `UnliftedWeakPtr`
test to avoid breaking this limitation in `keepAlive#`.

- - - - -
4ef1c65d by Ben Gamari at 2022-07-16T07:21:51-04:00
Make keepAlive# out-of-line

This is a naive approach to fixing the unsoundness noticed in #21708.
Specifically, we remove the lowering of `keepAlive#` via CorePrep and
instead turn it into an out-of-line primop.
This is simple, inefficient (since the continuation must now be heap
allocated), but good enough for 9.4.1. We will revisit this
(particiularly via #16098) in a future release.

Metric Increase:
    T4978
    T7257
    T9203

- - - - -
1bbff35d by Greg Steuck at 2022-07-16T07:22:29-04:00
Suppress extra output from configure check for c++ libraries

- - - - -
3acbd7ad by Ben Gamari at 2022-07-16T07:23:04-04:00
rel-notes: Drop mention of #21745 fix

Since we have backported the fix to 9.4.1.

- - - - -
b27c2774 by Dominik Peteler at 2022-07-16T07:23:43-04:00
Align the behaviour of `dopt` and `log_dopt`

Before the behaviour of `dopt` and `logHasDumpFlag` (and the underlying
function `log_dopt`) were different as the latter did not take the
verbosity level into account. This led to problems during the
refactoring as we cannot simply replace calls to `dopt` with calls to
`logHasDumpFlag`.

In addition to that a subtle bug in the GHC module was fixed:
`setSessionDynFlags` did not update the logger and as a consequence the
verbosity value of the logger was not set appropriately.

Fixes #21861

- - - - -
28347d71 by Douglas Wilson at 2022-07-16T13:25:06-04:00
rts: forkOn context switches the target capability

Fixes #21824

- - - - -
f1c44991 by Ben Gamari at 2022-07-16T13:25:41-04:00
cmm: Eliminate orphan Outputable instances

Here we reorganize `GHC.Cmm` to eliminate the orphan `Outputable` and
`OutputableP` instances for the Cmm AST. This makes it significantly
easier to use the Cmm pretty-printers in tracing output without
incurring module import cycles.

- - - - -
f2e5e763 by Ben Gamari at 2022-07-16T13:25:41-04:00
cmm: Move toBlockList to GHC.Cmm

- - - - -
fa092745 by Ben Gamari at 2022-07-16T13:25:41-04:00
compiler: Add haddock sections to GHC.Utils.Panic

- - - - -
097759f9 by Ben Gamari at 2022-07-16T13:26:17-04:00
configure: Don't override Windows CXXFLAGS

At some point we used the clang distribution from msys2's `MINGW64`
environment for our Windows toolchain. This defaulted to using libgcc
and libstdc++ for its runtime library. However, we found for a variety
of reasons that compiler-rt, libunwind, and libc++ were more reliable,
consequently we explicitly overrode the CXXFLAGS to use these.

However, since then we have switched to use the `CLANG64` packaging,
which default to these already. Consequently we can drop these
arguments, silencing some redundant argument warnings from clang.

Fixes #21669.

- - - - -
e38a2684 by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/Elf: Check that there are no NULL ctors

- - - - -
616365b0 by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/Elf: Introduce support for invoking finalizers on unload

Addresses #20494.

- - - - -
cdd3be20 by Ben Gamari at 2022-07-16T23:50:36-04:00
testsuite: Add T20494

- - - - -
03c69d8d by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/PEi386: Rename finit field to fini

fini is short for "finalizer", which does not contain a "t".

- - - - -
033580bc by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/PEi386: Refactor handling of oc->info

Previously we would free oc->info after running initializers. However,
we can't do this is we want to also run finalizers.

Moreover, freeing oc->info so early was wrong for another reason:
we will need it in order to unregister the exception tables (see the
call to `RtlDeleteFunctionTable`).

In service of #20494.

- - - - -
f17912e4 by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/PEi386: Add finalization support

This implements #20494 for the PEi386 linker.

Happily, this also appears to fix `T9405`, resolving #21361.

- - - - -
2cd75550 by Ben Gamari at 2022-07-16T23:50:36-04:00
Loader: Implement gnu-style -l:$path syntax

Gnu ld allows `-l` to be passed an absolute file path,
signalled by a `:` prefix. Implement this in the GHC's
loader search logic.

- - - - -
5781a360 by Ben Gamari at 2022-07-16T23:50:36-04:00
Statically-link against libc++ on Windows

Unfortunately on Windows we have no RPATH-like facility, making dynamic
linking extremely fragile. Since we cannot assume that the user will
add their GHC installation to `$PATH` (and therefore their DLL
search path) we cannot assume that the loader will be able to locate our
`libc++.dll`. To avoid this, we instead statically link against `libc++.a` on
Windows.

Fixes #21435.

- - - - -
8e2e883b by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/PEi386: Ensure that all .ctors/.dtors sections are run

It turns out that PE objects may have multiple `.ctors`/`.dtors`
sections but the RTS linker had assumed that there was only one. Fix
this.

Fixes #21618.

- - - - -
fba04387 by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/PEi386: Respect dtor/ctor priority

Previously we would run constructors and destructors in arbitrary order
despite explicit priorities.

Fixes #21847.

- - - - -
1001952f by Ben Gamari at 2022-07-16T23:50:36-04:00
testsuite: Add test for #21618 and #21847

- - - - -
6f3816af by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/PEi386: Fix exception unwind unregistration

RtlDeleteFunctionTable expects a pointer to the .pdata section
yet we passed it the .xdata section.

Happily, this fixes #21354.

- - - - -
d9bff44c by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/MachO: Drop dead code

- - - - -
d161e6bc by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/MachO: Use section flags to identify initializers

- - - - -
fbb17110 by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/MachO: Introduce finalizer support

- - - - -
5b0ed8a8 by Ben Gamari at 2022-07-16T23:50:37-04:00
testsuite: Use system-cxx-std-lib instead of config.stdcxx_impl

- - - - -
6c476e1a by Ben Gamari at 2022-07-16T23:50:37-04:00
rts/linker/Elf: Work around GCC 6 init/fini behavior

It appears that GCC 6t (at least on i386) fails to give
init_array/fini_array sections the correct SHT_INIT_ARRAY/SHT_FINI_ARRAY
section types, instead marking them as SHT_PROGBITS. This caused T20494
to fail on Debian.

- - - - -
5f8203b8 by Ben Gamari at 2022-07-16T23:50:37-04:00
testsuite: Mark T13366Cxx as unbroken on Darwin

- - - - -
1fd2f851 by Ben Gamari at 2022-07-16T23:50:37-04:00
rts/linker: Fix resolution of __dso_handle on Darwin

Darwin expects a leading underscore.

- - - - -
a2dc00f3 by Ben Gamari at 2022-07-16T23:50:37-04:00
rts/linker: Clean up section kinds

- - - - -
aeb1a7c3 by Ben Gamari at 2022-07-16T23:50:37-04:00
rts/linker: Ensure that __cxa_finalize is called on code unload

- - - - -
028f081e by Ben Gamari at 2022-07-16T23:51:12-04:00
testsuite: Fix T11829 on Centos 7

It appears that Centos 7 has a more strict C++ compiler than most
distributions since std::runtime_error is defined in <stdexcept> rather
than <exception>. In T11829 we mistakenly imported the latter.

- - - - -
a10584e8 by Ben Gamari at 2022-07-17T22:30:32-04:00
hadrian: Rename documentation directories for consistency with make

* Rename `docs` to `doc`
* Place pdf documentation in `doc/` instead of `doc/pdfs/`

Fixes #21164.

- - - - -
b27c5947 by Anselm Schüler at 2022-07-17T22:31:11-04:00
Fix incorrect proof of applyWhen’s properties

- - - - -
eb031a5b by Matthew Pickering at 2022-07-18T08:04:47-04:00
hadrian: Add multi:<pkg> and multi targets for starting a multi-repl

This patch adds support to hadrian for starting a multi-repl containing
all the packages which stage0 can build. In particular, there is the new
user-facing command:

```
./hadrian/ghci-multi
```

which when executed will start a multi-repl containing the `ghc` package
and all it's dependencies.

This is implemented by two new hadrian targets:

```
./hadrian/build multi:<pkg>
```

Construct the arguments for a multi-repl session where the top-level
package is <pkg>. For example, `./hadrian/ghci-multi` is implemented
using `multi:ghc` target.

There is also the `multi` command which constructs a repl for everything
in stage0 which we can build.

- - - - -
19e7cac9 by Eric Lindblad at 2022-07-18T08:05:27-04:00
changelog typo
- - - - -
af6731a4 by Eric Lindblad at 2022-07-18T08:05:27-04:00
typos

- - - - -
415468fe by Simon Peyton Jones at 2022-07-18T16:36:54-04:00
Refactor SpecConstr to use treat bindings uniformly

This patch, provoked by #21457, simplifies SpecConstr by treating
top-level and nested bindings uniformly (see the new scBind).

* Eliminates the mysterious scTopBindEnv

* Refactors scBind to handle top-level and nested definitions
  uniformly.

* But, for now at least, continues the status quo of not doing
  SpecConstr for top-level non-recursive bindings.  (In contrast
  we do specialise nested non-recursive bindings, although the
  original paper did not; see Note [Local let bindings].)

  I tried the effect of specialising top-level non-recursive
  bindings (which is now dead easy to switch on, unlike before)
  but found some regressions, so I backed off.  See !8135.

It's a pure refactoring.  I think it'll do a better job in a few
cases, but there is no regression test.

- - - - -
d4d3fe6e by Andreas Klebinger at 2022-07-18T16:37:29-04:00
Rule matching: Don't compute the FVs if we don't look at them.

- - - - -
5f907371 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
White space only in FamInstEnv

- - - - -
ae3b3b62 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
Make transferPolyIdInfo work for CPR

I don't know why this hasn't bitten us before, but it was plain wrong.

- - - - -
9bdfdd98 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
Inline mapAccumLM

This function is called in inner loops in the compiler, and it's
overloaded and higher order.  Best just to inline it.

This popped up when I was looking at something else.  I think
perhaps GHC is delicately balanced on the cusp of inlining this
automatically.

- - - - -
d0b806ff by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
Make SetLevels honour floatConsts

This fix,  in the definition of profitableFloat,
is just for consistency. `floatConsts` should
do what it says!

I don't think it'll affect anything much, though.

- - - - -
d1c25a48 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
Refactor wantToUnboxArg a bit

* Rename GHC.Core.Opt.WorkWrap.Utils.wantToUnboxArg to canUnboxArg
  and similarly wantToUnboxResult to canUnboxResult.

* Add GHC.Core.Opt.DmdAnal.wantToUnboxArg as a wrapper for
  the (new) GHC.Core.Opt.WorkWrap.Utils.canUnboxArg,
  avoiding some yukky duplication.

  I decided it was clearer to give it a new data type for its
  return type, because I nedeed the FD_RecBox case which was not
  otherwise readiliy expressible.

* Add dcpc_args to WorkWrap.Utils.DataConPatContext for the payload

* Get rid of the Unlift constructor of UnboxingDecision, eliminate
  two panics, and two arguments to canUnboxArg (new name).  Much
  nicer now.

- - - - -
6d8a715e by Teo Camarasu at 2022-07-18T16:38:44-04:00
Allow running memInventory when the concurrent nonmoving gc is enabled

If the nonmoving gc is enabled and we are using a threaded RTS,
we now try to grab the collector mutex to avoid memInventory and
the collection racing.

Before memInventory was disabled.

- - - - -
aa75bbde by Ben Gamari at 2022-07-18T16:39:20-04:00
gitignore: don't ignore all aclocal.m4 files

While GHC's own aclocal.m4 is generated by the aclocal tool, other
packages' aclocal.m4 are committed in the repository. Previously
`.gitignore` included an entry which covered *any* file named
`aclocal.m4`, which lead to quite some confusion (e.g. see #21740).
Fix this by modifying GHC's `.gitignore` to only cover GHC's own
`aclocal.m4`.

- - - - -
4b98c5ce by Boris Lykah at 2022-07-19T02:34:12-04:00
Add mapAccumM, forAccumM to Data.Traversable

Approved by Core Libraries Committee in
https://github.com/haskell/core-libraries-committee/issues/65#issuecomment-1186275433

- - - - -
bd92182c by Ben Gamari at 2022-07-19T02:34:47-04:00
configure: Use AC_PATH_TOOL to detect tools

Previously we used AC_PATH_PROG which, as noted by #21601, does not
look for tools with a target prefix,
breaking cross-compilation.

Fixes #21601.

- - - - -
e8c07aa9 by Matthew Pickering at 2022-07-19T10:07:53-04:00
driver: Fix implementation of -S

We were failing to stop before running the assembler so the object file
was also created.

Fixes #21869

- - - - -
e2f0094c by Ben Gamari at 2022-07-19T10:08:28-04:00
rts/ProfHeap: Ensure new Censuses are zeroed

When growing the Census array ProfHeap previously neglected to
zero the new part of the array. Consequently `freeEra` would attempt to
free random words that often looked suspiciously like pointers.

Fixes #21880.

- - - - -
81d65f7f by sheaf at 2022-07-21T15:37:22+02:00
Make withDict opaque to the specialiser

As pointed out in #21575, it is not sufficient to set withDict to inline
after the typeclass specialiser, because we might inline withDict in one
module and then import it in another, and we run into the same problem.
This means we could still end up with incorrect runtime results because
the typeclass specialiser would assume that distinct typeclass evidence
terms at the same type are equal, when this is not necessarily the case
when using withDict.

Instead, this patch introduces a new magicId, 'nospec', which is only
inlined in CorePrep. We make use of it in the definition of withDict
to ensure that the typeclass specialiser does not common up distinct
typeclass evidence terms.

Fixes #21575

- - - - -
9a3e1f31 by Dominik Peteler at 2022-07-22T08:18:40-04:00
Refactored Simplify pass

 * Removed references to driver from GHC.Core.LateCC, GHC.Core.Simplify
   namespace and GHC.Core.Opt.Stats.
   Also removed services from configuration records.

 * Renamed GHC.Core.Opt.Simplify to GHC.Core.Opt.Simplify.Iteration.

 * Inlined `simplifyPgm` and renamed `simplifyPgmIO` to `simplifyPgm`
   and moved the Simplify driver to GHC.Core.Opt.Simplify.

 * Moved `SimplMode` and `FloatEnable` to GHC.Core.Opt.Simplify.Env.

 * Added a configuration record `TopEnvConfig` for the `SimplTopEnv` environment
   in GHC.Core.Opt.Simplify.Monad.

 * Added `SimplifyOpts` and `SimplifyExprOpts`. Provide initialization functions
   for those in a new module GHC.Driver.Config.Core.Opt.Simplify.
   Also added initialization functions for `SimplMode` to that module.

 * Moved `CoreToDo` and friends to a new module GHC.Core.Pipeline.Types
   and the counting types and functions (`SimplCount` and `Tick`) to new
   module GHC.Core.Opt.Stats.

 * Added getter functions for the fields of `SimplMode`. The pedantic bottoms
   option and the platform are retrieved from the ArityOpts and RuleOpts and the
   getter functions allow us to retrieve values from `SpecEnv` without the
   knowledge where the data is stored exactly.

 * Moved the coercion optimization options from the top environment to
   `SimplMode`. This way the values left in the top environment are those
   dealing with monadic functionality, namely logging, IO related stuff and
   counting. Added a note "The environments of the Simplify pass".

 * Removed `CoreToDo` from GHC.Core.Lint and GHC.CoreToStg.Prep and got rid of
   `CoreDoSimplify`. Pass `SimplifyOpts` in the `CoreToDo` type instead.

 * Prep work before removing `InteractiveContext` from `HscEnv`.

- - - - -
2c5991cc by Simon Peyton Jones at 2022-07-22T08:18:41-04:00
Make the specialiser deal better with specialised methods

This patch fixes #21848, by being more careful to update unfoldings
in the type-class specialiser.

See the new Note [Update unfolding after specialisation]

Now that we are being so much more careful about unfoldings,
it turned out that I could dispense with se_interesting, and
all its tricky corners. Hooray.  This fixes #21368.

- - - - -
ae166635 by Ben Gamari at 2022-07-22T08:18:41-04:00
ghc-boot: Clean up UTF-8 codecs

In preparation for moving the UTF-8 codecs into `base`:

* Move them to GHC.Utils.Encoding.UTF8
* Make names more consistent
* Add some Haddocks

- - - - -
e8ac91db by Ben Gamari at 2022-07-22T08:18:41-04:00
base: Introduce GHC.Encoding.UTF8

Here we copy a subset of the UTF-8 implementation living in `ghc-boot`
into `base`, with the intent of dropping the former in the future. For
this reason, the `ghc-boot` copy is now CPP-guarded on
`MIN_VERSION_base(4,18,0)`.

Naturally, we can't copy *all* of the functions defined by `ghc-boot` as
some depend upon `bytestring`; we rather just copy those which only
depend upon `base` and `ghc-prim`.

Further consolidation?
----------------------

Currently GHC ships with at least five UTF-8 implementations:

* the implementation used by GHC in `ghc-boot:GHC.Utils.Encoding`; this
  can be used at a number of types including `Addr#`, `ByteArray#`,
  `ForeignPtr`, `Ptr`, `ShortByteString`, and `ByteString`. Most of this
  can be removed in GHC 9.6+2, when the copies in `base` will become
  available to `ghc-boot`.
* the copy of the `ghc-boot` definition now exported by
  `base:GHC.Encoding.UTF8`. This can be used at `Addr#`, `Ptr`,
  `ByteArray#`, and `ForeignPtr`
* the decoder used by `unpackCStringUtf8#` in `ghc-prim:GHC.CString`;
  this is specialised at `Addr#`.
* the codec used by the IO subsystem in `base:GHC.IO.Encoding.UTF8`;
  this is specialised at `Addr#` but, unlike the above, supports
  recovery in the presence of partial codepoints (since in IO contexts
  codepoints may be broken across buffers)
* the implementation provided by the `text` library

This does seem a tad silly. On the other hand, these implementations
*do* materially differ from one another (e.g. in the types they support,
the detail in errors they can report, and the ability to recover from
partial codepoints). Consequently, it's quite unclear that further
consolidate would be worthwhile.

- - - - -
f9ad8025 by Ben Gamari at 2022-07-22T08:18:41-04:00
Add a Note summarising GHC's UTF-8 implementations

GHC has a somewhat dizzying array of UTF-8 implementations. This note
describes why this is the case.

- - - - -
72dfad3d by Ben Gamari at 2022-07-22T08:18:42-04:00
upload_ghc_libs: Fix path to documentation

The documentation was moved in a10584e8df9b346cecf700b23187044742ce0b35
but this one occurrence was note updated.

Finally closes #21164.

- - - - -
a8b150e7 by sheaf at 2022-07-22T08:18:44-04:00
Add test for #21871

This adds a test for #21871, which was fixed by the No Skolem Info
rework (MR !7105).

Fixes #21871

- - - - -
6379f942 by sheaf at 2022-07-22T08:18:46-04:00
Add test for #21360

The way record updates are typechecked/desugared changed in MR !7981.
Because we desugar in the typechecker to a simple case expression, the
pattern match checker becomes able to spot the long-distance information
and avoid emitting an incorrect pattern match warning.

Fixes #21360

- - - - -
ce0cd12c by sheaf at 2022-07-22T08:18:47-04:00
Hadrian: don't try to build "unix" on Windows
- - - - -
dc27e15a by Simon Peyton Jones at 2022-07-25T09:42:01-04:00
Implement DeepSubsumption

This MR adds the language extension -XDeepSubsumption, implementing
GHC proposal #511.  This change mitigates the impact of GHC proposal

The changes are highly localised, by design.  See Note [Deep subsumption]
in GHC.Tc.Utils.Unify.

The main changes are:

* Add -XDeepSubsumption, which is on by default in Haskell98 and Haskell2010,
  but off in Haskell2021.

  -XDeepSubsumption largely restores the behaviour before the "simple subsumption" change.
  -XDeepSubsumpition has a similar flavour as -XNoMonoLocalBinds:
  it makes type inference more complicated and less predictable, but it
  may be convenient in practice.

* The main changes are in:
  * GHC.Tc.Utils.Unify.tcSubType, which does deep susumption and eta-expanansion
  * GHC.Tc.Utils.Unify.tcSkolemiseET, which does deep skolemisation
  * In GHC.Tc.Gen.App.tcApp we call tcSubTypeNC to match the result
    type. Without deep subsumption, unifyExpectedType would be sufficent.

  See Note [Deep subsumption] in GHC.Tc.Utils.Unify.

* There are no changes to Quick Look at all.

* The type of `withDict` becomes ambiguous; so add -XAllowAmbiguousTypes to
  GHC.Magic.Dict

* I fixed a small but egregious bug in GHC.Core.FVs.varTypeTyCoFVs, where
  we'd forgotten to take the free vars of the multiplicity of an Id.

* I also had to fix tcSplitNestedSigmaTys

  When I did the shallow-subsumption patch
    commit 2b792facab46f7cdd09d12e79499f4e0dcd4293f
    Date:   Sun Feb 2 18:23:11 2020 +0000
    Simple subsumption

  I changed tcSplitNestedSigmaTys to not look through function arrows
  any more.  But that was actually an un-forced change.  This function
  is used only in

  * Improving error messages in GHC.Tc.Gen.Head.addFunResCtxt
  * Validity checking for default methods: GHC.Tc.TyCl.checkValidClass
  * A couple of calls in the GHCi debugger: GHC.Runtime.Heap.Inspect

  All to do with validity checking and error messages. Acutally its
  fine to look under function arrows here, and quite useful a test
  DeepSubsumption05 (a test motivated by a build failure in the
  `lens` package) shows.

  The fix is easy.  I added Note [tcSplitNestedSigmaTys].

- - - - -
e31ead39 by Matthew Pickering at 2022-07-25T09:42:01-04:00
Add tests that -XHaskell98 and -XHaskell2010 enable DeepSubsumption

- - - - -
67189985 by Matthew Pickering at 2022-07-25T09:42:01-04:00
Add DeepSubsumption08

- - - - -
5e93a952 by Simon Peyton Jones at 2022-07-25T09:42:01-04:00
Fix the interaction of operator sections and deep subsumption

Fixes DeepSubsumption08

- - - - -
918620d9 by Zubin Duggal at 2022-07-25T09:42:01-04:00
Add DeepSubsumption09

- - - - -
2a773259 by Gabriella Gonzalez at 2022-07-25T09:42:40-04:00
Default implementation for mempty/(<>)

Approved by: https://github.com/haskell/core-libraries-committee/issues/61

This adds a default implementation for `mempty` and `(<>)` along
with a matching `MINIMAL` pragma so that `Semigroup` and `Monoid`
instances can be defined in terms of `sconcat` / `mconcat`.

The description for each class has also been updated to include the
equivalent set of laws for the `sconcat`-only / `mconcat`-only
instances.

- - - - -
73836fc8 by Bryan Richter at 2022-07-25T09:43:16-04:00
ci: Disable (broken) perf-nofib

See #21859

- - - - -
c24ca5c3 by sheaf at 2022-07-25T09:43:58-04:00
Docs: clarify ConstraintKinds infelicity

GHC doesn't consistently require the ConstraintKinds extension to
be enabled, as it allows programs such as type families returning
a constraint without this extension.

MR !7784 fixes this infelicity, but breaking user programs was deemed
to not be worth it, so we document it instead.

Fixes #21061.

- - - - -
5f2fbd5e by Simon Peyton Jones at 2022-07-25T09:44:34-04:00
More improvements to worker/wrapper

This patch fixes #21888, and simplifies finaliseArgBoxities
by eliminating the (recently introduced) data type FinalDecision.

A delicate interaction meant that this patch
   commit d1c25a48154236861a413e058ea38d1b8320273f
   Date:   Tue Jul 12 16:33:46 2022 +0100
   Refactor wantToUnboxArg a bit

make worker/wrapper go into an infinite loop.  This patch
fixes it by narrowing the handling of case (B) of
Note [Boxity for bottoming functions], to deal only the
arguemnts that are type variables.  Only then do we drop
the trimBoxity call, which is what caused the bug.

I also
* Added documentation of case (B), which was previously
  completely un-mentioned.  And a regression test,
  T21888a, to test it.

* Made unboxDeeplyDmd stop at lazy demands.  It's rare anyway
  for a bottoming function to have a lazy argument (mainly when
  the data type is recursive and then we don't want to unbox
  deeply).  Plus there is Note [No lazy, Unboxed demands in
  demand signature]

* Refactored the Case equation for dmdAnal a bit, to do less
  redundant pattern matching.

- - - - -
b77d95f8 by Simon Peyton Jones at 2022-07-25T09:45:09-04:00
Fix a small buglet in tryEtaReduce

Gergo points out (#21801) that GHC.Core.Opt.Arity.tryEtaReduce was
making an ill-formed cast.  It didn't matter, because the subsequent
guard discarded it; but still worth fixing.  Spurious warnings are
distracting.

- - - - -
3bbde957 by Zubin Duggal at 2022-07-25T09:45:45-04:00
Fix #21889, GHCi misbehaves with Ctrl-C on Windows

On Windows, we create multiple levels of wrappers for GHCi which ultimately
execute ghc --interactive. In order to handle console events properly, each of
these wrappers must call FreeConsole() in order to hand off event processing to
the child process. See #14150.

In addition to this, FreeConsole must only be called from interactive processes (#13411).

This commit makes two changes to fix this situation:

1. The hadrian wrappers generated using `hadrian/bindist/cwrappers/version-wrapper.c` call `FreeConsole`
   if the CPP flag INTERACTIVE_PROCESS is set, which is set when we are generating a wrapper for GHCi.
2. The GHCi wrapper in `driver/ghci/` calls the `ghc-$VER.exe` executable which is not wrapped rather
   than calling `ghc.exe` is is wrapped on windows (and usually non-interactive, so can't call `FreeConsole`:

   Before:
   ghci-$VER.exe calls ghci.exe which calls ghc.exe which calls ghc-$VER.exe

   After:
   ghci-$VER.exe calls ghci.exe which calls ghc-$VER.exe

- - - - -
79f1b021 by Simon Jakobi at 2022-07-25T09:46:21-04:00
docs: Fix documentation of \cases

Fixes #21902.

- - - - -
e4bf9592 by sternenseemann at 2022-07-25T09:47:01-04:00
ghc-cabal: allow Cabal 3.8 to unbreak make build

When bootstrapping GHC 9.4.*, the build will fail when configuring
ghc-cabal as part of the make based build system due to this upper
bound, as Cabal has been updated to a 3.8 release.

Reference #21914, see especially
https://gitlab.haskell.org/ghc/ghc/-/issues/21914#note_444699

- - - - -
726d938e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00
Fix isEvaldUnfolding and isValueUnfolding

This fixes (1) in #21831.  Easy, obviously correct.

- - - - -
5d26c321 by Simon Peyton Jones at 2022-07-25T14:38:14-04:00
Switch off eta-expansion in rules and unfoldings

I think this change will make little difference except to reduce
clutter.  But that's it -- if it causes problems we can switch it
on again.

- - - - -
d4fe2f4e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00
Teach SpecConstr about typeDeterminesValue

This patch addresses #21831, point 2.  See
Note [generaliseDictPats] in SpecConstr

I took the opportunity to refactor the construction of specialisation
rules a bit, so that the rule name says what type we are specialising
at.

Surprisingly, there's a 20% decrease in compile time for test
perf/compiler/T18223. I took a look at it, and the code size seems the
same throughout. I did a quick ticky profile which seemed to show a
bit less substitution going on.  Hmm.  Maybe it's the "don't do
eta-expansion in stable unfoldings" patch, which is part of the
same MR as this patch.

Anyway, since it's a move in the right direction, I didn't think it
was worth looking into further.

Metric Decrease:
    T18223

- - - - -
65f7838a by Simon Peyton Jones at 2022-07-25T14:38:14-04:00
Add a 'notes' file in testsuite/tests/perf/compiler

This file is just a place to accumlate notes about particular
benchmarks, so that I don't keep re-inventing the wheel.

- - - - -
61faff40 by Simon Peyton Jones at 2022-07-25T14:38:50-04:00
Get the in-scope set right in FamInstEnv.injectiveBranches

There was an assert error, as Gergo pointed out in #21896.

I fixed this by adding an InScopeSet argument to tcUnifyTyWithTFs.
And also to GHC.Core.Unify.niFixTCvSubst.

I also took the opportunity to get a couple more InScopeSets right,
and to change some substTyUnchecked into substTy.

This MR touches a lot of other files, but only because I also took the
opportunity to introduce mkInScopeSetList, and use it.

- - - - -
4a7256a7 by Cheng Shao at 2022-07-25T20:41:55+00:00
Add location to cc phase

- - - - -
96811ba4 by Cheng Shao at 2022-07-25T20:41:55+00:00
Avoid as pipeline when compiling c

- - - - -
2869b66d by Cheng Shao at 2022-07-25T20:42:20+00:00
testsuite: Skip test cases involving -S when testing unregisterised GHC

We no longer generate .s files anyway.

Metric Decrease:
    MultiLayerModules
    T10421
    T13035
    T13701
    T14697
    T16875
    T18140
    T18304
    T18923
    T9198

- - - - -
82a0991a by Ben Gamari at 2022-07-25T23:32:05-04:00
testsuite: introduce nonmoving_thread_sanity way

(cherry picked from commit 19f8fce3659de3d72046bea9c61d1a82904bc4ae)

- - - - -
4b087973 by Ben Gamari at 2022-07-25T23:32:06-04:00
rts/nonmoving: Track segment state

It can often be useful during debugging to be able to determine the
state of a nonmoving segment. Introduce some state, enabled by DEBUG, to
track this.

(cherry picked from commit 40e797ef591ae3122ccc98ab0cc3cfcf9d17bd7f)

- - - - -
54a5c32d by Ben Gamari at 2022-07-25T23:32:06-04:00
rts/nonmoving: Don't scavenge objects which weren't evacuated

This fixes a rather subtle bug in the logic responsible for scavenging
objects evacuated to the non-moving generation. In particular, objects
can be allocated into the non-moving generation by two ways:

 a. evacuation out of from-space by the garbage collector
 b. direct allocation by the mutator

Like all evacuation, objects moved by (a) must be scavenged, since they
may contain references to other objects located in from-space. To
accomplish this we have the following scheme:

 * each nonmoving segment's block descriptor has a scan pointer which
   points to the first object which has yet to be scavenged

 * the GC tracks a set of "todo" segments which have pending scavenging
   work

 * to scavenge a segment, we scavenge each of the unmarked blocks
   between the scan pointer and segment's `next_free` pointer.

   We skip marked blocks since we know the allocator wouldn't have
   allocated into marked blocks (since they contain presumably live
   data).

   We can stop at `next_free` since, by
   definition, the GC could not have evacuated any objects to blocks
   above `next_free` (otherwise `next_free wouldn't be the first free
   block).

However, this neglected to consider objects allocated by path (b).
In short, the problem is that objects directly allocated by the mutator
may become unreachable (but not swept, since the containing segment is
not yet full), at which point they may contain references to swept objects.
Specifically, we observed this in #21885 in the following way:

1. the mutator (specifically in #21885, a `lockCAF`) allocates an object
   (specifically a blackhole, which here we will call `blkh`; see Note
   [Static objects under the nonmoving collector] for the reason why) on
   the non-moving heap. The bitmap of the allocated block remains 0
   (since allocation doesn't affect the bitmap) and the containing
   segment's (which we will call `blkh_seg`) `next_free` is advanced.
2. We enter the blackhole, evaluating the blackhole to produce a result
   (specificaly a cons cell) in the nursery
3. The blackhole gets updated into an indirection pointing to the cons
   cell; it is pushed to the generational remembered set
4. we perform a GC, the cons cell is evacuated into the nonmoving heap
   (into segment `cons_seg`)
5. the cons cell is marked
6. the GC concludes
7. the CAF and blackhole become unreachable
8. `cons_seg` is filled
9. we start another GC; the cons cell is swept
10. we start a new GC
11. something is evacuated into `blkh_seg`, adding it to the "todo" list
12. we attempt to scavenge `blkh_seg` (namely, all unmarked blocks
    between `scan` and `next_free`, which includes `blkh`). We attempt to
    evacuate `blkh`'s indirectee, which is the previously-swept cons cell.
    This is unsafe, since the indirectee is no longer a valid heap
    object.

The problem here was that the scavenging logic *assumed* that (a) was
the only source of allocations into the non-moving heap and therefore
*all* unmarked blocks between `scan` and `next_free` were evacuated.
However, due to (b) this is not true.

The solution is to ensure that that the scanned region only encompasses
the region of objects allocated during evacuation. We do this by
updating `scan` as we push the segment to the todo-segment list to
point to the block which was evacuated into.

Doing this required changing the nonmoving scavenging implementation's
update of the `scan` pointer to bump it *once*, instead of after
scavenging each block as was done previously. This is because we may end
up evacuating into the segment being scavenged as we scavenge it. This
was quite tricky to discover but the result is quite simple,
demonstrating yet again that global mutable state should be used
exceedingly sparingly.

Fixes #21885

(cherry picked from commit 0b27ea23efcb08639309293faf13fdfef03f1060)

- - - - -
25c24535 by Ben Gamari at 2022-07-25T23:32:06-04:00
testsuite: Skip a few tests as in the nonmoving collector

Residency monitoring under the non-moving collector is quite
conservative (e.g. the reported value is larger than reality) since
otherwise we would need to block on concurrent collection. Skip a few
tests that are sensitive to residency.

(cherry picked from commit 6880e4fbf728c04e8ce83e725bfc028fcb18cd70)

- - - - -
42147534 by sternenseemann at 2022-07-26T16:26:53-04:00
hadrian: add flag disabling selftest rules which require QuickCheck

The hadrian executable depends on QuickCheck for building, meaning this
library (and its dependencies) will need to be built for bootstrapping
GHC in the future. Building QuickCheck, however, can require
TemplateHaskell. When building a statically linking GHC toolchain,
TemplateHaskell can be tricky to get to work, and cross-compiling
TemplateHaskell doesn't work at all without -fexternal-interpreter,
so QuickCheck introduces an element of fragility to GHC's bootstrap.

Since the selftest rules are the only part of hadrian that need
QuickCheck, we can easily eliminate this bootstrap dependency when
required by introducing a `selftest` flag guarding the rules' inclusion.

Closes #8699.

- - - - -
9ea29d47 by Simon Peyton Jones at 2022-07-26T16:27:28-04:00
Regression test for #21848

- - - - -
ef30e215 by Matthew Pickering at 2022-07-28T13:56:59-04:00
driver: Don't create LinkNodes when -no-link is enabled

Fixes #21866

- - - - -
fc23b5ed by sheaf at 2022-07-28T13:57:38-04:00
Docs: fix mistaken claim about kind signatures

This patch fixes #21806 by rectifying an incorrect claim about
the usage of kind variables in the header of a data declaration with
a standalone kind signature.

It also adds some clarifications about the number of parameters expected
in GADT declarations and in type family declarations.

- - - - -
2df92ee1 by Matthew Pickering at 2022-08-02T05:20:01-04:00
testsuite: Correctly set withNativeCodeGen

Fixes #21918

- - - - -
f2912143 by Matthew Pickering at 2022-08-02T05:20:45-04:00
Fix since annotations in GHC.Stack.CloneStack

Fixes #21894

- - - - -
aeb8497d by Andreas Klebinger at 2022-08-02T19:26:51-04:00
Add -dsuppress-coercion-types to make coercions even smaller.

Instead of `` `cast` <Co:11> :: (Some -> Really -> Large Type)``
simply print `` `cast` <Co:11> :: ... ``

- - - - -
97655ad8 by sheaf at 2022-08-02T19:27:29-04:00
User's guide: fix typo in hasfield.rst

Fixes #21950

- - - - -
35aef18d by Yiyun Liu at 2022-08-04T02:55:07-04:00
Remove TCvSubst and use Subst for both term and type-level subst

This patch removes the TCvSubst data type and instead uses Subst as
the environment for both term and type level substitution. This
change is partially motivated by the existential type proposal,
which will introduce types that contain expressions and therefore
forces us to carry around an "IdSubstEnv" even when substituting for
types. It also reduces the amount of code because "Subst" and
"TCvSubst" share a lot of common operations. There isn't any
noticeable impact on performance (geo. mean for ghc/alloc is around
0.0% but we have -94 loc and one less data type to worry abount).

Currently, the "TCvSubst" data type for substitution on types is
identical to the "Subst" data type except the former doesn't store
"IdSubstEnv". Using "Subst" for type-level substitution means there
will be a redundant field stored in the data type. However, in cases
where the substitution starts from the expression, using "Subst" for
type-level substitution saves us from having to project "Subst" into a
"TCvSubst". This probably explains why the allocation is mostly even
despite the redundant field.

The patch deletes "TCvSubst" and moves "Subst" and its relevant
functions from "GHC.Core.Subst" into "GHC.Core.TyCo.Subst".
Substitution on expressions is still defined in "GHC.Core.Subst" so we
don't have to expose the definition of "Expr" in the hs-boot file that
"GHC.Core.TyCo.Subst" must import to refer to "IdSubstEnv" (whose
codomain is "CoreExpr"). Most functions named fooTCvSubst are renamed
into fooSubst with a few exceptions (e.g. "isEmptyTCvSubst" is a
distinct function from "isEmptySubst"; the former ignores the
emptiness of "IdSubstEnv"). These exceptions mainly exist for
performance reasons and will go away when "Expr" and "Type" are
mutually recursively defined (we won't be able to take those
shortcuts if we can't make the assumption that expressions don't
appear in types).

- - - - -
b99819bd by Krzysztof Gogolewski at 2022-08-04T02:55:43-04:00
Fix TH + defer-type-errors interaction (#21920)

Previously, we had to disable defer-type-errors in splices because of #7276.
But this fix is no longer necessary, the test T7276 no longer segfaults
and is now correctly deferred.

- - - - -
fb529cae by Andreas Klebinger at 2022-08-04T13:57:25-04:00
Add a note about about W/W for unlifting strict arguments

This fixes #21236.

- - - - -
fffc75a9 by Matthew Pickering at 2022-08-04T13:58:01-04:00
Force safeInferred to avoid retaining extra copy of DynFlags

This will only have a (very) modest impact on memory but we don't want
to retain old copies of DynFlags hanging around so best to force this
value.

- - - - -
0f43837f by Matthew Pickering at 2022-08-04T13:58:01-04:00
Force name selectors to ensure no reference to Ids enter the NameCache

I observed some unforced thunks in the NameCache which were retaining a
whole Id, which ends up retaining a Type.. which ends up retaining old
copies of HscEnv containing stale HomeModInfo.

- - - - -
0b1f5fd1 by Matthew Pickering at 2022-08-04T13:58:01-04:00
Fix leaks in --make mode when there are module loops

This patch fixes quite a tricky leak where we would end up retaining
stale ModDetails due to rehydrating modules against non-finalised
interfaces.

== Loops with multiple boot files

It is possible for a module graph to have a loop (SCC, when ignoring boot files)
which requires multiple boot files to break. In this case we must perform the
necessary hydration steps before and after compiling modules which have boot files
which are described above for corectness but also perform an additional hydration step
at the end of the SCC to remove space leaks.

Consider the following example:

┌───────┐   ┌───────┐
│       │   │       │
│   A   │   │   B   │
│       │   │       │
└─────┬─┘   └───┬───┘
      │         │
 ┌────▼─────────▼──┐
 │                 │
 │        C        │
 └────┬─────────┬──┘
      │         │
 ┌────▼──┐  ┌───▼───┐
 │       │  │       │
 │ A-boot│  │ B-boot│
 │       │  │       │
 └───────┘  └───────┘

 A, B and C live together in a SCC. Say we compile the modules in order
 A-boot, B-boot, C, A, B then when we compile A we will perform the hydration steps
 (because A has a boot file). Therefore C will be hydrated relative to A, and the
 ModDetails for A will reference C/A. Then when B is compiled C will be rehydrated again,
 and so B will reference C/A,B, its interface will be hydrated relative to both A and B.
 Now there is a space leak because say C is a very big module, there are now two different copies of
 ModDetails kept alive by modules A and B.

The way to avoid this space leak is to rehydrate an entire SCC together at the
end of compilation so that all the ModDetails point to interfaces for .hs files.
In this example, when we hydrate A, B and C together then both A and B will refer to
C/A,B.

See #21900 for some more discussion.

-------------------------------------------------------

In addition to this simple case, there is also the potential for a leak
during parallel upsweep which is also fixed by this patch. Transcibed is
Note [ModuleNameSet, efficiency and space leaks]

Note [ModuleNameSet, efficiency and space leaks]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

During unsweep the results of compiling modules are placed into a MVar, to find
the environment the module needs to compile itself in the MVar is consulted and
the HomeUnitGraph is set accordingly. The reason we do this is that precisely tracking
module dependencies and recreating the HUG from scratch each time is very expensive.

In serial mode (-j1), this all works out fine because a module can only be compiled after
its dependencies have finished compiling and not interleaved with compiling module loops.
Therefore when we create the finalised or no loop interfaces, the HUG only contains
finalised interfaces.

In parallel mode, we have to be more careful because the HUG variable can contain
non-finalised interfaces which have been started by another thread. In order to avoid
a space leak where a finalised interface is compiled against a HPT which contains a
non-finalised interface we have to restrict the HUG to only the visible modules.

The visible modules is recording in the ModuleNameSet, this is propagated upwards
whilst compiling and explains which transitive modules are visible from a certain point.
This set is then used to restrict the HUG before the module is compiled to only
the visible modules and thus avoiding this tricky space leak.

Efficiency of the ModuleNameSet is of utmost importance because a union occurs for
each edge in the module graph. Therefore the set is represented directly as an IntSet
which provides suitable performance, even using a UniqSet (which is backed by an IntMap) is
too slow. The crucial test of performance here is the time taken to a do a no-op build in --make mode.

See test "jspace" for an example which used to trigger this problem.

Fixes #21900

- - - - -
1d94a59f by Matthew Pickering at 2022-08-04T13:58:01-04:00
Store interfaces in ModIfaceCache more directly

I realised hydration was completely irrelavant for this cache because
the ModDetails are pruned from the result. So now it simplifies things a
lot to just store the ModIface and Linkable, which we can put into the
cache straight away rather than wait for the final version of a
HomeModInfo to appear.

- - - - -
6c7cd50f by Cheng Shao at 2022-08-04T23:01:45-04:00
cmm: Remove unused ReadOnlyData16

We don't actually emit rodata16 sections anywhere.

- - - - -
16333ad7 by Andreas Klebinger at 2022-08-04T23:02:20-04:00
findExternalRules: Don't needlessly traverse the list of rules.

- - - - -
52c15674 by Krzysztof Gogolewski at 2022-08-05T12:47:05-04:00
Remove backported items from 9.6 release notes

They have been backported to 9.4 in commits 5423d84bd9a28f,
13c81cb6be95c5, 67ccbd6b2d4b9b.

- - - - -
78d232f5 by Matthew Pickering at 2022-08-05T12:47:40-04:00
ci: Fix pages job

The job has been failing because we don't bundle haddock docs anymore in
the docs dist created by hadrian.

Fixes #21789

- - - - -
037bc9c9 by Ben Gamari at 2022-08-05T22:00:29-04:00
codeGen/X86: Don't clobber switch variable in switch generation

Previously ce8745952f99174ad9d3bdc7697fd086b47cdfb5 assumed that it was
safe to clobber the switch variable when generating code for a jump
table since we were at the end of a block. However, this assumption is
wrong; the register could be live in the jump target.

Fixes #21968.

- - - - -
50c8e1c5 by Matthew Pickering at 2022-08-05T22:01:04-04:00
Fix equality operator in jspace test

- - - - -
e9c77a22 by Andreas Klebinger at 2022-08-06T06:13:17-04:00
Improve BUILD_PAP comments

- - - - -
41234147 by Andreas Klebinger at 2022-08-06T06:13:17-04:00
Make dropTail comment a haddock comment

- - - - -
ff11d579 by Andreas Klebinger at 2022-08-06T06:13:17-04:00
Add one more sanity check in stg_restore_cccs

- - - - -
1f6c56ae by Andreas Klebinger at 2022-08-06T06:13:17-04:00
StgToCmm: Fix isSimpleScrut when profiling is enabled.

When profiling is enabled we must enter functions that might represent
thunks in order for their sccs to show up in the profile.

We might allocate even if the function is already evaluated in this
case. So we can't consider any potential function thunk to be a simple
scrut when profiling.

Not doing so caused profiled binaries to segfault.

- - - - -
fab0ee93 by Andreas Klebinger at 2022-08-06T06:13:17-04:00
Change `-fprof-late` to insert cost centres after unfolding creation.

The former behaviour of adding cost centres after optimization but
before unfoldings are created is not available via the flag
`prof-late-inline` instead.

I also reduced the overhead of -fprof-late* by pushing the cost centres
into lambdas. This means the cost centres will only account for
execution of functions and not their partial application.

Further I made LATE_CC cost centres it's own CC flavour so they now
won't clash with user defined ones if a user uses the same string for
a custom scc.

LateCC: Don't put cost centres inside constructor workers.

With -fprof-late they are rarely useful as the worker is usually
inlined. Even if the worker is not inlined or we use -fprof-late-linline
they are generally not helpful but bloat compile and run time
significantly. So we just don't add sccs inside constructor workers.

-------------------------
Metric Decrease:
    T13701
-------------------------

- - - - -
f8bec4e3 by Ben Gamari at 2022-08-06T06:13:53-04:00
gitlab-ci: Fix hadrian bootstrapping of release pipelines

Previously we would attempt to test hadrian bootstrapping in the
`validate` build flavour. However, `ci.sh` refuses to run validation
builds during release pipelines, resulting in job failures. Fix this by
testing bootstrapping in the `release` flavour during release pipelines.

We also attempted to record perf notes for these builds, which is
redundant work and undesirable now since we no longer build in a
consistent flavour.

- - - - -
c0348865 by Ben Gamari at 2022-08-06T11:45:17-04:00
compiler: Eliminate two uses of foldr in favor of foldl'

These two uses constructed maps, which is a case where foldl' is
generally more efficient since we avoid constructing an intermediate
O(n)-depth stack.

- - - - -
d2e4e123 by Ben Gamari at 2022-08-06T11:45:17-04:00
rts: Fix code style

- - - - -
57f530d3 by Ben Gamari at 2022-08-06T11:45:17-04:00
genprimopcode: Drop ArrayArray# references

As ArrayArray# no longer exists

- - - - -
7267cd52 by Ben Gamari at 2022-08-06T11:45:17-04:00
base: Organize Haddocks in GHC.Conc.Sync

- - - - -
aa818a9f by Ben Gamari at 2022-08-06T11:48:50-04:00
Add primop to list threads

A user came to #ghc yesterday wondering how best to check whether they
were leaking threads. We ended up using the eventlog but it seems to me
like it would be generally useful if Haskell programs could query their
own threads.

- - - - -
6d1700b6 by Ben Gamari at 2022-08-06T11:51:35-04:00
rts: Move thread labels into TSO

This eliminates the thread label HashTable and instead tracks this
information in the TSO, allowing us to use proper StgArrBytes arrays for
backing the label and greatly simplifying management of object lifetimes
when we expose them to the user with the coming `threadLabel#` primop.

- - - - -
1472044b by Ben Gamari at 2022-08-06T11:54:52-04:00
Add a primop to query the label of a thread

- - - - -
43f2b271 by Ben Gamari at 2022-08-06T11:55:14-04:00
base: Share finalization thread label

For efficiency's sake we float the thread label assigned to the
finalization thread to the top-level, ensuring that we only need to
encode the label once.

- - - - -
1d63b4fb by Ben Gamari at 2022-08-06T11:57:11-04:00
users-guide: Add release notes entry for thread introspection support

- - - - -
09bca1de by Ben Gamari at 2022-08-07T01:19:35-04:00
hadrian: Fix binary distribution install attributes

Previously we would use plain `cp` to install various parts of the
binary distribution. However, `cp`'s behavior w.r.t. file attributes is
quite unclear; for this reason it is much better to rather use
`install`.

Fixes #21965.

- - - - -
2b8ea16d by Ben Gamari at 2022-08-07T01:19:35-04:00
hadrian: Fix installation of system-cxx-std-lib package conf

- - - - -
7b514848 by Ben Gamari at 2022-08-07T01:20:10-04:00
gitlab-ci: Bump Docker images

To give the ARMv7 job access to lld, fixing #21875.

- - - - -
afa584a3 by Ben Gamari at 2022-08-07T05:08:52-04:00
hadrian: Don't use mk/config.mk.in

Ultimately we want to drop mk/config.mk so here I extract the bits
needed by the Hadrian bindist installation logic into a Hadrian-specific
file. While doing this I fixed binary distribution installation, #21901.

- - - - -
b9bb45d7 by Ben Gamari at 2022-08-07T05:08:52-04:00
hadrian: Fix naming of cross-compiler wrappers

- - - - -
78d04cfa by Ben Gamari at 2022-08-07T11:44:58-04:00
hadrian: Extend xattr Darwin hack to cover /lib

As noted in #21506, it is now necessary to remove extended attributes
from `/lib` as well as `/bin` to avoid SIP issues on Darwin.

Fixes #21506.

- - - - -
20457d77 by Andreas Klebinger at 2022-08-08T14:42:26+02:00
NCG(x86): Compile add+shift as lea if possible.

- - - - -


6 changed files:

- .gitignore
- .gitlab-ci.yml
- .gitlab/ci.sh
- .gitlab/darwin/toolchain.nix
- + .gitlab/gen_ci.hs
- + .gitlab/generate_jobs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2915d1e690af5a8b38daab949362e42c8fb332fa...20457d775885d6c3df020d204da9a7acfb3c2e5a

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2915d1e690af5a8b38daab949362e42c8fb332fa...20457d775885d6c3df020d204da9a7acfb3c2e5a
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20220808/5ea29a45/attachment-0001.html>


More information about the ghc-commits mailing list