-
d7cfea49
by Recursion Ninja at 2026-06-30T21:37:12-04:00
Decoupling 'L.H.S' from 'GHC.Types.SourceText'
* Migrated 'IntegralLit' to 'L.H.S.Lit'.
* Migrated 'FractionalLit' to 'L.H.S.Lit'.
* Migrated 'StringLiteral' to 'L.H.S.Lit'.
* Added TTG extension points to the types above.
* Added nice export list to 'GHC.Hs.Lit'.
* Added 'rnOverLitVal' and 'tcOverLitVal' functions to 'GHC.Hs.Lit'.
* Added instance 'Anno (StringLiteral (GhcPass p)) = SrcSpanAnnN'
* Moved [Notes] about 'SourceText' from 'L.H.S.*' to 'GHC.*'.
* Removed all references to 'SourceText' from 'L.H.S'.
* Removed the trailing comma record field from 'StringLiteral'
* Renamed exported functions for nomenclature consistency.
* Deprecated the renamed functions
Fixes #26953
-
a1f2558b
by Recursion Ninja at 2026-06-30T21:37:12-04:00
Monomorphising GHC pass parameters where appropriate
-
7bf9e3c5
by Teo Camarasu at 2026-06-30T21:38:03-04:00
Make Q abstract
This patch aims to clearly demarcate the internal and external interfaces
of Q.
In the past the `Quasi` typeclass was both part of the external,
public-facing interface, and was used to give the implementation of `Q`.
Now we separate out these two distinct roles. `Quasi` continues to exist
in the public interface, but we introduce a new `MetaHandlers` type,
which is equivalent to `Dict Quasi`.
`Q a` is now defined to be `MetaHandlers -> IO a`, and, crucially,
the constructor and the new `MetaHandlers` type are not exposed from the
public interface.
This gives us the ability to vary the interface on the GHC side without
forcing a breaking change on the `template-haskell` side.
Similarly `template-haskell` has more freedom to change the `Quasi`
typeclass without needing any changes in `lib:ghc`.
Implements https://github.com/ghc-proposals/ghc-proposals/pull/700
Resolves #27341
-
4262af36
by L0neGamer at 2026-06-30T21:38:56-04:00
generically defines mconcat in terms of internal type's Semigroup instance
add changelog entry
use simpler definition for mconcat
`nonEmpty` isn't available yet; inline branches in case
add test case
fixup generically defines mconcat in terms of internal type's Semigroup instance
add comment on Generically and deriving mishaps
swap mconcat to foldr version
add some strictness testing for mconcat
add to `base` changelog entry
-
e22ad997
by Cheng Shao at 2026-06-30T21:39:43-04:00
hadrian/rts: fix unregisterised build for gcc 15+
This patch fixes unregisterised build for gcc 15+:
- Pass -optc-Wno-error in hadrian when +werror enables -optc-Werror,
see added comment for details.
- For RTS functions that the codegen would emit calls, ensure their
real prototype is hidden when the header is included in .hc fies
(IN_STG_CODE), and the dummy prototype is provided to match the EFF_
convention.
In the future we should get rid of EFF_ (#14647) and remove these
hacks, but for now this patch makes unregisterised work again on newer
toolchains. Fixes #27404.
Co-authored-by: Codex <codex@openai.com>
-
3f00f234
by Cheng Shao at 2026-06-30T21:40:32-04:00
compiler: fix missing handling of CmmUnsafeForeignCall node in LayoutStack
This patch fixes missing handling of `CmmUnsafeForeignCall` middle
node in the `LayoutStack` pass.
Before proc-points splitting, this pass computes liveliness of local
registers, and spills those alive across a Cmm native call onto the
stack. It need to traverse all middle nodes in each block and check
whether a local register is an assignee, if so then the previous
mapping in `sm_regs` is invalidated and needs to be dropped. However,
it didn't handle `CmmUnsafeForeignCall` node which may also assign to
a local register. When proc-points splitting is enabled, this can
produce an invalid basic block that doesn't properly backup the
updated local register to the stack before doing a Cmm call, resulting
in completely invalid runtime behavior.
The patch also adds a `T27447` regression test. With no-TNTC or with
LLVM backend, without the fix the test case would output a stale
0x1111111111111111 value, instead of the expected 0x2222222222222222
output.
Fixes #27447.
Co-authored-by: Codex <codex@openai.com>
-
701088db
by Ben Gamari at 2026-07-01T10:34:03-04:00
gitlab-ci: Drop vestigial references to make build system
-
62d54a53
by Ben Gamari at 2026-07-01T10:34:03-04:00
gitlab-ci: Add support for running specifying a job's testsuite ways
-
7f97ac2c
by Ben Gamari at 2026-07-01T10:34:03-04:00
gitlab-ci: Run llvm testsuite ways in llvm jobs
Addresses #25762.
-
7ea75116
by ARATA Mizuki at 2026-07-01T10:34:03-04:00
testsuite: Add normalise_ddump_deriv setup function
Some tests check the result of -ddump-deriv, which may contain INLINE pragmas depending on optimization flags.
With normalise_ddump_deriv setup function, INLINE pragmas are stripped off.
-
c7a8199f
by ARATA Mizuki at 2026-07-01T10:34:03-04:00
testsuite: Use -dsuppress-idinfo to make tests more robust
Previously, T18052a and T21755 were failing on 'optasm' and 'optllvm' ways because of visibility of unfoldings.
-
a12122e5
by ARATA Mizuki at 2026-07-01T10:34:03-04:00
testsuite: Use a trick to keep large objects alive
Previously, T17574 and T19381 were failing on 'optasm' and 'optllvm' ways because of compiler optimizations.
Change them to use NOINLINE to prevent unwanted optimizations.
-
1a95b327
by ARATA Mizuki at 2026-07-01T10:34:03-04:00
testsuite: Only run T24224 in 'normal' way
This test is a frontend-only one and breaks if optimizations are enabled.
-
8abea737
by ARATA Mizuki at 2026-07-01T10:34:03-04:00
testsuite: Ignore T18118's stderr
When optimizations are enabled, the compiler emits a warning (You cannot SPECIALISE ...).
The message is not important, so ignore it.
-
9453a722
by ARATA Mizuki at 2026-07-01T10:34:03-04:00
testsuite: Mark T816 and tc216 broken with optimizations
These tests are about type checking, so we should not care too much if they are broken with optimizations.
See #26952
-
0aef9ec0
by Ben Gamari at 2026-07-01T10:34:03-04:00
testsuite: ds014 is not longer broken
It now appears to pass in the ways it was marked as broken in.
Closes #14901.
-
4692d1e4
by Ben Gamari at 2026-07-01T10:34:03-04:00
testsuite: Only run stack cloning tests in the normal way
These are too dependent upon code generation specifics to pass in most
other ways.
-
c154df26
by ARATA Mizuki at 2026-07-01T10:34:03-04:00
testsuite: Update options_ghc_fbyte-code
The `-fbyte-code` option used to be overriden by `-fllvm` but it is no longer true since !14872 was merged.
I updated the test to accept the new behavior.
Closes #27049
-
5d8bb7b5
by ARATA Mizuki at 2026-07-01T10:34:03-04:00
testsuite: Only run T22744 in 'normal' way
This test takes a long time on optimized ways.
-
d1e74c8e
by ARATA Mizuki at 2026-07-01T10:34:03-04:00
testsuite: Disable tests that use -finfo-table-map on llvm ways
Currently, -finfo-table-map does not work with -fllvm. See #26435
-
3bf38c84
by ARATA Mizuki at 2026-07-01T10:34:03-04:00
testsuite: Don't run T24726 on optimized ways
If optimizations are enabled, the rewrite rule just fires and -drule-check will report nothing.
-
e4eef116
by ARATA Mizuki at 2026-07-01T10:34:03-04:00
testsuite: Use -fno-unoptimized-core-for-interpreter when running LinkableUsage01/02
Optimizations for the bytecode interpreter are considered experimental, and need a flag to be enabled.
-
234a9872
by ARATA Mizuki at 2026-07-01T10:34:03-04:00
testsuite: Suppress unwanted optimizations on T25284
-
99a2af2f
by ARATA Mizuki at 2026-07-01T10:34:03-04:00
testsuite: Don't run stack_big_ret with optimizations
Stack layout may change with optimizations enabled.
-
04c836df
by ARATA Mizuki at 2026-07-01T10:34:04-04:00
testsuite: Mark memo001 broken on optimized ways
See #27396
-
1a8a24f4
by ARATA Mizuki at 2026-07-01T10:34:04-04:00
testsuite: Mark syn-perf broken on optimized ways
See #27398
-
40412093
by Duncan Coutts at 2026-07-01T10:34:50-04:00
Add a test for thread scheduler fairness
It also tests that the interval timer and context switching works.
We also test that fairness is lost when the context switching interval
is too coarse for the duration of the test.
We add this test before doing surgery on the interval timer, so we have
decent coverage.
-
3f34d557
by Duncan Coutts at 2026-07-01T10:34:50-04:00
Make exported stop/startTimer no-ops, and rename internal functions
Specifically, internally rename:
stop/startTimer to pause/unpauseTimer
stop/startTicker to pause/unpauseTicker
and keep stop/startTimer as exported functions, but now as no-ops.
In the past the stop/startTicker actions were used incorrectly as if
they were synchronous, which they are not. See issue #27105. We now
document pause/unpackTicker as being async and not to be used for the
purpose of concurrency safety.
The existing stop/startTimer (note Timer not Ticker, the Timer calls the
Ticker!) are also exported from the RTS as a public API. This was
historically because the ticker used signals and it was important to
suspend the timer signel over a process fork. So these functions were
exported to be used by the process and unix libraries.
We cannot just remove the RTS exports, but we now make them no-ops, and
they can be removed from the process and unix library later. This
was already documented in a changelog.d entry no-more-timer-signal but
due to changes during the MR process the change to make stop/startTicker
into no-ops didn't make it into the earlier MR.
-
02e84e5f
by Duncan Coutts at 2026-07-01T10:34:51-04:00
Make exitTicker/exitTimer unconditionally synchronous
We never use them asynchronously, and we should never need to do so.
And update some related comments.
-
13db6a72
by Duncan Coutts at 2026-07-01T10:34:51-04:00
posix ticker: update and improve comments on (un)pause and exit
Clarify what is async vs sync.
-
43d9a07d
by Duncan Coutts at 2026-07-01T10:34:51-04:00
posix ticker: split out ppoll/select helper functions
Move the #ifdefs out of the main code body by introducing local helper
functions and types, which themselves have two implementations (with a
common API) based on ppoll or select.
This helps improve clarity/readability.
-
a5491baa
by Duncan Coutts at 2026-07-01T10:34:51-04:00
posix ticker: improve the implementation
The existing implementation supported pausing and exiting, with the
implementation of pausing reling on a mutex and condition variable.
It needed to check the pause and stop shared variables on every
iteration. It relies on ppoll or select, to wait on the timeout and also
wait on an interrupt fd. The interrupt fd was only used for prompt
exit/shutdown, and not for pausing or other notification. The pause only
needed a lock and a memory operation, but the pause was not prompt. The
resume used a lock, and signaling a cond var.
The new implementation uses a somewhat more regular design: every
notification is done by setting a shared variable and
interrupting/notifying the ticker via the fd. The ticker thread does not
need to check any shared variables on normal timer expiry, only when it
recevies notification. This may be a micro-optimisation, but the tick
occurs 100 times a second by default so any improvements in the hot path
are amplified. When the ticker thread does receive notification it can
check the various shared variables and update its local state. The
blocking relies on using ppoll/select but without a timeout. This avoids
the condition var and also allows further notifications when paused
(also used for unpausing).
This design can be extended with further notification types if needed by
using and checking further shared vars (or making existing shared vars
an enum or counter). This may be used in future for additional
notifications to the ticker thread. This will likely be used to proxy
wakeUpRts from a single handler context for example. And this approach,
avoiding mutexes, is compatible with use from signal handlers.
So overall, it's:
* slightly simpler / more regular;
* easier to extend with additional notifications;
* probably slightly more efficient (but a micro-optimisation);
* and supports calling notification from signal handlers
-
5b20821e
by Duncan Coutts at 2026-07-01T10:34:51-04:00
posix ticker: further minor local renaming for code clarity
Improve the clarity with better choice of names for several local vars
and function.
-
1f3ec5e0
by Duncan Coutts at 2026-07-01T10:34:51-04:00
win32 ticker: split out local helper functions
-
596e7307
by Duncan Coutts at 2026-07-01T10:34:51-04:00
win32 ticker: provide guarantee about concurrency and idempotency
Use a lock to ensure pause/unpause can be used concurrently. Use a
paused variable, protected by the lock, to ensure that pause and unpause
are both idempotent. This is what the portable API expects.
-
1870edd7
by Duncan Coutts at 2026-07-01T10:34:51-04:00
win32 ticker: make the initial tick be after one wait interval
There is no need to tick immediately. This is consistent with the
posix implementation.
-
7c15ab5b
by Duncan Coutts at 2026-07-01T10:34:51-04:00
ticker: remove now-unnecessary layer of enable/disable
There was an atomic variable used to block *part* of the actions of the
tick handler. This still did not make stopTimer synchronous, even for
the part of the the handle_tick actions it covered. It also added a more
expensive (sequentuially consistent) atomic operation in the hot path
for the handle_tick action, whereas our new design requires no atomic
ops at all.
Now that we have eliminate the need for synchronous stop/startTicker,
we don't need this not-quite-working-anyway atomic protocol. The new
pause/unpauseTicker is explicitly asynchronous and idempotent.
-
8585f8cb
by Duncan Coutts at 2026-07-01T10:34:51-04:00
ticker: add TODOs about issue #27250: too much being done from handle_tick
The handle_tick should not perform I/O, block, perform long-running
operations or call arbitrary user code. Unfortunately, everything to
do with the eventlog (at the moment) falls into all those categories.
-
6e381626
by Duncan Coutts at 2026-07-01T22:29:55+01:00
Adjust releaseCapability_ precondition to allow cap->running_task == NULL
There are two use cases for releaseCapability_:
1. The current Task (cap->running_task) releases the Capability.
The Capability is marked free, and if there is any work to do,
an appropriate Task is woken up.
2. There is no current task (cap->task == NULL), and thus the
Capability is idle, and we want to wake up an idle Task to animate
the Capability. This case uses always_wakeup.
Currently, the precondition for releaseCapability_ is
cap->running_task != NULL
and so the 2nd use cases have to set cap->running_task (which is then
immediately overwritten) just to satisfy the precondition. See the
use cases in sendMessage and prodCapability.
So we can relax the precondition to be:
cap->running_task != NULL || always_wakeup
so that in the always_wakeup case, we say it is ok for the
cap->running_task to be NULL.
This lets us simplify sendMessage and prodCapability. In particular it
will allow prodCapability to not need a Task parameter.
The ulterior motive for all this is that I want to be able to call
prodCapability from an OS thread that is not itself a Task, in persuit
of issue #27086: disentangle I/O managers from wakeUpRts. The most
straightforward way to wake the RTS is using prodCapability, but the
context in which we will need to do that are threads that are not Tasks.
-
89404ebc
by Duncan Coutts at 2026-07-01T22:29:55+01:00
prodCapability no longer needs to take a Task param
Now that releaseCapability_ can accept cap->running_task == NULL then it
is no longer necessary for prodCapability to require a Task.
-
4e60c5f6
by Duncan Coutts at 2026-07-01T22:29:56+01:00
Define prodOneCapability
There was an existing declaration for this in the header file, but no
definition.
Similarly, there is a declaration for prodAllCapabilities but no
definition, and we don't need it, so remove the declaration.
-
2527026f
by Duncan Coutts at 2026-07-01T22:29:56+01:00
Add a wakeUpRtsViaTicker feature to the posix ticker
It proxies a call to wakeUpRts, but crucially, this can be called from
a signal handler context. It will be used for ctl-c handling.
-
aa5a03a5
by Duncan Coutts at 2026-07-01T22:29:56+01:00
Change how wakeUpRts works
Previously it would call wakeupIOManager to get a capability to wake up
and run. This works but it entangles the I/O managers with unrelated
features: ctl-c handling and idle gc (the two features that use wakeUpRts).
The reason it used wakeupIOManager is that this action is safe to use
from a posix signal handler, since it just posts bytes to a pipe.
Otherwise the more direct approach (used e.g. by sendMessage when the
target capability is idle) is to use releaseCapability. But that uses
condition variables and mutexes, which are not safe to use from within a
signal handler.
So instead of entangling the (multiple) I/O managers with this, we make
wakeUpRts use the direct approach (using prodOneCapability). On win32
the ctl-c console handler can call wakeUpRts directly, since it is
called in a proper thread. On posix, to deal with the signal handler
problem, we make the signal handler ask the ticker thread to proxy the
call to wakeUpRts, since the ticker thread is also a proper thread.
This will allow the I/O managers to no longer be concerned with this.
This is good because there are many I/O managers (and they're
complicated), but there is (on posix) only one ticker implementation. So
this is an overall reduction in coupling and complexity.
Fixes issue #27086
-
c6d53c16
by sheaf at 2026-07-02T21:35:44-04:00
Test driver: normalise line numbers into libraries
When comparing the stdout of tests that print out callstacks, we can't
rely on the stability of exact line:column spans pointing into libraries
(e.g. ghc-internal), as any change (such as adding a comment) can change
them.
This commit addresses this by normalising away line:column in callstacks,
but only when those point into internal libraries. We don't do this in
general, as the exact span might be important to the test (e.g. for a
span within the test module itself).
Fixes #27387
-
81ee62e0
by Alan Zimmerman at 2026-07-02T21:36:33-04:00
EPA: Remove LocatedLW from MatchGroup
This is the last usage of LocatedLW / SrcSpanAnnLW
-
1155b4cd
by Alan Zimmerman at 2026-07-03T18:12:11+01:00
EPA: Move the 'where' annotation for PatSynBind
This allows us to move it out of the MatchGroup exact print annotation
too
-
5c8a1023
by Alan Zimmerman at 2026-07-03T18:12:11+01:00
EPA: Replace AnnListItem with simply [TrailingAnn]
Remove the unnecessary wrapper around a single field.
-
1a66c052
by Alan Zimmerman at 2026-07-03T18:12:12+01:00
EPA: Keep binds and sigs together in HsValBindsLR
This allows us to get rid of AnnSortKey BindTag
-
c198497b
by Alan Zimmerman at 2026-07-03T18:12:12+01:00
Keep decls together in ClassDecl
Keep binds and sigs together in HsValBindsLR
TBD
-
d305f5f8
by Alan Zimmerman at 2026-07-03T18:12:12+01:00
Fix ppr for ClassDecl to include DocDs
-
bb65584b
by Alan Zimmerman at 2026-07-03T18:12:12+01:00
Some tidy ups of the decls stuff. Squash it in
-
62231f12
by Alan Zimmerman at 2026-07-03T18:12:12+01:00
EPA: ClsInstDecl as list in GhcPs
-
8186b232
by Alan Zimmerman at 2026-07-03T18:12:12+01:00
EPA: Remove LocatedP from OverlapMode
-
457cb037
by Alan Zimmerman at 2026-07-03T18:12:12+01:00
EPA: Remove LocatedP from CType
-
18f6e75f
by Alan Zimmerman at 2026-07-04T12:30:21+01:00
EPA: Remove LocatedP, last use in WarningTxt