[Git][ghc/ghc][wip/fabu/T24848-meaningful-return] 342 commits: Demand: Combine examples into Note (#25107)

Fabricio Nascimento (@fabu) gitlab at gitlab.haskell.org
Fri Nov 22 08:58:20 UTC 2024



Fabricio Nascimento pushed to branch wip/fabu/T24848-meaningful-return at Glasgow Haskell Compiler / GHC


Commits:
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

- - - - -
d029f170 by Ben Gamari at 2024-10-11T23:43:17-04:00
testsuite: Normalise trailing digits from hole fits output

The type variables in the holes fit output from
`abstract_refinement_hole_fits` is quite sensitive to compiler
configuration. Specifically, a slight change in the inlining
behavior of `throw` changes type variable naming in `(>>=)` and a few
others.

Ideally we would make hole fits output more deterministic but in the
meantime we simply normalise this difference away as it not relevant
to the test's goal.

- - - - -
da5d7d0d by Ben Gamari at 2024-10-11T23:43:17-04:00
base: Add test for #25066

- - - - -
eb7ddae1 by Ben Gamari at 2024-10-11T23:43:17-04:00
base: Fix #25066

As noted in #25066, the exception backtrace proposal introduced a rather
subtle performance regression due to simplification producing Core which
the demand analyser concludes may diverge with a precise exception. The
nature of the problem is more completely described in the new Note
[Hiding precise exception signature in throw].

The (rather hacky) solution we use here hides the problematic
optimisation through judicious use of `noinline`. Ultimately however we
will want a more principled solution (e.g. #23847).

Fixes #255066

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

Metric Decrease:
    T9872d

- - - - -
0060ece7 by Ben Gamari at 2024-10-11T23:43:17-04:00
base: Improve documentation of Control.Exception.Backtrace

- - - - -
18f532f3 by Ben Gamari at 2024-10-11T23:43:53-04:00
Bump process submodule to v1.6.25.0

- - - - -
a9a3badf by Hassan Al-Awwadi at 2024-10-11T23:44:29-04:00
Move HsInteger and HsRat to an extension constructor

These constructors were only used during the TC stage,
or during template haskell. It seemed clear that it was
independent of the source syntax represented in L.H.S,
and thus we removed it according to #21592.

- - - - -
4dd30cba by Artem Pelenitsyn at 2024-10-11T23:45:09-04:00
Docs: Linear types: link Strict Patterns subsection

Also, fix a bug in RST with missing newline before a listing.

Co-authored-by: Arnaud Spiwack <arnaud at spiwack.net>

- - - - -
adca5f2b by Ben Gamari at 2024-10-11T23:45:45-04:00
users guide: Address remaining TODOs in eventlog format docs

Closes #25296.

- - - - -
9291c125 by Sylvain Henry at 2024-10-11T23:46:26-04:00
Fix z-encoding of tuples (#25364)

Tuples with prefix/suffix strings weren't always properly encoded with
their shortcut notations. Fix this.

- - - - -
c08b68bc by Sven Tennie at 2024-10-11T23:47:01-04:00
Delete constants that can be deduced

There are macros in MachRegs.h to figure those out.

- - - - -
8b402da2 by Zubin Duggal at 2024-10-12T20:36:57+00:00
hadrian: Handle broken symlinks properly when creating source dist directories

If we have a broken symlink in the repository, don't try to `need` the symlink
or the target of the symlink. Attempting to do so has `shake` attempt to read the
target to compute its hash, which fails because the target doesn't exist.

- - - - -
16f97667 by Zubin Duggal at 2024-10-12T20:36:57+00:00
hadrian: exclude cabal.project.symlink.broken from source archives

Cabal 3.14 introduced a broken symlink in its testsuite. Unfortunately,
this broke our source distribution as we use use `tar --dereference` to avoid
issues with symlink compatibility on windows, and `tar --dereference` chokes
when it encounters any broken symlinks.

We can't get rid of `--dereference` because symlinks are generally broken on
windows, so the only option is to exclude this file from source archives.

see also https://github.com/haskell/cabal/issues/10442

- - - - -
f1a2c9fc by Zubin Duggal at 2024-10-12T20:36:57+00:00
Bump Cabal submodule to 3.14

Metric Decrease:
    MultiLayerModulesTH_OneShot
Metric Increase:
    haddock.Cabal

- - - - -
745dd590 by Ben Gamari at 2024-10-14T09:13:12-04:00
users-guide: Document GHCi :where command

Resolve #24509.

- - - - -
e9cc4699 by Alan Zimmerman at 2024-10-14T09:13:48-04:00
EPA: Remove [AddEpAnn] from IE, Pat and some Tys

EPA: Remove [AddEpAnn] from LazyPat

EPA: Remove [AddEpAnn] from RecordCon/RecordUpd/ConPat

EPA: Remove [AddEpAnn] from HsFieldBind

EPA: Remove [AddEpAnn] from PatSynBind

EPA: Remove [AddEpAnn] from IPBind

EPA: Remove [AddEpAnn] from FixSig

EPA: Remove [AddEpAnn] from activation rules

EPA: Remove [AddEpann] from SpecInstSig

EPA: Remove [AddEpAnn] from MinimalSig

EPA: Remove [AddEpAnn] from SCCFunSig

EPA: Remove [AddEpAnn] from CompleteMatchSig

EPA: Remove [AddEpAnn] from AnnSig, as used in PatSynSig, ClassOpSig, TypeSig

EPA: Remove [AddEpAnn] from IEThingAbs

EPA: Remove [AddEpAnn] from IEThingAll / IEThingWith

EPA: Remove [AddEpAnn] from IEModuleContents

EPA: Remove [AddEpAnn] from HsOpTy

EPA: Remove [AddEpAnn] for various binders

EPA: Remove [AddEpAnn] for HsIParamTy

- - - - -
81a570bf by Sebastian Graf at 2024-10-14T22:15:31-04:00
Desugaring, plus -Wincomplete-record-selectors

This commit does several related things:

* Major refactor of the handling of applications in the desugarer.
  Now all applications are handled in `dsApp`, `ds_app` and related
  functions.  This dramatically simplifies the code and removes
  complicated cruft that had accumulated.  Hooray.

  Fixes #25281.

* Improve the handling of -Wincomplete-record-selectors.

  We now incorporate the result type of unsaturated record selector
  applications as well as consider long-distance information in
  getField applications.

  Plus, the implmentation now builds the improved `dsApp` stuff
  above, so it is much easier to understand.

  Plus, incorporates improved error message wording suggested
  by Adam Gundry in !12685.

  Fixes #24824, #24891

  See the long Note [Detecting incomplete record selectors]

* Add -Wincomplete-record-selectors to -Wall, as specified in
  GHC Proposal 516.

  To do this, I also had to add -Wno-incomplete-record-selectors
  to the build flags for Cabal in GHC's CI.  See
  hadrian/src/Settings/Warnings.hs.  We can remove this when
  Cabal is updated so that it doesn't trigger the warning:
  https://github.com/haskell/cabal/issues/10402

2.6% decrease in compile time allocation in RecordUpPerf

Metric Decrease:
    RecordUpdPerf

- - - - -
ae7bc08e by Simon Peyton Jones at 2024-10-14T22:15:31-04:00
Elmininate incomplete record selectors

This patch is a pure refactor of GHC's source code, to avoid the use
of partial record selectors.  It was provoked by adding
-Wincomplete-record-selectors to -Wall (as the GHC Proposal specified),
which in turn showed up lots of places where GHC was using incomplete
record selectors.

This patch does mostly-simple refactoring to make it clear to the pattern
match checker that there is in fact no partiality.

There is one externally-visible change: I changed the data type HoleFit
to split out the two cases

  data HoleFit = TcHoleFit  TcHoleFit | RawHoleFit SDoc
  data TcHoleFit = HoleFit { ...lots of fields }

There are large swathes of code that just deal with `TcHoleFit`, and
having it as a separate data types makes it apparent that `RawHoleFit`
can't occur.

This makes it much better -- but the change is visible in the
HolePlugin interface.  I decided that there are so few clients of this
API that it's worth the change.

I moved several functions from Language.Haskell.Syntax to GHC.Hs.
Reason, when instantiated at (GhcPass _), the extension data construtcor
is guaranteed unused, and that justifies omitted patterns in these
functions.  By putting them in GHC.Hs.X I can specialise the type for
(GhcPass _) and thereby make the function total.

An interesting side-light is that there were a few local function
definitions without a type signature, like this one in GHC.Parser.Header
     convImport (L _ i) = (ideclPkgQual i, reLoc $ ideclName i)
This is fully closed, and so is generalised; but that generalises
it to any old pass, not (GhcPass _), so GHC rightly complains about the
use of the selector `ideclPkgQual`.  I added a type signature to `i`, thus
     convImport (L _ (i::ImportDecl GhcPs))
         = (ideclPkgQual i, reLoc $ ideclName i)
which specialised the function enough to make the record selector complete.
Quite a surprising consequence of local let-generalisation!

- - - - -
6a067226 by Simon Peyton Jones at 2024-10-14T22:15:31-04:00
Add -Werror=-Wno-error=incomplete-record-selectors to hadrian-multi

In the main MR, -Wall now includes -Wincomplete-record-selectors.
However `hadrian-multi` has many, many warnings about incomplete
record selectors, so this patch stops those warnings being treated
as errors.  (See discussion on !13308.)

A better fix would be to remove the use of incomplete record
selectors, since each of them represents a potential crash.

- - - - -
edeafc14 by Ben Gamari at 2024-10-14T22:16:08-04:00
users-guide: Document field coalescence

- - - - -
55b83587 by ARATA Mizuki at 2024-10-14T22:16:49-04:00
LLVM backend: Use correct rounding for Float literals

Fixes #22033

- - - - -
e59fe5c6 by Hassan Al-Awwadi at 2024-10-15T08:25:33+00:00
Changed import from Ghc.  module to L.H.S module

Progresses #21592

For some reason we still imported GHC.Types.Fixity when the definitino of Fixity and LexicalFixity have already been moved to Language.Haskell.Syntax.Basic. This fixes that for

- - - - -
ab1767d5 by Simon Peyton Jones at 2024-10-15T23:45:04-04:00
Add a release-notes entry for -Wincomplete-record-selectors

- - - - -
6f0a62db by ur4t at 2024-10-16T15:33:43+00:00
GHCi: fix improper location of ghci_history file

Fixes #24266

- - - - -
5f67db48 by Alan Zimmerman at 2024-10-17T05:18:43-04:00
EPA: Remove [AddEpAnn] commit 3

EPA: Remove [AddEpAnn] from HsDocTy

EPA: Remove [AddEpAnn] from HsBangTy

EPA: Remove [AddEpAnn] from HsExplicitListTy

EPA: Remove [AddEpAnn] from HsExplicitTupleTy

EPA: Remove [AddEpAnn] from HsTypedBracket

EPA: Remove [AddEpAnn] from HsUntypedBracket

EPA: Remove [AddEpAnn] from PatBuilderOpApp

EPA: break out 'EpToken "|"' from ClassDecl anns

EPA: Remove [AddEpAnn] from ClassDecl

EPA: Remove [AddEpAnn] from SynDecl

- - - - -
fbbbd010 by Daan Rijks at 2024-10-17T05:19:19-04:00
Expand the haddocks for Control.Category

- - - - -
076c1a10 by Andrew Lelechenko at 2024-10-17T05:19:19-04:00
documentation: more examples for Control.Category

- - - - -
90891962 by Cheng Shao at 2024-10-17T16:41:18+00:00
ghci: mitigate host/target word size mismatch in BCOByteArray serialization

This patch mitigates a severe host/target word size mismatch issue in
BCOByteArray serialization logic introduced since !12142, see added
note for detailed explanation.

- - - - -
839ac52e by Cheng Shao at 2024-10-17T16:41:18+00:00
ghci: use plain malloc for mkConInfoTable on non-TNTC platforms

This patch avoids using mmap() to allocate executable memory for
mkConInfoTable on platforms without tables-next-to-code, see added
comment for explanation.

- - - - -
a998f69d by Cheng Shao at 2024-10-17T16:41:18+00:00
ghc-internal: add missing CPPs for wasm

This patch adds some missing CPP guards to ghc-internal, given those
functions are non existent on wasm and would cause linking issues.

- - - - -
71a471e7 by Cheng Shao at 2024-10-17T16:41:18+00:00
rts: rename prelude.js to prelude.mjs

This commit renames prelude.js to prelude.mjs for wasm backend rts
jsbits, and slightly adjusts the jsbits contents. This is for
preparing the implementation of dyld.mjs that contains wasm dynamic
linker logic, which needs to import prelude.mjs as a proper ESM
module.

- - - - -
33d9db17 by Cheng Shao at 2024-10-17T16:41:18+00:00
rts: add __wrapped_freeJSVal

This commit wraps imported freeJSVal in a __wrapped_freeJSVal C
function for wasm backend RTS. In general, wasm imports are only
supposed to be directly called by C; they shouldn't be used as
function pointers, which confuses wasm-ld at link-time when generating
shared libraries.

- - - - -
0d0a16a8 by Cheng Shao at 2024-10-17T16:41:18+00:00
rts: correct stale link in comment

- - - - -
90a35c41 by Cheng Shao at 2024-10-17T16:41:18+00:00
rts: drop interpretBCO support from non-dyn ways on wasm

This commit drops interpretBCO support from non dynamic rts ways on
wasm. The bytecode interpreter is only useful when the RTS linker also
works, and on wasm it only works for dynamic ways anyway. An
additional benefit of dropping interpretBCO is reduction in code size
of linked wasm modules, especially since interpretBCO references
ffi_call which is an auto-generated large function in libffi-wasm and
unused by most user applications.

- - - - -
98a32ec5 by Cheng Shao at 2024-10-17T16:41:18+00:00
rts: don't build predefined GloblRegs for wasm PIC mode

This commit wraps the predefined GlobalRegs in Wasm.S under a CPP
guard to prevent building for PIC mode. When building dynamic ways of
RTS, the wasm globals that represent STG GlobalRegs will be created
and supplied by dyld.mjs. The current wasm dylink convention doesn't
properly support exporting relocatable wasm globals at all, any wasm
global exported by a .so is assumed to be a GOT.mem entry.

- - - - -
bef94bde by Cheng Shao at 2024-10-17T16:41:18+00:00
rts: fix conflicting StgRun definitions on wasm

This commit fixes conflicting StgRun definition when building dynamic
ways of RTS for wasm in unregisterised mode.

- - - - -
a6a82cdb by Cheng Shao at 2024-10-17T16:41:18+00:00
hadrian: use targetSupportsRPaths predicate

This commit changes the hostSupportsRPaths predicate to
targetSupportsRPaths and use that to decide whether to pass
RPATH-related link-time options. It's not applied to stage0, we should
just use the default link-time options of stageBoot ghc.

- - - - -
f232c872 by Cheng Shao at 2024-10-17T16:41:18+00:00
hadrian: disable internal-interpreter of ghc library when cross compiling

This commit disable the internal-interpreter flag of ghc library when
cross compiling, only external interpreter works in such cases.

- - - - -
577c1819 by Cheng Shao at 2024-10-17T16:41:18+00:00
hadrian: enable internal-interpreter for ghc-bin stage0

This commit enables internal-interpreter flag for ghc-bin even when
compiling stage0, as long as target supports ghci. It enables ghci
functionality for cross targets that support ghci, since cross ghc-bin
is really stage0.

- - - - -
c247f2ee by Cheng Shao at 2024-10-17T16:41:18+00:00
hadrian: fix CFLAGS for gmp shared objs on wasm

This commit adds -fvisibility=default to CFLAGS of gmp when building
for wasm. This is required to generate the ghc-bignum shared library
without linking errors. Clang defaults to -fvisibility=hidden for wasm
targets, which will cause issues when a symbol is expected to be
exported in a shared library but without explicit visibility attribute
annotation.

- - - - -
775410fd by Cheng Shao at 2024-10-17T16:41:18+00:00
hadrian: re-enable PIC for gmp on wasm

This commit re-enables --with-pic=yes configuration option of gmp when
building for wasm, given we're about to include support for shared
libraries, TH and ghci.

- - - - -
b45080a3 by Cheng Shao at 2024-10-17T16:41:18+00:00
hadrian: add the host_fully_static flavour transformer

This commit adds the host_fully_static flavour transformer to hadrian,
which ensures stage0 is fully statically linked while still permitting
stage1 libdir to contain shared libraries. This is intended to be used
by the wasm backend to build portable linux bindists that contain wasm
shared libraries.

- - - - -
5043507c by Cheng Shao at 2024-10-17T16:41:18+00:00
ci: update wasm jobs configuration

This commit bumps ci-image revision to use updated wasm toolchain, and
use host_fully_static instead of fully_static for wasm jobs so to
ensure wasm shared libraries can be properly built.

- - - - -
2956a3f7 by Cheng Shao at 2024-10-17T16:41:18+00:00
hadrian/testsuite: implement config.cross logic

This commit implements the config.cross field in the testsuite driver.
It comes from the "cross compiling" ghc info field for both
in-tree/out-of-tree GHC, and is an accurate predicate of whether we're
cross-compiling or not (compared to the precense of target emulator),
and is useful to implement predicates to assert the precense of
internal interpreter (only available on non-cross GHC) for tests that
do require it (e.g. plugins).

- - - - -
8c74a0ed by Cheng Shao at 2024-10-17T16:41:18+00:00
hadrian/compiler: implement targetRTSLinkerOnlySupportsSharedLibs

This patch implements the targetRTSLinkerOnlySupportsSharedLibs
predicate in hadrian. Its definition in hadrian is the single source
of truth, and the information propagates to ghc settings file, ghc
driver and testsuite driver. It is used in various places to ensure
dynamic dependency is selected when the target RTS linker only
supports loading dynamic code.

- - - - -
b4c3c340 by Cheng Shao at 2024-10-17T16:41:18+00:00
testsuite: don't use host cpu features when testing cross ghc

This patch disables CPU feature detection logic when testing cross
GHC, since those features don't make sense for the target anyway.

- - - - -
3c21b696 by Cheng Shao at 2024-10-17T16:41:19+00:00
testsuite: implement & use req_plugins predicate

This commit implements req_plugins predicate to indicate that the test
requires plugin functionality. Currently this means cross GHC is
disabled since internal-interpreter doesn't work in cross GHC yet.

- - - - -
93b8af80 by Cheng Shao at 2024-10-17T16:41:19+00:00
testsuite: make use of config.interp_force_dyn

This commit takes config.interp_force_dyn into consideration when
setting up TH/ghci way flags.

- - - - -
94673d41 by Cheng Shao at 2024-10-17T16:41:19+00:00
testsuite: bump T17572 timeout

- - - - -
2b5efc2d by Cheng Shao at 2024-10-17T16:41:19+00:00
testsuite: bump T22744 pre_cmd timeout

- - - - -
45102e2a by Cheng Shao at 2024-10-17T16:41:19+00:00
testsuite: skip terminfo_so for cross ghc

- - - - -
05e40406 by Cheng Shao at 2024-10-17T16:41:19+00:00
testsuite: fix shared library size tests for cross ghc

This commit fixes shared library size tests (e.g. array_so in
testsuite/tests/perf/size/all.T) when testing cross ghc. Previously,
if shared library file extension of host and target differs, those
tests will fail with framework errors due to not finding the right
files.

- - - - -
fa68f833 by Cheng Shao at 2024-10-17T16:41:19+00:00
testsuite: skip ghc api tests that attempt to spawn processes inside wasm

This commit skips a few ghc api tests on wasm, since they would
attempt to spawn processes inside wasm, which is not supported at all.

- - - - -
1241c04e by Cheng Shao at 2024-10-17T16:41:19+00:00
testsuite: skip T22840 due to broken -dtag-inference-checks on wasm

- - - - -
78c8b900 by Cheng Shao at 2024-10-17T16:41:19+00:00
testsuite: ensure $(ghciWayFlags) can be overridden

This commit revises boilerplate.mk in testsuite as well as a few other
places, to ensure the tests that do make use of $(ghciWayFlags) can
receive the right $(ghciWayFlags) from testsuite driver config.

- - - - -
47989ecc by Cheng Shao at 2024-10-17T16:41:24+00:00
testsuite: skip rdynamic on wasm

- - - - -
fefb4ea1 by Cheng Shao at 2024-10-17T16:41:24+00:00
testsuite: skip T2615 on wasm

This commit marks T2615 as skip on wasm, given LD_* environment
variables aren't supported on wasm anyway.

- - - - -
77c79762 by Cheng Shao at 2024-10-17T16:41:24+00:00
testsuite: mark MultiLayerModulesTH_Make/MultiLayerModulesTH_OneShot as fragile on wasm

- - - - -
69bb4745 by Cheng Shao at 2024-10-17T16:41:24+00:00
testsuite: fix T16180 on wasm

This commit fixes T16180 on wasm once TH support is flipped on. The
fix is simply adding right asm code for wasm.

- - - - -
621c753d by Cheng Shao at 2024-10-17T16:41:24+00:00
driver: fix -fexternal-interpreter flag for JS backend

Previously, -fexternal-interpreter is broken for JS backend, since GHC
would attempt to launch a non-existent ghc-iserv* executable. This
commit fixes it by adjusting pattern matching order in
setTopSessionDynFlags.

- - - - -
80aa8983 by Cheng Shao at 2024-10-17T16:41:24+00:00
driver: use interpreterDynamic predicate in preloadLib

This commit use the interpreterDynamic predicate in preloadLib to
decide if we should do dynLoadObjs instead of loadObj. Previously we
used hostIsDynamic which was only written with non-cross internal
interpreter in mind.

The testsuite is also adjusted to remove hard-wired -fPIC flag for
cbits (doesn't work in i386 RTS linker in vanilla way, #25260) and
properly pass ghc_th_way_flags to ghc.

- - - - -
74411461 by Cheng Shao at 2024-10-17T16:41:24+00:00
compiler: fix Cmm dynamic CLabels for wasm

This commit fixes the handling of dynamic CLabels for the wasm
backend. Just do the simplest handling: preserve the original CLabel,
both unreg/NCG backends can handle them properly without issue.

- - - - -
f6abaf13 by Cheng Shao at 2024-10-17T16:41:24+00:00
driver: add necessary compile-time flags for wasm PIC mode

This commit adds necessary compile-time flags when compiling for wasm
PIC mode, see added comment for detailed explanation.

- - - - -
9745fcfb by Cheng Shao at 2024-10-17T16:41:24+00:00
driver: add necessary link-time flags for wasm shared libs

This commit adds necessary link-time flags for wasm shared libs, see
added comments for detailed explanation.

- - - - -
649aae00 by Cheng Shao at 2024-10-17T16:41:24+00:00
driver: enforce -fno-use-rpaths for wasm

This commit ensures the GHC driver never passes any RPATH-related
link-time flags on wasm, which is not supported at all.

- - - - -
47baa904 by Cheng Shao at 2024-10-17T16:41:24+00:00
driver: ensure static archives are picked when linking static .wasm modules

This commit ensures static archives are picked when linking .wasm
modules which are supposed to be fully static, even when ghc may be
invoked with -dynamic, see added comment for explanation.

- - - - -
fc3a5591 by Cheng Shao at 2024-10-17T16:41:24+00:00
compiler: fix dynamic_too_enable for targets that require dynamic libraries

This commit fixes dynamic_too_enable for targets whose RTS linker can
only load dynamic code.

- - - - -
94ef949e by Cheng Shao at 2024-10-17T16:41:24+00:00
compiler: fix checkNonStdWay for targets that require dynamic libraries

This commit fixes checkNonStdWay to ensure that for targets whose RTS
linker can only load dynamic code, the dynamic way of object is
selected.

- - - - -
88e99248 by Cheng Shao at 2024-10-17T16:41:24+00:00
ghc-bin: enforce dynamic way when the target requires so

This commit makes ghc-bin use dynamic way when it is doing interactive
stuff on certain targets whose RTS linker can only handle dynamic
code.

- - - - -
549582ef by Cheng Shao at 2024-10-17T16:41:24+00:00
hadrian/ghci: add wasm dyld

This commit adds the wasm dynamic linker implementation, as well as
ghci logic to call it and hadrian logic to install it to the correct
location. See the top-level note in utils/jsffi/dyld.mjs for more
details.

- - - - -
b562e3a6 by Cheng Shao at 2024-10-17T16:41:29+00:00
driver: fix getGccSearchDirectory for wasm target

This commit fixes getGccSearchDirectory logic for wasm target, ensures
the correct search directory containing libc.so etc can be found by
GHC. getGccSearchDirectory is also exported so it can be used
elsewhere to obtain the wasi-sdk libdir and pass to the dyld script.

- - - - -
2d6107dc by Cheng Shao at 2024-10-17T16:41:29+00:00
driver: add wasm backend iserv logic

This commit adds wasm backend iserv logic to the driver, see added
comments for explanation.

- - - - -
61f5baa5 by Cheng Shao at 2024-10-17T16:41:29+00:00
compiler: add PIC support to wasm backend NCG

This commit adds support for generating PIC to the wasm backend NCG.

- - - - -
652e7239 by Cheng Shao at 2024-10-17T16:41:29+00:00
hadrian/compiler: flip on support for shared libs & ghci for wasm

This commit flips on the support for shared libs and ghci for the wasm
target, given all required support logic has been added in previous
commits.

- - - - -
74a1f681 by Cheng Shao at 2024-10-17T16:41:29+00:00
testsuite: flip on support for shared libs, TH & ghci for wasm

This commit flips on support for shared libs, TH & ghci for wasm in
the testsuite, given support has been landed in previous commits.

- - - - -
525d451e by Cheng Shao at 2024-10-17T23:03:34-04:00
Revert "compiler: start deprecating cmmToRawCmmHook"

This reverts commit 1c064ef1f3e1aa2afc996e962ad53effa99ec5f4. Turns
out the GHC-WPC project does use it to observe Cmm in the pipeline,
see #25363.

- - - - -
5bcfefd5 by Cheng Shao at 2024-10-17T23:04:09-04:00
rts: fix pointer overflow undefined behavior in bytecode interpreter

This patch fixes an unnoticed undefined behavior in the bytecode
interpreter. It can be caught by building `rts/Interpreter.c` with
`-fsanitize=pointer-overflow`, the warning message is something like:

```
rts/Interpreter.c:1369:13: runtime error: addition of unsigned offset to 0x004200197660 overflowed to 0x004200197658
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/Interpreter.c:1369:13
rts/Interpreter.c:1265:13: runtime error: addition of unsigned offset to 0x004200197660 overflowed to 0x004200197658
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/Interpreter.c:1265:13
rts/Interpreter.c:1645:13: runtime error: addition of unsigned offset to 0x0042000b22f8 overflowed to 0x0042000b22f0
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/Interpreter.c:1645:13
```

Whenever we do something like `SpW(-1)`, the negative argument is
implicitly converted to an unsigned integer type and causes pointer
arithmetic overflow. It happens to be harmless for most targets since
overflowing would wrap the result to desired value, but it's still
coincidental and undefined behavior. Furthermore, it causes real
damage to the wasm backend, given clang-20 will emit invalid wasm code
that crashes at run-time for this kind of C code! (see
https://github.com/llvm/llvm-project/issues/108770)

The fix here is adding some explicit casts to ensure we always use the
signed `ptrdiff_t` type as right hand operand of pointer arithmetic.

- - - - -
eb67875f by Matthew Craven at 2024-10-18T12:18:35+00:00
Bump transformers submodule

The svg image files mentioned in transformers.cabal were
previously not checked in, which broke sdist generation.

- - - - -
366a1109 by Matthew Craven at 2024-10-18T12:18:35+00:00
Remove reference to non-existent file in haddock.cabal

- - - - -
826852e9 by Matthew Craven at 2024-10-18T12:18:35+00:00
Move tests T11462 and T11525 into tests/tcplugins

- - - - -
dbe27152 by Matthew Craven at 2024-10-18T12:18:35+00:00
Repair the 'build-cabal' hadrian target

Fixes #23117. Fixes #23281. Fixes #23490.

This required:
 * Updating the bit-rotted compiler/Setup.hs and its setup-depends
 * Listing a few recently-added libraries and utilities
   in cabal.project-reinstall
 * Setting allow-boot-library-installs to 'True' since Cabal
   now considers the 'ghc' package itself a boot library for
   the purposes of this flag

Additionally, the allow-newer block in cabal.project-reinstall
was removed.  This block was probably added because when the
libraries/Cabal submodule is too new relative to the cabal-install
executable, solving the setup-depends for any package with a custom
setup requires building an old Cabal (from Hackage) against the
in-tree version of base, and this can fail un-necessarily due to
tight version bounds on base.  However, the blind allow-newer can
also cause the solver to go berserk and choose a stupid build plan
that has no business succeeding, and the failures when this happens
are dreadfully confusing. (See #23281 and #24363.)

Why does setup-depends solving insist on an old version of Cabal? See:
  https://github.com/haskell/cabal/blob/0a0b33983b0f022b9697f7df3a69358ee9061a89/cabal-install/src/Distribution/Client/ProjectPlanning.hs#L1393-L1410

The right solution here is probably to use the in-tree cabal-install
from libraries/Cabal/cabal-install with the build-cabal target rather
than whatever the environment happens to provide.  But this is left
for future work.

- - - - -
b3c00c62 by Matthew Craven at 2024-10-18T12:18:35+00:00
Revert "CI: Disable the test-cabal-reinstall job"

This reverts commit 38c3afb64d3ffc42f12163c6f0f0d5c414aa8255.

- - - - -
a04959b8 by Daneel Yaitskov at 2024-10-19T09:34:15-04:00
base: speed up traceEventIO and friends when eventlogging is turned off #17949

Check the RTS flag before doing any work with the given lazy string.

Fix #17949

Co-authored-by: Michael Peyton Jones <me at michaelpj.com>
Co-authored-by: Sylvain Henry <sylvain at haskus.fr>
Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com>

- - - - -
eff16c22 by Matthew Pickering at 2024-10-19T21:55:55-04:00
ci: Add support for ONLY_JOBS variable to trigger any validation pipeline

By setting the ONLY_JOBS variable to the name of the job (or multiple
jobs), the resulting
pipeline will include a validation job for that pipeline.

For example - if you set ONLY_JOBS="x86_64-linux-ubuntu22_04-validate"
then a ubuntu22_04 job will be included in the validation pipeline. This
is useful for testing specific jobs.

Fixes #25332

- - - - -
280b6278 by Zubin Duggal at 2024-10-19T21:56:31-04:00
rel-eng: ghcup metadata generation: generated yaml anchors with meaningful names

(cherry picked from commit d83f5bd730a8aef37d8a38b3560590d9798f8e45)

- - - - -
25edf849 by Alan Zimmerman at 2024-10-19T21:57:08-04:00
EPA: Remove [AddEpAnn] Commit 4

EPA: Remove [AddEpAnn] from DataDecl

This is quite a big change.
The most important part is moving the annotations into HsDataDefn,
using a specific annotation data type.

It has a knock-on to everything that uses HsDataDefn

EPA: Remove [AddEpAnn] for FunDep

EPA: Remove [AddEpann] from FamilyDecl

EPA: Remove [AddEpAnn] From InjectivityAnn

EPA: Remove [AddEpAnn] from DefaultDecl

EPA: Remove [AddEpAnn] from RuleDecls

EPA: Remove [AddEpAnn] from Warnings

- - - - -
d5f42045 by Luite Stegeman at 2024-10-20T16:34:47-04:00
Interpreter: Add locking for communication with external interpreter

This adds locking to communication with the external interpreter
to prevent concurrent tasks interfering with each other. This
fixes Template Haskell with the external interpreter in parallel (-j)
builds.

Fixes #25083

- - - - -
d6bfea76 by Matthew James Kraai at 2024-10-20T16:35:29-04:00
Use monospace font for "Either a b" in fmap docs

The documentation for fmap shows "`Either a b`" in the default font
instead of showing "Either a b" in a monospace font.

- - - - -
4bc7f9c8 by Luite Stegeman at 2024-10-20T16:36:15-04:00
Parser: remove non-ASCII characters from Parser.y

Non-ASCII characters in the source causes a problem with the default
Haskell Language Server setup in VSCode. Two characters seems to have
been left in by accident.

Workaround for #25396

- - - - -
7f61ed4e by Alan Zimmerman at 2024-10-21T06:39:45-04:00
EPA: Remove [AddEpAnn] Commit 5

EPA: Remove [AddEpAnn] from AnnPragma

EPA: Remove [AddEpAnn] From ForeignDecl

EPA: Remove [AddEpAnn] from RoleAnnotDecl

EPA: Remove [AddEpAnn] from StandaloneKindSig

EPA: Remove [AddEpAnn] From HsDeriving

EPA: Remove [AddEpAnn] from ConDeclField

EPA: Remove [AddEpAnn] from ConDeclGADT

EPA: Remove [AddEpAnn] from ConDeclH98

EPA: Remove [AddEpAnn] from ClsInstDecl

- - - - -
f8694fe7 by Cheng Shao at 2024-10-21T06:40:21-04:00
wasm: bump dyld v8 heap size limit

This patch adds `--max-old-space-size=8192` to wasm dyld shebang
arguments to bump V8 heap size limit. The default limit
(`heap_size_limit` returned by `v8.getHeapStatistics()`) is
dynamically determined and a bit too low under certain workloads, and
V8 would waste too much CPU time to garbage collect old generation
heap more aggressively. Bumping the limit to 8G doesn't imply dyld
would really take that much memory at run-time, but it lessens V8 heap
stress significantly.

- - - - -
d328d173 by Luite Stegeman at 2024-10-21T12:39:18+00:00
Add requestTickyCounterSamples to GHC.Internal.Profiling

This allows the user to request ticky counters to be written to
the eventlog at specific times.

See #24645

- - - - -
71765b1d by Simon Peyton Jones at 2024-10-21T20:55:00-04:00
Move defaulting code into a new module

GHC.Tc.Solver had reached 4,000 lines -- although quite a lot of them
are comments.

This MR

* Adds the new module GHC.Tc.Solver.Default, which has all the
  complex, but well modularised, defaulting code

* Moves a bit of code from GHC.Tc.Solver into the existing
  GHC.Tc.Solver.Solve. Notably solveWanteds and simplifyWantedsTcM,
  which are called from GHC.Tc.Solver.Default

It's a pure refactor.  No code changes.

- - - - -
a398227b by Simon Peyton Jones at 2024-10-21T20:55:00-04:00
Improve the generalisation code in Solver.simplifyInfer

The code in `decideQuantification` has become quite complicated.
This MR straightens it out, adds a new Note, and on the way
fixes #25266.

See especially Note [decideAndPromoteTyVars] which is is where
all the action happens in this MR.

- - - - -
148059fe by Andrzej Rybczak at 2024-10-21T20:55:40-04:00
Adjust catches to properly rethrow exceptions

https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13302 implemented exception
rethrowing proposal, but it didn't adjust `catches`. This fixes it.

- - - - -
25121dbc by doyougnu at 2024-10-22T09:38:18-04:00
linker: add --optimistic-linking flag

This patch adds:

- the --optimistic-linking flag which binds unknown symbols in the
runtime linker to 0xDEADBEEF instead of exiting with failure

- The test T25240 which tests these flags using dead code in the FFI system.

- closes #25240

This patch is part of the upstreaming haskell.nix patches project.

- - - - -
f19e076d by doyougnu at 2024-10-22T09:38:18-04:00
ghc-internal: hide linkerOptimistic in MiscFlags

- - - - -
edc02197 by Cheng Shao at 2024-10-22T09:38:54-04:00
hadrian: fix bindist executable wrapper logic for cross targets

This commit fixes an oversight of hadrian wrapper generation logic:
when doing cross compilation, `wrapper` is called on executable names
with cross prefix, therefore we must use `isSuffixOf` when matching to
take the cross prefix into account. Also add missing cross prefix to
ghci wrapper content and fix hsc2hs wrapper logic.

- - - - -
edf3bdf5 by Andreas Klebinger at 2024-10-22T16:30:42-04:00
mkTick: Push ticks through unsafeCoerce#.

unsafeCoerce# doesn't exist at runtime so we should treat it like a Cast
for the purpose of mkTick.

This means if we have `{-# SCC foo #-} (unsafeCoerce# trivial_expr))` we
now push the scope part of the cost centre up to `trivial_expr` at which
point we can discard it completely if the expression is trivial enough.

This fixes #25212.

- - - - -
1bdb1317 by Cheng Shao at 2024-10-22T16:31:17-04:00
hadrian: enable late-CCS for perf flavour as well

This patch enables late-CCS for perf flavour so that the testsuite can
pass for perf as well. Fixes #25308.

- - - - -
fde12aba by Cheng Shao at 2024-10-22T16:31:54-04:00
hadrian: make sure ghc-bin internal-interpreter is disabled for stage0 when not cross compiling

This patch disables internal-interpreter flag for stage0 ghc-bin when
not cross compiling, see added comment for explanation. Fixes #25406.

- - - - -
6ab8d751 by ignatiusm at 2024-10-24T01:23:35-04:00
Improve heap overflow exception message (#25198)

Catch heap overflow exceptions and suggest using `+RTS -M<size>`.

Fix #25198

- - - - -
b3f7fb80 by Rodrigo Mesquita at 2024-10-24T01:24:12-04:00
determinism: Interface re-export list det

In 'DocStructureItem' we want to make sure the 'Avails' are sorted, for
interface file determinism. This commit introduces 'DetOrdAvails', a
newtype that should only be constructed by sorting Avails with
'sortAvails' unless the avails are known to be deterministically
ordered. This newtype is used by 'DocStructureItem' where 'Avails' was
previously used to ensure the list of avails is deterministically sorted
by construction.

Note: Even though we order the constructors and avails in the interface
file, the order of constructors in the haddock output is still
determined from the order of declaration in the source. This was also
true before, when the list of constructors in the interface file <docs>
section was non-deterministic. Some haddock tests such as
"ConstructorArgs" observe this (check the order of constructors in
out/ConstructorArgs.html vs src/ConstructorArgs.hs vs its interface file)

The updated tests are caused by haddock corners where the order in the
source is not preserved (and was non-deterministic before this PR):
    * Module header in the latex backend
    * Re-export of pattern synonyms associated to a datatype (#25342)

Fixes #25304

- - - - -
e39c8c99 by Rodrigo Mesquita at 2024-10-24T01:24:12-04:00
Revert "ci: Allow abi-test to fail."

After #25304, the abi-test with interface and object determinism
succeeds.

This reverts commit 7b37afc9f3e79559055488998ee73187886a0e00.

- - - - -
7b1b0c6d by Alan Zimmerman at 2024-10-24T13:07:02-04:00
EPA: reduce [AddEpann] in AnnList

Remove it from the `al_rest` field, and make `AnnList` parameterized
on a type to be used in `al_rest`, for the various use cases.

- - - - -
4a00731e by Rodrigo Mesquita at 2024-10-24T13:07:38-04:00
Fix -fobject-determinism flag definition

The flag should be defined as an fflag to make sure the
-fno-object-determinism flag is also an available option.

Fixes #25397

- - - - -
55e4b9f2 by Sebastian Graf at 2024-10-25T07:01:54-04:00
CorePrep: Attach evaldUnfolding to floats to detect more values

See `Note [Pin evaluatedness on floats]`.

- - - - -
9f57c96d by Sebastian Graf at 2024-10-25T07:01:54-04:00
Make DataCon workers strict in strict fields (#20749)

This patch tweaks `exprIsConApp_maybe`, `exprIsHNF` and friends, and Demand
Analysis so that they exploit and maintain strictness of DataCon workers. See
`Note [Strict fields in Core]` for details.

Very little needed to change, and it puts field seq insertion done by Tag
Inference into a new perspective: That of *implementing* strict field semantics.
Before Tag Inference, DataCon workers are strict. Afterwards they are
effectively lazy and field seqs happen around use sites. History has shown
that there is no other way to guarantee taggedness and thus the STG Strict Field
Invariant.

Knock-on changes:

  * I reworked the whole narrative around "Tag inference".
    It's now called "EPT enforcement" and I recycyled the different overview
    Notes into `Note [EPT enforcement]`.

  * `exprIsHNF` previously used `exprOkForSpeculation` on unlifted arguments
    instead of recursing into `exprIsHNF`. That regressed the termination
    analysis in CPR analysis (which simply calls out to `exprIsHNF`), so I made
    it call `exprOkForSpeculation`, too.

  * There's a small regression in Demand Analysis, visible in the changed test
    output of T16859: Previously, a field seq on a variable would give that
    variable a "used exactly once" demand, now it's "used at least once",
    because `dmdTransformDataConSig` accounts for future uses of the field
    that actually all go through the case binder (and hence won't re-enter the
    potential thunk). The difference should hardly be observable.

  * The Simplifier's fast path for data constructors only applies to lazy
    data constructors now. I observed regressions involving Data.Binary.Put's
    `Pair` data type.

  * Unfortunately, T21392 does no longer reproduce after this patch, so I marked
    it as "not broken" in order to track whether we regress again in the future.

Fixes #20749, the satisfying conclusion of an annoying saga (cf. the ideas
in #21497 and #22475).

Compiler perf generally improves, sometimes drastically:

                                                     Baseline
                                 Test    Metric          value      New value Change
--------------------------------------------------------------------------------
             ManyConstructors(normal) ghc/alloc  3,629,760,116  3,711,852,800  +2.3%  BAD
  MultiLayerModulesTH_OneShot(normal) ghc/alloc  2,502,735,440  2,565,282,888  +2.5%  BAD
                       T12707(normal) ghc/alloc    804,399,798    791,807,320  -1.6% GOOD
                       T17516(normal) ghc/alloc    964,987,744  1,008,383,520  +4.5%
                       T18140(normal) ghc/alloc     75,381,152     49,860,560 -33.9% GOOD
                      T18698b(normal) ghc/alloc    232,614,457    184,262,736 -20.8% GOOD
                       T18923(normal) ghc/alloc     62,002,368     58,301,408  -6.0% GOOD
                       T20049(normal) ghc/alloc     75,719,168     70,494,368  -6.9% GOOD
                        T3294(normal) ghc/alloc  1,237,925,833  1,157,638,992  -6.5% GOOD
                        T9233(normal) ghc/alloc    686,490,105    635,166,688  -7.5% GOOD

                            geo. mean                                          -0.7%
                            minimum                                           -33.9%
                            maximum                                            +4.5%

I looked at T17516. It seems we do a few more simplifier iterations and end up
with a larger program. It seems that some things inline more, while other things
inline less. I don't see low-hanging fruit.

I also looked at MultiLayerModulesTH_OneShot. It appears we generate a strange
join point in the `getUnique` method of `Uniquable GHC.Unit.Types.Module` that
should better call-site inline, but does not. Perhaps with !11492.

NoFib does not seem affected much either:

+-------------------------------++--+------------+-----------+---------------+-----------+
|                               ||  |      base/ | std. err. | T20749/ (rel) | std. err. |
+===============================++==+============+===========+===============+===========+
|           spectral/last-piece ||  |    7.263e8 |      0.0% |        +0.62% |      0.0% |
+===============================++==+============+===========+===============+===========+
|                     geom mean ||  |     +0.00% |           |               |           |
+-------------------------------++--+------------+-----------+---------------+-----------+

I had a look at last-piece. Nothing changes in stg-final, but there is a bit
of ... movement around Data.Map.insert's use of GHC.Exts.lazy that is gone in
stg-final.

Co-Authored-By: Jaro Reinders <jaro.reinders at gmail.com>

Metric Decrease:
    T12707
    T18140
    T18698b
    T18923
    T19695
    T20049
    T3294
    T9233
    T21839c
Metric Increase:
    ManyConstructors
    MultiLayerModulesTH_OneShot

- - - - -
0225249a by Simon Peyton Jones at 2024-10-25T07:02:32-04:00
Some renaming

This is a pure refactor, tidying up some inconsistent naming:

   isEqPred          -->  isEqClassPred
   isEqPrimPred      -->  isEqPred
   isReprEqPrimPred  -->  isReprEqPred
   mkPrimEqPred      -->  mkNomEqPred
   mkReprPrimEqPred  -->  mkReprEqPred
   mkPrimEqPredRold  -->  mkEqPredRole

Plus I moved mkNomEqPred, mkReprEqPred, mkEqPredRolek
  from GHC.Core.Coercion to GHC.Core.Predicate
where they belong.  That means that Coercion imports Predicate
rather than vice versa -- better.

- - - - -
15a3456b by Ryan Hendrickson at 2024-10-25T07:02:32-04:00
compiler: Fix deriving with method constraints

See Note [Inferred contexts from method constraints]

Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com>

- - - - -
dbc77ce8 by Alan Zimmerman at 2024-10-25T18:20:13+01:00
EPA: Remove AddEpann commit 7

EPA: Remove [AddEpAnn] from HYPHEN in Parser.y

The return value is never used, as it is part of the backpack
configuration parsing.

EPA: Remove last [AddEpAnn] usages

Remove residual usage in GHC. It is still used
- In haddock TTG extension point definitions (to be removed)
- Some check-exact residual, to be removed
- Comments around DisambECP in PostProcess

EPA: Clean up [AddEpAnn] from check-exact

There is one left, to be cleaned up when we remove AddEpann itself

EPA: Remove [AddEpAnn] from haddock

The TTG extension points need a value, it is not critical what that
value is, in most cases.

EPA: Remove AddEpAnn from HsRuleAnn

EPA: Remove AddEpAnn from HsCmdArrApp

- - - - -
23ddcc01 by Simon Peyton Jones at 2024-10-26T12:44:34-04:00
Fix optimisation of InstCo

It turned out (#25387) that the fix to #15725 was not quite right:

  commit 48efbc04bd45d806c52376641e1a7ed7278d1ec7
  Date:   Mon Oct 15 10:25:02 2018 +0200

    Fix #15725 with an extra Sym

Optimising InstCo is quite subtle, and the invariants surrounding
the LiftingContext in the coercion optimiser were not stated explicitly.

This patch refactors the InstCo optimisation, and documents these
invariants.  See
  * Note [Optimising InstCo]
  * Note [The LiftingContext in optCoercion]

I also did some refactoring of course:

* Instead of a Bool swap-flag, I am not using GHC.Types.Basic.SwapFlag

* I added some invariant-checking the coercion-construction functions
  in GHC.Core.Coercion.Opt.  (Sadly these invariants don't hold during
  typechecking, becuase the types are un-zonked, so I can't put these
  checks in GHC.Core.Coercion.)

- - - - -
589fea7f by Cheng Shao at 2024-10-27T05:36:38-04:00
ghcid: use multi repl for ghcid

- - - - -
d52a0475 by Andrew Lelechenko at 2024-10-27T05:37:13-04:00
documentation: add motivating section to Control.Monad.Fix

- - - - -
301c3b54 by Cheng Shao at 2024-10-27T05:37:49-04:00
wasm: fix safari console error message related to import("node:timers")

This patch fixes the wasm backend JSFFI prelude script to avoid
calling `import("node:timers")` on non-deno hosts. Safari doesn't like
it and would print an error message to the console. Fixes
https://gitlab.haskell.org/ghc/ghc-wasm-meta/-/issues/13.

- - - - -
9f02dfb5 by Simon Peyton Jones at 2024-10-27T15:10:08-04:00
Add a missing tidy in UnivCo

We were failing to tidy the argument coercions of a UnivCo, which
led directly to #25391.

The fix is, happily, trivial.

I don't have a small repro case (it came up when building horde-ad,
which uses typechecker plugins).  It should be possible to make a
repro case, by using a plugin (which builds a UnivCo) but I decided
it was not worth the bother. The bug is egregious and easily fixed.

- - - - -
853050c3 by Andrew Lelechenko at 2024-10-27T15:10:44-04:00
Bump text submodule to 2.1.2

- - - - -
90746a59 by Andrew Lelechenko at 2024-10-27T15:10:44-04:00
hadrian: allow -Wunused-imports for text package

- - - - -
8a6691c3 by Alan Zimmerman at 2024-10-27T19:44:48+00:00
EPA: Remove AddEpAnn Commit 8/final

EPA: Remove AddEpAnn from AnnList

EPA: Remove AddEpAnn from GrhsAnn

This is the last actual use

EPA: Remove NameAdornment from NameAnn

Also rework AnnContext to use EpToken, and AnnParen

EPA: Remove AddEpAnn.  Final removal

There are now none left, except for in a large note/comment in
PostProcess, describing the historical transition to the
disambiguation infrastructure

- - - - -
d5e7990c by Alan Zimmerman at 2024-10-28T21:41:05+00:00
EPA: Remove AnnKeywordId.

This was used as part of AddEpAnn, and is no longer needed.

Also remove all the haddock comments about which of are attached to
the various parts of the AST.  This is now clearly captured in the
appropriate TTG extension points, and the `ExactPrint.hs` file.

- - - - -
e08b8370 by Serge S. Gulin at 2024-10-29T23:17:01-04:00
JS: Re-add optimization for literal strings in genApp (fixes #23479)

Based on https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10588/

Co-authored-by: Sylvain Henry <sylvain at haskus.fr>
Co-authored-by: Andrei Borzenkov <root at sandwitch.dev>
Co-authored-by: Danil Berestov <goosedb at yandex.ru>

-------------------------
Metric Decrease:
    T25046_perf_size_gzip
    size_hello_artifact
    size_hello_artifact_gzip
    size_hello_unicode
    size_hello_unicode_gzip
-------------------------

- - - - -
e3496ef6 by Cheng Shao at 2024-10-29T23:17:37-04:00
compiler: remove unused hscDecls/hscDeclsWithLocation

This patch removes unused `hscDecls`/`hscDeclsWithLocation` functions
from the compiler, to reduce maintenance burden when doing
refactorings related to ghci.

- - - - -
b1eed26f by Cheng Shao at 2024-10-29T23:18:13-04:00
testsuite: add T25414 test case marked as broken

This commit adds T25414 test case to demonstrate #25414. It is marked
as broken and will be fixed by the next commit.

- - - - -
e70009bc by Cheng Shao at 2024-10-29T23:18:13-04:00
driver: fix foreign stub handling logic in hscParsedDecls

This patch fixes foreign stub handling logic in `hscParsedDecls`.
Previously foreign stubs were simply ignored here, so any feature that
involve foreign stubs would not work in ghci (e.g. CApiFFI). The patch
reuses `generateByteCode` logic and eliminates a large chunk of
duplicate logic that implements Core to bytecode generation pipeline
here. Fixes #25414.

- - - - -
1d7cd7fe by Andreas Klebinger at 2024-10-30T19:14:28-04:00
Add since tag for -fwrite-if-compression in user guide.

Partial fix for #25395

- - - - -
b349fd1b by Alan Zimmerman at 2024-10-30T19:15:04-04:00
EPA: Remove some unused functions

- - - - -
f859d61c by Alan Zimmerman at 2024-10-30T19:15:04-04:00
EPA: use explicit vertical bar token for ExplicitSum / SumPat

- - - - -
721ac00d by Ben Gamari at 2024-10-31T08:37:38-04:00
rts/Disassembler: Fix encoding of BRK_FUN instruction

The offset of the CC field was not updated after the encoding change in
b85b11994e0130ff2401dd4bbdf52330e0bcf776. Fix this.

Fixes #25374.

- - - - -
0bc94360 by Alan Zimmerman at 2024-10-31T08:38:15-04:00
EPA: Bring in last EpToken usages

For import declarations, NameAnnCommas and NPlusKPat.

And remove anchor, it is the same as epaLocationRealSrcSpan.

- - - - -
0b11cdc0 by sheaf at 2024-10-31T08:38:55-04:00
Assert that ctEvCoercion is called on an equality

Calling 'ctEvCoercion' on non-equality constraints is always incorrect.
We add an assertion to this function to detect such cases; for example
a type-checking plugin might erroneously do this.

- - - - -
ea458779 by doyougnu at 2024-11-01T18:11:33-04:00
ghc-internal: strict, unboxed src loc ranges

- closes: #20449
- See CLC proposal: #55

- - - - -
778ac793 by Kazuki Okamoto at 2024-11-01T18:12:13-04:00
No haddock markup in doctest line

- - - - -
cf0deeaf by Andreas Klebinger at 2024-11-02T17:54:52-04:00
Reword -fexpose-overloaded-unfoldings docs.

This should make them slightly clearer. Fixes #24844

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

- - - - -
1c21e7d4 by Andreas Klebinger at 2024-11-02T17:55:29-04:00
Compile T25062 simd tests even if we can't run them.

Helps avoid them being utterly broken.

Fixes #25341

- - - - -
573cad4b by Cheng Shao at 2024-11-02T17:56:04-04:00
Remove unused USE_REPORT_PRELUDE code paths from the tree

This patch removes unused `USE_REPORT_PRELUDE` code paths from the
tree. They have been present since the first git revision
4fb94ae5e5d632748fa2e6c35e259eccc5a1a3f4, and might have been useful
for debugging purposes many years ago, but these code paths are never
actually built. Removing these ease maintenance of relevant modules in
the future, and also allows us to get rid of `CPP` extension in those
modules as a nice byproduct.

- - - - -
97f600c6 by Hassan Al-Awwadi at 2024-11-04T15:52:12+00:00
Refactored BooleanFormula to be in line with TTG (#21592)

There are two parts to this commit.
* We moved the definition of BooleanFormula over to L.H.S.BooleanFormula
* We parameterized the BooleanFormula over the pass

The GHC specific details of BooleanFormula remain in Ghc.Data.BooleanFormula.
Because its parameterized over the pass its no longer a functor or
traversable, but we defined bfMap and bfTraverse for the cases where we
needed fmap and traverse originally. Most other changes are just churn.

-------------------------
Metric Decrease:
    MultiLayerModulesTH_OneShot
-------------------------

- - - - -
d4fd3580 by Andreas Klebinger at 2024-11-05T07:36:16-05:00
ghc-heap: Fix incomplete selector warnings.

Use utility functions instead of selectors to read partial attributes.

Part of fixing #25380.

- - - - -
fdd9f62a by Peter Trommler at 2024-11-05T07:36:51-05:00
PPC NCG: Implement fmin and fmax

- - - - -
8e217256 by Mike Pilgrem at 2024-11-07T04:34:20-05:00
Re CLC #293 - Don't specify Data.List.NonEmpty in terms of partial

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

`List.init` had already been driven out of `tails1` by 21fc180bec93d964a7f4ffdf2429ef6f74b49ab6 but this specification also avoided partial `fromList`, so I preferred it.

The `changelog.md` for `base` is updated, with an entry added under `base-4.22.0.0`.

- - - - -
346e4cd1 by Zubin Duggal at 2024-11-07T04:34:57-05:00
release: copy zip files into the correct directory

Fixes #25446

- - - - -
bbdbe225 by Zubin Duggal at 2024-11-07T04:34:57-05:00
release: Sign .gz bindists too

Fixes #25447

- - - - -
0c722e14 by Hécate Kleidukos at 2024-11-07T04:35:37-05:00
hadrian: Enforce the usage of GHC >=9.8.1 for ghci-multi

GHC 9.6 no good when it comes to multi-repl stuff, despite being well
within the range of n-2 releases for bootstrapping, when the script was
adapted to load haddock, in !12851

- - - - -
d8f8a1c3 by Sylvain Henry at 2024-11-07T19:27:46-05:00
Handle the special ghc-prim:GHC.Prim module in the compiler

Before this patch, some custom hacks were necessary in ghc-prim's
Setup.hs to register the GHC.Prim (virtual) module and in Hadrian to
generate haddocks properly.

In this patch we special-case this module in the compiler itself instead
(which it already is, see ghcPrimIface in GHC.Iface.Load). From
Cabal/Hadrian's perspective GHC.Prim is now just a normal autogenerated
module.

This simplification is worthwhile on its own. It was found while looking
into the work needed for #24453 which aims to merge ghc-prim,
ghc-bignum, and ghc-internal. It's also one step closer to remove
ghc-prim's custom setup.

- - - - -
a55adc8e by Cheng Shao at 2024-11-07T19:28:22-05:00
Clean up obsolete CPP guarded code paths from the tree

This patch cleans up obsolete CPP guarded code paths from the tree.
The minimum supported boot GHC version is 9.6, and all the pre-9.6 era
code paths can be removed.

- - - - -
9ede97f3 by Cheng Shao at 2024-11-07T19:28:58-05:00
Remove obsolete executable wrappers from the tree

The executable wrappers are handled by hadrian and bindist Makefile.
The various .wrapper scripts in the tree are unused since removal of
Make build system, so this patch removes them all.

- - - - -
7d42b2df by tristian at 2024-11-07T19:29:40-05:00
TcRnDuplicateDecls now suggests to use the DuplicateRecordFields extension.

Fixes: !24627

- - - - -
e56ed179 by Zubin Duggal at 2024-11-11T15:16:35+05:30
testsuite: normalise some versions in callstacks

(cherry picked from commit f230e29f30d0c1c566d4dd251807fcab76a2710e)

- - - - -
a28fc903 by Zubin Duggal at 2024-11-11T15:16:35+05:30
testsuite: use -fhide-source-paths to normalise some backpack tests

(cherry picked from commit b19de476bc5ce5c7792e8af1354b94a4286a1a13)

- - - - -
ed16d303 by Zubin Duggal at 2024-11-11T15:16:36+05:30
testsuite/haddock: strip version identifiers and unit hashes from html tests

(cherry picked from commit fbf0889eadc410d43dd5c1657e320634b6738fa5)

- - - - -
e45e5836 by Zubin Duggal at 2024-11-11T15:16:36+05:30
haddock: oneshot tests can drop files if they share modtimes. Stop this by
including the filename in the key.

Ideally we would use `ghc -M` output to do a proper toposort

Partially addresses #25372

(cherry picked from commit e78c7ef96e395f1ef41f04790aebecd0409b92b9)

- - - - -
9104e6eb by Zubin Duggal at 2024-11-11T15:16:36+05:30
testsuite: fix normalisation of T9930fail so that it doesn't get tripped up by ghc executable (ARGV[0]) differences

(cherry picked from commit a79a587e025d42d34bb30e115fc5c7cab6c1e030)

- - - - -
2c31264a by Zubin Duggal at 2024-11-11T15:16:36+05:30
testsuite: normalise windows file seperators

(cherry picked from commit f858875e03b9609656b542aaaaff85ad0a83878a)

- - - - -
2807f91b by Zubin Duggal at 2024-11-11T15:21:30+05:30
testsuite: Also match <VERSION> placeholders when normalising callsites

- - - - -
c02add17 by Ben Gamari at 2024-11-12T01:22:11-05:00
configure: Check version number validity

Here we verify the previously informal invariant that stable release
version numbers must have three components, preventing costly failed
releases.

Specifically, the check fails in the following scenarios:

 * `version=9.13` while `RELEASE=YES` since this would imply a
   release made from an unstable branch
 * `version=9.13.0` since unstable versions should only have two
   components
 * `version=9.12` since this has the wrong number of version components
   for a stable branch

Fixes #25390.

- - - - -
747fd322 by Teo Camarasu at 2024-11-12T01:22:49-05:00
docs: link to #14474 in the template-haskell docs

- - - - -
6d96bb62 by Zubin Duggal at 2024-11-12T01:23:25-05:00
testsuite: normalise execvp vs exec differences in process tests

Fixes #25431

- - - - -
502e6711 by Torsten Schmits at 2024-11-12T01:24:01-05:00
fix test lint that accumulated while the checks were broken

I didn't fix the issues flagged by the #ifdef linter because it were so
many that it seemed like the rule has become obsolete.

- - - - -
223a4cb5 by Torsten Schmits at 2024-11-12T01:24:02-05:00
test driver: fix file collection for regex linters

When a testsuite linter is executed with the `tracked` strategy, the
driver runs `git ls-tree` to collect eligible files.

This appears to have ceased producing any paths – `ls-tree` restricts
its results to the current working directory, which is
`testsuite/tests/linters` in this case.

As a quick fix, this patch changes the working directory to match
expectations.

- - - - -
9ad9ac63 by Alan Zimmerman at 2024-11-12T01:24:39-05:00
EPA: Capture location of '_' for wild card type binder

And keep track of promotion status in HsExplicitTupleTy, so the
round-trip ppr test works for it.

Updates Haddock output too, using the PromotionFlag in
HsExplicitTupleTy.

Closes #25454

- - - - -
c37b96fa by Cheng Shao at 2024-11-12T01:25:15-05:00
wasm: fix setImmediate() implementation for Cloudflare Workers

This patch fixes setImmediate() implementation for Cloudflare Workers
in the wasm backend's js prelude script. Cloudflare Workers doesn't
support the MessageChannel API, and we use a setTimeout() based
fallback implementation in this case.

- - - - -
bea8ea4c by Cheng Shao at 2024-11-12T01:25:15-05:00
wasm: fix FinalizationRegistry logic for Cloudflare Workers

This patch fixes FinalizationRegistry related logic for Cloudflare
Workers in wasm backend js post linker. Cloudflare Workers doesn't
support FinalizationRegistry, in this case we use a dummy
implementation that doesn't do anything.

- - - - -
00d551bf by Cheng Shao at 2024-11-13T08:48:21-05:00
Remove obsolete cross-port script

This patch removes the obsolete cross-port script in the tree. The
script was based on the legacy Make build system which has been pruned
from the tree long ago. For hadrian, proper support for two-stage
bootstrapping onto a new unsupported platform is a work in progress in
!11444.

- - - - -
75a2eae4 by Cheng Shao at 2024-11-13T08:48:58-05:00
hadrian: fix bindist makefile for wasm32-wasi target

This patch fixes one incoherent place between bindist makefile and
hadrian logic: I forgot to include wasi/wasm32 in
OsSupportsGHCi/ArchSupportsGHCi as well. And this results in incorrect
settings file generated after installing the bindist, and "Use
interpreter"/"Have interpreter" fields incorrectly have "NO" values
where they should be "YES" like --info output of in-tree version.

- - - - -
0614abef by Alan Zimmerman at 2024-11-13T08:49:34-05:00
EPA: Correctly capture leading semis in decl list

Closes #25467

- - - - -
00d58ae1 by Sebastian Graf at 2024-11-13T15:21:23-05:00
DmdAnal: Make `prompt#` lazy (#25439)

This applies the same treatment to `prompt#` as for `catch#`.
See `Note [Strictness for mask/unmask/catch/prompt]`.

Fixes #25439.

- - - - -
93233a66 by Ben Gamari at 2024-11-13T15:21:59-05:00
boot: Do not attempt to update config.sub

While Apple ARM hardware was new we found that the autoconf scripts
included in some boot packages were too old. As a mitigation for this,
we introduced logic in the `boot` script to update the `config.sub`
with that from the GHC tree. However, this causes submodules which
have `config.sub` committted to appear to be dirty. This is a
considerable headache.

Now since `config.sub` with full platform support is more common we can
remove `boot`'s `config.sub` logic.

Fixes #19574.

- - - - -
fa66fa64 by Ryan Scott at 2024-11-14T19:05:00-05:00
Add regression test for #16234

Issue #16234 was likely fixed by !9765. This adds a regression test to ensure
that it remains fixed.

Fixes #16234.

- - - - -
bfe64df8 by Matthew Pickering at 2024-11-14T19:05:36-05:00
ghc-internal: Update to Unicode 16

This patch updates the automatically generated code for querying unicode
properties to unicode 16.

Fixes #25402

- - - - -
1fd83f86 by Ben Gamari at 2024-11-14T19:06:13-05:00
configure: Accept happy-2.1.2

happy-2.1 was released in late Oct 2024. I have confirmed that master
bootstraps with it. Here we teach configure to accept this tool.

Fixes #25438.

- - - - -
aa58fc5b by Ben Gamari at 2024-11-14T19:06:49-05:00
rts: Tighten up invariants of PACK

- - - - -
8aa4c10a by Ben Gamari at 2024-11-14T19:06:49-05:00
testsuite: Fix badly escaped literals

Use raw string literals to ensure that `\s` is correctly interpreted as
a character class.

- - - - -
0e084029 by Ben Gamari at 2024-11-14T19:06:49-05:00
rts: Improve documentation of SLIDE bytecode instruction

- - - - -
9bf3663b by Ben Gamari at 2024-11-14T19:06:49-05:00
rts/Interpreter: Assert that TEST*_P discriminators are valid

- - - - -
1f668511 by Ben Gamari at 2024-11-14T19:06:49-05:00
rts/Interpreter: Improve documentation of TEST*_P instructions

- - - - -
59e0a770 by Cheng Shao at 2024-11-14T19:07:25-05:00
misc: improve clangd compile_flags.txt flags

This patch improves the compile_flags.txt config used to power clangd
for the rts C codebase. The flags in the file are sampled & deduped
from a real stage1 build with clang-19 and vastly improves the IDE
accuracy when hacking the rts.

For maximum code coverage under the default settings,
compile_flags.txt defaults to threaded+profiled+dynamic+debug way.
This does not mean profdyn needs to be actually built in _build/stage1
for IDE to work. To activate IDE for other RTS ways, simply remove one
of the -D flags at the end of compile_flags.txt and restart clangd.

- - - - -
c2c562e0 by Ben Gamari at 2024-11-14T19:08:01-05:00
testsuite: Don't consider untracked files in dirtiness check

Considering trees containing untracked files as dirty is a bridge too
far. The chance of an untracked file significantly affecting measured
performanced metrics is quite small whereas not collecting measurements
is quite inconvenient for some workflows. We now ignore untracked files
in the dirtiness check.

Fixes #25471.

- - - - -
ed2ed6c5 by Cheng Shao at 2024-11-14T19:08:37-05:00
testsuite: add regression test T25473

This commit adds regression test T25473 marked as broken due to #25473.
It will be fixed in the subsequent commit.

- - - - -
bd0a8b7e by Cheng Shao at 2024-11-14T19:08:37-05:00
wasm: fix foreign import javascript "wrapper" in TH/ghci

This patch fixes foreign import javascript "wrapper" in wasm backend's
TH/ghci by fixing the handling of dyld/finalization_registry magic
variables. Fixes T25473 and closes #25473.

- - - - -
f1b0bc32 by Ben Gamari at 2024-11-14T19:09:13-05:00
rts/linker: Make FreeBSD declarations proper prototypes

The iconv declarations for FreeBSD were previously not prototypes,
leading to warnings.

- - - - -
086cbbc1 by Ben Gamari at 2024-11-14T19:09:13-05:00
base: Drop redundant import in FreeBSD ExecutablePath implementation

- - - - -
79ecd199 by Ben Gamari at 2024-11-14T19:09:13-05:00
compiler: Fix partial selector warnings in GHC.Runtime.Heap.Inspect

- - - - -
1acb73bf by Andrew Lelechenko at 2024-11-15T06:10:47-05:00
gitlab: mention CLC in MR template

- - - - -
8f2e0832 by Ben Gamari at 2024-11-15T06:11:24-05:00
rts: Allow use of GNU-stack notes on FreeBSD

Previously we gated use of GNU-style non-executable stack notes to only
apply on Linux. However, these are also supported by FreeBSD, which also
uses ELF. Fix this.

Fixes #25475.

- - - - -
2c427cb0 by Ben Gamari at 2024-11-16T05:27:40-05:00
rts: Fix EINTR check in timerfd ticker

When `poll` failed we previously checked that `errno == -EINTR` to
silence the failure warning. However, this is wrong as `errno` values
are generally not negated error codes (in contrast to many system call
results, which is likely what the original author had in mind).

Fixes #25477.

- - - - -
a0fa4941 by Ben Gamari at 2024-11-16T05:28:16-05:00
rts: Increase gen_workspace alignment to 128 bytes on AArch64

Increase to match the 128-byte cache-line size of Apple's ARMv8
implementation.

Closes #25459.

- - - - -
142d8afa by Ben Gamari at 2024-11-16T16:20:47-05:00
rts/RtsFlags: Refactor size parsing

This makes a number of improvements mentioned in #20201:

 * fail if the argument cannot be parsed as a number (`-Mturtles`)
 * fail if an unrecognized unit is given (e.g. `-M1x`)

- - - - -
b7a146e5 by Ben Gamari at 2024-11-16T16:20:47-05:00
testsuite: Add tests for RTS flag parsing error handling

See #20201.

- - - - -
ddb7afa6 by Ben Gamari at 2024-11-16T16:21:23-05:00
users guide: Mention language extensions in equality constraints discussion

As suggested in #24127, mention the language extensions necessary for
usage of equality constriants in their documentation.

Closes #24127.

- - - - -
36133dac by Ben Gamari at 2024-11-16T16:21:23-05:00
users-guide/9.14.1-notes: Fix list syntax

- - - - -
888de658 by Ben Gamari at 2024-11-16T16:21:23-05:00
users-guide/debug-info: Fix duplicate flag descriptions

- - - - -
f120e427 by Ben Gamari at 2024-11-16T16:21:23-05:00
users-guide: Fix reference to 9.14.1 release notes

- - - - -
8e975032 by Ben Gamari at 2024-11-16T16:21:59-05:00
Introduce GHC.Tc.Plugin.lookupTHName

This makes it significantly more convenient (and less
GHC-version-dependent) to resolve a template-haskell name into a GHC
Name.

As proposed in #24741.

- - - - -
a0e168ec by ARATA Mizuki at 2024-11-16T16:22:40-05:00
x86 NCG SIMD: Lower packFloatX4#, insertFloatX4# and broadcastFloatX4# to SSE1 instructions

Fixes #25441

Co-authored-by: sheaf <sam.derbyshire at gmail.com>

- - - - -
3936bf1b by sheaf at 2024-11-16T16:23:22-05:00
X86 NCG: allow VXOR at scalar floating-point types

The NCG can emit VXOR instructions at scalar floating-point types,
but the pretty-printer would panic instead of emitting the appropriate
VXORPS/VXORPD instructions. This patch rectifies that oversight.

Fixes #25455

- - - - -
d9dff93a by Ben Gamari at 2024-11-16T16:23:58-05:00
rts: Fix platform-dependent pointer casts

Previously we had unnecessary (and incorrect) platform-dependent casts
to turn `OSThreadIds`s into a integer. We now just uniformly cast first
to a `uintptr_t` (which is always safe, regardless of whether
`OSThreadId` is a pointer), and then cast to the desired integral type.

This fixes a warning on musl platforms.

- - - - -
6d95cdb8 by Ben Gamari at 2024-11-16T16:24:34-05:00
testsuite: Mark encoding004 as broken on FreeBSD

Due to #22003, CP936 fails to roundtrip:
```diff
 == CP936
+Failed to roundtrip given mutant byte at index 891 (251 /= 123 at index 891)
+Failed to roundtrip given mutant byte at index 1605 (197 /= 69 at index 1605)
+Failed to roundtrip given mutant byte at index 2411 (235 /= 107 at index 2411)
+Failed to roundtrip given mutant byte at index 6480 (208 /= 80 at index 6480)
+Failed to roundtrip given mutant byte at index 6482 (210 /= 82 at index 6482)
+Failed to roundtrip given mutant byte at index 6484 (212 /= 84 at index 6484)
+Failed to roundtrip given mutant byte at index 6496 (224 /= 96 at index 6496)
+Failed to roundtrip given mutant byte at index 7243 (203 /= 75 at index 7243)
+Failed to roundtrip given mutant byte at index 7277 (237 /= 109 at index 7277)
+Failed to roundtrip given mutant byte at index 8027 (219 /= 91 at index 8027)
+Failed to roundtrip given mutant byte at index 8801 (225 /= 97 at index 8801)
```

- - - - -
26e86984 by Ben Gamari at 2024-11-18T04:05:31-05:00
hadrian: Allow haddock options to be passed via key-value settings

- - - - -
6e68b117 by Matthew Pickering at 2024-11-18T04:06:07-05: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>

- - - - -
a4e0d235 by Rodrigo Mesquita at 2024-11-18T04:06:07-05:00
exceptions: Improve the message layout as per #285

This commit fixes the layout of the additional information included when
displaying an exception, namely the type of the exception.

It also fixes the default handler's heading message to work well
together with the improved display message of SomeException.

CLC proposal#285

- - - - -
284ffab3 by Rodrigo Mesquita at 2024-11-18T04:06:07-05:00
Display type and callstack of exception on handler

This commit changes the Exception instance of SomeException to *simply*
display the underlying exception in `displayException`. The augmented
exception message that included the type and backtrace of the exception
are now only printed on a call to `displayExceptionWithInfo`.

At a surface level, existing programs should behave the same since the
`uncaughtExceptionHandler`, which is responsible for printing out uncaught
exceptions to the user, will use `displayExceptionWithInfo` by default.

However, unlike the instance's `displayException` method, the
`uncaughtExceptionHandler` can be overriden with
`setUncaughtExceptionHandler`. This makes the extra information opt-in
without fixing it the instance, which can be valuable if your program
wants to display uncaught exceptions to users in a user-facing way
(ie without backtraces).

This is what was originally agreed for CLC#231 or CLC#261 with regard to
the type of the exception information.

The call stack also becoming part of the default handler rather than the
Exception instance is an ammendment to CLC#164.

Discussion of the ammendment is part of CLC#285.

- - - - -
36cddd2c by Rodrigo Mesquita at 2024-11-18T04:06:08-05:00
Remove redundant CallStack from exceptions

Before the exception backtraces proposal was implemented, ErrorCall
accumulated its own callstack via HasCallStack constraints, but
ExceptionContext is now accumulated automatically.

The original ErrorCall mechanism is now redundant and we get a duplicate
CallStack

Updates Cabal submodule to fix their usage of ErrorCallWithLocation to ErrorCall

CLC proposal#285

Fixes #25283

- - - - -
7a74330b by Rodrigo Mesquita at 2024-11-18T04:06:08-05:00
Freeze call stack in error throwing functions

CLC proposal#285

- - - - -
3abf31a4 by Rodrigo Mesquita at 2024-11-18T04:06:08-05:00
De-duplicate displayContext and displayExceptionContext

The former was unused except for one module where it was essentially
re-defining displayExceptionContext.

Moreover, this commit extends the fix from
bfe600f5bb3ecd2c8fa71c536c63d3c46984e3f8 to displayExceptionContext too,
which was missing.

- - - - -
c0d783f8 by Rodrigo Mesquita at 2024-11-18T04:06:08-05:00
Re-export NoBacktrace from Control.Exception

This was originally proposed and accepted in section
    "2.7   Capturing Backtraces on Exceptions"
of the CLC proposal for exception backtraces.

However, the implementation missed this re-export, which this commit now
fixes.

- - - - -
802b5c3e by Rodrigo Mesquita at 2024-11-18T04:06:08-05:00
Fix exception backtraces from GHCi

When running the program with `runhaskell`/`runghc` the backtrace should
match the backtrace one would get by compiling and running the program.
But currently, an exception thrown in a program interpreted with
`runhaskell` will:

    * Not include the original exception backtrace at all
    * Include the backtrace from the internal GHCi/ghc rethrowing of the
      original exception

This commit fixes this divergence by not annotating the ghc(i) backtrace
(with NoBacktrace) and making sure that the backtrace of the original
exception is serialized across the boundary and rethrown with the
appropriate context.

Fixes #25116

The !13301 MR (not this commit in particular) improves performance of
MultiLayerModules. Unfortunately, T3294 regresses on aarch64-linux-deb12
by 1% allocations. Since this patch must be merged for 9.12 ASAP, we
will not be able to investigate the slight regression on this platform
in time.

-------------------------
Metric Decrease:
    MultiLayerModulesRecomp
    MultiLayerModulesTH_OneShot
Metric Increase:
    T3294
-------------------------

- - - - -
3e89eb65 by Rodrigo Mesquita at 2024-11-18T04:06:08-05:00
base: Add to changelog.md CLC #285

- - - - -
d9326a48 by Rodrigo Mesquita at 2024-11-18T04:06:08-05:00
Bump array and stm submodules for testsuite

The testsuites of array and stm had to be updated according to !13301.

Updates submodule array and stm.

- - - - -
325fcb5d by Ben Gamari at 2024-11-18T04:06:45-05:00
rts/adjustor: Clean up code style of Nativei386 adjustor

- - - - -
39bb6e58 by Ben Gamari at 2024-11-18T04:06:45-05:00
rts/adjustor: Fix stack overrun error in Nativei386 adjustor

We were reserving the wrong kind of adjustor context (the generic
`AdjustorContext` used by other adjustor implementations, rather than
the i386-specific `CCallContext`) to return the adjustor context while
freeing, resulting in #25485.

Fixes #25485.

- - - - -
831aab22 by sheaf at 2024-11-18T21:22:36-05:00
Include diagnostic reason in -fdiagnostics-as-json

This commit ensures that the -fdiagnostics-as-json output includes the
diagnostic reason. This allows the full error message produced by GHC
to be re-constructed from the JSON output.

Fixes #25403

- - - - -
3e5bfdd3 by Ben Gamari at 2024-11-18T21:23:12-05:00
rts: Introduce printIPE

This is a convenience utility for use in GDB.

- - - - -
44d909a3 by Sjoerd Visscher at 2024-11-19T14:38:24-05:00
Don't store boot locations in finder cache

Partially reverts commit fff55592a7b

Amends add(Home)ModuleToFinder so that locations for boot files are not stored in the finder cache.

Removes InstalledModule field from InstalledFound constructor since it's the same as the key that was searched for.

- - - - -
64c95292 by Sjoerd Visscher at 2024-11-19T14:38:24-05:00
Concentrate boot extension logic in Finder

With new mkHomeModLocation that takes an extra HscSource to add boot extensions if required.

- - - - -
11bad98d by ARATA Mizuki at 2024-11-19T14:39:08-05:00
Better documentation for floating-point min/max and SIMD primitives

See #25350 for floating-point min/max

Co-authored-by: sheaf <sam.derbyshire at gmail.com>

- - - - -
791a47b2 by Arnaud Spiwack at 2024-11-20T14:00:05+00:00
Add test for #25185

- - - - -
374e18e5 by Arnaud Spiwack at 2024-11-20T14:09:30+00:00
Quick look: emit the multiplicity of app heads in tcValArgs

Otherwise it's not scaled properly by the context, allowing unsound
expressions.

Fixes #25185.

- - - - -
1fc02399 by sheaf at 2024-11-20T18:11:03-05:00
x86 NCG: fix regUsageOfInstr for VMOVU & friends

This commit fixes the implementation of 'regUsageOfInstr' for vector
operations that take an 'Operand' as the destination, by ensuring that
when the destination is an address then the address should be *READ*,
and not *WRITTEN*.

Getting this wrong is a disaster, as it means the register allocator
has incorrect information, which can lead to it discard stores to
registers, segfaults ensuing.

Fixes #25486

- - - - -
7bd407a6 by Brandon Chinn at 2024-11-21T14:08:15-05:00
Fix CRLF in multiline strings (#25375)

- - - - -
7575709b by Rodrigo Mesquita at 2024-11-21T14:08:52-05:00
Improve reachability queries on ModuleGraph

Introduces `ReachabilityIndex`, an index constructed from a
`GHC.Data.Graph.Directed` `Graph` that supports fast reachability
queries (in $O(1)$). This abstract data structure is exposed from
`GHC.Data.Graph.Directed.Reachability`.

This index is constructed from the module graph nodes and cached in
`ModuleGraph`, enabling efficient reachability queries on the module
graph. Previously, we'd construct a Map of Set of ModuleGraph nodes
which used a lot of memory (`O(n^2)` in the number of nodes) and cache
that in the `ModuleGraph`. By using the reachability index we get rid of
this space leak in the module graph -- even though the index is still
quadratic in the number of modules, it is much, much more space
efficient due to its representation using an IntMap of IntSet as opposed
to the transitive closure we previously cached.

In a memory profile of MultiLayerModules with 100x100 modules, memory
usage improved from 6GB residency to 2.8GB, out of which roughly 1.8GB
are caused by a second space leak related to ModuleGraph. On the same
program, it brings compile time from 7.5s to 5.5s.

Note how we simplify `checkHomeUnitsClosed` in terms of
`isReachableMany` and by avoiding constructing a second graph with the
full transitive closure -- it suffices to answer the reachability query
on the full graph without collapsing the transitive closure completely
into nodes.

Unfortunately, solving this leak means we have to do a little bit more
work since we can no longer cache the result of turning vertex indices
into nodes. This results in a slight regression in MultiLayerModulesTH_Make,
but results in large performance and memory wins when compiling large
amounts of modules.

-------------------------
Metric Decrease:
    mhu-perf
Metric Increase:
    MultiLayerModulesTH_Make
-------------------------

- - - - -
bcbcdaaf by Cheng Shao at 2024-11-21T14:09:28-05:00
driver: fix hpc undefined symbol issue in TH with -fprefer-byte-code

This commit fixes an undefined symbol error in RTS linker when
attempting to compile home modules with -fhpc and
-fbyte-code-and-object-code/-fprefer-byte-code, see #25510 for
detailed description and analysis of the bug.

Also adds T25510/T25510c regression tests to test make mode/oneshot
mode of the bug.

- - - - -
506daa08 by Fabricio de Sousa Nascimento at 2024-11-22T17:56:24+09:00
Implements the proposal for MeaningfulMainReturn extension
at https://github.com/ghc-proposals/ghc-proposals/pull/631

Aside from adding the extension, it adds the errors and
warnings.

It does not make the extension default as this would be
done later.

Closes #24848

- - - - -


20 changed files:

- .ghcid
- .gitattributes
- .gitignore
- .gitlab-ci.yml
- .gitlab/ci.sh
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
- .gitlab/merge_request_templates/Default.md
- .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py
- .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py
- .gitlab/rel_eng/recompress-all
- .gitlab/rel_eng/upload.sh
- .gitmodules
- CODEOWNERS
- boot
- cabal.project-reinstall
- compile_flags.txt
- compiler/GHC.hs
- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Builtin/Types.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/432326cb90ba61e7ce091d9e44e418a589e20920...506daa08f5808b70fb9242deb54175cabf55203c

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/432326cb90ba61e7ce091d9e44e418a589e20920...506daa08f5808b70fb9242deb54175cabf55203c
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/20241122/a0fe9bc6/attachment-0001.html>


More information about the ghc-commits mailing list