[Git][ghc/ghc][wip/romes/ast-ohne-faststring] 434 commits: JS: establish single source of truth for symbols

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Fri Oct 11 16:55:23 UTC 2024



Rodrigo Mesquita pushed to branch wip/romes/ast-ohne-faststring at Glasgow Haskell Compiler / GHC


Commits:
6bd850e8 by doyougnu at 2024-06-09T21:02:14-04:00
JS: establish single source of truth for symbols

In pursuit of: #22736.

This MR moves ad-hoc symbols used throughout the js backend into a
single symbols file. Why? First, this cleans up the code by removing
ad-hoc strings created on the fly and therefore makes the code more
maintainable. Second, it makes it much easier to eventually type these
identifiers.

- - - - -
f3017dd3 by Cheng Shao at 2024-06-09T21:02:49-04:00
rts: replace ad-hoc MYTASK_USE_TLV with proper CC_SUPPORTS_TLS

This patch replaces the ad-hoc `MYTASK_USE_TLV` with the
`CC_SUPPORTS_TLS` macro. If TLS support is detected by autoconf, then
we should use that for managing `myTask` in the threaded RTS.

- - - - -
e17d7e8c by Ben Gamari at 2024-06-11T05:25:21-04:00
users-guide: Fix stylistic issues in 9.12 release notes

- - - - -
8a8a982a by Hugo Peters at 2024-06-11T05:25:57-04:00
fix typo in the simplifier debug output:

baling -> bailing

- - - - -
16475bb8 by Hécate Moonlight at 2024-06-12T03:07:55-04:00
haddock: Correct the Makefile to take into account Darwin systems

- - - - -
a2f60da5 by Hécate Kleidukos at 2024-06-12T03:08:35-04:00
haddock: Remove obsolete links to github.com/haskell/haddock in the docs

- - - - -
de4395cd by qqwy at 2024-06-12T03:09:12-04:00
Add `__GLASGOW_HASKELL_ASSERTS_IGNORED__` as CPP macro name if `-fasserts-ignored is set.

This allows users to create their own Control.Exception.assert-like functionality that
does something other than raising an `AssertFailed` exception.

Fixes #24967

- - - - -
0e9c4dee by Ryan Hendrickson at 2024-06-12T03:09:53-04:00
compiler: add hint to TcRnBadlyStaged message

- - - - -
2747cd34 by Simon Peyton Jones at 2024-06-12T12:51:37-04:00
Fix a QuickLook bug

This MR fixes the bug exposed by #24676.  The problem was that
quickLookArg was trying to avoid calling tcInstFun unnecessarily; but
it was in fact necessary.  But that in turn forced me into a
significant refactoring, putting more fields into EValArgQL.

Highlights: see Note [Quick Look overview] in GHC.Tc.Gen.App

* Instantiation variables are now distinguishable from ordinary
  unification variables, by level number = QLInstVar. This is
  treated like "level infinity".  See Note [The QLInstVar TcLevel]
  in GHC.Tc.Utils.TcType.

* In `tcApp`, we don't track the instantiation variables in a set Delta
  any more; instead, we just tell them apart by their level number.

* EValArgQL now much more clearly captures the "half-done" state
  of typechecking an argument, ready for later resumption.
  See Note [Quick Look at value arguments] in GHC.Tc.Gen.App

* Elminated a bogus (never used) fast-path in
  GHC.Tc.Utils.Instantiate.instCallConstraints
  See Note [Possible fast path for equality constraints]

Many other small refactorings.

- - - - -
1b1523b1 by George Thomas at 2024-06-12T12:52:18-04:00
Fix non-compiling extensible record `HasField` example
- - - - -
97b141a3 by Zubin Duggal at 2024-06-12T12:52:55-04:00
haddock: Fix hyperlinker source urls (#24907)

This fixes a bug introduced by f56838c36235febb224107fa62334ebfe9941aba Links to
external modules in the hyperlinker are uniformly generated using splicing the
template given to us instead of attempting to construct the url in an ad-hoc manner.

- - - - -
954f864c by Zubin Duggal at 2024-06-12T12:52:55-04:00
haddock: Add name anchor to external source urls from documentation page

URLs for external source links from documentation pages were missing a splice
location for the name.

Fixes #24912

- - - - -
b0b64177 by Simon Peyton Jones at 2024-06-12T12:53:31-04:00
Prioritise nominal equalities

The main payload of this patch is

* Prioritise nominal equalities in the constraint solver. This
  ameliorates the incompleteness of solving for representational
  constraints over newtypes: see #24887.

   See (EX2) in Note [Decomposing newtype equalities] in
   GHC.Tc.Solver.Equality

In doing this patch I tripped over some other things that I refactored:

* Move `isCoVarType` from `GHC.Core.Type` to `GHC.Core.Predicate`
  where it seems more at home.

* Clarify the "rewrite role" of a constraint.  I was very puzzled
  about what the role of, say `(Eq a)` might be, but see the new
  Note [The rewrite-role of a constraint].

  In doing so I made predTypeEqRel crash when given a non-equality.
  Usually it expects an equality; but it was being mis-used for
  the above rewrite-role stuff.

- - - - -
cb7c1b83 by Liam Goodacre at 2024-06-12T12:54:09-04:00
compiler: missing-deriving-strategies suggested fix

Extends the missing-deriving-strategies warning with a suggested fix
that includes which deriving strategies were assumed.

For info about the warning, see comments for
`TcRnNoDerivStratSpecified`, `TcRnNoDerivingClauseStrategySpecified`, &
`TcRnNoStandaloneDerivingStrategySpecified`.

For info about the suggested fix, see
`SuggestExplicitDerivingClauseStrategies` &
`SuggestExplicitStandalanoDerivingStrategy`.

docs: Rewords missing-deriving-strategies to mention the suggested fix.

Resolves #24955

- - - - -
4e36d3a3 by Jan Hrček at 2024-06-12T12:54:48-04:00
Further haddocks improvements in Language.Haskell.Syntax.Pat.Pat

- - - - -
558353f4 by Cheng Shao at 2024-06-12T12:55:24-04:00
rts: use page sized mblocks on wasm

This patch changes mblock size to page size on wasm. It allows us to
simplify our wasi-libc fork, makes it much easier to test third party
libc allocators like emmalloc/mimalloc, as well as experimenting with
threaded RTS in wasm.

- - - - -
b3cc5366 by Matthew Pickering at 2024-06-12T23:06:57-04:00
compiler: Make ghc-experimental not wired in

If you need to wire in definitions, then place them in ghc-internal and
reexport them from ghc-experimental.

Ticket #24903

- - - - -
700eeab9 by Hécate Kleidukos at 2024-06-12T23:07:37-04:00
base: Use a more appropriate unicode arrow for the ByteArray diagram

This commit rectifies the usage of a unicode arrow in favour of one that
doesn't provoke mis-alignment.

- - - - -
cca7de25 by Matthew Pickering at 2024-06-12T23:08:14-04:00
ghcup-metadata: Fix debian version ranges

This was caught by `ghcup-ci` failing and attempting to install a deb12
bindist on deb11.

```
configure: WARNING: m4/prep_target_file.m4: Expecting YES/NO but got  in ArSupportsDashL_STAGE0. Defaulting to False.
bin/ghc-toolchain-bin: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by bin/ghc-toolchain-bin)
bin/ghc-toolchain-bin: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /tmp/tmp.LBhwvFbVoy/foobarbaz/.ghcup/tmp/ghcup-708d9668d5d82287/ghc-9.11.20240609-x86_64-unknown-linux/bin/../lib/x86_64-linux-ghc-9.11.20240609/libHSunix-2.8.5.1-inplace-ghc9.11.20240609.so)
bin/ghc-toolchain-bin: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /tmp/tmp.LBhwvFbVoy/foobarbaz/.ghcup/tmp/ghcup-708d9668d5d82287/ghc-9.11.20240609-x86_64-unknown-linux/bin/../lib/x86_64-linux-ghc-9.11.20240609/libHSunix-2.8.5.1-inplace-ghc9.11.20240609.so)
```

Fixes #24974

- - - - -
7b23ce8b by Pierre Le Marre at 2024-06-13T15:35:04-04:00
ucd2haskell: remove Streamly dependency + misc

- Remove dead code.
- Remove `streamly` dependency.
- Process files with `bytestring`.
- Replace Unicode files parsers with the corresponding ones from the
  package `unicode-data-parser`.
- Simplify cabal file and rename module
- Regenerate `ghc-internal` Unicode files with new header

- - - - -
4570319f by Jacco Krijnen at 2024-06-13T15:35:41-04:00
Document how to run haddocks tests (#24976)

Also remove ghc 9.7 requirement

- - - - -
fb629e24 by amesgen at 2024-06-14T00:28:20-04:00
compiler: refactor lower_CmmExpr_Ptr

- - - - -
def46c8c by amesgen at 2024-06-14T00:28:20-04:00
compiler: handle CmmRegOff in lower_CmmExpr_Ptr

- - - - -
ce76bf78 by Simon Peyton Jones at 2024-06-14T00:28:56-04:00
Small documentation update in Quick Look

- - - - -
19bcfc9b by Simon Peyton Jones at 2024-06-14T14:44:19-04:00
Add hack for #24623

..Th bug in #24623 is randomly triggered by this MR!..

- - - - -
7a08a025 by Simon Peyton Jones at 2024-06-14T14:44:19-04:00
Various fixes to type-tidying

This MR was triggered by #24868, but I found a number of bugs
and infelicities in type-tidying as I went along.  Highlights:

* Fix to #24868 is in GHC.Tc.Errors.report_unsolved: avoid
  using the OccNames of /bound/ variables when tidying /free/
  variables; see the call to `tidyAvoiding`.  That avoid the
  gratuitous renaming which was the cause of #24868. See
     Note [tidyAvoiding] in GHC.Core.TyCo.Tidy

* Refactor and document the tidying of open types.
  See GHC.Core.TyCo.Tidy
     Note [Tidying open types]
     Note [Tidying is idempotent]

* Tidy the coercion variable in HoleCo. That's important so
  that tidied types have tidied kinds.

* Some small renaming to make things consistent.  In particular
  the "X" forms return a new TidyEnv.  E.g.
     tidyOpenType  :: TidyEnv -> Type -> Type
     tidyOpenTypeX :: TidyEnv -> Type -> (TidyEnv, Type)

- - - - -
2eac0288 by Simon Peyton Jones at 2024-06-14T14:44:19-04:00
Wibble

- - - - -
e5d24cc2 by Simon Peyton Jones at 2024-06-14T14:44:20-04:00
Wibbles

- - - - -
246bc3a4 by Simon Peyton Jones at 2024-06-14T14:44:56-04:00
Localise a case-binder in SpecConstr.mkSeqs

This small change fixes #24944

See (SCF1) in Note [SpecConstr and strict fields]

- - - - -
a5994380 by Sylvain Henry at 2024-06-15T03:20:29-04:00
PPC: display foreign label in panic message (cf #23969)

- - - - -
bd95553a by Rodrigo Mesquita at 2024-06-15T03:21:06-04:00
cmm: Parse MO_BSwap primitive operation

Parsing this operation allows it to be tested using `test-primops` in a
subsequent MR.

- - - - -
e0099721 by Andrew Lelechenko at 2024-06-16T17:57:38-04:00
Make flip representation polymorphic, similar to ($) and (&)

CLC proposal: https://github.com/haskell/core-libraries-committee/issues/245

- - - - -
118a1292 by Alan Zimmerman at 2024-06-16T17:58:15-04:00
EPA: Add location to Match Pats list

So we can freely modify the pats and the following item spacing will
still be valid when exact printing.

Closes #24862

- - - - -
db343324 by Fabricio de Sousa Nascimento at 2024-06-17T10:01:51-04:00
compiler: Rejects RULES whose LHS immediately fails to type-check

Fixes GHC crashing on `decomposeRuleLhs` due to ignoring coercion values. This
happens when we have a RULE that does not type check, and enable
`-fdefer-type-errors`. We prevent this to happen by rejecting RULES with an
immediately LHS type error.

Fixes #24026

- - - - -
e7a95662 by Dylan Thinnes at 2024-06-17T10:02:35-04:00
Add hscTypecheckRenameWithDiagnostics, for HLS (#24996)

Use runHsc' in runHsc so that both functions can't fall out of sync

We're currently copying parts of GHC code to get structured warnings
in HLS, so that we can recreate `hscTypecheckRenameWithDiagnostics`
locally. Once we get this function into GHC we can drop the copied code
in future versions of HLS.

- - - - -
d70abb49 by sheaf at 2024-06-18T18:47:20-04:00
Clarify -XGADTs enables existential quantification

Even though -XGADTs does not turn on -XExistentialQuantification,
it does allow the user of existential quantification syntax, without
needing to use GADT-style syntax.

Fixes #20865

- - - - -
13fdf788 by David Binder at 2024-06-18T18:48:02-04:00
Add RTS flag --read-tix-file (GHC Proposal 612)

This commit introduces the RTS flag `--read-tix-file=<yes|no>` which
controls whether a preexisting .tix file is read in at the beginning
of a program run. The default is currently `--read-tix-file=yes` but
will change to `--read-tix-file=no` in a future release of GHC. For
this reason, whenever a .tix file is read in a warning is emitted to
stderr. This warning can be silenced by explicitly passing the
`--read-tix-file=yes` option. Details can be found in the GHC proposal
cited below.

Users can query whether this flag has been used with the help of the
module `GHC.RTS.Flags`. A new field `readTixFile` was added to the
record `HpcFlags`.

These changes have been discussed and approved in
- GHC proposal 612: https://github.com/ghc-proposals/ghc-proposals/pull/612
- CLC proposal 276: https://github.com/haskell/core-libraries-committee/issues/276

- - - - -
f0e3cb6a by Fendor at 2024-06-18T18:48:38-04:00
Improve sharing of duplicated values in `ModIface`, fixes #24723

As a `ModIface` often contains duplicated values that are not
necessarily shared, we improve sharing by serialising the `ModIface`
to an in-memory byte array. Serialisation uses deduplication tables, and
deserialisation implicitly shares duplicated values.

This helps reducing the peak memory usage while compiling in
`--make` mode. The peak memory usage is especially smaller when
generating interface files with core expressions
(`-fwrite-if-simplified-core`).

On agda, this reduces the peak memory usage:

* `2.2 GB` to `1.9 GB` for a ghci session.

On `lib:Cabal`, we report:

* `570 MB` to `500 MB` for a ghci session
* `790 MB` to `667 MB` for compiling `lib:Cabal` with ghc

There is a small impact on execution time, around 2% on the agda code
base.

- - - - -
1bab7dde by Fendor at 2024-06-18T18:48:38-04:00
Avoid unneccessarily re-serialising the `ModIface`

To reduce memory usage of `ModIface`, we serialise `ModIface` to an
in-memory byte array, which implicitly shares duplicated values.

This serialised byte array can be reused to avoid work when we actually
write the `ModIface` to disk.
We introduce a new field to `ModIface` which allows us to save the byte
array, and write it direclty to disk if the `ModIface` wasn't changed
after the initial serialisation.

This requires us to change absolute offsets, for example to jump to the
deduplication table for `Name` or `FastString` with relative offsets, as
the deduplication byte array doesn't contain header information, such as
fingerprints.
To allow us to dump the binary blob to disk, we need to replace all
absolute offsets with relative ones.

We introduce additional helpers for `ModIface` binary serialisation, which
construct relocatable binary blobs. We say the binary blob is relocatable,
if the binary representation can be moved and does not contain any
absolute offsets.

Further, we introduce new primitives for `Binary` that allow to create
relocatable binaries, such as `forwardGetRel` and `forwardPutRel`.

-------------------------
Metric Decrease:
    MultiLayerModulesDefsGhcWithCore
Metric Increase:
    MultiComponentModules
    MultiLayerModules
    T10421
    T12150
    T12234
    T12425
    T13035
    T13253-spj
    T13701
    T13719
    T14697
    T15703
    T16875
    T18698b
    T18140
    T18304
    T18698a
    T18730
    T18923
    T20049
    T24582
    T5837
    T6048
    T9198
    T9961
    mhu-perf
-------------------------

These metric increases may look bad, but they are all completely benign,
we simply allocate 1 MB per module for `shareIface`. As this allocation
is quite quick, it has a negligible impact on run-time performance.
In fact, the performance difference wasn't measurable on my local
machine. Reducing the size of the pre-allocated 1 MB buffer avoids these
test failures, but also requires us to reallocate the buffer if the
interface file is too big. These reallocations *did* have an impact on
performance, which is why I have opted to accept all these metric
increases, as the number of allocated bytes is merely a guidance.

This 1MB allocation increase causes a lot of tests to fail that
generally have a low allocation number. E.g., increasing from 40MB to
41MB is a 2.5% increase.
In particular, the tests T12150, T13253-spj, T18140, T18304, T18698a,
T18923, T20049, T24582, T5837, T6048, and T9961 only fail on i386-darwin
job, where the number of allocated bytes seems to be lower than in other
jobs.
The tests T16875 and T18698b fail on i386-linux for the same reason.

- - - - -
099992df by Andreas Klebinger at 2024-06-18T18:49:14-04:00
Improve documentation of @Any@ type.

In particular mention possible uses for non-lifted types.

Fixes #23100.

- - - - -
5e75412b by Jakob Bruenker at 2024-06-18T18:49:51-04:00
Update user guide to indicate support for 64-tuples

- - - - -
4f5da595 by Andreas Klebinger at 2024-06-18T18:50:28-04:00
lint notes: Add more info to notes.stdout

When fixing a note reference CI fails with a somewhat confusing diff.
See #21123. This commit adds a line to the output file being compared
which hopefully makes it clear this is the list of broken refs, not all
refs.

Fixes #21123

- - - - -
1eb15c61 by Jakob Bruenker at 2024-06-18T18:51:04-04:00
docs: Update mention of ($) type in user guide

Fixes #24909

- - - - -
1d66c9e3 by Jan Hrček at 2024-06-18T18:51:47-04:00
Remove duplicate Anno instances

- - - - -
8ea0ba95 by Sven Tennie at 2024-06-18T18:52:23-04:00
AArch64: Delete unused RegNos

This has the additional benefit of getting rid of the -1 encoding (real
registers start at 0.)

- - - - -
325422e0 by Sjoerd Visscher at 2024-06-18T18:53:04-04:00
Bump stm submodule to current master

- - - - -
64fba310 by Cheng Shao at 2024-06-18T18:53:40-04:00
testsuite: bump T17572 timeout on wasm32

- - - - -
eb612fbc by Sven Tennie at 2024-06-19T06:46:00-04:00
AArch64: Simplify BL instruction

The BL constructor carried unused data in its third argument.

- - - - -
b0300503 by Alan Zimmerman at 2024-06-19T06:46:36-04:00
TTG: Move SourceText from `Fixity` to `FixitySig`

It is only used there, simplifies the use of `Fixity` in the rest of
the code, and is moved into a TTG extension point.

Precedes !12842, to simplify it

- - - - -
842e119b by Rodrigo Mesquita at 2024-06-19T06:47:13-04:00
base: Deprecate some .Internal modules

Deprecates the following modules according to clc-proposal #217:
https://github.com/haskell/core-libraries-committee/issues/217

* GHC.TypeNats.Internal
* GHC.TypeLits.Internal
* GHC.ExecutionStack.Internal

Closes #24998

- - - - -
24e89c40 by Jacco Krijnen at 2024-06-20T07:21:27-04:00
ttg: Use List instead of Bag in AST for LHsBindsLR

Considering that the parser used to create a Bag of binds using a
cons-based approach, it can be also done using lists. The operations in
the compiler don't really require Bag.

By using lists, there is no dependency on GHC.Data.Bag anymore from the
AST.

Progress towards #21592

- - - - -
04f5bb85 by Simon Peyton Jones at 2024-06-20T07:22:03-04:00
Fix untouchability test

This MR fixes #24938.  The underlying problem was tha the test for
"does this implication bring in scope any equalities" was plain wrong.

See
  Note [Tracking Given equalities] and
  Note [Let-bound skolems]
both in GHC.Tc.Solver.InertSet.

Then
* Test LocalGivenEqs succeeds for a different reason than before;
  see (LBS2) in Note [Let-bound skolems]

* New test T24938a succeeds because of (LBS2), whereas it failed
  before.

* Test LocalGivenEqs2 now fails, as it should.

* Test T224938, the repro from the ticket, fails, as it should.

- - - - -
9a757a27 by Simon Peyton Jones at 2024-06-20T07:22:40-04:00
Fix demand signatures for join points

This MR tackles #24623 and #23113

The main change is to give a clearer notion of "worker/wrapper arity", esp
for join points. See GHC.Core.Opt.DmdAnal
     Note [Worker/wrapper arity and join points]
This Note is a good summary of what this MR does:

(1) The "worker/wrapper arity" of an Id is
    * For non-join-points: idArity
    * The join points: the join arity (Id part only of course)
    This is the number of args we will use in worker/wrapper.
    See `ww_arity` in `dmdAnalRhsSig`, and the function `workWrapArity`.

(2) A join point's demand-signature arity may exceed the Id's worker/wrapper
    arity.  See the `arity_ok` assertion in `mkWwBodies`.

(3) In `finaliseArgBoxities`, do trimBoxity on any argument demands beyond
    the worker/wrapper arity.

(4) In WorkWrap.splitFun, make sure we split based on the worker/wrapper
    arity (re)-computed by workWrapArity.

- - - - -
5e8faaf1 by Jan Hrček at 2024-06-20T07:23:20-04:00
Update haddocks of Import/Export AST types

- - - - -
cd512234 by Hécate Kleidukos at 2024-06-20T07:24:02-04:00
haddock: Update bounds in cabal files and remove allow-newer stanza in cabal.project

- - - - -
8a8ff8f2 by Rodrigo Mesquita at 2024-06-20T07:24:38-04:00
cmm: Don't parse MO_BSwap for W8

Don't support parsing bswap8, since bswap8 is not really an operation
and would have to be implemented as a no-op (and currently is not
implemented at all).

Fixes #25002

- - - - -
5cc472f5 by sheaf at 2024-06-20T07:25:14-04:00
Delete unused testsuite files

These files were committed by mistake in !11902.
This commit simply removes them.

- - - - -
7b079378 by Matthew Pickering at 2024-06-20T07:25:50-04:00
Remove left over debugging pragma from 2016

This pragma was accidentally introduced in 648fd73a7b8fbb7955edc83330e2910428e76147

The top-level cost centres lead to a lack of optimisation when compiling
with profiling.

- - - - -
c872e09b by Hécate Kleidukos at 2024-06-20T19:28:36-04:00
haddock: Remove unused pragmata, qualify usages of Data.List functions, add more sanity checking flags by default

This commit enables some extensions and GHC flags in the cabal file in a way
that allows us to reduce the amount of prologuing on top of each file.

We also prefix the usage of some List functions that removes ambiguity
when they are also exported from the Prelude, like foldl'.
In general, this has the effect of pointing out more explicitly
that a linked list is used.

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

- - - - -
8c87d4e1 by Arnaud Spiwack at 2024-06-20T19:29:12-04:00
Add test case for #23586

- - - - -
568de8a5 by Arnaud Spiwack at 2024-06-20T19:29:12-04:00
When matching functions in rewrite rules: ignore multiplicity

When matching a template variable to an expression, we check that it
has the same type as the matched expression. But if the variable `f` has
type `A -> B` while the expression `e` has type `A %1 -> B`, the match was
previously rejected.

A principled solution would have `f` substituted by `\(%Many x) -> e
x` or some other appropriate coercion. But since linearity is not
properly checked in Core, we can be cheeky and simply ignore
multiplicity while matching. Much easier.

This has forced a change in the linter which, when `-dlinear-core-lint`
is off, must consider that `a -> b` and `a %1 -> b` are equal. This is
achieved by adding an argument to configure the behaviour of
`nonDetCmpTypeX` and modify `ensureEqTys` to call to the new behaviour
which ignores multiplicities when comparing two `FunTy`.

Fixes #24725.

- - - - -
c8a8727e by Simon Peyton Jones at 2024-06-20T19:29:12-04:00
Faster type equality

This MR speeds up type equality, triggered by perf regressions that
showed up when fixing #24725 by parameterising type equality over
whether to ignore multiplicity.

The changes are:

* Do not use `nonDetCmpType` for type /equality/. Instead use a specialised
  type-equality function, which we have always had!

  `nonDetCmpType` remains, but I did not invest effort in refactoring
  or optimising it.

* Type equality is parameterised by
    - whether to expand synonyms
    - whether to respect multiplicities
    - whether it has a RnEnv2 environment
  In this MR I systematically specialise it for static values of these
  parameters.  Much more direct and predictable than before.  See
  Note [Specialising type equality]

* We want to avoid comparing kinds if possible.  I refactored how this
  happens, at least for `eqType`.
  See Note [Casts and coercions in type comparison]

* To make Lint fast, we want to avoid allocating a thunk for <msg> in
      ensureEqTypes ty1 ty2 <msg>
  because the test almost always succeeds, and <msg> isn't needed.
  See Note [INLINE ensureEqTys]

Metric Decrease:
    T13386
    T5030

- - - - -
21fc180b by Ryan Hendrickson at 2024-06-22T10:40:55-04:00
base: Add inits1 and tails1 to Data.List

- - - - -
d640a3b6 by Sebastian Graf at 2024-06-22T10:41:32-04:00
Derive previously hand-written `Lift` instances (#14030)

This is possible now that #22229 is fixed.

- - - - -
33fee6a2 by Sebastian Graf at 2024-06-22T10:41:32-04:00
Implement the "Derive Lift instances for data types in template-haskell" proposal (#14030)

After #22229 had been fixed, we can finally derive the `Lift` instance for the
TH AST, as proposed by Ryan Scott in
https://mail.haskell.org/pipermail/libraries/2015-September/026117.html.

Fixes #14030, #14296, #21759 and #24560.

The residency of T24471 increases by 13% because we now load `AnnLookup`
from its interface file, which transitively loads the whole TH AST.
Unavoidable and not terrible, I think.

Metric Increase:
    T24471

- - - - -
383c01a8 by Matthew Pickering at 2024-06-22T10:42:08-04:00
bindist: Use complete relative paths when cding to directories

If a user has configured CDPATH on their system then `cd lib` may change
into an unexpected directory during the installation process.

If you write `cd ./lib` then it will not consult `CDPATH` to determine
what you mean.

I have added a check on ghcup-ci to verify that the bindist installation
works in this situation.

Fixes #24951

- - - - -
5759133f by Hécate Kleidukos at 2024-06-22T10:42:49-04:00
haddock: Use the more precise SDocContext instead of DynFlags

The pervasive usage of DynFlags (the parsed command-line options passed
to ghc) blurs the border between different components of Haddock, and
especially those that focus solely on printing text on the screen.

In order to improve the understanding of the real dependencies of a
function, the pretty-printer options are made concrete earlier in the
pipeline instead of late when pretty-printing happens.

This also has the advantage of clarifying which functions actually
require DynFlags for purposes other than pretty-printing, thus making
the interactions between Haddock and GHC more understandable when
exploring the code base.

See Henry, Ericson, Young. "Modularizing GHC".
https://hsyl20.fr/home/files/papers/2022-ghc-modularity.pdf. 2022

- - - - -
749e089b by Alexander McKenna at 2024-06-22T10:43:24-04:00
Add INLINE [1] pragma to compareInt / compareWord

To allow rules to be written on the concrete implementation of
`compare` for `Int` and `Word`, we need to have an `INLINE [1]`
pragma on these functions, following the
`matching_overloaded_methods_in_rules` note in `GHC.Classes`.

CLC proposal https://github.com/haskell/core-libraries-committee/issues/179

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

- - - - -
db033639 by Rodrigo Mesquita at 2024-06-24T17:21:15-04:00
ci: Enable strict ghc-toolchain setting for bindists

- - - - -
14308a8f by Rodrigo Mesquita at 2024-06-24T17:21:15-04:00
ghc-toolchain: Improve parse failure error

Improves the error message for when `ghc-toolchain` fails to read a
valid `Target` value from a file (in doFormat mode).

- - - - -
6e7cfff1 by Rodrigo Mesquita at 2024-06-24T17:21:15-04:00
bindist: ghc-toolchain related options in configure

- - - - -
958d6931 by Matthew Pickering at 2024-06-24T17:21:15-04:00
ci: Fail when bindist configure fails when installing bindist

It is better to fail earlier if the configure step fails rather than
carrying on for a more obscure error message.

- - - - -
f48d157d by Rodrigo Mesquita at 2024-06-24T17:21:15-04:00
ghc-toolchain: Fix error logging indentation

- - - - -
f1397104 by Rodrigo Mesquita at 2024-06-24T17:21:15-04:00
bindist: Correct default.target substitution

The substitution on `default.target.in` must be done after
`PREP_TARGET_FILE` is called -- that macro is responsible for
setting the variables that will be effectively substituted in the target
file. Otherwise, the target file is invalid.

Fixes #24792 #24574

- - - - -
665e653e by Rodrigo Mesquita at 2024-06-24T17:21:15-04:00
configure: Prefer tool name over tool path

It is non-obvious whether the toolchain configuration should use
full-paths to tools or simply their names. In addressing #24574, we've
decided to prefer executable names over paths, ultimately, because the
bindist configure script already does this, thus is the default in ghcs
out there.

Updates the in-tree configure script to prefer tool names
(`AC_CHECK_TOOL` rather than `AC_PATH_TOOL`) and `ghc-toolchain` to
ignore the full-path-result of `findExecutable`, which it previously
used over the program name.

This change doesn't undo the fix in bd92182cd56140ffb2f68ec01492e5aa6333a8fc
because `AC_CHECK_TOOL` still takes into account the target triples,
unlike `AC_CHECK_PROG/AC_PATH_PROG`.

- - - - -
463716c2 by Rodrigo Mesquita at 2024-06-24T17:21:15-04:00
dist: Don't forget to configure JavascriptCPP

We introduced a configuration step for the javascript preprocessor, but
only did so for the in-tree configure script.

This commit makes it so that we also configure the javascript
preprocessor in the configure shipped in the compiler bindist.

- - - - -
e99cd73d by Rodrigo Mesquita at 2024-06-24T17:21:15-04:00
distrib: LlvmTarget in distrib/configure

LlvmTarget was being set and substituted in the in-tree configure, but
not in the configure shipped in the bindist.

We want to set the LlvmTarget to the canonical LLVM name of the platform
that GHC is targetting.

Currently, that is going to be the boostrapped llvm target (hence the
code which sets LlvmTarget=bootstrap_llvm_target).

- - - - -
4199aafe by Matthew Pickering at 2024-06-24T17:21:51-04:00
Update bootstrap plans for recent GHC versions (9.6.5, 9.8.2, 9.10.10)

- - - - -
f599d816 by Matthew Pickering at 2024-06-24T17:21:51-04:00
ci: Add 9_10 bootstrap testing job

- - - - -
8f4b799d by Hécate Kleidukos at 2024-06-24T17:22:30-04:00
haddock: Move the usage of mkParserOpts directly to ppHyperlinkedModuleSource in order to avoid passing a whole DynFlags

Follow up to !12931

- - - - -
210cf1cd by Hécate Kleidukos at 2024-06-24T17:22:30-04:00
haddock: Remove cabal file linting rule

This will be reintroduced with a properly ignored commit
when the cabal files are themselves formatted for good.

- - - - -
7fe85b13 by Peter Trommler at 2024-06-24T22:03:41-04:00
PPC NCG: Fix sign hints in C calls

Sign hints for parameters are in the second component of the pair.

Fixes #23034

- - - - -
949a0e0b by Andrew Lelechenko at 2024-06-24T22:04:17-04:00
base: fix missing changelog entries

- - - - -
1bfa9111 by Andreas Klebinger at 2024-06-26T21:49:53-04:00
GHCi interpreter: Tag constructor closures when possible.

When evaluating PUSH_G try to tag the reference we are pushing if it's a
constructor. This is potentially helpful for performance and required to
fix #24870.

- - - - -
caf44a2d by Andrew Lelechenko at 2024-06-26T21:50:30-04:00
Implement Data.List.compareLength and Data.List.NonEmpty.compareLength

`compareLength xs n` is a safer and faster alternative to `compare (length xs) n`.
The latter would force and traverse the entire spine (potentially diverging),
while the former traverses as few elements as possible.

The implementation is carefully designed to maintain as much laziness as possible.

As per https://github.com/haskell/core-libraries-committee/issues/257

- - - - -
f4606ae0 by Serge S. Gulin at 2024-06-26T21:51:05-04:00
Unicode: adding compact version of GeneralCategory (resolves #24789)

The following features are applied:
1. Lookup code like Cmm-switches (draft implementation proposed by Sylvain Henry @hsyl20)
2. Nested ifs (logarithmic search vs linear search) (the idea proposed by Sylvain Henry @hsyl20)

-------------------------
Metric Decrease:
    size_hello_artifact
    size_hello_unicode
-------------------------

- - - - -
0e424304 by Hécate Kleidukos at 2024-06-26T21:51:44-04:00
haddock: Restructure import statements

This commit removes idiosyncrasies that have accumulated with the years
in how import statements were laid out, and defines clear but simple
guidelines in the CONTRIBUTING.md file.

- - - - -
9b8ddaaf by Arnaud Spiwack at 2024-06-26T21:52:23-04:00
Rename test for #24725

I must have fumbled my tabs when I copy/pasted the issue number in
8c87d4e1136ae6d28e92b8af31d78ed66224ee16.

- - - - -
b0944623 by Arnaud Spiwack at 2024-06-26T21:52:23-04:00
Add original reproducer for #24725

- - - - -
77ce65a5 by Matthew Pickering at 2024-06-27T07:57:14-04:00
Expand LLVM version matching regex for compability with bsd systems

sed on BSD systems (such as darwin) does not support the + operation.

Therefore we take the simple minded approach of manually expanding
group+ to groupgroup*.

Fixes #24999

- - - - -
bdfe4a9e by Matthew Pickering at 2024-06-27T07:57:14-04:00
ci: On darwin configure LLVMAS linker to match LLC and OPT toolchain

The version check was previously broken so the toolchain was not
detected at all.

- - - - -
07e03a69 by Matthew Pickering at 2024-06-27T07:57:15-04:00
Update nixpkgs commit for darwin toolchain

One dependency (c-ares) changed where it hosted the releases which
breaks the build with the old nixpkgs commit.

- - - - -
144afed7 by Rodrigo Mesquita at 2024-06-27T07:57:50-04:00
base: Add changelog entry for #24998

- - - - -
eebe1658 by Sylvain Henry at 2024-06-28T07:13:26-04:00
X86/DWARF: support no tables-next-to-code and asm-shortcutting (#22792)

- Without TNTC (tables-next-to-code), we must be careful to not
  duplicate labels in pprNatCmmDecl. Especially, as a CmmProc is
  identified by the label of its entry block (and not of its info
  table), we can't reuse the same label to delimit the block end and the
  proc end.

- We generate debug infos from Cmm blocks. However, when
  asm-shortcutting is enabled, some blocks are dropped at the asm
  codegen stage and some labels in the DebugBlocks become missing.
  We fix this by filtering the generated debug-info after the asm
  codegen to only keep valid infos.

Also add some related documentation.

- - - - -
6e86d82b by Sylvain Henry at 2024-06-28T07:14:06-04:00
PPC NCG: handle JMP to ForeignLabels (#23969)

- - - - -
9e4b4b0a by Sylvain Henry at 2024-06-28T07:14:06-04:00
PPC NCG: support loading 64-bit value on 32-bit arch (#23969)

- - - - -
50caef3e by Sylvain Henry at 2024-06-28T07:14:46-04:00
Fix warnings in genapply

- - - - -
37139b17 by Matthew Pickering at 2024-06-28T07:15:21-04:00
libraries: Update os-string to 2.0.4

This updates the os-string submodule to 2.0.4 which removes the usage of
`TemplateHaskell` pragma.

- - - - -
0f3d3bd6 by Sylvain Henry at 2024-06-30T00:47:40-04:00
Bump array submodule

- - - - -
354c350c by Sylvain Henry at 2024-06-30T00:47:40-04:00
GHCi: Don't use deprecated sizeofMutableByteArray#

- - - - -
35d65098 by Ben Gamari at 2024-06-30T00:47:40-04:00
primops: Undeprecate addr2Int# and int2Addr#

addr2Int# and int2Addr# were marked as deprecated with the introduction
of the OCaml code generator (1dfaee318171836b32f6b33a14231c69adfdef2f)
due to its use of tagged integers. However, this backend has long
vanished and `base` has all along been using `addr2Int#` in the Show
instance for Ptr.

While it's unlikely that we will have another backend which has tagged
integers, we may indeed support platforms which have tagged pointers.
Consequently we undeprecate the operations but warn the user that the
operations may not be portable.

- - - - -
3157d817 by Sylvain Henry at 2024-06-30T00:47:41-04:00
primops: Undeprecate par#

par# is still used in base and it's not clear how to replace it with
spark# (see #24825)

- - - - -
c8d5b959 by Ben Gamari at 2024-06-30T00:47:41-04:00
Primops: Make documentation generation more efficient

Previously we would do a linear search through all primop names, doing a
String comparison on the name of each when preparing the HsDocStringMap.
Fix this.

- - - - -
65165fe4 by Ben Gamari at 2024-06-30T00:47:41-04:00
primops: Ensure that deprecations are properly tracked

We previously failed to insert DEPRECATION pragmas into GHC.Prim's
ModIface, meaning that they would appear in the Haddock documentation
but not issue warnings. Fix this.

See #19629. Haddock also needs to be fixed: https://github.com/haskell/haddock/issues/223

Co-authored-by: Sylvain Henry <sylvain at haskus.fr>

- - - - -
bc1d435e by Mario Blažević at 2024-06-30T00:48:20-04:00
Improved pretty-printing of unboxed TH sums and tuples, fixes #24997

- - - - -
0d170eaf by Zubin Duggal at 2024-07-04T11:08:41-04:00
compiler: Turn `FinderCache` into a record of operations so that GHC API clients can
have full control over how its state is managed by overriding `hsc_FC`.

Also removes the `uncacheModule` function as this wasn't being used by anything
since 1893ba12fe1fa2ade35a62c336594afcd569736e

Fixes #23604

- - - - -
4664997d by Teo Camarasu at 2024-07-04T11:09:18-04:00
Add HasCallStack to T23221

This makes the test a bit easier to debug

- - - - -
66919dcc by Teo Camarasu at 2024-07-04T11:09:18-04:00
rts: use live words to estimate heap size

We use live words rather than live blocks to determine the size of the
heap for determining memory retention.

Most of the time these two metrics align, but they can come apart in
normal usage when using the nonmoving collector.

The nonmoving collector leads to a lot of partially occupied blocks. So,
using live words is more accurate.

They can also come apart when the heap is suffering from high levels
fragmentation caused by small pinned objects, but in this case, the
block size is the more accurate metric. Since this case is best avoided
anyway. It is ok to accept the trade-off that we might try (and
probably) fail to return more memory in this case.

See also the Note [Statistics for retaining memory]

Resolves #23397

- - - - -
8dfca66a by Oleg Grenrus at 2024-07-04T11:09:55-04:00
Add reflections of GHC.TypeLits/Nats type families

-------------------------
Metric Increase:
    ghc_experimental_dir
    ghc_experimental_so
-------------------------

- - - - -
6c469bd2 by Adam Gundry at 2024-07-04T11:10:33-04:00
Correct -Wpartial-fields warning to say "Definition" rather than "Use"

Fixes #24710.  The message and documentation for `-Wpartial-fields` were
misleading as (a) the warning occurs at definition sites rather than use
sites, and (b) the warning relates to the definition of a field independently
of the selector function (e.g. because record updates are also partial).

- - - - -
977b6b64 by Max Ulidtko at 2024-07-04T11:11:11-04:00
GHCi: Support local Prelude

Fixes #10920, an issue where GHCi bails out when started alongside a
file named Prelude.hs or Prelude.lhs (even empty file suffices).

The in-source Note [GHCi and local Preludes] documents core reasoning.

Supplementary changes:

 * add debug traces for module lookups under -ddump-if-trace;
 * drop stale comment in GHC.Iface.Load;
 * reduce noise in -v3 traces from GHC.Utils.TmpFs;
 * new test, which also exercizes HomeModError.

- - - - -
87cf4111 by Ryan Scott at 2024-07-04T11:11:47-04:00
Add missing gParPat in cvtp's ViewP case

When converting a `ViewP` using `cvtp`, we need to ensure that the view pattern
is parenthesized so that the resulting code will parse correctly when
roundtripped back through GHC's parser.

Fixes #24894.

- - - - -
b05613c5 by Adam Gundry at 2024-07-04T11:12:23-04:00
Use structured error representation for module cycle errors (see #18516)

This removes the re-export of cyclicModuleErr from the top-level GHC module.

- - - - -
70389749 by Adam Gundry at 2024-07-04T11:12:23-04:00
Use structured error representation when reloading a nonexistent module

- - - - -
680ade3d by sheaf at 2024-07-04T11:12:23-04:00
Use structured errors for a Backpack instantiation error

- - - - -
97c6d6de by sheaf at 2024-07-04T11:12:23-04:00
Move mkFileSrcSpan to GHC.Unit.Module.Location

- - - - -
f9e7bd9b by Adriaan Leijnse at 2024-07-04T11:12:59-04:00
ttg: Remove SourceText from OverloadedLabel

Progress towards #21592

- - - - -
00d63245 by Alexander Foremny at 2024-07-04T11:12:59-04:00
AST: GHC.Prelude -> Prelude

Refactor occurrences to GHC.Prelude with Prelude within
Language/Haskell.

Progress towards #21592

- - - - -
cc846ea5 by Alexander Foremny at 2024-07-04T11:12:59-04:00
AST: remove occurrences of GHC.Unit.Module.ModuleName

`GHC.Unit.Module` re-exports `ModuleName` from
`Language.Haskell.Syntax.Module.Name`.

Progress towards #21592

- - - - -
24c7d287 by Fabian Kirchner at 2024-07-04T11:12:59-04:00
AST: move Data instance definition for ModuleName to GHC.Unit.Types

To remove the dependency on GHC.Utils.Misc inside
Language.Haskell.Syntax.Module.Name, the instance definition is moved
from there into GHC.Unit.Types.

Progress towards #21592

- - - - -
6cbba381 by Fabian Kirchner at 2024-07-04T11:12:59-04:00
AST: move negateOverLitVal into GHC.Hs.Lit

The function negateOverLitVal is not used within Language.Haskell and
therefore can be moved to the respective module inside GHC.Hs.

Progress towards #21592

- - - - -
611aa7c6 by Fabian Kirchner at 2024-07-04T11:12:59-04:00
AST: move conDetailsArity into GHC.Rename.Module

The function conDetailsArity is only used inside GHC.Rename.Module.  We
therefore move it there from Language.Haskell.Syntax.Lit.

Progress towards #21592

- - - - -
1b968d16 by Mauricio at 2024-07-04T11:12:59-04:00
AST: Remove GHC.Utils.Assert from GHC

Simple cleanup.

Progress towards #21592

- - - - -
3d192e5d by Fabian Kirchner at 2024-07-04T11:12:59-04:00
ttg: extract Specificity, ForAllTyFlag and helper functions from GHC.Types.Var

Progress towards #21592

Specificity, ForAllTyFlag and its' helper functions are extracted from
GHC.Types.Var and moved into a new module Language.Haskell.Syntax.Specificity.

Note: Eventually (i.e. after Language.Haskell.Syntax.Decls does not depend on
GHC.* anymore) these should be moved into Language.Haskell.Syntax.Decls.
At this point, this would cause cyclic dependencies.

- - - - -
257d1adc by Adowrath at 2024-07-04T11:12:59-04:00
ttg: Split HsSrcBang, remove ref to DataCon from Syntax.Type

Progress towards #21592

This splits HsSrcBang up, creating the new HsBang within
`Language.Haskell.Syntax.Basic`. `HsBang` holds the unpackedness
and strictness information, while `HsSrcBang` only adds the SourceText
for usage within the compiler directly.

Inside the AST, to preserve the SourceText, it is hidden behind the
pre-existing extension point `XBindTy`. All other occurrences of
`HsSrcBang` were adapted to deconstruct the inner `HsBang`, and when
interacting with the `BindTy` constructor, the hidden `SourceText` is
extracted/inserted into the `XBindTy` extension point.

`GHC.Core.DataCon` exports both `HsSrcBang` and `HsBang` for
convenience. A constructor function `mkHsSrcBang` that takes all
individual components has been added.

Two exceptions has been made though:
- The `Outputable HsSrcBang` instance is replaced by
  `Outputable HsBang`. While being only GHC-internal, the only place
  it's used is in outputting `HsBangTy` constructors -- which already
  have `HsBang`. It wouldn't make sense to reconstruct a `HsSrcBang` just
  to ignore the `SourceText` anyway.
- The error `TcRnUnexpectedAnnotation` did not use the `SourceText`,
  so it too now only holds a `HsBang`.

- - - - -
24757fec by Mauricio at 2024-07-04T11:12:59-04:00
AST: Moved definitions that use GHC.Utils.Panic to GHC namespace

Progress towards #21592

- - - - -
9be49379 by Mike Pilgrem at 2024-07-04T11:13:41-04:00
Fix #25032 Refer to Cabal's `includes` field, not `include-files`

- - - - -
9e2ecf14 by Andrew Lelechenko at 2024-07-04T11:14:17-04:00
base: fix more missing changelog entries

- - - - -
a82121b3 by Peter Trommler at 2024-07-04T11:14:53-04:00
X86 NCG: Fix argument promotion in foreign C calls

Promote 8 bit and 16 bit signed arguments by sign extension.

Fixes #25018

- - - - -
fab13100 by Bryan Richter at 2024-07-04T11:15:29-04:00
Add .gitlab/README.md with creds instructions

- - - - -
564981bd by Matthew Pickering at 2024-07-05T07:35:29-04:00
configure: Set LD_STAGE0 appropiately when 9.10.1 is used as a boot compiler

In 9.10.1 the "ld command" has been removed, so we fall back to using
the more precise "merge objects command" when it's available as
LD_STAGE0 is only used to set the object merging command in hadrian.

Fixes #24949

- - - - -
a949c792 by Matthew Pickering at 2024-07-05T07:35:29-04:00
hadrian: Don't build ghci object files for ./hadrian/ghci target

There is some convoluted logic which determines whether we build ghci
object files are not. In any case, if you set `ghcDynPrograms = pure
False` then it forces them to be built.

Given we aren't ever building executables with this flavour it's fine
to leave `ghcDynPrograms` as the default and it should be a bit faster
to build less.

Also fixes #24949

- - - - -
48bd8f8e by Matthew Pickering at 2024-07-05T07:36:06-04:00
hadrian: Remove STG dump from ticky_ghc flavour transformer

This adds 10-15 minutes to build time, it is a better strategy to
precisely enable dumps for the modules which show up prominently in a
ticky profile.

Given I am one of the only people regularly building ticky compilers I
think it's worthwhile to remove these.

Fixes #23635

- - - - -
5b1aefb7 by Matthew Pickering at 2024-07-05T07:36:06-04:00
hadrian: Add dump_stg flavour transformer

This allows you to write `--flavour=default+ticky_ghc+dump_stg` if you
really want STG for all modules.

- - - - -
ab2b60b6 by Sven Tennie at 2024-07-08T15:03:41-04:00
AArch64: Simplify stmtToInstrs type

There's no need to hand `Nothing`s around... (there was no case with a
`BlockId`.)

- - - - -
71a7fa8c by Sven Tennie at 2024-07-08T15:03:41-04:00
AArch64: Simplify stmtsToInstrs type

The `BlockId` parameter (`bid`) is never used, only handed around.
Deleting it simplifies the surrounding code.

- - - - -
8bf6fd68 by Simon Peyton Jones at 2024-07-08T15:04:17-04:00
Fix eta-expansion in Prep

As #25033 showed, we were eta-expanding in a way that broke a join point,
which messed up Note [CorePrep invariants].

The fix is rather easy.  See Wrinkle (EA1) of
Note [Eta expansion of arguments in CorePrep]

- - - - -
96acf823 by Sjoerd Visscher at 2024-07-09T06:16:14-04:00
One-shot Haddock

- - - - -
74ec4c06 by Sjoerd Visscher at 2024-07-09T06:16:14-04:00
Remove haddock-stdout test option

Superseded by output handling of Hadrian

- - - - -
ed8a8f0b by Rodrigo Mesquita at 2024-07-09T06:16:51-04:00
ghc-boot: Relax Cabal bound

Fixes #25013

- - - - -
3f9548fe by Matthew Pickering at 2024-07-09T06:17:36-04:00
ci: Unset ALEX/HAPPY variables when testing bootstrap jobs

Ticket #24826 reports a regression in 9.10.1 when building from a source
distribution. This patch is an attempt to reproduce the issue on CI by
more aggressively removing `alex` and `happy` from the environment.

- - - - -
aba2c9d4 by Andrea Bedini at 2024-07-09T06:17:36-04:00
hadrian: Ignore build-tool-depends fields in cabal files

hadrian does not utilise the build-tool-depends fields in cabal files
and their presence can cause issues when building source distribution
(see #24826)

Ideally Cabal would support building "full" source distributions which
would remove the need for workarounds in hadrian but for now we can
patch the build-tool-depends out of the cabal files.

Fixes #24826

- - - - -
12bb9e7b by Matthew Pickering at 2024-07-09T06:18:12-04:00
testsuite: Don't attempt to link when checking whether a way is supported

It is sufficient to check that the simple test file compiles as it will
fail if there are not the relevant library files for the requested way.

If you break a way so badly that even a simple executable fails to link
(as I did for profiled dynamic way), it will just mean the tests for
that way are skipped on CI rather than displayed.

- - - - -
46ec0a8e by Torsten Schmits at 2024-07-09T13:37:02+02:00
Improve docs for NondecreasingIndentation

The text stated that this affects indentation of layouts nested in do
expressions, while it actually affects that of do layouts nested in any
other.

- - - - -
dddc9dff by Zubin Duggal at 2024-07-12T11:41:24-04:00
compiler: Fingerprint -fwrite-if-simplified-core

We need to recompile if this flag is changed because later modules might depend on the
simplified core for this module if -fprefer-bytecode is enabled.

Fixes #24656

- - - - -
145a6477 by Matthew Pickering at 2024-07-12T11:42:00-04:00
Add support for building profiled dynamic way

The main payload of this change is to hadrian.

* Default settings will produced dynamic profiled objects
* `-fexternal-interpreter` is turned on in some situations when there is
  an incompatibility between host GHC and the way attempting to be
  built.
* Very few changes actually needed to GHC

There are also necessary changes to the bootstrap plans to work with the
vendored Cabal dependency. These changes should ideally be reverted by
the next GHC release.

In hadrian support is added for building profiled dynamic libraries
(nothing too exciting to see there)

Updates hadrian to use a vendored Cabal submodule, it is important that
we replace this usage with a released version of Cabal library before
the 9.12 release.

Fixes #21594

-------------------------
Metric Increase:
    libdir
-------------------------

- - - - -
414a6950 by Matthew Pickering at 2024-07-12T11:42:00-04:00
testsuite: Make find_so regex more precise

The hash contains lowercase [a-z0-9] and crucially not _p which meant we
sometimes matched on `libHS.._p` profiled shared libraries rather than
the normal shared library.

- - - - -
dee035bf by Alex Mason at 2024-07-12T11:42:41-04:00
ncg(aarch64): Add fsqrt instruction, byteSwap primitives [#24956]

Implements the FSQRT machop using native assembly rather than a C call.

Implements MO_BSwap by producing assembly to do the byte swapping
instead of producing a foreign call a C function.

In `tar`, the hot loop for `deserialise` got almost 4x faster by
avoiding the foreign call which caused spilling live variables to the
stack -- this means the loop did 4x more memory read/writing than
necessary in that particular case!

- - - - -
5104ee61 by Sylvain Henry at 2024-07-12T11:43:23-04:00
Linker: use m32 allocator for sections when NEED_PLT (#24432)

Use M32 allocator to avoid fragmentation when allocating ELF sections.
We already did this when NEED_PLT was undefined. Failing to do this led
to relocations impossible to fulfil (#24432).

- - - - -
52d66984 by Sylvain Henry at 2024-07-12T11:43:23-04:00
RTS: allow M32 allocation outside of 4GB range when assuming -fPIC

- - - - -
c34fef56 by Sylvain Henry at 2024-07-12T11:43:23-04:00
Linker: fix stub offset

Remove unjustified +8 offset that leads to memory corruption (cf
discussion in #24432).

- - - - -
280e4bf5 by Simon Peyton Jones at 2024-07-12T11:43:59-04:00
Make type-equality on synonyms a bit faster

This MR make equality fast for (S tys1 `eqType` S tys2),
where S is a non-forgetful type synonym.

It doesn't affect compile-time allocation much, but then comparison doesn't
allocate anyway.  But it seems like a Good Thing anyway.

See Note [Comparing type synonyms] in GHC.Core.TyCo.Compare
and Note [Forgetful type synonyms] in GHC.Core.TyCon

Addresses #25009.

- - - - -
cb83c347 by Alan Zimmerman at 2024-07-12T11:44:35-04:00
EPA: Bring back SrcSpan in EpaDelta

When processing files in ghc-exactprint, the usual workflow is to
first normalise it with makeDeltaAst, and then operate on it.

But we need the original locations to operate on it, in terms of
finding things.

So restore the original SrcSpan for reference in EpaDelta

- - - - -
7bcda869 by Matthew Pickering at 2024-07-12T11:45:11-04:00
Update alpine release job to 3.20

alpine 3.20 was recently released and uses a new python and sphinx
toolchain which could be useful to test.

- - - - -
43aa99b8 by Matthew Pickering at 2024-07-12T11:45:11-04:00
testsuite: workaround bug in python-3.12

There is some unexplained change to binding behaviour in python-3.12
which requires moving this import from the top-level into the scope of
the function.

I didn't feel any particular desire to do a deep investigation as to why
this changed as the code works when modified like this. No one in the
python IRC channel seemed to know what the problem was.

- - - - -
e3914028 by Adam Sandberg Ericsson at 2024-07-12T11:45:47-04:00
initialise mmap_32bit_base during RTS startup #24847
- - - - -
86b8ecee by Hécate Kleidukos at 2024-07-12T11:46:27-04:00
haddock: Only fetch supported languages and extensions once per Interface list

This reduces the number of operations done on each Interface, because
supported languages and extensions are determined from architecture and
operating system of the build host. This information remains stable
across Interfaces, and as such doesn not need to be recovered for each
Interface.

- - - - -
4f85366f by sheaf at 2024-07-13T05:58:14-04:00
Testsuite: use py-cpuinfo to compute CPU features

This replaces the rather hacky logic we had in place for checking
CPU features. In particular, this means that feature availability now
works properly on Windows.

- - - - -
41f1354d by Matthew Pickering at 2024-07-13T05:58:51-04:00
testsuite: Replace $CC with $TEST_CC

The TEST_CC variable should be set based on the test compiler, which may
be different to the compiler which is set to CC on your system (for
example when cross compiling).

Fixes #24946

- - - - -
572fbc44 by sheaf at 2024-07-15T08:30:32-04:00
isIrrefutableHsPat: consider COMPLETE pragmas

This patch ensures we taken into account COMPLETE pragmas when we
compute whether a pattern is irrefutable. In particular, if a pattern
synonym is the sole member of a COMPLETE pragma (without a result TyCon),
then we consider a pattern match on that pattern synonym to be irrefutable.

This affects the desugaring of do blocks, as it ensures we don't use
a "fail" operation.

Fixes #15681 #16618 #22004

- - - - -
84dadea9 by Zubin Duggal at 2024-07-15T08:31:09-04:00
haddock: Handle non-hs files, so that haddock can generate documentation for modules with
foreign imports and template haskell.

Fixes #24964

- - - - -
0b4ff9fa by Zubin Duggal at 2024-07-15T12:12:30-04:00
haddock: Keep track of warnings/deprecations from dependent packages in `InstalledInterface`
and use this to propagate these on items re-exported from dependent packages.

Fixes #25037

- - - - -
b8b4b212 by Zubin Duggal at 2024-07-15T12:12:30-04:00
haddock: Keep track of instance source locations in `InstalledInterface` and use this to add
source locations on out of package instances

Fixes #24929

- - - - -
559a7a7c by Matthew Pickering at 2024-07-15T12:13:05-04:00
ci: Refactor job_groups definition, split up by platform

The groups are now split up so it's easier to see which jobs are
generated for each platform

No change in behaviour, just refactoring.

- - - - -
20383006 by Matthew Pickering at 2024-07-16T11:48:25+01:00
ci: Replace debian 10 with debian 12 on validation jobs

Since debian 10 is now EOL we migrate onwards to debian 12 as the basis
for most platform independent validation jobs.

- - - - -
12d3b66c by Matthew Pickering at 2024-07-17T13:22:37-04:00
ghcup-metadata: Fix use of arch argument

The arch argument was ignored when making the jobname, which lead to
failures when generating metadata for the alpine_3_18-aarch64 bindist.

Fixes #25089

- - - - -
bace981e by Matthew Pickering at 2024-07-19T10:14:02-04:00
testsuite: Delay querying ghc-pkg to find .so dirs until test is run

The tests which relied on find_so would fail when `test` was run
before the tree was built. This was because `find_so` was evaluated too
eagerly.

We can fix this by waiting to query the location of the libraries until
after the compiler has built them.

- - - - -
478de1ab by Torsten Schmits at 2024-07-19T10:14:37-04:00
Add `complete` pragmas for backwards compat patsyns `ModLocation` and `ModIface`

!12347 and !12582 introduced breaking changes to these two constructors
and mitigated that with pattern synonyms.

- - - - -
b57792a8 by Matthew Pickering at 2024-07-19T10:15:13-04:00
ci: Fix ghcup-metadata generation (again)

I made some mistakes in 203830065b81fe29003c1640a354f11661ffc604

* Syntax error
* The aarch-deb11 bindist doesn't exist

I tested against the latest nightly pipeline locally:

```
nix run .gitlab/generate-ci#generate-job-metadata
nix shell -f .gitlab/rel_eng/ -c ghcup-metadata --pipeline-id 98286 --version 9.11.20240715 --fragment --date 2024-07-17 --metadata=/tmp/meta
```

- - - - -
1fa35b64 by Andreas Klebinger at 2024-07-19T17:35:20+02:00
Revert "Allow non-absolute values for bootstrap GHC variable"

This broke configure in subtle ways resulting in #25076 where hadrian
didn't end up the boot compiler it was configured to use.

This reverts commit 209d09f52363b261b900cf042934ae1e81e2caa7.

- - - - -
55117e13 by Simon Peyton Jones at 2024-07-24T02:41:12-04:00
Fix bad bug in mkSynonymTyCon, re forgetfulness

As #25094 showed, the previous tests for forgetfulness was
plain wrong, when there was a forgetful synonym in the RHS
of a synonym.

- - - - -
a8362630 by Sergey Vinokurov at 2024-07-24T12:22:45-04:00
Define Eq1, Ord1, Show1 and Read1 instances for basic Generic representation types

This way the Generically1 newtype could be used to derive Eq1 and Ord1
for user types with DerivingVia.

The CLC proposal is https://github.com/haskell/core-libraries-committee/issues/273.

The GHC issue is https://gitlab.haskell.org/ghc/ghc/-/issues/24312.

- - - - -
de5d9852 by Simon Peyton Jones at 2024-07-24T12:23:22-04:00
Address #25055, by disabling case-of-runRW# in Gentle phase

See Note [Case-of-case and full laziness]
in GHC.Driver.Config.Core.Opt.Simplify

- - - - -
3f89ab92 by Andreas Klebinger at 2024-07-25T14:12:54+02:00
Fix -freg-graphs for FP and AARch64 NCG (#24941).

It seems we reserve 8 registers instead of four for global regs
based on the layout in Note [AArch64 Register assignments].

I'm not sure it's neccesary, but for now we just accept this state of
affairs and simple update -fregs-graph to account for this.

- - - - -
f6b4c1c9 by Simon Peyton Jones at 2024-07-27T09:45:44-04:00
Fix nasty bug in occurrence analyser

As #25096 showed, the occurrence analyser was getting one-shot info
flat out wrong.

This commit does two things:

* It fixes the bug and actually makes the code a bit tidier too.
  The work is done in the new function
     GHC.Core.Opt.OccurAnal.mkRhsOccEnv,
  especially the bit that prepares the `occ_one_shots` for the RHS.

  See Note [The OccEnv for a right hand side]

* When floating out a binding we must be conservative about one-shot
  info.  But we were zapping the entire demand info, whereas we only
  really need zap the /top level/ cardinality.

  See Note [Floatifying demand info when floating]
  in GHC.Core.Opt.SetLevels

For some reason there is a 2.2% improvement in compile-time allocation
for CoOpt_Read.  Otherwise nickels and dimes.

Metric Decrease:
    CoOpt_Read

- - - - -
646ee207 by Torsten Schmits at 2024-07-27T09:46:20-04:00
add missing cell in flavours table

- - - - -
ec2eafdb by Ben Gamari at 2024-07-28T20:51:12+02:00
users-guide: Drop mention of dead __PARALLEL_HASKELL__ macro

This has not existed for over a decade.

- - - - -
e2f2a56e by Arnaud Spiwack at 2024-07-28T22:21:07-04:00
Add tests for 25081

- - - - -
23f50640 by Arnaud Spiwack at 2024-07-28T22:21:07-04:00
Scale multiplicity in list comprehension

Fixes #25081

- - - - -
d2648289 by romes at 2024-07-30T01:38:12-04:00
TTG HsCmdArrForm: use Fixity via extension point

Also migrate Fixity from GHC.Hs to Language.Haskell.Syntax
since it no longer uses any GHC-specific data types.

Fixed arrow desugaring bug. (This was dead code before.)
Remove mkOpFormRn, it is also dead code, only used in the arrow
desugaring now removed.

Co-authored-by: Fabian Kirchner <kirchner at posteo.de>
Co-authored-by: Alan Zimmerman <alan.zimm at gmail.com>

- - - - -
e258ad54 by Matthew Pickering at 2024-07-30T01:38:48-04:00
ghcup-metadata: More metadata fixes

* Incorrect version range on the alpine bindists
* Missing underscore in "unknown_versioning"

Fixes #25119

- - - - -
72b54c07 by Rodrigo Mesquita at 2024-08-01T00:47:29-04:00
Deriving-via one-shot strict state Monad instances

A small refactor to use deriving via GHC.Utils.Monad.State.Strict
Monad instances for state Monads with unboxed/strict results which all
re-implemented the one-shot trick in the instance and used unboxed
tuples:

* CmmOptM in GHC.Cmm.GenericOpt
* RegM in GHC.CmmToAsm.Reg.Linear.State
* UniqSM in GHC.Types.Unique.Supply

- - - - -
bfe4b3d3 by doyougnu at 2024-08-01T00:48:06-04:00
Rts linker: add case for pc-rel 64 relocation

part of the upstream haskell.nix patches

- - - - -
5843c7e3 by doyougnu at 2024-08-01T00:48:42-04:00
RTS linker: aarch64: better debug information

Dump better debugging information when a symbol address is null.

Part of the haskell.nix patches upstream project

Co-authored-by: Sylvain Henry <sylvain at haskus.fr>

- - - - -
c2e9c581 by Rodrigo Mesquita at 2024-08-01T00:49:18-04:00
base: Add haddocks to HasExceptionContext

Fixes #25091

- - - - -
f954f428 by Sylvain Henry at 2024-08-01T00:49:59-04:00
Only lookup ghcversion.h file in the RTS include-dirs by default.

The code was introduced in 3549c952b535803270872adaf87262f2df0295a4.
It used `getPackageIncludePath` which name doesn't convey that it looks
into all include paths of the preload units too. So this behavior is
probably unintentional and it should be ok to change it.

Fix #25106

- - - - -
951ce3d5 by Matthew Pickering at 2024-08-01T00:50:35-04:00
driver: Fix -Wmissing-home-modules when multiple units have the same module name

It was assumed that module names were unique but that isn't true with
multiple units.

The fix is quite simple, maintain a set of `(ModuleName, UnitId)` and
query that to see whether the module has been specified.

Fixes #25122

- - - - -
bae1fea4 by sheaf at 2024-08-01T00:51:15-04:00
PMC: suggest in-scope COMPLETE sets when possible

This commit modifies GHC.HsToCore.Pmc.Solver.generateInhabitingPatterns
to prioritise reporting COMPLETE sets in which all of the ConLikes
are in scope. This avoids suggesting out of scope constructors
when displaying an incomplete pattern match warning, e.g. in

  baz :: Ordering -> Int
  baz = \case
    EQ -> 5

we prefer:

  Patterns of type 'Ordering' not matched:
      LT
      GT

over:

  Patterns of type 'Ordering' not matched:
      OutOfScope

Fixes #25115

- - - - -
ff158fcd by Tommy Bidne at 2024-08-02T01:14:32+12:00
Print exception metadata in default handler

CLC proposals 231 and 261:

- Add exception type metadata to SomeException's displayException.
- Add "Exception" header to default exception handler.

See:

https://github.com/haskell/core-libraries-committee/issues/231
https://github.com/haskell/core-libraries-committee/issues/261

Update stm submodule for test fixes.

- - - - -
8b2f70a2 by Andrei Borzenkov at 2024-08-01T23:00:46-04:00
Type syntax in expressions (#24159, #24572, #24226)

This patch extends the grammar of expressions with syntax that is
typically found only in types:
  * function types (a -> b), (a ->. b), (a %m -> b)
  * constrained types (ctx => t)
  * forall-quantification (forall tvs. t)

The new forms are guarded behind the RequiredTypeArguments extension,
as specified in GHC Proposal #281. Examples:

  {-# LANGUAGE RequiredTypeArguments #-}
  e1 = f (Int    -> String)          -- function type
  e2 = f (Int %1 -> String)          -- linear function type
  e3 = f (forall a. Bounded a => a)  -- forall type, constraint

The GHC AST and the TH AST have been extended as follows:

   syntax        | HsExpr   | TH.Exp
  ---------------+----------+--------------
   a -> b        | HsFunArr | ConE (->)
   a %m -> b     | HsFunArr | ConE FUN
   ctx => t      | HsQual   | ConstrainedE
   forall a. t   | HsForAll | ForallE
   forall a -> t | HsForAll | ForallVisE

Additionally, a new warning flag -Wview-pattern-signatures has been
introduced to aid with migration to the new precedence of (e -> p :: t).

Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com>

- - - - -
66e7f57d by Brandon Chinn at 2024-08-01T21:50:58-07:00
Implement MultilineStrings (#24390)

This commit adds support for multiline strings, proposed at
https://github.com/ghc-proposals/ghc-proposals/pull/569.
Multiline strings can now be written as:

    myString =
      """
      this is a
      multiline string
      """

The multiline string will have leading indentation stripped away.
Full details of this post-processing may be found at the new
GHC.Parser.String module.

In order to cleanly implement this and maximize reusability, I
broke out the lexing logic for strings out of Lexer.x into a
new GHC.Parser.String module, which lexes strings with any
provided "get next character" function. This also gave us the
opportunity to clean up this logic, and even optimize it a bit.
With this change, parsing string literals now takes 25% less
time and 25% less space.

- - - - -
cf47b96f by Rodrigo Mesquita at 2024-08-03T05:59:40-04:00
hi: Stable sort avails

Sorting the Avails in DocStructures is required to produce fully
deterministic interface files in presence of re-exported modules.

Fixes #25104

- - - - -
af2ae742 by M. Taimoor Zaeem at 2024-08-03T18:52:50+05:00
haddock: decrease margin on top of small headings

- - - - -
a1e42e7a by Rodrigo Mesquita at 2024-08-05T21:03:04-04:00
hi: Deterministic ImportedMods in Usages

The `mi_usages` field of the interface files must use a deterministic
list of `Usage`s to guarantee a deterministic interface. However, this
list was, in its origins, constructed from a `ModuleEnv` which uses a
non-deterministic ordering that was leaking into the interface.

Specifically, ImportedMods = ModuleEnv ... would get converted to a list and
then passed to `mkUsageInfo` to construct the Usages.

The solution is simple. Back `ImportedMods` with a deterministic map.
`Map Module ...` is enough, since the Ord instance for `Module` already
uses a stable, deterministic, comparison.

Fixes #25131

- - - - -
eb1cb536 by Serge S. Gulin at 2024-08-06T08:54:55+00:00
testsuite: extend size performance tests with gzip (fixes #25046)

The main purpose is to create tests for minimal app (hello world and its variations, i.e. unicode used) distribution size metric.

Many platforms support distribution in compressed form via gzip. It would be nice to collect information on how much size is taken by the executional bundle for each platform at minimal edge case.

2 groups of tests are added:
1. We extend javascript backend size tests with gzip-enabled versions for all cases where an optimizing compiler is used (for now it is google closure compiler).
2. We add trivial hello world tests with gzip-enabled versions for all other platforms at CI pipeline where no external optimizing compiler is used.

- - - - -
d94410f8 by Rodrigo Mesquita at 2024-08-07T11:49:19-04:00
ghc-internal: @since for backtraceDesired

Fixes point 1 in #25052

- - - - -
bfe600f5 by Rodrigo Mesquita at 2024-08-07T11:49:19-04:00
ghc-internal: No trailing whitespace in exceptions

Fixes #25052

- - - - -
62650d9f by Andreas Klebinger at 2024-08-07T11:49:54-04:00
Add since annotation for -fkeep-auto-rules.

This partially addresses #25082.

- - - - -
5f0e23fd by Andreas Klebinger at 2024-08-07T11:49:54-04:00
Mention `-fkeep-auto-rules` in release notes.

It was added earlier but hadn't appeared in any release notes yet.
Partially addresses #25082.

- - - - -
7446a09a by Sylvain Henry at 2024-08-07T11:50:35-04:00
Cmm: don't perform unsound optimizations on 32-bit compiler hosts

- beef61351b240967b49169d27a9a19565cf3c4af enabled the use of
  MO_Add/MO_Sub for 64-bit operations in the C and LLVM backends
- 6755d833af8c21bbad6585144b10e20ac4a0a1ab did the same for the x86 NCG
  backend

However we store some literal values as `Int` in the compiler. As a
result, some Cmm optimizations transformed target 64-bit literals into
compiler `Int`. If the compiler is 32-bit, this leads to computing with
wrong literals (see #24893 and #24700).

This patch disables these Cmm optimizations for 32-bit compilers. This
is unsatisfying (optimizations shouldn't be compiler-word-size
dependent) but it fixes the bug and it makes the patch easy to backport.
A proper fix would be much more invasive but it shall be implemented in
the future.

Co-authored-by: amesgen <amesgen at amesgen.de>

- - - - -
d59faaf2 by Vladislav Zavialov at 2024-08-07T11:51:11-04:00
docs: Update info on RequiredTypeArguments

Add a section on "types in terms" that were implemented in 8b2f70a202
and remove the now outdated suggestion of using `type` for them.

- - - - -
39fd6714 by Sylvain Henry at 2024-08-07T11:51:52-04:00
JS: fix minor typo in base's jsbits

- - - - -
e7764575 by Sylvain Henry at 2024-08-07T11:51:52-04:00
RTS: remove hack to force old cabal to build a library with only JS sources

Need to extend JSC externs with Emscripten RTS definitions to avoid
JSC_UNDEFINED_VARIABLE errors when linking without the emcc rts.

Fix #25138

Some recompilation avoidance tests now fail. This is tracked with the
other instances of this failure in #23013. My hunch is that they were
working by chance when we used the emcc linker.

Metric Decrease:
    T24602_perf_size

- - - - -
d1a40233 by Brandon Chinn at 2024-08-07T11:53:08-04:00
Support multiline strings in type literals (#25132)

- - - - -
610840eb by Sylvain Henry at 2024-08-07T11:53:50-04:00
JS: fix callback documentation (#24377)

Fix #24377

- - - - -
6ae4b76a by Zubin Duggal at 2024-08-13T13:36:57-04:00
haddock: Build haddock-api and haddock-library using hadrian

We build these two packages as regular boot library dependencies rather
than using the `in-ghc-tree` flag to include the source files into the haddock
executable.

The `in-ghc-tree` flag is moved into haddock-api to ensure that haddock built
from hackage can still find the location of the GHC bindist using `ghc-paths`.

Addresses #24834

This causes a metric decrease under non-release flavours because under these
flavours libraries are compiled with optimisation but executables are not.

Since we move the bulk of the code from the haddock executable to the
haddock-api library, we see a metric decrease on the validate flavours.

Metric Decrease:
    haddock.Cabal
    haddock.base
    haddock.compiler

- - - - -
51ffba5d by Arnaud Spiwack at 2024-08-13T13:37:50-04:00
Add an extension field to HsRecFields

This is the Right Thing to Do™. And it prepares for storing a
multiplicity coercion there.

First step of the plan outlined here and below
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/12947#note_573091

- - - - -
4d2faeeb by Arnaud Spiwack at 2024-08-13T13:37:50-04:00
Add test for #24961

- - - - -
623b4337 by Arnaud Spiwack at 2024-08-13T13:37:50-04:00
Ensures that omitted record fields in pattern have multiplicity Many

Omitted fields were simply ignored in the type checker and produced
incorrect Core code.

Fixes #24961

Metric Increase:
    RecordUpdPerf

- - - - -
c749bdfd by Sylvain Henry at 2024-08-13T13:38:41-04:00
AARCH64 linker: skip NONE relocations

This patch is part of the patches upstreamed from haskell.nix.
See https://github.com/input-output-hk/haskell.nix/pull/1960 for the
original report/patch.

- - - - -
682a6a41 by Brandon Chinn at 2024-08-13T13:39:17-04:00
Support multiline strings in TH

- - - - -
ee0a9c18 by Matthew Pickering at 2024-08-14T14:27:39-04:00
Extend -reexported-module flag to support module renaming

The -reexported-module flag now supports renaming -rexported-modules.

```
-rexported-module "A as B"
```

This feature is only relevant to multi-component sessions.

Fixes #25139

- - - - -
e9496000 by Arnaud Spiwack at 2024-08-14T14:28:20-04:00
Don't restrict eta-reduction of linear functions

This commit simply removes code. All the supporting implementation has
been done as part of !12883.

Closes #25129

- - - - -
2bb4156e by sheaf at 2024-08-14T14:28:56-04:00
Allow @ character in C labels

Generated symbol names can include the '@' character, for example when using
`__attribute__((vectorcall))`.
- - - - -
7602ca23 by Sylvain Henry at 2024-08-14T14:29:36-04:00
Linker: replace blind tuple with a datatype + docs

- - - - -
bdd77b9e by sheaf at 2024-08-16T12:47:11-04:00
isIrrefutableHsPat: look up ConLikes in the HscEnv

At GhcRn stage, in isIrrefutableHsPat we only looked up data constructors
in the RdrEnv, which meant that we lacked fallibility information for
out-of-scope constructors (which can arise from Template Haskell splices).

Instead, we use 'lookupGREInfo', which looks up the information in
the type environment. This was the correct function to call all along,
but was not used in 572fbc44 due to import cycle reasons. The appropriate
functions, 'irrefutableConLike{Rn,Tc}' have been moved to 'GHC.Rename.Env',
which avoids import cycles.

Fixes #25164

- - - - -
4bee377c by Sylvain Henry at 2024-08-16T12:47:53-04:00
Linker: some refactoring to prepare for #24886

- Rename LoadedBCOs into LazyBCOs
- Bundle SptEntries with CompiledByteCode and removed [SptEntry] field
  from the BCOs constructor
- Rename Linkable's LM constructor into Linkable: in the past we had LM
  and LP for Module and Package, now we only have the former.
- Rename Unlinked into LinkablePart (and linkableUnlinked into
  linkableParts)
- Use NonEmpty to encode invariant in Linkable's linkableParts type
- Add helpers: linkableLibs, linkableBCOs, etc.
- Add documentation
- Remove partial nameOfObject
- Rename nameOfObject_maybe into linkablePartPath
- Rename byteCodeOfObject into linkablePartAllBCOs.
- Refactor linkablePartAllBCOs to avoid a panic if a LazyBCO has a C
  stub. Document the fact that LazyBCOs are returned in this case
  (contrary to linkableBCOs which only returns non-lazy ones)

Refactoring done while trying to understand how to adapt the linker code
to support the JS backend too (cf #24886).

- - - - -
fa0dbaca by Mario Blažević at 2024-08-17T03:31:32+00:00
Implements the Exportable Named Default proposal (#24305)

This squashed commit adds support for exportable named defaults, the accepted
GHC proposal at https://github.com/ghc-proposals/ghc-proposals/pull/409

The proposal extends the Haskell '98 declarations

    default (Int, Double)

which were implicitly always applying to Num class alone, to allow specifying
an arbitrary single-parameter class:

    default IsString (Text, String)

The effect of this declaration would be to eliminate the ambiguous type errors
around string literals when OverloadedStrings extension is active. The
declaration by itself has effect only in its module, so the proposal also adds
the ability to export class defaults:

    module MyModule (default IsIstring)

Once the language extension is published and established, we can consider using
it in base and other libraries.

See Note [Named default declarations] in GHC.Tc.Gen.Default
for implementation details.

- - - - -
1deba6b2 by Simon Peyton Jones at 2024-08-17T13:58:13-04:00
Make kick-out more selective

This MR revised the crucial kick-out criteria in the constraint solver.

Ticket #24984 showed an example in which
 * We were kicking out unnecessarily
 * That gave rise to extra work, of course
 * But it /also/ led to exponentially-sized coercions due to lack
   of sharing in coercions (something we want to fix separately #20264)

This MR sharpens up the kick-out criteria; specifially in (KK2) we look
only under type family applications if (fs>=fw).

This forced me to understand the existing kick-out story, and I ended
up rewriting many of the careful Notes in GHC.Tc.Solver.InertSet.
Especially look at the new `Note [The KickOut Criteria]`

The proof of termination is not air-tight, but it is better than before,
and both Richard and I think it's correct :-).

- - - - -
88488847 by Cheng Shao at 2024-08-18T04:44:01+02:00
testsuite: remove undesired -fasm flag from test ways

This patch removes the -fasm flag from test ways, except ways like
optasm that explicitly state they are meant to be compiled with NCG
backend. Most test ways should use the default codegen backend, and
the precense of -fasm can cause stderr mismatches like this when GHC
is configured with the unregisterised backend:

```
--- /dev/null
+++ /tmp/ghctest-3hydwldj/test   spaces/testsuite/tests/profiling/should_compile/prof-late-cc.run/prof-late-cc.comp.stderr.normalised
@@ -0,0 +1,2 @@
+when making flags consistent: warning: [GHC-74335] [-Winconsistent-flags (in -Wdefault)]
+    Target platform uses unregisterised ABI, so compiling via C
*** unexpected failure for prof-late-cc(prof_no_auto)
```

This has been breaking the wasm unreg nightly job since !12595 landed.

- - - - -
3a145315 by Cheng Shao at 2024-08-18T13:05:45-04:00
ghci: fix isMinTTY.h casing for Windows targets

This commit fixes isMinTTY.h casing in isMinTTY.c that's compiled for
Windows targets. While this looks harmless given Windows filesystems
are case-insensitive by default, it does cause a compilation warning
with recent versions of clang, so we might as well fix the casing:

```
driver\ghci\isMinTTY.c:10:10: error:
     warning: non-portable path to file '"isMinTTY.h"'; specified path differs in case from file name on disk [-Wnonportable-include-path]
   |
10 | #include "isMINTTY.h"
   |          ^

 #include "isMINTTY.h"
         ^~~~~~~~~~~~
         "isMinTTY.h"
1 warning generated.
```

- - - - -
5f972bfb by Zubin Duggal at 2024-08-21T03:18:15-04:00
compiler: Fix pretty printing of ticked prefix constructors (#24237)

- - - - -
ef0a08e7 by Mike Pilgrem at 2024-08-21T03:18:57-04:00
Fix #15773 Clarify further -rtsopts 'defaults' in docs

- - - - -
05a4be58 by Sebastian Graf at 2024-08-21T03:19:33-04:00
Improve efficiency of `assertError` (#24625)

... by moving `lazy` to the exception-throwing branch.
It's all documented in `Note [Strictness of assertError]`.

- - - - -
c29b2b5a by sheaf at 2024-08-21T13:11:30-04:00
GHCi debugger: drop record name spaces for Ids

When binding new local variables at a breakpoint, we should create
Ids with variable namespace, and not record field namespace. Otherwise
the rest of the compiler falls over because the IdDetails are wrong.

Fixes #25109

- - - - -
bd82ac9f by Hécate Kleidukos at 2024-08-21T13:12:12-04:00
base: Final deprecation of GHC.Pack

The timeline mandated by #21461 has come to its term and after two years
and four minor releases, we are finally removing GHC.Pack from base.

Closes #21536

- - - - -
5092dbff by Sylvain Henry at 2024-08-21T13:12:54-04:00
JS: support rubbish static literals (#25177)

Support for rubbish dynamic literals was added in #24664. This patch
does the same for static literals.

Fix #25177

- - - - -
b5a2c061 by Phil de Joux at 2024-08-21T13:13:33-04:00
haddock docs: prefix comes before, postfix comes after

- - - - -
6fde3685 by Marcin Szamotulski at 2024-08-21T23:15:39-04:00
haddock: include package info with --show-interface

- - - - -
7e02111b by Andreas Klebinger at 2024-08-21T23:16:15-04:00
Document the (x86) SIMD macros.

Fixes #25021.

- - - - -
05116c83 by Rodrigo Mesquita at 2024-08-22T10:37:44-04:00
ghc-internal: Derive version from ghc's version

Fixes #25005

- - - - -
73f5897d by Ben Gamari at 2024-08-22T10:37:44-04:00
base: Deprecate GHC.Desugar

See https://github.com/haskell/core-libraries-committee/issues/216.

This will be removed in GHC 9.14.

- - - - -
821d0a9a by Cheng Shao at 2024-08-22T10:38:22-04:00
compiler: Store ForeignStubs and foreign C files in interfaces

This data is used alongside Core bindings to reconstruct intermediate
build products when linking Template Haskell splices with bytecode.

Since foreign stubs and files are generated in the pipeline, they were
lost with only Core bindings stored in interfaces.

The interface codec type `IfaceForeign` contains a simplified
representation of `ForeignStubs` and the set of foreign sources that
were manually added by the user.

When the backend phase writes an interface, `mkFullIface` calls
`encodeIfaceForeign` to read foreign source file contents and assemble
`IfaceForeign`.

After the recompilation status check of an upstream module,
`initWholeCoreBindings` calls `decodeIfaceForeign` to restore
`ForeignStubs` and write the contents of foreign sources to the file
system as temporary files.
The restored foreign inputs are then processed by `hscInteractive` in
the same manner as in a regular pipeline.

When linking the stub objects for splices, they are excluded from suffix
adjustment for the interpreter way through a new flag in `Unlinked`.

For details about these processes, please consult Note [Foreign stubs
and TH bytecode linking].

Metric Decrease:
    T13701

- - - - -
f0408eeb by Cheng Shao at 2024-08-23T10:37:10-04:00
git: remove a.out and include it in .gitignore

a.out is a configure script byproduct. It was mistakenly checked into
the tree in !13118. This patch removes it, and include it in
.gitignore to prevent a similar error in the future.

- - - - -
1f95c5e4 by Matthew Pickering at 2024-08-23T10:37:46-04:00
docs: Fix code-block syntax on old sphinx version

This code-block directive breaks the deb9 sphinx build.

Fixes #25201

- - - - -
27dceb42 by Sylvain Henry at 2024-08-26T11:05:11-04:00
JS: add basic support for POSIX *at functions (#25190)

openat/fstatat/unlinkat/dup are now used in the recent release of the
`directory` and `file-io` packages.

As such, these functions are (indirectly) used in the following tests
one we'll bump the `directory` submodule (see !13122):
- openFile008
- jsOptimizer
- T20509
- bkpcabal02
- bkpcabal03
- bkpcabal04

- - - - -
c68be356 by Matthew Pickering at 2024-08-26T11:05:11-04:00
Update directory submodule to latest master

The primary reason for this bump is to fix the warning from `ghc-pkg
check`:

```
Warning: include-dirs: /data/home/ubuntu/.ghcup/ghc/9.6.2/lib/ghc-9.6.2/lib/../lib/aarch64-linux-ghc-9.6.2/directory-1.3.8.1/include doesn't exist or isn't a directory
```

This also requires adding the `file-io` package as a boot library (which
is discussed in #25145)

Fixes #23594 #25145

- - - - -
4ee094d4 by Matthew Pickering at 2024-08-26T11:05:47-04:00
Fix aarch64-alpine target platform description

We are producing bindists where the target triple is

aarch64-alpine-linux

when it should be

aarch64-unknown-linux

This is because the bootstrapped compiler originally set the target
triple to `aarch64-alpine-linux` which is when propagated forwards by
setting `bootstrap_target` from the bootstrap compiler target.

In order to break this chain we explicitly specify build/host/target for
aarch64-alpine.

This requires a new configure flag `--enable-ignore-` which just
switches off a validation check that the target platform of the
bootstrap compiler is the same as the build platform. It is the same,
but the name is just wrong.

These commits can be removed when the bootstrap compiler has the correct
target triple (I looked into patching this on ci-images, but it looked
hard to do correctly as the build/host platform is not in the settings
file).

Fixes #25200

- - - - -
e0e0f2b2 by Matthew Pickering at 2024-08-26T11:05:47-04:00
Bump nixpkgs commit for gen_ci script

- - - - -
63a27091 by doyougnu at 2024-08-26T20:39:30-04:00
rts: win32: emit additional debugging information

-- migration from haskell.nix

- - - - -
aaab3d10 by Vladislav Zavialov at 2024-08-26T20:40:06-04:00
Only export defaults when NamedDefaults are enabled (#25206)

This is a reinterpretation of GHC Proposal #409 that avoids a breaking
change introduced in fa0dbaca6c "Implements the Exportable Named Default proposal"

Consider a module M that has no explicit export list:

	module M where
	default (Rational)

Should it export the default (Rational)?

The proposal says "yes", and there's a test case for that:

	default/DefaultImport04.hs

However, as it turns out, this change in behavior breaks existing
programs, e.g. the colour-2.3.6 package can no longer be compiled,
as reported in #25206.

In this patch, we make implicit exports of defaults conditional on
the NamedDefaults extension. This fix is unintrusive and compliant
with the existing proposal text (i.e. it does not require a proposal
amendment). Should the proposal be amended, we can go for a simpler
solution, such as requiring all defaults to be exported explicitly.

Test case: testsuite/tests/default/T25206.hs

- - - - -
3a5bebf8 by Matthew Pickering at 2024-08-28T14:16:42-04:00
simplifier: Fix space leak during demand analysis

The lazy structure (a list) in a strict field in `DmdType` is not fully
forced which leads to a very large thunk build-up.

It seems there is likely still more work to be done here as it seems we
may be trading space usage for work done. For now, this is the right
choice as rather than using all the memory on my computer, compilation
just takes a little bit longer.

See #25196

- - - - -
c2525e9e by Ryan Scott at 2024-08-28T14:17:17-04:00
Add missing parenthesizeHsType in cvtp's InvisP case

We need to ensure that when we convert an `InvisP` (invisible type pattern) to
a `Pat`, we parenthesize it (at precedence `appPrec`) so that patterns such as
`@(a :: k)` will parse correctly when roundtripped back through the parser.

Fixes #25209.

- - - - -
1499764f by Sjoerd Visscher at 2024-08-29T16:52:56+02:00
Haddock: Add no-compilation flag

This flag makes sure to avoid recompilation of the code when generating documentation by only reading the .hi and .hie files, and throw an error if it can't find them.

- - - - -
768fe644 by Andreas Klebinger at 2024-09-03T13:15:20-04:00
Add functions to check for weakly pinned arrays.

This commit adds `isByteArrayWeaklyPinned#` and `isMutableByteArrayWeaklyPinned#` primops.
These check if a bytearray is *weakly* pinned. Which means it can still be explicitly moved
by the user via compaction but won't be moved by the RTS.

This moves us one more stop closer to nailing down #22255.

- - - - -
b16605e7 by Arsen Arsenović at 2024-09-03T13:16:05-04:00
ghc-toolchain: Don't leave stranded a.outs when testing for -g0

This happened because, when ghc-toolchain tests for -g0, it does so by
compiling an empty program.  This compilation creates an a.out.

Since we create a temporary directory, lets place the test program
compilation in it also, so that it gets cleaned up.

Fixes: 25b0b40467d0a12601497117c0ad14e1fcab0b74
Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/25203

- - - - -
83e70b14 by Torsten Schmits at 2024-09-03T13:16:41-04:00
Build foreign objects for TH with interpreter's way when loading from iface

Fixes #25211

When linking bytecode for TH from interface core bindings with
`-fprefer-byte-code`, foreign sources are loaded from the interface as
well and compiled to object code in an ad-hoc manner.

The results are then loaded by the interpreter, whose way may differ
from the current build's target way.

This patch ensures that foreign objects are compiled with the
interpreter's way.

- - - - -
0d3bc2fa by Cheng Shao at 2024-09-04T07:20:06-04:00
rts: fix checkClosure error message

This patch fixes an error message in checkClosure() when the closure
has already been evacuated. The previous logic was meant to print the
evacuated closure's type in the error message, but it was completely
wrong, given info was not really an info table, but a tagged pointer
that points to the closure's new address.

- - - - -
fb0a4e5c by Sven Tennie at 2024-09-04T07:20:43-04:00
MO_AcquireFence: Less restrictive barrier

GCC and CLang translate the built-in `atomic_thread_fence(memory_order_acquire)`
to `dmb ishld`, which is a bit less restrictive than `dmb ish` (which
also implies stores.)

- - - - -
a45f1488 by Fendor at 2024-09-04T20:22:00-04:00
testsuite: Add support to capture performance metrics via 'perf'

Performance metrics collected via 'perf' can be more accurate for
run-time performance than GHC's rts, due to the usage of hardware
counters.

We allow performance tests to also record PMU events according to 'perf
list'.

- - - - -
ce61fca5 by Fendor at 2024-09-04T20:22:00-04:00
gitlab-ci: Add nightly job for running the testsuite with perf profiling support

- - - - -
6dfb9471 by Fendor at 2024-09-04T20:22:00-04:00
Enable perf profiling for compiler performance tests

- - - - -
da306610 by sheaf at 2024-09-04T20:22:41-04:00
RecordCon lookup: don't allow a TyCon

This commit adds extra logic when looking up a record constructor.
If GHC.Rename.Env.lookupOccRnConstr returns a TyCon (as it may, due to
the logic explained in Note [Pattern to type (P2T) conversion]),
we emit an error saying that the data constructor is not in scope.

This avoids the compiler falling over shortly thereafter, in the call to
'lookupConstructorInfo' inside 'GHC.Rename.Env.lookupRecFieldOcc',
because the record constructor would not have been a ConLike.

Fixes #25056

- - - - -
9c354beb by Matthew Pickering at 2024-09-04T20:23:16-04:00
Use deterministic names for temporary files

When there are multiple threads they can race to create a temporary
file, in some situations the thread will create ghc_1.c and in some it
will create ghc_2.c. This filename ends up in the debug info for object
files after compiling a C file, therefore contributes to object
nondeterminism.

In order to fix this we store a prefix in `TmpFs` which serves to
namespace temporary files. The prefix is populated from the counter in
TmpFs when the TmpFs is forked. Therefore the TmpFs must be forked
outside the thread which consumes it, in a deterministic order, so each
thread always receives a TmpFs with the same prefix.

This assumes that after the initial TmpFs is created, all other TmpFs
are created from forking the original TmpFs. Which should have been try
anyway as otherwise there would be file collisions and non-determinism.

Fixes #25224

- - - - -
59906975 by Hécate Kleidukos at 2024-09-05T10:57:15-04:00
Silence x-partial in Haddock.Backends.Xhtml

This is an unfortunate consequence of two mechanisms:
  * GHC provides (possibly-empty) lists of names
  * The functions that retrieve those names are not equipped to do error
    reporting, and thus accept these lists at face value. They will have
    to be attached an effect for error reporting in a later refactoring

- - - - -
8afbab62 by Hécate Kleidukos at 2024-09-05T10:57:15-04:00
hadrian: Support loading haddock in ghci

There is one tricky aspect with wired-in packages where the boot package
is built with `-this-unit-id ghc` but the dependency is reported as
`-package-id ghc-9.6...`. This has never been fixed in GHC as the
situation of loading wired-in packages into the multi-repl seems like
quite a niche feature that is always just easier to workaround.

- - - - -
6cac9eb8 by Matthew Pickering at 2024-09-05T10:57:15-04:00
hadrian/multi: Load all targets when ./hadrian/ghci-multi is called

This seems to make a bit more sense than just loading `ghc` component
(and dependencies).

- - - - -
7d84df86 by Matthew Pickering at 2024-09-05T10:57:51-04:00
ci: Beef up determinism interface test

There have recently been some determinism issues with the simplifier and
documentation. We enable more things to test in the ABI test to check
that we produce interface files deterministically.

- - - - -
5456e02e by Sylvain Henry at 2024-09-06T11:57:01+02:00
Transform some StgRhsClosure into StgRhsCon after unarisation (#25166)

Before unarisation we may have code like:

  Test.foo :: Test.D
  [GblId, Unf=OtherCon []] =
      \u []
          case (# |_| #) [GHC.Types.(##)] of sat_sAw [Occ=Once1] {
          __DEFAULT -> Test.D [GHC.Types.True sat_sAw];
          };

After unarisation we get:

  Test.foo :: Test.D
  [GblId, Unf=OtherCon []] =
      {} \u [] Test.D [GHC.Types.True 2#];

Notice that it's still an Updatable closure for no reason anymore. This
patch transforms appropriate StgRhsClosures into StgRhsCons after
unarisation, allowing these closures to be statically allocated. Now we
get the expected:

  Test.foo :: Test.D
  [GblId, Unf=OtherCon []] =
      Test.D! [GHC.Types.True 2#];

Fix #25166

To avoid duplicating code, this patch refactors the mk(Top)StgRhs
functions and put them in a GHC.Stg.Make module alongside the new
mk(Top)StgRhsCon_maybe functions.

- - - - -
958b4518 by Hécate Kleidukos at 2024-09-06T16:40:56-04:00
haddock: Add missing requirements.txt for the online manual

- - - - -
573f9833 by Sven Tennie at 2024-09-08T09:58:21+00:00
AArch64: Implement takeRegRegMoveInstr

This has likely been forgotten.

- - - - -
20b0de7d by Hécate Kleidukos at 2024-09-08T14:19:28-04:00
haddock: Configuration fix for ReadTheDocs

- - - - -
03055c71 by Sylvain Henry at 2024-09-09T14:58:15-04:00
JS: fake support for native adjustors (#25159)

The JS backend doesn't support adjustors (I believe) and in any case if
it ever supports them it will be a native support, not one via libffi.

- - - - -
5bf0e6bc by Sylvain Henry at 2024-09-09T14:58:56-04:00
JS: remove redundant h$lstat

It was introduced a second time by mistake in
27dceb42376c34b99a38e36a33b2abc346ed390f (cf #25190)

- - - - -
ffbc2ab0 by Simon Peyton Jones at 2024-09-10T00:40:37-04:00
Refactor only newSysLocalDs

* Change newSysLocalDs to take a scaled type
* Add newSysLocalMDs that takes a type and makes a ManyTy local

Lots of files touched, nothing deep.

- - - - -
7124e4ad by Simon Peyton Jones at 2024-09-10T00:40:37-04:00
Don't introduce 'nospec' on the LHS of a RULE

This patch address #25160.  The main payload is:

* When desugaring the LHS of a RULE, do not introduce the `nospec` call
  for non-canonical evidence.  See GHC.Core.InstEnv
  Note [Coherence and specialisation: overview]

  The `nospec` call usually introdued in `dsHsWrapper`, but we don't want it
  on the LHS of a RULE (that's what caused #25160).  So now `dsHsWrapper` takes
  a flag to say if it's on the LHS of a RULE.  See wrinkle (NC1) in
  `Note [Desugaring non-canonical evidence]` in GHC.HsToCore.Binds.

But I think this flag will go away again when I have finished with my
(entirely separate) speciaise-on-values patch (#24359).

All this meant I had to re-understand the `nospec` stuff and coherence, and
that in turn made me do some refactoring, and add a lot of new documentation

The big change is that in GHC.Core.InstEnv, I changed
  the /type synonym/ `Canonical` into
  a /data type/ `CanonicalEvidence`
and documented it a lot better.

That in turn made me realise that CalLStacks were being treated with a
bit of a hack, which I documented in `Note [CallStack and ExecptionContext hack]`.

- - - - -
663daf8d by Simon Peyton Jones at 2024-09-10T00:40:37-04:00
Add defaulting of equalities

This MR adds one new defaulting strategy to the top-level
defaulting story: see Note [Defaulting equalities] in GHC.Tc.Solver.

This resolves #25029 and #25125, which showed that users were
accidentally relying on a GHC bug, which was fixed by

    commit 04f5bb85c8109843b9ac2af2a3e26544d05e02f4
    Author: Simon Peyton Jones <simon.peytonjones at gmail.com>
    Date:   Wed Jun 12 17:44:59 2024 +0100

    Fix untouchability test

    This MR fixes #24938.  The underlying problem was tha the test for
    "does this implication bring in scope any equalities" was plain wrong.

This fix gave rise to a number of user complaints; but the improved
defaulting story of this MR largely resolves them.

On the way I did a bit of refactoring, of course

* Completely restructure the extremely messy top-level defaulting
  code. The new code is in GHC.Tc.Solver.tryDefaulting, and is much,
  much, much esaier to grok.

- - - - -
e28cd021 by Andrzej Rybczak at 2024-09-10T00:41:18-04:00
Don't name a binding pattern

It's a keyword when PatternSynonyms are set.

- - - - -
b09571e2 by Simon Peyton Jones at 2024-09-10T00:41:54-04:00
Do not use an error thunk for an absent dictionary

In worker/wrapper we were using an error thunk for an absent dictionary,
but that works very badly for -XDictsStrict, or even (as #24934 showed)
in some complicated cases involving strictness analysis and unfoldings.

This MR just uses RubbishLit for dictionaries. Simple.

No test case, sadly because our only repro case is rather complicated.

- - - - -
8bc9f5f6 by Hécate Kleidukos at 2024-09-10T00:42:34-04:00
haddock: Remove support for applehelp format in the Manual

- - - - -
9ca15506 by doyougnu at 2024-09-10T10:46:38-04:00
RTS linker: add support for hidden symbols (#25191)

Add linker support for hidden symbols. We basically treat them as weak
symbols.

Patch upstreamed from haskell.nix

Co-authored-by: Sylvain Henry <sylvain at haskus.fr>
Co-authored-by: Moritz Angermann <moritz.angermann at gmail.com>

- - - - -
3b2dc826 by Sven Tennie at 2024-09-10T10:47:14-04:00
Fix C warnings (#25237)

GCC 14 treats the fixed warnings as errors by default. I.e. we're
gaining GCC 14 compatibility with these fixes.

- - - - -
05715994 by Sylvain Henry at 2024-09-10T10:47:55-04:00
JS: fix codegen of static string data

Before this patch, when string literals are made trivial, we would
generate `h$("foo")` instead of `h$str("foo")`. This was
introduced by mistake in 6bd850e887b82c5a28bdacf5870d3dc2fc0f5091.

- - - - -
949ebced by Hécate Kleidukos at 2024-09-10T19:19:40-04:00
haddock: Re-organise cross-OS compatibility layer

- - - - -
84ac9a99 by Hécate Kleidukos at 2024-09-10T19:19:40-04:00
haddock: Remove CPP for obsolete GHC and Cabal versions

- - - - -
370d1599 by Hécate Kleidukos at 2024-09-10T19:19:40-04:00
haddock: Move the changelog file to the 'extra-doc-files' section in the cabal file

- - - - -
cfbff65a by Simon Peyton Jones at 2024-09-10T19:20:16-04:00
Add ZonkAny and document it

This MR fixed #24817 by adding ZonkAny, which takes a Nat
argument.

See Note [Any types] in GHC.Builtin.Types, especially
wrinkle (Any4).

- - - - -
0167e472 by Matthew Pickering at 2024-09-11T02:41:42-04:00
hadrian: Make sure ffi headers are built before using a compiler

When we are using ffi adjustors then we rely on `ffi.h` and
`ffitarget.h` files during code generation when compiling stubs.

Therefore we need to add this dependency to the build system (which this
patch does).

Reproducer, configure with `--enable-libffi-adjustors` and then build
"_build/stage1/libraries/ghc-prim/build/GHC/Types.p_o".

Observe that this fails before this patch and works afterwards.

Fixes #24864

Co-authored-by: Sylvain Henry <sylvain at haskus.fr>

- - - - -
0f696958 by Rodrigo Mesquita at 2024-09-11T02:42:18-04:00
base: Deprecate BCO primops exports from GHC.Exts

See https://github.com/haskell/core-libraries-committee/issues/212.

These reexports will be removed in GHC 9.14.

- - - - -
cf0e7729 by Alan Zimmerman at 2024-09-11T02:42:54-04:00
EPA: Remove Anchor = EpaLocation synonym

This just causes confusion.

- - - - -
8e462f4d by Andrew Lelechenko at 2024-09-11T22:20:37-04:00
Bump submodule deepseq to 1.5.1.0

- - - - -
aa4500ae by Sebastian Graf at 2024-09-11T22:21:13-04:00
User's guide: Fix the "no-backtracking" example of -XOrPatterns (#25250)

Fixes #25250.

- - - - -
1c479c01 by Sven Tennie at 2024-09-12T10:39:38+00:00
RISCV64: Add Native Code Generator (NCG)

This architecture wasn't supported before.

Co-authored-by: Moritz Angermann <moritz.angermann at gmail.com>

- - - - -
51b678e1 by Sven Tennie at 2024-09-12T10:39:38+00:00
Adjust test timings for slower computers

Increase the delays a bit to be able to run these tests on slower
computers.

The reference was a Lichee Pi 4a RISCV64 machine.

- - - - -
a0e41741 by Sven Tennie at 2024-09-12T10:39:38+00:00
RISCV64: Add RTS linker

This architecture wasn't supported before.

Co-authored-by: Moritz Angermann <moritz.angermann at gmail.com>

- - - - -
d365b1d4 by Sven Tennie at 2024-09-12T10:39:38+00:00
RISCV64: Ignore divbyzero test

The architecture's behaviour differs from the test's expectations. See
comment in code why this is okay.

- - - - -
abf3d699 by Sven Tennie at 2024-09-12T10:39:38+00:00
RISCV64: Enable MulMayOflo_full test

It works and thus can be tested.

- - - - -
38c7ea8c by Sven Tennie at 2024-09-12T10:39:38+00:00
RISCV64: LibffiAdjustor: Ensure code caches are flushed

RISCV64 needs a specific code flushing sequence (involving fence.i) when
new code is created/loaded.

- - - - -
7edc6965 by Sven Tennie at 2024-09-12T10:39:38+00:00
RISCV64: Add additional linker symbols for builtins

We're relying on some GCC/Clang builtins. These need to be visible to
the linker (and not be stripped away.)

- - - - -
92ad3d42 by Sven Tennie at 2024-09-12T10:39:38+00:00
RISCV64: Add GHCi support

As we got a RTS linker for this architecture now, we can enable GHCi for
it.

- - - - -
a145f701 by Sven Tennie at 2024-09-12T10:39:38+00:00
RISCV64: Set codeowners of the NCG

- - - - -
8e6d58cf by Sven Tennie at 2024-09-12T10:39:38+00:00
Add test for C calling convention

Ensure that parameters and return values are correctly processed. A
dedicated test (like this) helps to get the subtleties of calling
conventions easily right.

The test is failing for WASM32 and marked as fragile to not forget to
investigate this (#25249).

- - - - -
fff55592 by Torsten Schmits at 2024-09-12T21:50:34-04:00
finder: Add `IsBootInterface` to finder cache keys

- - - - -
cdf530df by Alan Zimmerman at 2024-09-12T21:51:10-04:00
EPA: Sync ghc-exactprint to GHC

- - - - -
1374349b by Sebastian Graf at 2024-09-13T07:52:11-04:00
DmdAnal: Fast path for `multDmdType` (#25196)

This is in order to counter a regression exposed by SpecConstr.

Fixes #25196.

- - - - -
80769bc9 by Andrew Lelechenko at 2024-09-13T07:52:47-04:00
Bump submodule array to 0.5.8.0

- - - - -
49ac3fb8 by Sylvain Henry at 2024-09-16T10:33:01-04:00
Linker: add support for extra built-in symbols (#25155)

See added Note [Extra RTS symbols] and new user guide entry.

Co-authored-by: Hamish Mackenzie <Hamish.K.Mackenzie at gmail.com>
Co-authored-by: Moritz Angermann <moritz.angermann at gmail.com>

- - - - -
3939a8bf by Samuel Thibault at 2024-09-16T10:33:44-04:00
GNU/Hurd: Add getExecutablePath support

GNU/Hurd exposes it as /proc/self/exe just like on Linux.

- - - - -
d3b19851 by Sylvain Henry at 2024-09-17T11:03:28-04:00
RTS: expose closure_sizeW_ (#25252)

C code using the closure_sizeW macro can't be linked with the RTS linker
without this patch. It fails with:

  ghc-9.11.20240911: Failed to lookup symbol: closure_sizeW_

Fix #25252

Co-authored-by: Hamish Mackenzie <Hamish.K.Mackenzie at gmail.com>
Co-authored-by: Moritz Angermann <moritz.angermann at gmail.com>

- - - - -
137bf74d by Sebastian Graf at 2024-09-17T11:04:05-04:00
HsExpr: Inline `HsWrap` into `WrapExpr`

This nice refactoring was suggested by Simon during review:
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13261#note_583374

Fixes #25264.

- - - - -
7fd9e5e2 by Sebastian Graf at 2024-09-17T11:04:05-04:00
Pmc: Improve Desugaring of overloaded list patterns (#25257)

This actually makes things simpler.

Fixes #25257.

- - - - -
e4169ba9 by Ben Gamari at 2024-09-18T07:55:28-04:00
configure: Correctly report when subsections-via-symbols is disabled

As noted in #24962, currently subsections-via-symbols is disabled on
AArch64/Darwin due to alleged breakage. However, `configure` reports to
the user that it is enabled. Fix this.

- - - - -
9d20a787 by Mario Blažević at 2024-09-18T07:56:08-04:00
Modified the default export implementation to match the amended spec

- - - - -
35eb4f42 by Sylvain Henry at 2024-09-18T07:57:00-04:00
FFI: don't ppr Id/Var symbols with debug info (#25255)

Even if `-dpp-debug` is enabled we should still generate valid C code.
So we disable debug info printing when rendering with Code style.

- - - - -
9e96dad8 by Sebastian Graf at 2024-09-21T17:47:59-04:00
Demand: Combine examples into Note (#25107)

Just a leftover from !13060.

Fixes #25107.

- - - - -
21aaa34b by sheaf at 2024-09-21T17:48:36-04:00
Use x86_64-unknown-windows-gnu target for LLVM on Windows

- - - - -
992a7624 by sheaf at 2024-09-21T17:48:36-04:00
LLVM: use -relocation-model=pic on Windows

This is necessary to avoid the segfaults reported in #22487.

Fixes #22487

- - - - -
c50d29be by Ryan Hendrickson at 2024-09-21T17:49:15-04:00
compiler: Use type abstractions when deriving

For deriving newtype and deriving via, in order to bring type variables
needed for the coercions into scope, GHC generates type signatures for
derived class methods. As a simplification, drop the type signatures and
instead use type abstractions to bring method type variables into scope.

- - - - -
f04fd0ae by Zubin Duggal at 2024-09-21T17:49:51-04:00
driver: Ensure we run driverPlugin for staticPlugins (#25217)

driverPlugins are only run when the plugin state changes. This meant they were
never run for static plugins, as their state never changes.

We need to keep track of whether a static plugin has been initialised to ensure
we run static driver plugins at least once. This necessitates an additional field
in the `StaticPlugin` constructor as this state has to be bundled with the plugin
itself, as static plugins have no name/identifier we can use to otherwise reference
them

- - - - -
620becd7 by Andreas Klebinger at 2024-09-21T17:50:27-04:00
Allow unknown fd device types for setNonBlockingMode.

This allows fds with a unknown device type to have blocking mode
set. This happens for example for fds from the inotify subsystem.

Fixes #25199.

- - - - -
c76e25b3 by Hécate Kleidukos at 2024-09-21T17:51:07-04:00
Use Hackage version of Cabal 3.14.0.0 for Hadrian.
We remove the vendored Cabal submodule.

Also update the bootstrap plans

Fixes #25086

- - - - -
6c83fd7f by Zubin Duggal at 2024-09-21T17:51:07-04:00
ci: Ensure we source ci.sh in any jobs that run commands outside of ci.sh

ci.sh sets up the toolchain environment, including paths for the cabal directory, the
toolchain binaries etc. If we run any commands outside of ci.sh, unless we
source ci.sh we will use the wrong values for these environment variables.

In particular, I ran into an issue where the cabal invocation `hadrian/ghci` was
using an old index state despite `ci.sh setup` updating and setting the correct
index state. This is because `ci.sh` sets the `CABAL_DIR` to a different place, which
is where the index was downloaded to, but we were using the default cabal directory
outside ci.sh

The solution is to source the correct environment `ci.sh` using `. ci.sh setup`

- - - - -
9586998d by Sven Tennie at 2024-09-21T17:51:43-04:00
ghc-toolchain: Set -fuse-ld even for ld.bfd

This reflects the behaviour of the autoconf scripts.

- - - - -
d7016e0d by Sylvain Henry at 2024-09-21T17:52:24-04:00
Parser: be more careful when lexing extended literals (#25258)

Previously we would lex invalid prefixes like "8#Int3" as [8#Int, 3].

A side-effect of this patch is that we now allow negative unsigned
extended literals. They trigger an overflow warning later anyway.

- - - - -
ca67d7cb by Zubin Duggal at 2024-09-22T02:34:06-04:00
rts: Ensure we dump new Cost Centres added by freshly loaded objects to the eventlog.

To do this, we keep track of the ID of the last cost centre we dumped in DUMPED_CC_ID,
and call dumpCostCentresToEventLog from refreshProfilingCCSs, which will dump all the new
cost centres up to the one we already dumped in DUMPED_CC_ID.

Fixes #24148

- - - - -
c0df5aa9 by Alan Zimmerman at 2024-09-22T02:34:42-04:00
EPA: Replace AnnsModule am_main with EpTokens

Working towards removing `AddEpAnn`

- - - - -
2a551cd5 by Matthew Pickering at 2024-09-24T16:33:50+05:30
ci: Run abi-test on test-abi label

- - - - -
ab4039ac by Rodrigo Mesquita at 2024-09-24T16:33:50+05:30
testsuite: Add a test for object determinism

Extends the abi_test with an object determinism check
Also includes a standalone test to be run by developers manually when
debugging issues with determinism.

- - - - -
d62c18d8 by Rodrigo Mesquita at 2024-09-24T16:33:50+05:30
determinism: Sampling uniques in the CG

To achieve object determinism, the passes processing Cmm and the rest of
the code generation pipeline musn't create new uniques which are
non-deterministic.

This commit changes occurrences of non-deterministic unique sampling
within these code generation passes by a deterministic unique sampling
strategy by propagating and threading through a deterministic
incrementing counter in them. The threading is done implicitly with
`UniqDSM` and `UniqDSMT`.

Secondly, the `DUniqSupply` used to run a `UniqDSM` must be threaded
through all passes to guarantee uniques in different passes are unique
amongst them altogether. Specifically, the same `DUniqSupply` must be
threaded through the CG Streaming pipeline, starting with Driver.Main
calling `StgToCmm.codeGen`, `cmmPipeline`, `cmmToRawCmm`, and
`codeOutput` in sequence.

To thread resources through the `Stream` abstraction, we use the `UniqDSMT`
transformer on top of `IO` as the Monad underlying the Stream. `UniqDSMT` will
thread the `DUniqSupply` through every pass applied to the `Stream`, for every
element. We use @type CgStream = Stream (UniqDSMT IO)@ for the Stream used in
code generation which that carries through the deterministic unique supply.

See Note [Deterministic Uniques in the CG]

- - - - -
3bbe4af4 by Rodrigo Mesquita at 2024-09-24T16:33:50+05:30
determinism: Cmm unique renaming pass

To achieve object determinism, we need to prevent the non-deterministic
uniques from leaking into the object code. We can do this by
deterministically renaming the non-external uniques in the Cmm groups
that are yielded right after StgToCmm.

The key to deterministic renaming is observing that the order of
declarations, instructions, and data in the Cmm groups are already
deterministic (modulo other determinism bugs), regardless of the
uniques. We traverse the Cmm AST in this deterministic order and
rename the uniques, incrementally, in the order they are found, thus
making them deterministic. This renaming is guarded by
-fobject-determinism which is disabled by default for now.

This is one of the key passes for object determinism. Read about the
overview of object determinism and a more detailed explanation of this
pass in:
* Note [Object determinism]
* Note [Renaming uniques deterministically]

Significantly closes the gap to #12935

- - - - -
8357ed50 by Rodrigo Mesquita at 2024-09-24T16:33:50+05:30
determinism: DCmmGroup vs CmmGroup

Part of our strategy in producing deterministic objects, namely,
renaming all Cmm uniques in order, depend on the object code produced
having a deterministic order (say, A_closure always comes before
B_closure).

However, the use of LabelMaps in the Cmm representation invalidated this
requirement because the LabelMaps elements would already be in a
non-deterministic order (due to the original uniques), and the renaming
in sequence wouldn't work because of that non-deterministic order.

Therefore, we now start off with lists in CmmGroup (which preserve the
original order), and convert them into LabelMaps (for performance in the
code generator) after the uniques of the list elements have been
renamed.

See Note [DCmmGroup vs CmmGroup or: Deterministic Info Tables] and #12935.

Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com>

- - - - -
0e675fb8 by Rodrigo Mesquita at 2024-09-24T16:33:50+05:30
determinism: Don't print unique in pprFullName

This unique was leaking as part of the profiling description in info
tables when profiling was enabled, despite not providing information
relevant to the profile.

- - - - -
340f58b0 by Rodrigo Mesquita at 2024-09-24T16:33:50+05:30
determinism: UDFM for distinct-constructor-tables

In order to produce deterministic objects when compiling with
-distinct-constructor-tables, we also have to update the data
constructor map to be backed by a deterministic unique map (UDFM) rather
than a non-deterministic one (UniqMap).

- - - - -
282f37a0 by Rodrigo Mesquita at 2024-09-24T16:33:50+05:30
determinism: InfoTableMap uniques in generateCgIPEStub

Fixes object determinism when using -finfo-table-map

Make sure to also deterministically rename the IPE map (as per Note
[Renaming uniques deterministically]), and to use a deterministic unique
supply when creating new labels for the IPE information to guarantee
deterministic objects when IPE information is requested.

Note that the Cmm group produced in generateCgIPEStub must /not/ be
renamed because renaming uniques is not idempotent, and the references
to the previously renamed code in the IPE Cmm group would be renamed
twice and become invalid references to non-existent symbols.

We do need to det-rename the InfoTableMap that is created in the
conversion from Core to Stg. This is not a problem since that map won't
refer any already renamed names (since it was created before the
renaming).

- - - - -
7b37afc9 by Zubin Duggal at 2024-09-24T16:33:50+05:30
ci: Allow abi-test to fail.

We are not fully deterministic yet, see #12935 for work that remains to be done.

- - - - -
a63ee33a by Simon Peyton Jones at 2024-09-25T17:08:24-04:00
Add Given injectivity for built-in type families

Ticket #24845 asks (reasonably enough) that if we have
   [G] a+b ~ 0
then we also know
   [G] a ~ 0, b ~ 0
and similar injectivity-like facts for other built-in type
families.  The status quo was that we never generate evidence for
injectivity among Givens -- but it is quite reasonnable to do so.
All we need is to have /evidence/ for the new constraints

This MR implements that goal.  I also took the opportunity to
* Address #24978: refactoring UnivCo
* Fix #25248, which was a consequences of the previous formulation of UnivCo

As a result this MR touches a lot of code.  The big things are:

* Coercion constructor UnivCo now takes a [Coercion] as argument to
  express the coercions on which the UnivCo depends. A nice consequence
  is that UnivCoProvenance now has no free variables, simpler in a number
  of places.

* Coercion constructors AxiomInstCo and AxiomRuleCo are combined into
  AxiomCo.  The new AxiomCo, carries a (slightly oddly named)
  CoAxiomRule, which itself is a sum type of the various forms of
  built-in axiom.  See Note [CoAxiomRule] in GHC.Core.Coercion.Axiom

  A merit of this is that we can separate the case of open and closed
  type families, and eliminate the redundant `BranchIndex` in the former
  case.

* Much better representation for data BuiltInSynFamily, which means we
  no longer need to enumerate built-in axioms as well as built-in tycons.

* There is a massive refactor in GHC.Builtin.Types.Literals, which contains all
  the built-in axioms for type-level operations (arithmetic, append, cons etc).

  A big change is that instead of redundantly having (a) a hand-written
  matcher, and (b) a template-based "proves" function, which were hard to
  keep in sync, the two are derive from one set of human-supplied info.
  See GHC.Builtin.Types.Literals.mkRewriteAxiom, and friends.

* Significant changes in GHC.Tc.Solver.Equality to account for the new
  opportunity for Given/Given equalities.

Smaller things

* Improve pretty-printing to avoid parens around atomic coercions.

* Do proper eqType in findMatchingIrreds, not `eqTypeNoKindCheck`.
  Looks like a bug, Richard agrees.

* coercionLKind and coercionRKind are hot functions.  I refactored the
  implementation (which I had to change anyway) to increase sharing.
  See Note [coercionKind performance] in GHC.Core.Coercion

* I wrote a new Note [Finding orphan names] in GHC.Core.FVs about orphan
  names

* I improved the `is_concrete` flag in GHC.Core.Type.buildSynTyCon, to avoid
  calling tyConsOfType.  I forget exactly why I did this, but it's definitely
  better now.

* I moved some code from GHC.Tc.Types.Constraint into GHC.Tc.Types.CtLocEnv
  and I renamed the module GHC.Tc.Types.CtLocEnv to GHC.Tc.Types.CtLoc

- - - - -
dd8ef342 by Ryan Scott at 2024-09-25T17:09:01-04:00
Resolve ambiguous method-bound type variables in vanilla defaults and GND

When defining an instance of a class with a "vanilla" default, such as in the
following example (from #14266):

```hs
class A t where
  f :: forall x m. Monoid x => t m -> m
  f = <blah>

instance A []
```

We have to reckon with the fact that the type of `x` (bound by the type
signature for the `f` method) is ambiguous. If we don't deal with the ambiguity
somehow, then when we generate the following code:

```hs
instance A [] where
  f = $dmf @[] -- NB: the type of `x` is still ambiguous
```

Then the generated code will not typecheck. (Issue #25148 is a more recent
example of the same problem.)

To fix this, we bind the type variables from the method's original type
signature using `TypeAbstractions` and instantiate `$dmf` with them using
`TypeApplications`:

```hs
instance A [] where
  f @x @m = $dmf @[] @x @m -- `x` is no longer ambiguous
```

Note that we only do this for vanilla defaults and not for generic defaults
(i.e., defaults using `DefaultSignatures`). For the full details, see `Note
[Default methods in instances] (Wrinkle: Ambiguous types from vanilla method
type signatures)`.

The same problem arose in the code generated by `GeneralizedNewtypeDeriving`,
as we also fix it here using the same technique. This time, we can take
advantage of the fact that `GeneralizedNewtypeDeriving`-generated code
_already_ brings method-bound type variables into scope via `TypeAbstractions`
(after !13190), so it is very straightforward to visibly apply the type
variables on the right-hand sides of equations. See `Note [GND and ambiguity]`.

Fixes #14266. Fixes #25148.

- - - - -
0a4da5d2 by ARATA Mizuki at 2024-09-25T17:09:41-04:00
Document primitive string literals and desugaring of string literals

Fixes #17474 and #17974

Co-authored-by: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org>

- - - - -
ad0731ad by Zubin Duggal at 2024-09-25T17:10:18-04:00
rts: Fix segfault when using non-moving GC with profiling

`nonMovingCollect()` swaps out the `static_flag` value used as a
sentinel for `gct->scavenged_static_objects`, but the subsequent call
`resetStaticObjectForProfiling()` sees the old value of `static_flag` used as
the sentinel and segfaults. So we must call `resetStaticObjectForProfiling()`
before calling `nonMovingCollect()` as otherwise it looks for the incorrect
sentinel value

Fixes #25232 and #23958

Also teach the testsuite driver about nonmoving profiling ways
and stop disabling metric collection when nonmoving GC is enabled.

- - - - -
e7a26d7a by Sylvain Henry at 2024-09-25T17:11:00-04:00
Fix interaction between fork and kqueue (#24672)

A kqueue file descriptor isn't inherited by a child created with fork.
As such we mustn't try to close this file descriptor as we would close a
random one, e.g. the one used by timerfd.

Fix #24672

- - - - -
6863503c by Simon Peyton Jones at 2024-09-25T17:11:37-04:00
Improve GHC.Tc.Solver.defaultEquality

This MR improves GHC.Tc.Solver.defaultEquality to solve #25251.

The main change is to use checkTyEqRhs to check the equality, so
that we do promotion properly.

But within that we needed a small enhancement to LC_Promote.  See
Note [Defaulting equalites] (DE4) and (DE5)

The tricky case is (alas) hard to trigger, so I have not added a
regression test.

- - - - -
97a6c6c3 by Sylvain Henry at 2024-09-25T17:12:18-04:00
JS: fix h$withCStringOnHeap helper (#25288)

strlen returns the length of the string without the \0 terminating byte,
hence CString weren't properly allocated on the heap (ending \0 byte was
missing).

- - - - -
5f7c20bc by Ben Gamari at 2024-09-26T04:14:05-04:00
base: Propagate `error` CallStack to thrown exception

Previously `errorCallWithCallStackException` failed to propagate its
`CallStack` argument, which represents the call-chain of the preceding
`error` call, to the exception that it returned. Consequently, the
call-stack of `error` calls were quite useless.

Unfortunately, this is the second time that I have fixed this but it
seems the first must have been lost in rebasing.

Fixes a bug in the implementation of CLC proposal 164
<https://github.com/haskell/core-libraries-committee/issues/164>

Fixes #24807.

- - - - -
c20d5186 by Matthew Pickering at 2024-09-26T04:14:42-04:00
driver: Fix -working-dir for foreign files

-working-dir definitely needs more serious testing, there are some easy
ways to test this.

* Modify Cabal to call ghc using -working-dir rather than changing
  directory.
* Modify the testsuite to run ghc using `-working-dir` rather than
  running GHC with cwd = temporary directory.

However this will have to wait until after 9.12.

Fixes #25150

- - - - -
88eaa7ac by Sylvain Henry at 2024-09-26T04:15:24-04:00
Enum deriving: reuse predError, succError, toEnumError

Reuse predError, succError, and toEnumError when deriving Enum instances
to avoid generating different error strings per instance. E.g. before
this patch for every instance for a type FOO we would generate a string:

  "pred{FOO}: tried to take `pred' of first tag in enumeration"#

- - - - -
e9fa1163 by Sylvain Henry at 2024-09-26T04:15:24-04:00
Enum deriving: generate better code (#16364)

Generate better code for Enum.toEnum: check both the lower and the upper
bounds at once with an unsigned comparison.

Initially I've used a type ascription with a call to 'fromIntegral',
hence the slight refactoring of nlAscribe. Using 'fromIntegral' was
problematic (too low in the module hierarchy) so 'enumIntToWord' was
introduced instead.

Combined with the previous commit, T21839c ghc/alloc decrease by 5%

Metric Decrease:
    T21839c

- - - - -
383af074 by Sylvain Henry at 2024-09-26T04:16:06-04:00
Core: add absorb rules for binary or/and (#16351)

Rules:
  x or (x and y) ==> x
  x and (x or y) ==> x

- - - - -
783c8b29 by Matthew Pickering at 2024-09-26T12:07:44-04:00
Don't compile `asBox` with -fprof-late

The `asBox` function is intended to store exactly the closure which the
user passes to it. Placing a cost centre on asBox introduces a thunk,
which violates this expectation and can change the result of using asBox
when profiling is enabled.

See #25212 for more details and ample opportunity to discuss if this is
a bug or not.

- - - - -
0967dcc7 by Matthew Pickering at 2024-09-26T12:07:44-04:00
Fix normalisation of .prof files

Fix 1: If a cost centre contained CAF then the normalisation was
corrupted, now only check if CAF is at the start of a line.

Fix 2: "no location info" contain a space, which messed up the next
normalisation logic which assumed that columns didn't have spaced in.

- - - - -
9eda1cb9 by Matthew Pickering at 2024-09-26T12:07:44-04:00
testsuite: Fix normalisation of prof_files removing newlines

These normalisation steps were collapsing lines together, which made
subsequent normalisation steps fail.

```
foo x y z
CAF x y z
qux x y z
```

was getting normalised to

```
foo x y z qux x y z
```

which means that subsequent line based filters would not work correctly.

- - - - -
2b25f9e2 by Matthew Pickering at 2024-09-26T12:07:44-04:00
packaging: Enable late-ccs for release flavour

This enables late cost centres when building profiled libraries and
subsequently greatly improves the resolution of cost centre stacks when
profiling.

This patch also introduces the `grep_prof` test modifier which is used
to apply a further filter to the .prof file before they are compared.

Fixes #21732

-------------------------
Metric Increase:
    libdir
-------------------------

- - - - -
bb030d0d by Brandon Chinn at 2024-09-26T12:08:21-04:00
Replace manual string lexing (#25158)

Metric Increase:
    MultilineStringsPerf

This commit replaces the manual string lexing logic with native Alex
lexing syntax. This aligns the lexer much closer to the Haskell Report,
making it easier to see how the implementation and spec relate. This
slightly increases memory usage when compiling multiline strings because
we now have two distinct phases: lexing the multiline string with Alex
and post-processing the string afterwards. Before, these were done at
the same time, but separating them allows us to push as much logic into
normal Alex lexing as possible.

Since multiline strings are a new feature, this regression shouldn't be
too noticeable. We can optimize this over time.

- - - - -
16742987 by Matthew Pickering at 2024-09-26T12:08:57-04:00
Revert !4655: Stop 'import "base" Prelude' removing implicit Prelude import

This behaviour is problematic for the principle reason that `import
Prelude` may not refer to the `base` package, and in which case
importing an entirely unrelated module causing your implicit prelude to
leave the scope is extremely surprising. See the added test for this
example. Discussion on #17045.

The secondary reason for reverting this patch is that "base" can't be a
wired in package any more (see #24903), so we have to remove special
logic which singles out base from the compiler.

The rule for implicit shadowing is now simply:

* If you write import Prelude (..) then you don't get an implicit prelude import
* If you write import "foobar" Prelude (..) for all pkgs foobar,
  you get an implicit import of prelude.

If you want to write a package import of Prelude, then you can enable
`NoImplicitPrelude` for the module in question to recover the behaviour
of ghc-9.2-9.10.

Fixes #17045

- - - - -
57c50f41 by Matthew Pickering at 2024-09-26T12:08:57-04:00
Rename COMPILING_BASE_PACKAGE to COMPILING_GHC_INTERNAL_PACKAGE

The COMPILING_BASE_PACKAGE macro is concerned with issues defining
symbols and using symbols in the same compilation unit. However, these
symbols now exist in ghc-internal rather than base, so we should rename
the macro accordingly.

The code is guards is likely never used as we never produce windows DLLs
but it is simpler to just perform the renaming for now.

These days there is little doubt that this macro defined in this ad-hoc
manner would be permitted to exist, but these days are not those days.

Fixes #25221

- - - - -
70764243 by Matthew Pickering at 2024-09-26T12:08:57-04:00
Preload ghc-internal rather than base

This occurence of baseUnitId was missed when moving the bulk of internal
definitions into `ghc-internal`.

We need to remove this preloading of `base` now because `base` should
not be wired in.

Towards #24903

- - - - -
12915609 by Matthew Pickering at 2024-09-26T12:08:57-04:00
Remove Data.List compat warning

There is currently a warning implemented in -Wcompat which warns you
when importing Data.List in a non-qualified manner.

```
A.hs:3:8: warning: [-Wcompat-unqualified-imports]
    To ensure compatibility with future core libraries changes
    imports to Data.List should be
    either qualified or have an explicit import list.
  |
3 | import Data.List
  |        ^^^^^^^^^
Ok, one module loaded.
```

GHC ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/17244
CLC discussion: https://groups.google.com/g/haskell-core-libraries/c/q3zHLmzBa5E

This warning was implemented as part of the migration to making
Data.List monomorphic again (and to be used like Data.Set, Data.Map
etc). That doesn't seem like it happened, and I imagine that the current
CLC would require a new proposal anyway in order to do that now. It's
not clear in any case what "future core libraries changes" we are
waiting to happen before this warning can be removed.

Given the first phase of the proposal has lasted 5 years it doesn't seem
that anyone is motivated to carry the proposal to completion. It does
seem a bit unnecessary to include a warning in the compiler about
"future changes to the module" when there's no timeline or volunteer to
implement these changes.

The removal of this warning was discussed again at:
https://github.com/haskell/core-libraries-committee/issues/269

During the discussion there was no new enthusiasm to move onto the next
stages of the proposal so we are removing the warning to unblock the
reinstallable "base" project (#24903)

Fixes #24904

- - - - -
d4e4d498 by Matthew Pickering at 2024-09-26T12:08:57-04:00
Move Control.Monad.Zip into ghc-internal

mzip is wired in and therefore needs to be in ghc-internal.

Fixes #25222

Towards #24903

- - - - -
d3dacdfb by Matthew Pickering at 2024-09-26T12:08:57-04:00
Unwire the base package

This patch just removes all the functions related to wiring-in the base
package and the `-this-unit-id=base` flag from the cabal file.

After this commit "base" becomes just like any other package and the
door is opened to moving base into an external repo and releasing base
on a separate schedule to the rest of ghc.

Closes #24903

- - - - -
1b39363b by Patrick at 2024-09-27T06:10:19-04:00
Add entity information to HieFile #24544

Enhanced HieFile to capture entity information for identifiers, enabling better support for language tools and protocols. See issue #24544 for more details.

Work have been done:
* Introduction of new data type `EntityInfo` in `GHC.Iface.Ext.Types`.
* Add extra field `hie_entity_infos :: NameEntityInfo` to `HieFile`
  to store the mapping from entity name to corresponding entity infos
  in `GHC.Iface.Ext.Types`.
* Compute `EntityInfo` for each entity name in the HieAst from `TyThing,
  Id, OccName` when generating the `HieFile` in `GHC.Iface.Ext.Ast`.
* Add test T24544 to test the generation of `EntityInfo`.

- - - - -
4f3618d8 by sheaf at 2024-09-27T06:10:57-04:00
The X86 SIMD patch.

This commit adds support for 128 bit wide SIMD vectors and vector
operations to GHC's X86 native code generator.

Main changes:

  - Introduction of vector formats (`GHC.CmmToAsm.Format`)
  - Introduction of 128-bit virtual register (`GHC.Platform.Reg`),
    and removal of unused Float virtual register.
  - Refactor of `GHC.Platform.Reg.Class.RegClass`: it now only contains
    two classes, `RcInteger` (for general purpose registers) and `RcFloatOrVector`
    (for registers that can be used for scalar floating point values as well
    as vectors).
  - Modify `GHC.CmmToAsm.X86.Instr.regUsageOfInstr` to keep track
    of which format each register is used at, so that the register
    allocator can know if it needs to spill the entire vector register
    or just the lower 64 bits.
  - Modify spill/load/reg-2-reg code to account for vector registers
    (`GHC.CmmToAsm.X86.Instr.{mkSpillInstr, mkLoadInstr, mkRegRegMoveInstr, takeRegRegMoveInstr}`).
  - Modify the register allocator code (`GHC.CmmToAsm.Reg.*`) to propagate
    the format we are storing in any given register, for instance changing
    `Reg` to `RegFormat` or `GlobalReg` to `GlobalRegUse`.
  - Add logic to lower vector `MachOp`s to X86 assembly
    (see `GHC.CmmToAsm.X86.CodeGen`)
  - Minor cleanups to genprimopcode, to remove the llvm_only attribute
    which is no longer applicable.

Tests for this feature are provided in the "testsuite/tests/simd" directory.

Fixes #7741

Keeping track of register formats adds a small memory overhead to the
register allocator (in particular, regUsageOfInstr now allocates more
to keep track of the `Format` each register is used at). This explains
the following metric increases.

-------------------------
Metric Increase:
    T12707
    T13035
    T13379
    T3294
    T4801
    T5321FD
    T5321Fun
    T783
-------------------------

- - - - -
10e431ef by sheaf at 2024-09-27T06:10:57-04:00
Use xmm registers in genapply

This commit updates genapply to use xmm, ymm and zmm registers, for
stg_ap_v16/stg_ap_v32/stg_ap_v64, respectively.

It also updates the Cmm lexer and parser to produce Cmm vectors rather
than 128/256/512 bit wide scalars for V16/V32/V64, removing bits128,
bits256 and bits512 in favour of vectors.

The Cmm Lint check is weakened for vectors, as (in practice, e.g. on X86)
it is okay to use a single vector register to hold multiple different
types of data, and we don't know just from seeing e.g. "XMM1" how to
interpret the 128 bits of data within.

Fixes #25062

- - - - -
8238fb2d by sheaf at 2024-09-27T06:10:57-04:00
Add vector fused multiply-add operations

This commit adds fused multiply add operations such as `fmaddDoubleX2#`.
These are handled both in the X86 NCG and the LLVM backends.

- - - - -
2cb7b748 by sheaf at 2024-09-27T06:10:57-04:00
Add vector shuffle primops

This adds vector shuffle primops, such as

```
shuffleFloatX4# :: FloatX4# -> FloatX4# -> (# Int#, Int#, Int#, Int# #) -> FloatX4#
```

which shuffle the components of the input two vectors into the output vector.

NB: the indices must be compile time literals, to match the X86 SHUFPD
instruction immediate and the LLVM shufflevector instruction.

These are handled in the X86 NCG and the LLVM backend.

Tested in simd009.

- - - - -
0d2428d6 by sheaf at 2024-09-27T06:10:57-04:00
Add Broadcast MachOps

This adds proper MachOps for broadcast instructions, allowing us to
produce better code for broadcasting a value than simply packing that
value (doing many vector insertions in a row).

These are lowered in the X86 NCG and LLVM backends. In the LLVM backend,
it uses the previously introduced shuffle instructions.

- - - - -
e6c19a41 by sheaf at 2024-09-27T06:10:57-04:00
Fix treatment of signed zero in vector negation

This commit fixes the handling of signed zero in floating-point vector
negation.

A slight hack was introduced to work around the fact that Cmm doesn't
currently have a notion of signed floating point literals
(see get_float_broadcast_value_reg). This can be removed once CmmFloat
can express the value -0.0.

The simd006 test has been updated to use a stricter notion of equality
of floating-point values, which ensure the validity of this change.

- - - - -
f496ff7f by sheaf at 2024-09-27T06:10:57-04:00
Add min/max primops

This commit adds min/max primops, such as

  minDouble# :: Double# -> Double# -> Double#
  minFloatX4# :: FloatX4# -> FloatX4# -> FloatX4#
  minWord16X8# :: Word16X8# -> Word16X8# -> Word16X8#

These are supported in:
  - the X86, AArch64 and PowerPC NCGs,
  - the LLVM backend,
  - the WebAssembly and JavaScript backends.

Fixes #25120

- - - - -
5dd2a423 by sheaf at 2024-09-27T06:10:57-04:00
Add test for C calls & SIMD vectors

- - - - -
f824e1ee by sheaf at 2024-09-27T06:10:58-04:00
Add test for #25169

- - - - -
d54db7f3 by sheaf at 2024-09-27T06:10:58-04:00
Fix #25169 using Plan A from the ticket

We now compile certain low-level Cmm functions in the RTS multiple
times, with different levels of vector support. We then dispatch
at runtime in the RTS, based on what instructions are supported.

See Note [realArgRegsCover] in GHC.Cmm.CallConv.

Fixes #25169

-------------------------
Metric Increase:
    T10421
    T12425
    T18730
    T1969
    T9198
-------------------------

- - - - -
d5f8778a by sheaf at 2024-09-27T06:10:58-04:00
Fix C calls with SIMD vectors

This commit fixes the code generation for C calls, to take into account
the calling convention.

This is particularly tricky on Windows, where all vectors are expected
to be passed by reference. See Note [The Windows X64 C calling convention]
in GHC.CmmToAsm.X86.CodeGen.

- - - - -
f64bd564 by sheaf at 2024-09-27T06:10:58-04:00
X86 CodeGen: refactor getRegister CmmLit

This refactors the code dealing with loading literals into registers,
removing duplication and putting all the code in a single place.
It also changes which XOR instruction is used to place a zero value
into a register, so that we use VPXOR for a 128-bit integer vector
when AVX is supported.

- - - - -
ab12de6b by sheaf at 2024-09-27T06:10:58-04:00
X86 genCCall: promote arg before calling evalArgs

The job of evalArgs is to ensure each argument is put into a temporary
register, so that it can then be loaded directly into one of the
argument registers for the C call, without the generated code clobbering
any other register used for argument passing.

However, if we promote arguments after calling evalArgs, there is the
possibility that the code used for the promotion will clobber a register,
defeating the work of evalArgs.
To avoid this, we first promote arguments, and only then call evalArgs.

- - - - -
8fd12429 by sheaf at 2024-09-27T06:10:58-04:00
X86 genCCall64: simplify loadArg code

This commit simplifies the argument loading code by making the
assumption that it is safe to directly load the argument into register,
because doing so will not clobber any previous assignments.

This assumption is borne from the use of 'evalArgs', which evaluates
any arguments which might necessitate non-trivial code generation into
separate temporary registers.

- - - - -
12504a9f by sheaf at 2024-09-27T06:10:58-04:00
LLVM: propagate GlobalRegUse information

This commit ensures we keep track of how any particular global register
is being used in the LLVM backend. This informs the LLVM type
annotations, and avoids type mismatches of the following form:

  argument is not of expected type '<2 x double>'
    call ccc <2 x double> (<2 x double>)
      (<4 x i32> arg)

- - - - -
2bb1e8df by Cheng Shao at 2024-09-27T06:11:35-04:00
Link bytecode from interface-stored core bindings in oneshot mode

!13042

Part of #T25090

If the flag `-fprefer-byte-code` is given when compiling a module
containing TH, GHC will use Core bindings stored in interfaces to
compile and link bytecode for splices.

This was only implemented for `--make` mode initially, so this commit
adds the same mechanism to oneshot mode (`-c`).

When an interface is loaded into the EPS in `loadInterface` that has
dehydrated Core bindings, an entry is added to the new field
`eps_iface_bytecode`, containing an IO action that produces a bytecode
`Linkable`, lazily processing the `mi_extra_decls` by calling
`loadIfaceByteCode`.

When Template Haskell dependencies are resolved in `getLinkDeps`, this
action is looked up after loading a module's interface.
If it exists, the action is evaluated and the bytecode is added to the
set of `Linkable`s used for execution of the splice; otherwise it falls
back on the traditional object file.

Metric Decrease:
    MultiLayerModules
    T13701

- - - - -
7cb7172e by Matthew Pickering at 2024-09-27T06:12:12-04:00
ci: Fix variable inheritence for ghcup-metadata testing job

Downstream in ghcup-ci we use the CONFIGURE_ARGS variable to determine
how to setup all the different jobs.

On the downstream trigger this was being inherited from the default
setting in .gitlab.yml file.

Therefore this led to job failures as the necessary CONFIGURE_ARGS were
not being passed to the configure script when installing the bindist.

See docs:

* https://docs.gitlab.com/ee/ci/yaml/#inherit
* https://docs.gitlab.com/ee/ci/yaml/#triggerforward

1. inherit:variables:fals
  - This stops the global variables being inherited into the job and
    hence forwarded onto the downstream job.

2. trigger:forward:*
  - yaml_variables: true (default) pass yaml variables to downstream,
    this is important to pass the upstream pipeline id to downstream.
  - pipeline_variables: false (default) but don't pass pipeline
    variables (normal environment variables).

Fixes #25294

- - - - -
9ffd6163 by Leo at 2024-09-27T16:26:01+05:30
Fix typo in Prelude doc for (>>=)

Fix a minor typo ("equivialent" instead of "equivalent") in the documentation for (>>=) in the prelude.

- - - - -
5745dbd3 by Vladislav Zavialov at 2024-09-27T16:26:52+05:30
Wildcard binders in type declarations (#23501)

Add support for wildcard binders in type declarations:

	type Const a b = a   -- BEFORE: the `b` had to be named
	                     --         even if unused on the RHS

	type Const a _ = a   -- AFTER: the compiler accepts
	                     --        a wildcard binder `_`

The new feature is part of GHC Proposal #425 "Invisible binders
in type declarations", and more specifically its amendment #641.

Just like a named binder, a wildcard binder `_` may be:

	* plain:      _
	* kinded:    (_ :: k -> Type)
	* invisible, plain:  @_
	* invisible, kinded: @(_ :: k -> Type)

Those new forms of binders are allowed to occur on the LHSs of
data, newtype, type, class, and type/data family declarations:

	data D _ = ...
	newtype N _ = ...
	type T _ = ...
	class C _ where ...
	type family F _
	data family DF _

(Test case: testsuite/tests/typecheck/should_compile/T23501a.hs)

However, we choose to reject them in forall telescopes and
type family result variable binders (the latter being part
of the TypeFamilyDependencies extension):

	type family Fd a = _    -- disallowed  (WildcardBndrInTyFamResultVar)
	fn :: forall _. Int     -- disallowed  (WildcardBndrInForallTelescope)

(Test case: testsuite/tests/rename/should_fail/T23501_fail.hs)

See the new Notes:
	* Note [Type variable binders]
	* Note [Wildcard binders in disallowed contexts]

To accommodate the new forms of binders, HsTyVarBndr was changed
as follows (demonstrated without x-fields for clarity)

	-- BEFORE (ignoring x-fields and locations)
	data HsTyVarBndr flag
	  = UserTyVar   flag Name
	  | KindedTyVar flag Name HsKind

	-- AFTER (ignoring x-fields and locations)
	data HsTyVarBndr flag = HsTvb flag HsBndrVar HsBndrKind
	data HsBndrVar  = HsBndrVar Name | HsBndrWildCard
	data HsBndrKind = HsBndrNoKind | HsBndrKind LHsKind

The rest of the patch is downstream from this change.

To avoid a breaking change to the TH AST, we generate fresh
names to replace wildcard binders instead of adding a dedicated
representation for them (as discussed in #641).

And to put a cherry on top of the cake, we now allow wildcards in
kind-polymorphic type variable binders in constructor patterns,
see Note [Type patterns: binders and unifiers] and the tyPatToBndr
function in GHC.Tc.Gen.HsType; example:

	fn (MkT @(_ :: forall k. k -> Type) _ _) = ...

(Test case: testsuite/tests/typecheck/should_compile/T23501b.hs)

- - - - -
ff2bdca2 by Matthew Pickering at 2024-09-27T16:27:08+05:30
ci: Push perf notes from wasm jobs

It was observed in #25299 that we were failing to push performance
numbers from the wasm jobs.

In future we might want to remove this ad-hoc check but for now it's
easier to add another special case.

Towards #25299

- - - - -
4c76f75c by Zubin Duggal at 2024-09-27T16:44:00+05:30
Bump GHC version to 9.12

- - - - -
e4ac1b0d by Zubin Duggal at 2024-09-27T19:12:24+05:30
Bump GHC version to 9.13

- - - - -
da20cac1 by Andreas Klebinger at 2024-10-02T22:18:48-04:00
SpecConstr: Introduce a separate argument limit for forced specs.

We used to put no limit at all on specializations forced via the SPEC
argument. This isn't always reasonable so we introduce a very high limit
that applies to forced specializations, a flag to control it, and we now
emit a warning if we fail a specialization because we exceed the
warning.

Fixes #25197

- - - - -
39497eed by Andreas Klebinger at 2024-10-02T22:19:24-04:00
ghc-experimental: Expose primops and ghc extensions via GHC.PrimOps

This will be the new place for functions that would have gone into
GHC.Exts in the past but are not stable enough to do so now.

Addresses #25242

- - - - -
e9dc2690 by Sylvain Henry at 2024-10-02T22:20:06-04:00
RTS: cleanup timerfd file descriptors after a fork (#25280)

When we init a timerfd-based ticker, we should be careful to cleanup the
old file descriptors (e.g. after a fork).

- - - - -
64e876bc by Rodrigo Mesquita at 2024-10-02T22:20:43-04:00
determinism: Deterministic MonadGetUnique LlvmM

Update LlvmM to thread a unique deterministic supply (using UniqDSMT),
and use it in the MonadGetUnique instance.

This makes uniques sampled from LlvmM deterministic, which guarantees
object determinism with -fllvm.

Fixes #25274

- - - - -
36bbb167 by Matthew Pickering at 2024-10-02T22:21:18-04:00
Bump LLVM upper bound to allow LLVM 19

Also bumps the ci-images commit so that the deb12 images uses LLVM 19
for testing.

-------------------------
Metric Decrease:
    size_hello_artifact_gzip
    size_hello_unicode_gzip
-------------------------

Fixes #25295

- - - - -
0029ca91 by Matthew Pickering at 2024-10-02T22:21:54-04:00
configure: Allow happy-2.0.2

happy-2.0.2 can be used to compile GHC.

happy-2.0 and 2.0.1 have bugs which make it unsuitable to use.

The version bound is now == 1.20.* || >= 2.0.2 && < 2.1

Fixes #25276

- - - - -
92976985 by ARATA Mizuki at 2024-10-02T22:22:35-04:00
Use bundled llc/opt on Windows (#22438)

- - - - -
af59749a by Matthew Pickering at 2024-10-02T22:23:11-04:00
Fix registerArch for riscv64

The register allocator doesn't support vector registers on riscv64,
therefore advertise as NoVectors.

Fixes #25314

- - - - -
a49e66fc by Matthew Pickering at 2024-10-02T22:23:11-04:00
riscv: Avoid using csrr instruction to test for vector registers

The csrr instruction isn't allowed in qemu user-mode, and raises an
illegal instruction error when it is encountered.

Therefore for now, we just hard-code that there is no support for vector
registers since the rest of the compiler doesn't support vector
registers for riscv.

Fixes #25312

- - - - -
115a30e9 by Andreas Klebinger at 2024-10-02T22:23:11-04:00
Add support for fp min/max to riscv

Fixes #25313

- - - - -
f28b5992 by Ben Gamari at 2024-10-02T22:23:47-04:00
testsuite/perf: Report better error message on malformed note

Previously a malformed perf note resulted in very poor errors.
Here we slight improve this situation.

- - - - -
51377508 by Ben Gamari at 2024-10-02T22:23:47-04:00
testsuite: Handle division-by-zero more gracefully

Previously we would fail with an ZeroDivisionError.

Fixes #25321

- - - - -
50490075 by Matthew Pickering at 2024-10-03T05:55:13-04:00
ci: Add nightly & release ubuntu-22.04 jobs

This adds build of bindists on ubuntu-22.04 on nightly and release
pipelines.

We also update ghcup-metadata to provide ubuntu-22.04 bindists on
ubuntu-22.04.

Fixes #25317

- - - - -
9cf1cef5 by Zubin Duggal at 2024-10-03T05:55:49-04:00
haddock: Bump binary interface version to 46.

This allows haddock to give good error messages when being used on mismatched interface files.

We bump to 46 since GHC 9.12 uses version 45: https://gitlab.haskell.org/ghc/ghc/-/commit/362afd632032ee8f174690c3ffe0015076b83ce6

This should have been done in e4ac1b0d281b85a0144d1ef6f84a1df00e236052 but was overlooked.

- - - - -
2293c0b7 by Andreas Klebinger at 2024-10-03T05:56:25-04:00
Change versionig of ghc-experimental to follow ghc versions.

Just like ghc-internal it will now use the @ProjectVersionForLib@ macro for versioning.
This means for ghc=9.10.1, ghc-experimental's version will be 9.1001.0 and so on.

This fixes #25289

- - - - -
876d6e0e by Ben Gamari at 2024-10-04T15:07:53+01:00
base: Add `HasCallStack` constraint to `ioError`

As proposed in core-libraries-committee#275.

- - - - -
9bfd9fd0 by Matthew Pickering at 2024-10-04T15:08:03+01:00
Fix toException method for ExceptionWithContext

Fixes #25235

- - - - -
ac004028 by Matthew Pickering at 2024-10-04T15:09:07+01:00
Exception rethrowing

Basic changes:

* Change `catch` function to propagate exceptions using the
  WhileHandling mechanism.
* Introduce `catchNoPropagate`, which does the same as before, but
  passes an exception which can be rethrown.
* Introduce `rethrowIO` combinator, which rethrows an exception with a
  context and doesn't add a new backtrace.
* Introduce `tryWithContext` for a variant of `try` which can rethrow
  the exception with it's original context.
* onException is modified to rethrow the original error rather than
  creating a new callstack.
* Functions which rethrow in GHC.Internal.IO.Handle.FD,
  GHC.Internal.IO.Handle.Internals, GHC.Internal.IO.Handle.Text, and
  GHC.Internal.System.IO.Error are modified to not add a new callstack.

Implements CLC proposal#202 <https://github.com/haskell/core-libraries-committee/issues/202>

- - - - -
bcb293f2 by Cheng Shao at 2024-10-04T17:59:28-04:00
testsuite: remove accidentally checked in debug print logic

- - - - -
68e2da5a by Rodrigo Mesquita at 2024-10-05T10:36:15-04:00
Deprecation for WarnCompatUnqualifiedImports

Fixes #25330

- - - - -
4327f0e8 by Andrew Lelechenko at 2024-10-05T10:36:52-04:00
Restrict Data.List.NonEmpty.unzip to NonEmpty (a, b) -> (NonEmpty a, NonEmpty b)

Implementing the final phase of CLC proposal https://github.com/haskell/core-libraries-committee/issues/86

- - - - -
ceca9efb by Cheng Shao at 2024-10-06T02:18:31+00:00
driver: fix runWorkerLimit on wasm

This commit fixes link-time unresolved symbol errors for sem_open etc
on wasm, by making runWorkerLimit always behave single-threaded. This
avoids introducing the jobserver logic into the final wasm module and
thus avoids referencing the posix semaphore symbols.

- - - - -
135fd1ac by Torsten Schmits at 2024-10-06T02:18:31+00:00
Parallelize getRootSummary computations in dep analysis downsweep

This reuses the upsweep step's infrastructure to process batches of
modules in parallel.

I benchmarked this by running `ghc -M` on two sets of 10,000 modules;
one with a linear dependency chain and the other with a binary tree.
Comparing different values for the number of modules per thread
suggested an optimum at `length targets `div` (n_cap * 2)`, with results
similar to this one (6 cores, 12 threads):

```
Benchmark 1: linear 1 jobs
  Time (mean ± σ):      1.775 s ±  0.026 s    [User: 1.377 s, System: 0.399 s]
  Range (min … max):    1.757 s …  1.793 s    2 runs

Benchmark 2: linear 6 jobs
  Time (mean ± σ):     876.2 ms ±  20.9 ms    [User: 1833.2 ms, System: 518.6 ms]
  Range (min … max):   856.2 ms … 898.0 ms    3 runs

Benchmark 3: linear 12 jobs
  Time (mean ± σ):     793.5 ms ±  23.2 ms    [User: 2318.9 ms, System: 718.6 ms]
  Range (min … max):   771.9 ms … 818.0 ms    3 runs
```

Results don't differ much when the batch size is reduced to a quarter
of that, but there's significant thread scheduling overhead for a size
of 1:

```
Benchmark 1: linear 1 jobs
  Time (mean ± σ):      2.611 s ±  0.029 s    [User: 2.851 s, System: 0.783 s]
  Range (min … max):    2.591 s …  2.632 s    2 runs

Benchmark 2: linear 6 jobs
  Time (mean ± σ):      1.189 s ±  0.007 s    [User: 2.707 s, System: 1.103 s]
  Range (min … max):    1.184 s …  1.194 s    2 runs

Benchmark 3: linear 12 jobs
  Time (mean ± σ):      1.097 s ±  0.006 s    [User: 2.938 s, System: 1.300 s]
  Range (min … max):    1.093 s …  1.101 s    2 runs
```

Larger batches also slightly worsen performance.

- - - - -
535a2117 by Daniel Díaz at 2024-10-06T09:51:46-04:00
Clarify the meaning of "exactly once" in LinearTypes

Solves documentaion issue #25084.

- - - - -
92f8939a by Krzysztof Gogolewski at 2024-10-06T09:52:22-04:00
Only allow (a => b) :: Constraint rather than CONSTRAINT rep

Fixes #25243

- - - - -
4a2f0f13 by Alan Zimmerman at 2024-10-07T05:16:54-04:00
EPA: Remove unused hsCaseAnnsRest

We never populate it, so remove it.

- - - - -
5099057b by John Paul Adrian Glaubitz at 2024-10-07T05:17:40-04:00
rts: Fix invocation of __ieee_set_fp_control() on alpha-linux

Fixes the following error when building GHC on alpha-linux:

rts/posix/Signals.c: In function ‘initDefaultHandlers’:

rts/posix/Signals.c:709:5: error:
     error: implicit declaration of function ‘ieee_set_fp_control’ [-Wimplicit-function-declaration]
      709 |     ieee_set_fp_control(0);
          |     ^~~~~~~~~~~~~~~~~~~
    |
709 |     ieee_set_fp_control(0);
    |

- - - - -
c9590ba0 by Teo Camarasu at 2024-10-07T05:18:17-04:00
Add changelog entries for !12479

- - - - -
bf9c9566 by Matthew Pickering at 2024-10-07T13:19:30-04:00
javascript: Read fields of ObjectBlock lazily

When linking a module with a large dependency footprint too much of the
object files were forced during linking. This lead to a large amount of
memory taken up by thunks which would never be forced

On the PartialDownsweep test this halves the memory required (from 25G
to 13G).

Towards #25324

-------------------------
Metric Increase:
    size_hello_obj
-------------------------

- - - - -
571329df by Matthew Pickering at 2024-10-07T13:20:06-04:00
ci: Run the i386 validation job when i386 label is set

This is helpful when making changes to base and must update the
javascript and i386 base exports files.

- - - - -
e68f9aaf by Matthew Pickering at 2024-10-07T13:20:42-04:00
Rewrite partitionByWorkerSize to avoid pattern match checker bug

With `-g3` the pattern match checker would warn about these incomplete
patterns. This affects the debug_info builds on CI.

```
    Pattern match(es) are non-exhaustive
    In an equation for ‘go’:
        Patterns of type ‘[a]’, ‘[a]’, ‘[SpecFailWarning]’ not matched:
            (_:_) _ _
     |
2514 |         go [] small warnings = (small, warnings)
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
```

Workaround for #25338

- - - - -
d915dc8b by Arnaud Spiwack at 2024-10-07T19:23:00-04:00
Remove the wrapper/coercion-passing logic for submultiplicity checks

Instead, we use a dedicated DelayedError, which is emitted
systematically on submultiplicity checks, but is suppressed if we can
indeed solve the submultiplicity constraint with a reflexivity
coercion.

This way, we don't have to return anything from `tcSubMult`, which now
looks like a regular constraint check, the rest is implementation
detail. This removes all of the strange boilerplate that I'd been
struggling with under the previous implementation. Even if
submultiplicity checks are not properly constraints, this way it's
contained entirely within a `WantedConstraint`. Much more pleasant.

Closes #25128.

- - - - -
1d226116 by Sven Tennie at 2024-10-07T19:23:37-04:00
AArch64: Implement switch/jump tables (#19912)

This improves the performance of Cmm switch statements (compared to a
chain of if statements.)

- - - - -
3fe621dd by Mario Blažević at 2024-10-07T19:24:18-04:00
Fixes #25256, missing parens inside TH-printed pattern type signature

- - - - -
ea4b4391 by ARATA Mizuki at 2024-10-07T19:24:59-04:00
Better documentation for floatRange function

Closes #16479

- - - - -
ff09205c by Andreas Klebinger at 2024-10-07T19:25:35-04:00
Adjust progress message for hadrian to include cwd.

Fixes #25335

- - - - -
5fd320da by Sven Tennie at 2024-10-07T19:26:12-04:00
CCallConv test: Align argument types

The C calling convention / standard requires that arguments and their
values are of the same type.

- - - - -
c6e5fd3d by Cheng Shao at 2024-10-07T19:26:47-04:00
hadrian: remove unused ghciWithDebugger field from flavour config

This patch removes the ghciWithDebugger field from flavour config
since it's actually not used anywhere.

- - - - -
9c9c790d by sheaf at 2024-10-07T19:27:23-04:00
user's guide: update docs for X86 CPU flags

This commit updates the section of the user's guide pertaining to
X86 feature flags with the following changes:

  - the NCG backend now supports SIMD, so remove all text
    that says the contrary,
  - the LLVM backend does not "automatically detect" features,
    so remove any text that makes that claim.

- - - - -
a1ecc826 by Sven Tennie at 2024-10-08T13:36:03-04:00
ci: RISCV64 cross-compile testing

This adds a validation job which tests that we can build a riscv64 cross
compiler and build a simple program using it. We do not currently run
the whole testsuite.

Towards #25254

Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com>

- - - - -
d5c2577f by Arnaud Spiwack at 2024-10-08T13:36:44-04:00
Remove unused accumulators in partition_errors

- - - - -
55609880 by Andrzej Rybczak at 2024-10-09T16:41:46-04:00
Fix typo in the @since annotation of annotateIO

- - - - -
ef481813 by Alan Zimmerman at 2024-10-09T16:42:23-04:00
EPA: Remove [AddEpAnn] from (most of) HsExpr

EPA: introduce EpAnnLam for lambda annotationsi, and remove `glAA`
from `Parser.y`, it is the same as `glR`

EPA: Remove unused annotation from XOpApp

EPA: Use EpToken for XNPat and XNegApp

EPA: specific anns for XExplicitTuple / XTuplePat / sumPatParens.

EPA: Use specific annotation for MultiIf

EPA: Move annotations into FunRhs

EPA: Remove [AddEpAnn] from SigPat and ExprWithTySig

EPA: Remove [AddEpAnn] from ArithSeq

EPA: Remove [AddEpAnn] from HsProc

EPA: Remove [AddEpAnn] from HsStatic

EPA: Remove [AddEpAnn] from BindStmt

EPA: Remove [AddEpAnn] from TransStmt

EPA: Remove [AddEpAnn] from HsTypedSplice

EPA: Remove [AddEpAnn] from HsUntypedSpliceExpr

- - - - -
69960230 by Fabian Thorand at 2024-10-10T19:03:59+00:00
Handle exceptions from IO manager backend

If an IO manager backend throws, it will not actually have registered
the file descriptor. However, at that point, the IO manager state was
already updated to assume the file descriptor is being tracked, leading
to errors and an eventual deadlock down the line as documented in the
issue #21969.

The fix for this is to undo the IO manager state change in case the
backend throws (just as we already do when the backend signals that the
file type is not supported). The exception then bubbles up to user code.

That way we make sure that
1. the bookkeeping state of the IO manager is consistent with the
   actions taken by the backend, even in the presence of unexpected
   failures, and
2. the error is not silent and visible to user code, making failures
   easier to debug.

- - - - -
1587cccf by Hassan Al-Awwadi at 2024-10-11T03:52:36-04:00
Put RdrName in the foExt field of FieldOcc

The main purpose of this commit is to rip RdrName out of FieldOcc, in
accordance with #21592, and as a side note it has simplified the method
we use to deal with ambiguity somewhat.

To do the first, we make FieldOccs store (LIdP p) instead of always
storing Located RdrName, and moved the readername to the extension
points where necessary.

For the second, well, we just turn an ambiguous RdrName into a unbound
Name through mkUnboundName. Later during disambiguateRecordBinds of the
type checking phase, we will try and do type-directed disambiguation based
on the rdrName field (for now), so this hack works out fine.

See Note [Ambiguous FieldOcc in record updates] for more details.

There are two additional minor changes in this commit:
*  The HsRecSel constructor of HsExpr has been moved to the extension
constuctors, since its really GHC specific.
*  HsProjection no longer has a Located DotFieldOcc as a field, but just a
regular DotFieldOcc, since DotFieldOcc already wraps a located
FieldLabelString

co-authored by: @Jade       <Jade512 at proton.me>
                @alt-romes  <rodrigo.m.mesquita at gmail.com>

- - - - -
2338a971 by Cheng Shao at 2024-10-11T03:53:13-04:00
driver: bail out when -fllvm is passed to GHC not configured with LLVM

This patch makes GHC bail out with an proper error message when it's
not configured with LLVM but users attempt to pass -fllvm, see #25011
and added comment for details.

Fixes #25011

Co-authored-by: Rodrigo Mesquita <rodrigo.m.mesquita at gmail.com>

- - - - -
78ad81ec by Cristiano Moraes at 2024-10-11T03:53:55-04:00
configure: Find C++ probing when GCC version is the latest but G++ is old #23118
- - - - -
083703a1 by Simon Peyton Jones at 2024-10-11T03:54:32-04:00
Consider Wanteds with rewriters as insoluble

This MR fixes #25325

See GHC.Tc.Types.Constraint, Note [Insoluble Wanteds], especially (IW2)

There is a small change in the error message for T14172, but it looks
entirely acceptable to me.

- - - - -
0dfaeb66 by Simon Peyton Jones at 2024-10-11T03:54:32-04:00
Wibbles

- - - - -
09d24d82 by Simon Peyton Jones at 2024-10-11T03:54:32-04:00
Spelling errors

- - - - -
694489ed by sheaf at 2024-10-11T03:55:14-04:00
LLVM: use sse4.2 instead of sse42

LLVM expects the former instead of the latter since version 3.4.

Fixes #25019

- - - - -
06ae8507 by sheaf at 2024-10-11T03:55:14-04:00
LLVM: make SSE4.2 imply +popcnt

For consistency with the NCG as well as with Clang and GCC, we make
the SSE4.2 feature flag imply +popcnt when using the LLVM backend.

Fixes #25353

- - - - -
3fe843c7 by Cheng Shao at 2024-10-11T03:55:50-04:00
Drop obsolete libffi Makefile

This patch drops obsolete libffi Makefile from the tree, given it's
completely unused since removal of make build system in !7094.

- - - - -
df70405c by Ben Gamari at 2024-10-11T03:56:26-04:00
ghc-internal: Fix incomplete matches on IOError

As noted in #25362, these incomplete matches were previously not being
warned about. They were easily addressed by use of
`GHC.Internal.Event.Windows.withException`.

Closes #25362.

- - - - -
8584504b by Matthew Pickering at 2024-10-11T03:57:02-04:00
compiler: Fix orientation of GHC.Hs.Doc boot file

We should be free to import things from Language.Haskell.Syntax in GHC
modules. Therefore the the boot file for the loop between ImpExp and
GHC.Hs.Doc was in the wrong place.

Issue #21592

- - - - -
dfca9db8 by Rodrigo Mesquita at 2024-10-11T16:48:29+01:00
ttg: Start using Text over FastString in the AST

Towards the goal of making the AST independent of GHC, this commit
starts the task of replacing usages of `FastString` with `Text` in the
AST (Language.Haskell.* modules).

Even though we /do/ want to use FastStrings -- critically in Names or Ids
-- there is no particular reason for the FastStrings that occur in the
AST proper to be FastStrings. Primarily, ...

Progress towards #21592

- - - - -
36251cd3 by Rodrigo Mesquita at 2024-10-11T16:49:59+01:00
A handful of progress

- - - - -
b4e16b58 by Rodrigo Mesquita at 2024-10-11T16:51:20+01:00
more

- - - - -
d7f9b42b by Rodrigo Mesquita at 2024-10-11T16:51:21+01:00
CType Text rather than FastString

Todo: maybe don't use decode/encode utf8 in binary instance?

- - - - -
46d06a05 by Rodrigo Mesquita at 2024-10-11T16:52:02+01:00
Parser getSTRING progress

- - - - -
772ff158 by Rodrigo Mesquita at 2024-10-11T16:52:51+01:00
HsLit Text-backed Strings

- - - - -
8c039d84 by Rodrigo Mesquita at 2024-10-11T16:55:25+01:00
the biggest boy

- - - - -
6263f9a6 by Rodrigo Mesquita at 2024-10-11T17:55:00+01:00
FIX

- - - - -


18 changed files:

- .gitignore
- .gitlab-ci.yml
- + .gitlab/README.md
- .gitlab/ci.sh
- .gitlab/darwin/nix/sources.json
- .gitlab/darwin/toolchain.nix
- .gitlab/generate-ci/flake.lock
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
- .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py
- .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py
- .gitmodules
- CODEOWNERS
- compiler/CodeGen.Platform.h
- compiler/GHC.hs
- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Builtin/Names/TH.hs
- compiler/GHC/Builtin/PrimOps.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d9408cc56ae54d0bd86a27308fe97dbf635fe727...6263f9a6e0ff1ada977d71422a2e0a8aef1a46d4

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d9408cc56ae54d0bd86a27308fe97dbf635fe727...6263f9a6e0ff1ada977d71422a2e0a8aef1a46d4
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/20241011/67abb298/attachment-0001.html>


More information about the ghc-commits mailing list