-
d72505e4
by Simon Jakobi at 2026-11-12T15:26:14-05:00
testsuite: Fix T17088 flakiness and restore bug coverage
T17088 reads and prints a byte from an uninitialized array. Debug RTS
ways fill allocated memory with 0xaa, so the test can fail due to an
output mismatch unrelated to the pointer-tagging bug it covers.
Initialize the byte to zero to make the output deterministic.
The original bug requires the compacting collector and particular
compiler and RTS settings. Run the test only in the compacting_gc way
with -O1 and -A128k. Also disable STG lambda lifting because it removes
the closure shape needed to reproduce the pointer-tagging failure.
This makes the test reliable while ensuring it remains an effective
reproducer for #17088.
Closes #27534.
Assisted-by: gpt-5.6-sol via Codex CLI
-
5a7591b3
by David Eichmann at 2026-11-12T15:26:56-05:00
testsuite: Fix python type errors
These errors appear when using the VSCode python extension which uses
Pylance under the hood.
-
52f129f8
by David Eichmann at 2026-11-12T15:26:56-05:00
Add test modifier to test over all IO Managers
-
22e8b92a
by David Eichmann at 2026-11-12T15:26:56-05:00
testsuite: include custom IO Manager in test name
-
82c34ccd
by Simon Jakobi at 2026-11-12T15:27:40-05:00
Make T2464 actually test #ifdef'd pragmas
The test guarded a LANGUAGE EmptyDataDecls pragma behind #if, but
EmptyDataDecls is on by default since Haskell2010, so the module
compiled even when the guarded pragma was ignored. Guard MagicHash
instead, which is unlikely to be included in a future default language.
The test also checks that warnings from file-header pragmas are emitted
only once, even though the pragmas are parsed both before and after
CPP, using the -fffi deprecation warning as the canary. Use an
unrecognised warning flag instead, so the test no longer depends on a
deprecated flag that is about to be removed.
Context: #27939
Assisted-by: Claude Fable 5.1
-
419f2a12
by Simon Jakobi at 2026-11-12T15:27:40-05:00
Remove command-line flags deprecated in GHC 8.2 or earlier
Also remove the INCLUDE file-header pragma, which only expanded to
the now-removed -#include.
Closes #27939.
Assisted-by: Claude Fable 5.1
-
adc294d0
by Erik de Castro Lopo at 2026-11-12T15:28:21-05:00
TimerManager: publish only evaluated timeout queues (#9809)
The issue in #9809 was triggered by many threads registering timeouts
at the same time and those timeouts being stored as unevaluated thunks
in the shared list. When say 100,000 timeouts are registered at the
same time, the program can be slowed down considerably and the memory
usage grow unacceptably large.
The commit that caused the problem was 2d5eccdf1c, a 2013 change that
fixed #7653.
The fix is to add a modifyTimeouts function which applies an edit to a
copy of the list and fully evaluates the result before replacing the
shared list with a CAS operation.
Performance has improved for the threaded case and not regressed for
the single thread case:
Forked registrations of 100k timeouts (median of 5 runs):
-N4: 0.577 s, 428 MB -> 0.078 s, 39 MB
-N12: 1.227 s, 479 MB -> 0.127 s, 80 MB
Forked registrations of 1M timeouts on -N1 (median of 3 and 10 runs):
5.21 s (range 0.67-9.47 s), 1613 MB -> 0.67 s, 250 MB
Single-thread registrations are unchanged or slightly faster, and timer
latency during registration storms improves (p99 lateness of a 1 ms
threadDelay during 100k forked registrations on -N4: 302-394 ms ->
3.5-4.1 ms).
The registration code still runs in constant stack, so #7653 stays fixed;
T7653 and the concurrent, base and ghc-internal testsuites pass.
modifyTimeouts is OPAQUE so that the optimiser cannot expose the edit
function's inspection of the old queue next to the compare-and-swap and
replace the expected pointer with the evaluated queue, which would make the
compare-and-swap keep failing when the MutVar# holds a thunk or indirection.
Regression test T9809.hs included.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
-
b294b82f
by Moritz Angermann at 2026-11-12T15:28:21-05:00
testsuite: give pause_resume_via_safe_ffi_concurrent 60s on Darwin CI
The 10s System.Timeout watchdog was a false deadlock: five serialized
1s pauses plus rts_pause waiting on threadDelay/timer-manager traffic
overruns that budget on loaded Mac runners. Keep a watchdog so a real
hang still fails.
-
1543f834
by Simon Jakobi at 2026-11-12T15:29:03-05:00
testsuite/README: Don't append new tests at the end of all.T
Patches that each add a test at the end of the same all.T conflict
with each other. Tests added elsewhere in the file usually merge cleanly.
Context: #26285
Assisted-by: Claude Opus 5.5
-
9ad25cb2
by Sven Tennie at 2026-11-14T06:20:13-05:00
hadrian: Add Stage3 cross-compiled target bindist (#26924)
Add a `binary-dist-stage3` Hadrian target that packages target
executables (produced by the stage2 compiler) into a separate
'_build/bindist-stage3/' folder, distinct from the stage2 regular or
cross-compiler bindist in '_build/bindist/'.
This allows a single CI pipeline job to produce both a cross-compiler
bindist (e.g. x86_64 -> RISC-V) and a target-architecture bindist (e.g.
RISC-V -> RISC-V) that can be installed and run natively on the target.
To avoid issues with stale files or race-conditions on them, generate
the `configure` script per stage in `_build/<stage>/distrib`
directories.
-
ca91017d
by Sven Tennie at 2026-11-14T06:20:13-05:00
ci: Build Stage3 and Stage2 bindists for cross targets in one job (#26924)
Building the stage3 target bindist already produces most of the stage2
cross-compiler bindist as a byproduct, so building them in separate jobs
duplicates the build efforts for no benefit. Instead of a separate
CROSS_STAGE=3 job, the stage3 job now also builds and publishes the
stage2 bindist.
The stage3 tarball is named and versioned as if it were built natively
on the target (target triple prefix, non-cross opsys), so its artifact
name stays what downstream consumers already expect and no changes are
needed on their side.
For now, this is only enabled for the RISC-V job. Others can easily
follow.
-
71b41e09
by Sven Tennie at 2026-11-14T06:20:14-05:00
ci: model cross targets as structured TargetPlatform triples (#26924)
Storing the cross target as a raw triple forced ad-hoc parsing at every
use, and broke the single responsibility rule. Modelling it as a
structured `TargetPlatform`` instead, avoids parsing and provides a
clear separation of concerns.
-
8067c2f9
by Sven Tennie at 2026-11-14T06:20:14-05:00
ci: extract the cross smoke tests into a separate smoke_test command (#26924)
This reduces if-nesting and complexity of the main `test_hadrian`
command. The decision how to test is now made by the caller. This is a
fair choice, because most test cases can run under emulation - they are
just very slow then.
The Stage3 smoke test also checks that the target compiler does not report
itself as cross-compiling and, when supported, runs a small GHCi expression.
-
7ece99a7
by fendor at 2026-11-14T06:20:57-05:00
Add `-dep-json` flag to `ghc -M`
Add an optional flag to `ghc -M` that allows to write the dependency
information in JSON Lines format.
The JSON Lines format enables us to stream the output of the dependency
generation to a consumer.
The output of `-dep-json` is streamed to a temporary file and then
copied to the final destination to avoid partial writes.
Each line contains one of two possible json objects:
1. A Home Unit Dependency
* Contains the name of the home module, its unit, where it is
located, whether a preprocessor is used, and all of its imports.
Importantly, the imports include `-XExplicitLevelImports`
information.
* If requested via `-include-pkg-deps`, includes imports of external
units, e.g. modules from `base`.
* If requested via `-include-cpp-deps`, files included via CPP.
2. External Unit Dependency
* Only if `-include-pkg-deps` is given
* Contains unit-id, its package name and package id.
---
This PR refactors the Makefile generation to use phases appropriately.
We introduce an intermediate data structure that is generated based on
the module graph nodes, and only then generate the Makefile rules.
This allows the dep-json and dep-makefile generation to use the same
dependency processing.
-
0f6e0146
by fendor at 2026-11-14T06:20:57-05:00
Add multiple home unit support to `ghc -M`
Allows to process the module graph of multiple home units at once using
the same syntax as `--make` and `--interactive`:
ghc -M -unit @unitA -unit @unitB
The semantics are identical to `--make` and `--interactive`.
Each home unit can declare individually to use `-include-cpp-deps` and
`-include-pkg-deps`.
However, there can only be one output file, and `-dep-json` and
`-dep-makefile` can only be provided at the top of the cli invocation.
We introduce a new GHC API `doMkDepend` that allows to use multiple home
units conveniently.
The output of `-dep-json` and `-dep-makefile` does not change, since we
were careful to choose a format that supports multiple home units from
the start.
Single home units are still accepted like before with no changes.
-
5598e6a0
by fendor at 2026-11-14T06:20:57-05:00
Deprecate `doMkDependHS` in favour of `doMkDepend`
-
39f2943e
by David Eichmann at 2026-11-14T06:21:41-05:00
rts: Expose getRtsSymbols() and store redirect labels and external symbols tag
-
aa159605
by David Eichmann at 2026-11-14T06:21:41-05:00
hadrian: when running tests, properly set have_gdb and have_readelf
-
ff826da4
by David Eichmann at 2026-11-14T06:21:41-05:00
testsuite: add have_ldd() test modifier
-
b9f0b7e2
by David Eichmann at 2026-11-14T06:21:41-05:00
testsuite driver: on windows, ensure PATH correctly contains mingw and ghc-pkg libraries
-
543c108e
by David Eichmann at 2026-11-14T06:21:41-05:00
testsuite: driver now sets WAY_FLAGS variable for makefile tests
-
13408a2b
by David Eichmann at 2026-11-14T06:21:41-05:00
Add golden test for rts/RtsSymbols.c
This test compares declared symbols against symbols observed
in the rts DSO (.so file).
-
06055b48
by Duncan Coutts at 2026-11-16T11:31:47+00:00
Make clock_gettime required on posix platforms
It was defined in POSIX.1-2001 and has been manditory since
POSIX.1-2008. We will rely on CLOCK_MONOTONIC for the RTS-internal
monotonic time source.
On macOS it has been available since 10.12 released in 2016 (and EOL
2019). We already have 11.0 as our minimum version for which we build
binaries (MACOSX_DEPLOYMENT_TARGET=11.0).
Also we must now drop the workaround from #12858 that would make the CI
configuration invoke configure in a way that would always fail to detect
clock_gettime (since obviously now we must detect it). Re-generate the
gitlab jobs files for the benefit of CI.
-
9d32830c
by Duncan Coutts at 2026-11-16T11:31:47+00:00
Simplify time code based on assuming defined(HAVE_CLOCK_GETTIME)
No need to fall back to gettimeofday or times
-
8368c51a
by Duncan Coutts at 2026-11-16T11:31:47+00:00
Use clock_gettime CLOCK_REALTIME for getUnixEpochTime
-
680c8fa7
by Duncan Coutts at 2026-11-16T11:31:47+00:00
Simplify getCurrentThreadCPUTime to use clock_gettime
except on Solaris where it doesn't work.
In particular, this means we now use it on macOS. It apparently works
there from 10.12 onwards.
We drop the check for clock_getcpuclockid which is linux-specific,
archaic, and in any case isn't necessarily fatal.
-
d6e18c62
by Duncan Coutts at 2026-11-16T11:31:47+00:00
Remove now-redundant darwin time code
-
caba06bc
by Duncan Coutts at 2026-11-16T11:31:47+00:00
Simplify getProcessCPUTime to use clock_gettime CLOCK_PROCESS_CPUTIME_ID
It would be nice to check during startup using sysconf that this is
really available. Unfortunately this doesn't actually work on macOS: it
reports via sysconf that it is not available, when actually it is.
Great.
-
ffe43c12
by Duncan Coutts at 2026-11-16T15:32:50+00:00
Tidy up posix time headers in various places
Also remove the definition of CLOCK_ID in HsBase.h, where CLOCK_ID does
not appear to be used at all. And we're going to tweak the clock
definitions soon so we don't want these parallel definitions getting
out of sync.
-
d24e4749
by Duncan Coutts at 2026-11-16T15:32:50+00:00
Split getPageFaults out into OSStats.{h,c}
Strictly speaking it never had any business living with the time
functions. It was merely convenience. Moving it out allows the remainder
to use PosixSource.h (at least on posix).
-
25424341
by Duncan Coutts at 2026-11-16T15:32:50+00:00
Move getProcessTimes to its only use site
Historically getProcessTimes made sense, since the main way to get the
elapsed time would also get the cpu time as well. After recent time code
simplification on posix then in all platforms it is just the pair of
getProcessCPUTime and getProcessElapsedTime separarely. So we can remove
three identical implementations and move it to be a local function in
Stats.c where it is used.
-
f9907b0f
by Duncan Coutts at 2026-11-16T15:32:50+00:00
Make the "get the time" functions more consistent
We had:
Time getProcessElapsedTime(void); // pulbic
StgWord64 getMonotonicNSec(void); // public
void getUnixEpochTime(StgWord64 *sec, StgWord32 *nsec); // internal
These don't follow any naming convention, nor any common type
convention.
Now we have:
Time getMonotonicTime(void); // internal
Time getWallClockTime(void); // internal
StgWord64 getMonotonicNSec(void); // public compat alias
Time getProcessElapsedTime(void); // public compat alias
Now the two main ones use a common representation: Time which is int64_t
nanoseconds since the epoch. And their names better reflect that they
use different clocks: a monotonic clock, or a real time / wall clock.
We keep getMonotonicNSec and getProcessElapsedTime as aliases for
getMonotonicTime(). They are still used in ghc-internal.
Future directions: export the new ones from ghc-internal and base, and
provide clock precision functions. Provide more clocks, like coarse
ones: faster but less precise.
-
2768c693
by Duncan Coutts at 2026-11-16T15:32:50+00:00
Improve win32 implementation of getMonotonicNSec
We don't need the fallback GetTickCount method.
Fixes #14233
-
4f823be2
by Duncan Coutts at 2026-11-16T15:32:50+00:00
Improve win32 implementation of getUnixEpochTime
We can now use GetSystemTimePreciseAsFileTime, which is supported from
Windows 8 onwards. This is the recommendation from MS.
-
000af422
by Duncan Coutts at 2026-11-16T15:32:50+00:00
Remove initializeTimer
It is now a no-op on all platforms.
-
a135d12e
by Duncan Coutts at 2026-11-16T15:32:50+00:00
Refine the meaning of the main monotonic clock and add a high-res clock
We now define the monotonic clock to prioritise accuracy, and to be
steady: which implies it must count time while the system is suspended.
In particular this means that on Linux we must use CLOCK_BOOTTIME.
Since different use cases want different trade-offs (where such
trade-offs are necessary on some platforms) we also add support for a
high resolution clock. This is defined to be as precise as possible, but
not necessarily steady or accurate over long timer periods. This is the
appropriate choice for measuring the time of short-running actions. We
don't get use this one, but will do in susbequent changes.
-
ac7acd67
by Duncan Coutts at 2026-11-16T15:57:11+00:00
Switch some RTS uses from getMonotonicTime to getHighResolutionTime
Wherever we want to measure the duration of relatively short time
intervals then we want getHighResolutionTime rather than
getMonotonicTime. In particular this is appropriate for RTS stats,
profiling and the eventlog timestamps.
In practice this is hardly a change in behaviour compared to the prior
implementation of getMonotonicNSec/getProcessElapsedTime. On Linux and
FreeBSD it used CLOCK_MONOTONIC, and still does (or the more-or-less
equivalent CLOCK_BOOTTIME on Linux). On macOS it used the low-level
mach_absolute_time and now uses the equivalent CLOCK_UPTIME_RAW for
getHighResolutionTime. While on Windows getHighResolutionTime uses
QueryPerformanceCounter, the same as previously.
-
b2447b43
by Duncan Coutts at 2026-11-16T15:57:11+00:00
Add support for macOS non-standard clock_gettime_nsec_np
It's a way to get what we want with fewer conversions, so plausibly
faster.
-
fc1c1bc9
by Duncan Coutts at 2026-11-16T15:57:11+00:00
Remove unused rtsSleep utility
-
1f64668d
by Duncan Coutts at 2026-11-16T15:57:11+00:00
Add a changelog entry for the clock_gettime changes