[Git][ghc/ghc][wip/supersven/hadrian-cross-stage3] Fix final ghc-pkg recache run
by Sven Tennie (@supersven) 14 Feb '26
by Sven Tennie (@supersven) 14 Feb '26
14 Feb '26
Sven Tennie pushed to branch wip/supersven/hadrian-cross-stage3 at Glasgow Haskell Compiler / GHC
Commits:
cfb65334 by Sven Tennie at 2026-02-14T19:44:49+01:00
Fix final ghc-pkg recache run
Sage3 cross-compiler's ghc-pkg cannot run on the build host. Resort to a
prior stage's ghc-pkg.
- - - - -
2 changed files:
- hadrian/src/BindistConfig.hs
- hadrian/src/Rules/BinaryDist.hs
Changes:
=====================================
hadrian/src/BindistConfig.hs
=====================================
@@ -1,29 +1,33 @@
module BindistConfig where
-import Stage
-import Oracles.Flag
import Expression
+import Oracles.Flag
-data BindistConfig = BindistConfig { library_stage :: Stage -- ^ The stage compiler which builds the libraries
- , executable_stage :: Stage -- ^ The stage compiler which builds the executables
- }
+data BindistConfig = BindistConfig
+ { -- | The stage compiler which builds the libraries
+ library_stage :: Stage,
+ -- | The stage compiler which builds the executables
+ executable_stage :: Stage,
+ -- | Which ghc-pkg to use (`targetBindist`'s
+ -- ghc-pkg cannot run on the build platform)
+ use_inplace_ghcPkg :: Bool
+ }
-- | A bindist for when the host = target, non cross-compilation setting.
-- Both the libraries and final executables are built with stage1 compiler.
normalBindist :: BindistConfig
-normalBindist = BindistConfig { library_stage = Stage1, executable_stage = Stage1 }
+normalBindist = BindistConfig {library_stage = Stage1, executable_stage = Stage1, use_inplace_ghcPkg = True}
-- | A bindist which contains a cross compiler (when host /= target)
-- The cross compiler is produced by the stage1 compiler, but then we must compile
-- all the boot libraries with the cross compiler (hence stage2 for libraries)
crossBindist :: BindistConfig
-crossBindist = BindistConfig { library_stage = Stage2, executable_stage = Stage1 }
+crossBindist = BindistConfig {library_stage = Stage2, executable_stage = Stage1, use_inplace_ghcPkg = True}
-- | A bindist which contains executables for the target, which produce code for the
-- target. These are produced as "Stage3" build products, produced by a stage2 cross compiler.
-targetBindist :: BindistConfig
-targetBindist = BindistConfig { library_stage = Stage2, executable_stage = Stage2 }
-
+targetBindist :: BindistConfig
+targetBindist = BindistConfig {library_stage = Stage2, executable_stage = Stage2, use_inplace_ghcPkg = False}
-- | The implicit bindist config, if we don't know any better.
implicitBindistConfig :: Action BindistConfig
@@ -35,7 +39,7 @@ implicitBindistConfig = do
return $ if cross then crossBindist else normalBindist
-- | Are we building things in this stage for the final target?
-buildingForTarget :: Stage -> Action Bool
+buildingForTarget :: Stage -> Action Bool
buildingForTarget st = do
cfg <- implicitBindistConfig
return $ st >= (library_stage cfg)
=====================================
hadrian/src/Rules/BinaryDist.hs
=====================================
@@ -222,9 +222,16 @@ buildBinDistDir dirPrefix root conf@BindistConfig{..} = do
--
-- N.B. the ghc-pkg executable may be prefixed with a target triple
-- (c.f. #20267).
-
- ghcPkgName <- programName (vanillaContext executable_stage ghcPkg)
- cmd_ (bindistFilesDir -/- "bin" -/- ghcPkgName) ["recache", "--package-db", bindistFilesDir -/- "lib" -/- "package.conf.d" ]
+ --
+ -- For Stage3 cross-compilers (those that are supposed to run on the target
+ -- platform), we have to resort to a prior stage's ghc-pkg as the final
+ -- stage can naturally not be executed on our current build host.
+ if use_inplace_ghcPkg then do
+ ghcPkgName <- programName (vanillaContext executable_stage ghcPkg)
+ cmd_ (bindistFilesDir -/- "bin" -/- ghcPkgName) ["recache", "--package-db", bindistFilesDir -/- "lib" -/- "package.conf.d" ]
+ else do
+ ghcPkgPath <- builderPath $ GhcPkg Recache library_stage
+ cmd_ ghcPkgPath ["recache", "--package-db", bindistFilesDir -/- "lib" -/- "package.conf.d" ]
need ["docs"]
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cfb653349053053053a9982ee181623…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cfb653349053053053a9982ee181623…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/supersven/hadrian-cross-stage3] 83 commits: PPC NCG: Generate clear right insn at arch width
by Sven Tennie (@supersven) 14 Feb '26
by Sven Tennie (@supersven) 14 Feb '26
14 Feb '26
Sven Tennie pushed to branch wip/supersven/hadrian-cross-stage3 at Glasgow Haskell Compiler / GHC
Commits:
56db94f7 by Peter Trommler at 2026-01-26T11:26:18+01:00
PPC NCG: Generate clear right insn at arch width
The clear right immediate (clrrxi) is only available in word and
doubleword width. Generate clrrxi instructions at architecture
width for all MachOp widths.
Fixes #24145
- - - - -
5957a8ad by Wolfgang Jeltsch at 2026-01-27T06:11:40-05:00
Add operations for obtaining operating-system handles
This contribution implements CLC proposal #369. It adds operations for
obtaining POSIX file descriptors and Windows handles that underlie
Haskell handles. Those operating system handles can also be obtained
without such additional operations, but this is more involved and, more
importantly, requires using internals.
- - - - -
86a0510c by Greg Steuck at 2026-01-27T06:12:34-05:00
Move flags to precede patterns for grep and read files directly
This makes the tests pass with non-GNU (i.e. POSIX-complicant) tools.
There's no reason to use cat and pipe where direct file argument works.
- - - - -
50761451 by Cheng Shao at 2026-01-27T21:51:23-05:00
ci: update darwin boot ghc to 9.10.3
This patch updates darwin boot ghc to 9.10.3, along with other related
updates, and pays off some technical debt here:
- Update `nixpkgs` and use the `nixpkgs-25.05-darwin` channel.
- Update the `niv` template.
- Update LLVM to 21 and update `llvm-targets` to reflect LLVM 21
layout changes for arm64/x86_64 darwin targets.
- Use `stdenvNoCC` to prevent nix packaged apple sdk from being used
by boot ghc, and manually set `DEVELOPER_DIR`/`SDKROOT` to enforce
the usage of system-wide command line sdk for macos.
- When building nix derivation for boot ghc, run `configure` via the
`arch` command so that `configure` and its subprocesses pick up the
manually specified architecture.
- Remove the previous horrible hack that obliterates `configure` to
make autoconf test result in true. `configure` now properly does its
job.
- Remove the now obsolete configure args and post install settings
file patching logic.
- Use `scheme-small` for texlive to avoid build failures in certain
unused texlive packages, especially on x86_64-darwin.
- - - - -
94dcd15e by Matthew Pickering at 2026-01-27T21:52:05-05:00
Evaluate backtraces for "error" exceptions at the moment they are thrown
See Note [Capturing the backtrace in throw] and
Note [Hiding precise exception signature in throw] which explain the
implementation.
This commit makes `error` and `throw` behave the same with regard to
backtraces. Previously, exceptions raised by `error` would not contain
useful IPE backtraces.
I did try and implement `error` in terms of `throw` but it started to
involve putting diverging functions into hs-boot files, which seemed to
risky if the compiler wouldn't be able to see if applying a function
would diverge.
CLC proposal: https://github.com/haskell/core-libraries-committee/issues/383
Fixes #26751
- - - - -
ef35e3ea by Teo Camarasu at 2026-01-27T21:52:46-05:00
ghc-internal: move all Data instances to Data.Data
Most instances of Data are defined in GHC.Internal.Data.Data.
Let's move all remaining instance there.
This moves other modules down in the dependency hierarchy allowing for
more parallelism, and it decreases the likelihood that we would need to
load this heavy .hi file if we don't actually need it.
Resolves #26830
Metric Decrease:
T12227
T16875
- - - - -
5e0ec555 by sheaf at 2026-01-28T06:56:38-05:00
Add test case for #25679
This commit adds the T25679 test case. The test now passes, thanks to
commit 1e53277af36d3f0b6ad5491f70ffc5593a49dcfd.
Fixes #25679
- - - - -
f1cd1611 by sheaf at 2026-01-28T06:56:38-05:00
Improve defaulting of representational equalities
This commit makes the defaulting of representational equalities, introduced
in 1e53277a, a little bit more robust. Now, instead of calling the eager
unifier, it calls the full-blown constraint solver, which means that it can
handle some subtle situations, e.g. involving functional dependencies and
type-family injectivity annotations, such as:
type family F a = r | r -> a
type instance F Int = Bool
[W] F beta ~R Bool
- - - - -
25edf516 by sheaf at 2026-01-28T06:56:38-05:00
Improve errors for unsolved representational equalities
This commit adds a new field of CtLoc, CtExplanations, which allows the
typechecker to leave some information about what it has done. For the moment,
it is only used to improve error messages for unsolved representational
equalities. The typechecker will now accumulate, when unifying at
representational role:
- out-of-scope newtype constructors,
- type constructors that have nominal role in a certain argument,
- over-saturated type constructors,
- AppTys, e.g. `c a ~R# c b`, to report that we must assume that 'c' has
nominal role in its parameters,
- data family applications that do not reduce, potentially preventing
newtype unwrapping.
Now, instead of having to re-construct the possible errors after the fact,
we simply consult the CtExplanations field.
Additionally, this commit modifies the typechecker error messages that
concern out-of-scope newtype constructors. The error message now depends
on whether we have an import suggestion to provide to the user:
- If we have an import suggestion for the newtype constructor,
the message will be of the form:
The data constructor MkN of the newtype N is out of scope
Suggested fix: add 'MkN' to the import list in the import of 'M'
- If we don't have any import suggestions, the message will be
of the form:
NB: The type 'N' is an opaque newtype, whose constructor is hidden
Fixes #15850, #20289, #20468, #23731, #25949, #26137
- - - - -
4d0e6da1 by Simon Peyton Jones at 2026-01-28T06:57:19-05:00
Fix two bugs in short-cut constraint solving
There are two main changes here:
* Use `isSolvedWC` rather than `isEmptyWC` in `tryShortCutSolver`
The residual constraint may have some fully-solved, but
still-there implications, and we don't want them to abort short
cut solving! That bug caused #26805.
* In the short-cut solver, we abandon the fully-solved residual
constraint; but we may thereby lose track of Givens that are
needed, and either report them as redundant or prune evidence
bindings that are in fact needed.
This bug stopped the `constraints` package from compiling;
see the trail in !15389.
The second bug led me to (another) significant refactoring
of the mechanism for tracking needed EvIds. See the new
Note [Tracking needed EvIds] in GHC.Tc.Solver.Solve
It's simpler and much less head-scratchy now.
Some particulars:
* An EvBindsVar now tracks NeededEvIds
* We deal with NeededEvIds for an implication only when it is
fully solved. Much simpler!
* `tryShortCutTcS` now takes a `TcM WantedConstraints` rather than
`TcM Bool`, so that is can plumb the needed EvIds correctly.
* Remove `ic_need` and `ic_need_implic` from Implication (hooray),
and add `ics_dm` and `ics_non_dm` to `IC_Solved`.
Pure refactor
* Shorten data constructor `CoercionHole` to `CH`, following
general practice in GHC.
* Rename `EvBindMap` to `EvBindsMap` for consistency
- - - - -
662480b7 by Cheng Shao at 2026-01-28T06:58:00-05:00
ci: use debian validate bindists instead of fedora release bindists in testing stage
This patch changes the `abi-test`, `hadrian-multi` and `perf` jobs in
the full-ci pipeline testing stage to use debian validate bindists
instead of fedora release bindists, to increase pipeline level
parallelism and allow full-ci pipelines to complete earlier. Closes #26818.
- - - - -
39581ec6 by Cheng Shao at 2026-01-28T06:58:40-05:00
ci: run perf test with -j$cores
This patch makes the perf ci job compile Cabal with -j$cores to speed
up the job.
- - - - -
607b287b by Wolfgang Jeltsch at 2026-01-28T15:41:53+02:00
Remove `GHC.Desugar` from `base`
`GHC.Desugar` was deprecated and should have been removed in GHC 9.14.
However, the removal was forgotten, although there was a code block that
was intended to trigger a compilation error when the GHC version in use
was 9.14 or later. This code sadly didn’t work, because the
`__GLASGOW_HASKELL__` macro was misspelled as `__GLASGOW_HASKELL`.
- - - - -
e8f5a45d by sterni at 2026-01-29T04:19:18-05:00
users_guide: fix runtime error during build with Sphinx 9.1.0
Appears that pathto is stricter about what it accepts now.
Tested Sphinx 8.2.3 and 9.1.0 on the ghc-9.10 branch.
Resolves #26810.
Co-authored-by: Martin Weinelt <hexa(a)darmstadt.ccc.de>
- - - - -
ce2d62fb by Jessica Clarke at 2026-01-29T19:48:51-05:00
PPC NCG: Use libcall for 64-bit cmpxchg on 32-bit PowerPC
There is no native instruction for this, and even if there were a
register pair version we could use, the implementation here is assuming
the values fit in a single register, and we end up only using / defining
the low halves of the registers.
Fixes: b4d39adbb5 ("PrimOps: Add CAS op for all int sizes")
Fixes: #23969
- - - - -
43d97761 by Michael Karcher at 2026-01-29T19:49:43-05:00
NCG for PPC: add pattern for CmmRegOff to iselExpr64
Closes #26828
- - - - -
aeeb4a20 by Matthew Pickering at 2026-01-30T11:42:47-05:00
determinism: Use deterministic map for Strings in TyLitMap
When generating typeable evidence the types we need evidence for all
cached in a TypeMap, the order terms are retrieved from a type map
determines the order the bindings appear in the program.
A TypeMap is quite diligent to use deterministic maps, apart from in the
TyLitMap, which uses a UniqFM for storing strings, whose ordering
depends on the Unique of the FastString.
This can cause non-deterministic .hi and .o files.
An unexpected side-effect is the error message but RecordDotSyntaxFail8
changing. I looked into this with Sam and this change caused the
constraints to be solved in a different order which results in a
slightly different error message. I have accepted the new test, since
the output before was non-deterministic and the new output is consistent
with the other messages in that file.
Fixes #26846
- - - - -
9e4d70c2 by Andrew Lelechenko at 2026-01-30T11:43:29-05:00
Upgrade text submodule to 2.1.4
- - - - -
631fa5ae by Recursion Ninja at 2026-01-31T22:30:11+00:00
Decouple `L.S.H.Decls` from importing `GHC.Types.Basic`
Data-types within `GHC.Types.Basic` which describe components of
the AST are migrated to `Language.Haskell.Syntax.Basic`. Related
function definitions are also moved.
Types moved to L.H.S. because they are part of the AST:
* TopLevelFlag
* RuleName
Types moved from L.H.S. to GHC.Hs. because they are not needed in the AST:
* TyConFlavour
* TypeOrData
* NewOrData
Migrated instances:
* `Outputable` instances moved to in `GHC.Utils.Outputable`
* `Binary` instance of `Boxity` moved to to `GHC.Utils.Binary`
* Other `Binary` instances are orphans to be migrated later.
The `OverlapMode` data-type is given a TTG extension point.
The `OverlapFlag` data-type, which depends on `OverlapMode`,
is updated to support `OverlapMode` with a GHC "pass" type paramerter.
In order to avoid module import cycles, `OverlapMode` and `OverlapFlag`
are migrated to new modules (no way around this).
* Migrated `OverlapMode` to new module `Language.Haskell.Syntax.Overlap`
* Migrated `OverlapFlag` to new module `GHC.Hs.Decls.Overlap`
- - - - -
9769cc03 by Simon Hengel at 2026-02-01T04:21:03-05:00
Update the documentation for MultiWayIf (fixes #25376)
(so that it matches the implementation)
- - - - -
5fc9442a by Peter Trommler at 2026-02-01T04:21:44-05:00
hadrian: Fix dependency generation for assembler
Assembler files allow # for comments unless in column 1. A modern
cpp for C treats those a preprocessor directives. We tell gcc that
a .S file is assembler with cpp and not C.
Fixes #26819
- - - - -
269c4087 by Simon Peyton Jones at 2026-02-01T19:38:10-05:00
Include current phase in the range for rule/unfoldings
This MR fixes a bad loop in the compiler: #26826.
The fix is to add (WAR2) to
Note [What is active in the RHS of a RULE or unfolding?]
in GHC.Core.Opt.Simplify.Utils
- - - - -
ddf1434f by Vladislav Zavialov at 2026-02-01T19:38:52-05:00
Refactor: merge HsMultilineString into HsString (#26860)
Before this patch, HsLit defined two separate constructors to represent
single-line and multi-line strings:
data HsLit x
...
| HsString (XHsString x) FastString
| HsMultilineString (XHsMultilineString x) FastString
I found this to be an unnecessary complication and an obstacle to unifying
HsLit with HsTyLit. Now we use HsString for both kinds of literals.
One user-facing change here is `ppr (HsString st s)` behaving differently for
single-line strings containing newlines:
x = "first line \
\asdf\n\
\second line"
Previously, the literal was fed to `ftext` with its newlines, producing an
ill-formed SDoc. This issue is now addressed by using `split` for both
single-line and multi-line strings:
vcat $ map text $ split '\n' (unpackFS src)
See the parser/should_fail/T26860ppr test.
In addition (and unrelatedly to the main payload of this patch),
drop the unused pmPprHsLit helper.
- - - - -
2b4f463c by Simon Peyton Jones at 2026-02-02T17:32:32+00:00
Remove exprIsCheap from doFloatFromRhs
See #26854 and Note [Float when expandable]
This patch simplifies the code, by removing an extra unnecessary test.
- - - - -
9db7f21f by Brandon Chinn at 2026-02-03T09:15:10-05:00
Refactor: make function patterns exhaustive
Also added missing (==) logic for:
* HsMultilineString
* HsInt{8,16,32}
* HsWord{8,16,32}
- - - - -
aa9c5e2c by Hécate Kleidukos at 2026-02-03T15:58:35-05:00
driver: Hide source paths at verbosity level 1 by default
- - - - -
c64cca1e by mangoiv at 2026-02-03T15:59:29-05:00
ExplicitLevelImports: check staging for types just like for values
Previously, imported types were entirely exempted from staging checks as
the implicit stage persistance assumed to be all imported types to be
well staged. ExplicitLevelImports' change specification, however, does
not do such an exemption. Thus we want to introduce such a check, just
like we have for values.
ExplicitLevelImports does not, however, talk about local names - from
its perspective, we could theoretically keep treating locally introduced
types specially - e.g. an ill-staged used in a quote would only emit a
warning, not an error. To allow for a potential future migration away
from such wrinkles as the staging check in notFound
(see Note [Out of scope might be a staging error]) we consistently do
the strict staging check that we also do for value if ExplicitLevelImports
is on.
Closes #26098
- - - - -
5f0dbeb6 by Simon Hengel at 2026-02-03T16:00:12-05:00
Use Haddock formatting in deprecation message of `initNameCache`
- - - - -
01ecb612 by Andreas Klebinger at 2026-02-04T09:56:25-05:00
testsuite: Explicitly use utf-8 encoding in rts-includes linter.
Not doing so caused failures on windows, as python failed to pick a
reasonable encoding even with locale set.
Fixes #26850
- - - - -
ea0d1317 by Zubin Duggal at 2026-02-04T09:57:06-05:00
Bump transformers submodule to 0.6.3.0
Fixes #26790
- - - - -
cbe4300e by Simon Peyton Jones at 2026-02-05T04:31:04-05:00
Fix subtle bug in GHC.Core.Utils.mkTick
This patch fixes a decade-old bug in `mkTick`, which
could generate type-incorrect code! See the diagnosis
in #26772.
The new code is simpler and easier to understand.
(As #26772 says, I think it could be improved further.)
- - - - -
a193a8da by Simon Peyton Jones at 2026-02-05T04:31:04-05:00
Modify a debug-trace in the Simplifier
...just to show a bit more information.
- - - - -
b579dfdc by Simon Peyton Jones at 2026-02-05T04:31:04-05:00
Fix long-standing interaction between ticks and casts
The code for Note [Eliminate Identity Cases] was simply wrong when
ticks and casts interacted. This patch fixes the interaction.
It was shown up when validating #26772, although it's not the exactly
the bug that's reported by #26772. Nor is it easy to reproduce, hence
no regression test.
- - - - -
fac0de1e by Cheng Shao at 2026-02-05T04:31:49-05:00
libraries: bump Cabal submodule to 3.16.1.0
- - - - -
00589122 by Cheng Shao at 2026-02-05T04:31:49-05:00
libraries: bump deepseq submodule to 1.5.2.0
Also:
- Get rid of usage of deprecated `NFData` function instance in the
compiler
- `T21391` still relies on `NFData` function instance, add
`-Wno-deprecations` for the time being.
- - - - -
84474c71 by Cheng Shao at 2026-02-05T04:31:50-05:00
libraries: bump directory submodule to 1.3.10.1
- - - - -
1a9f4662 by Cheng Shao at 2026-02-05T04:31:50-05:00
libraries: bump exceptions submodule to 0.10.12
- - - - -
2e39a340 by Peng Fan at 2026-02-07T03:42:01-05:00
NCG/LA64: adjust register usage to avoid src-register being clobbered
- - - - -
9faf1b35 by Teo Camarasu at 2026-02-07T03:42:43-05:00
ghc-internal: Delete unnecessary GHC.Internal.Data.Ix
This module merely re-exports GHC.Internal.Ix. It was copied from
`base` when `ghc-internal` was split, but there is no reason to have
this now. So, let's delete it.
Resolves #26848
- - - - -
d112b440 by Sven Tennie at 2026-02-07T10:47:56-05:00
Add cabal.project file to generate-ci
This fixes the HLS setup for our CI code generation script
(generate-ci).
The project file simply makes `generate-ci` of the cabal file
discoverable.
- - - - -
5339f6f0 by Andreas Klebinger at 2026-02-07T10:48:40-05:00
CI: Don't collapse test results.
This puts test output back into the primary test log instead of a
subsection removing the need to expand a section to see test results.
While the intention was good in practice the old behaviour mostly wastes time
by requiring expansion of the section.
Fixes #26882
- - - - -
0e1cd2e0 by Evan Piro at 2026-02-08T10:35:16-08:00
Linker.MacOS reduce dynflags import
- - - - -
1c79a4cd by Michael Alan Dorman at 2026-02-09T08:11:51-05:00
Remove `extra_src_files` variable from `testsuite/driver/testlib.py`
While reading through the test harness code, I noticed this variable
with a TODO attached that referenced #12223. Although that bug is
closed, it strongly implied that this special-case variable that only
affected a single test was expected to be removed at some point.
I also looked at 3415bcaa0b1903b5e12dfaadb5b774718e406eab---where it
was added---whose commit message suggested that it would have been
desirable to remove it, but that there were special circumstances that
meant it had to remain (though it doesn't elucidate what those special
circumstances are).
However, the special circumstances were mentioned as if the test was
in a different location than is currently is, so I decided to try
changing the test to use the standard `extra_files` mechanism, which
works in local testing.
This also seems like a reasonable time to remove the script that was
originally used in the transition, since it doesn't really serve a
purpose anymore.
- - - - -
0020e38a by Matthew Pickering at 2026-02-09T17:29:14-05:00
determinism: Use a stable sort in WithHsDocIdentifiers binary instance
`WithHsDocIdentifiers` is defined as
```
71 data WithHsDocIdentifiers a pass = WithHsDocIdentifiers
72 { hsDocString :: !a
73 , hsDocIdentifiers :: ![Located (IdP pass)]
74 }
```
This list of names is populated from `rnHsDocIdentifiers`, which calls
`lookupGRE`, which calls `lookupOccEnv_AllNameSpaces`, which calls
`nonDetEltsUFM` and returns the results in an order depending on
uniques.
Sorting the list with a stable sort before returning the interface makes
the output deterministic and follows the approach taken by other fields
in `Docs`.
Fixes #26858
- - - - -
89898ce6 by echoumcp1 at 2026-02-09T17:30:01-05:00
Replace putstrln with logMsg in handleSeqHValueStatus
Fixes #26549
- - - - -
7c52c4f9 by John Paul Adrian Glaubitz at 2026-02-10T13:52:43-05:00
rts: Switch prim to use modern atomic compiler builtins
The __sync_*() atomic compiler builtins have been deprecated in GCC
for a while now and also don't provide variants for 64-bit values
such as __sync_fetch_and_add_8().
Thus, replace them with the modern __atomic_*() compiler builtins and
while we're at it, also drop the helper macro CAS_NAND() which is now
no longer needed since we stopped using the __sync_*() compiler builtins
altogether.
Co-authored-by: Ilias Tsitsimpis <iliastsi(a)debian.org>
Fixes #26729
- - - - -
cf60850a by Recursion Ninja at 2026-02-10T13:53:27-05:00
Decoupling L.H.S.Decls from GHC.Types.ForeignCall
- Adding TTG extension point for 'CCallTarget'
- Adding TTG extension point for 'CType'
- Adding TTG extension point for 'Header'
- Moving ForeignCall types that do not need extension
to new L.H.S.Decls.Foreign module
- Replacing 'Bool' parameters with descriptive data-types
to increase clairty and prevent "Boolean Blindness"
- - - - -
11a04cbb by Eric Lee at 2026-02-11T09:20:46-05:00
Derive Semigroup/Monoid for instances believed could be derived in #25871
- - - - -
15d9ce44 by Eric Lee at 2026-02-11T09:20:46-05:00
add Ghc.Data.Pair deriving
- - - - -
c85dc170 by Evan Piro at 2026-02-11T09:21:45-05:00
Linker.MacOS reduce options import
- - - - -
a541dd83 by Chris Wendt at 2026-02-11T16:06:41-05:00
Initialize plugins for `:set +c` in GHCi
Fixes #23110.
- - - - -
0f5a73bc by Cheng Shao at 2026-02-11T16:07:27-05:00
compiler: add Binary Text instance
This patch adds `Binary` instance for strict `Text`, in preparation of
making `Text` usable in certain GHC API use cases (e.g. haddock). This
also introduces `text` as a direct dependency of the `ghc` package.
- - - - -
9e58b8a1 by Cheng Shao at 2026-02-11T16:08:10-05:00
ghc-toolchain: add C11 check
This patch partially reverts commit
b8307eab80c5809df5405d76c822bf86877f5960 that removed C99 check in
autoconf/ghc-toolchain. Now we:
- No longer re-implement `FP_SET_CFLAGS_C11` similar to
`FP_SET_CFLAGS_C99` in the past, since autoconf doesn't provide a
convenient `AC_PROG_CC_C11` function. ghc-toolchain will handle it
anyway.
- The Cmm CPP C99 check is relanded and repurposed for C11.
- The C99 logic in ghc-toolchain is relanded and repurposed for C11.
- The C99 check in Stg.h is corrected to check for C11. The obsolete
_ISOC99_SOURCE trick is dropped.
- Usages of `-std=gnu99` in the testsuite are corrected to use
`-std=gnu11`.
Closes #26908.
- - - - -
4df0adf6 by Simon Peyton Jones at 2026-02-11T21:50:13-05:00
Simplify the treatment of static forms
This MR implements GHC proposal 732: simplify static forms,
https://github.com/ghc-proposals/ghc-proposals/pull/732
thereby addressing #26556.
See `Note [Grand plan for static forms]` in GHC.Iface.Tidy.StaticPtrTable
The main changes are:
* There is a new, simple rule for (static e), namely that the free
term variables of `e` must be bound at top level. The check is
done in the `HsStatic` case of `GHC.Rename.Expr.rnExpr`
* That in turn substantially simplifies the info that the typechecker
carries around in its type environment. Hooray.
* The desugarer emits static bindings to top level directly; see the
`HsStatic` case of `dsExpr`.
* There is no longer any special static-related magic in the FloatOut
pass. And the main Simplifier pipeline no longer needs a special case
to run FloatOut even with -O0. Hooray.
All this forced an unexpected change to the pattern match checker. It
recursively invokes the main Hs desugarer when it wants to take a look
at a term to spot some special cases (notably constructor applications).
We don't want to emit any nested (static e) bindings to top level a
second time! Yikes.
That forced a modest refactor in GHC.HsToCore.Pmc:
* The `dsl_nablas` field of `DsLclEnv` now has a `NoPmc` case, which says
"I'm desugaring just for pattern-match checking purposes".
* When that flag is set we don't emit static binds.
That in turn forces a cascade of refactoring, but the net effect is an
improvement; less risk of duplicated (even exponential?) work.
See Note [Desugaring HsExpr during pattern-match checking].
10% metric decrease, on some architectures, of compile-time max-bytes-used on T15304.
Metric Decrease:
T15304
- - - - -
7922f728 by Teo Camarasu at 2026-02-11T21:50:58-05:00
ghc-internal: avoid depending on GHC.Internal.Exts
This module is mostly just re-exports. It made sense as a user-facing
module, but there's no good reason ghc-internal modules should depend on
it and doing so linearises the module graph
- move considerAccessible to GHC.Internal.Magic
Previously it lived in GHC.Internal.Exts, but it really deserves to live
along with the other magic function, which are already re-exported from .Exts
- move maxTupleSize to GHC.Internal.Tuple
This previously lived in GHC.Internal.Exts but a comment already said it
should be moved to .Tuple
Resolves #26832
- - - - -
b6a4a29b by Eric Lee at 2026-02-11T21:51:55-05:00
Remove unused Semigroup imports to fix GHC 9.14 bootstrapping
- - - - -
99d8c146 by Simon Peyton Jones at 2026-02-12T17:36:59+00:00
Fix subtle bug in cast worker/wrapper
See (CWw4) in Note [Cast worker/wrapper].
The true payload is in the change to the definition of
GHC.Types.Id.Info.hasInlineUnfolding
Everthing else is just documentation.
There is a 2% compile time decrease for T13056;
I'll take the win!
Metric Decrease:
T13056
- - - - -
530e8e58 by Simon Peyton Jones at 2026-02-12T20:17:23-05:00
Add regression tests for four StaticPtr bugs
Tickets #26545, #24464, #24773, #16981 are all solved by the
recently-landed MR
commit 318ee13bcffa6aa8df42ba442ccd92aa0f7e210c
Author: Simon Peyton Jones <simon.peytonjones(a)gmail.com>
Date: Mon Oct 20 23:07:20 2025 +0100
Simplify the treatment of static forms
This MR just adds regression tests for them.
- - - - -
4157160f by Cheng Shao at 2026-02-13T06:27:04-05:00
ci: remove unused hlint-ghc-and-base job definition
This patch removes the unused `hlint-ghc-and-base` job definition,
it's never run since !9806. Note that hadrian lint rules still work
locally, so anyone that wishes to run hlint on the codebase can
continue to do so in their local worktree.
- - - - -
039f1977 by Cheng Shao at 2026-02-13T06:27:47-05:00
wasm: use import.meta.main for proper distinction of nodejs main modules
This patch uses `import.meta.main` for proper distinction of nodejs
main modules, especially when the main module might be installed as a
symlink. Fixes #26916.
- - - - -
eded9001 by Matthew Pickering at 2026-02-14T08:44:28+01:00
Add missing req_interp modifier to T18441fail3 and T18441fail19
These tests require the interpreter but they were failing in a different
way with the javascript backend because the interpreter was disabled and
stderr is ignored by the test.
- - - - -
0961528a by Matthew Pickering at 2026-02-14T08:44:28+01:00
Use explicit syntax rather than pure
- - - - -
e85f8596 by Matthew Pickering at 2026-02-14T08:44:28+01:00
packaging: correctly propagate build/host/target to bindist configure script
At the moment the host and target which we will produce a compiler for
is fixed at the initial configure time. Therefore we need to persist
the choice made at this time into the installation bindist as well so we
look for the right tools, with the right prefixes at install time.
In the future, we want to provide a bit more control about what kind of
bindist we produce so the logic about what the host/target will have to
be written by hadrian rather than persisted by the configure script. In
particular with cross compilers we want to either build a normal stage 2
cross bindist or a stage 3 bindist, which creates a bindist which has a
native compiler for the target platform.
Fixes #21970
- - - - -
1ed68fcf by Matthew Pickering at 2026-02-14T08:44:28+01:00
hadrian: Fill in more of the default.host toolchain file
When you are building a cross compiler this file will be used to build
stage1 and it's libraries, so we need enough information here to work
accurately. There is still more work to be done (see for example, word
size is still fixed).
- - - - -
c37f06dc by Matthew Pickering at 2026-02-14T08:44:28+01:00
hadrian: Disable docs when cross compiling
Before there were a variety of ad-hoc places where doc building was
disabled when cross compiling.
* Some CI jobs sets --docs=none in gen_ci.hs
* Some CI jobs set --docs=none in .gitlab/ci.sh
* There was some logic in hadrian to not need the ["docs"] target when
making a bindist.
Now the situation is simple:
* If you are cross compiling then defaultDocsTargets is empty by
default.
In theory, there is no reason why we can't build documentation for cross
compiler bindists, but this is left to future work to generalise the
documentation building rules to allow this (#24289)
- - - - -
c4dcc945 by Matthew Pickering at 2026-02-14T08:44:28+01:00
hadrian: Build stage 2 cross compilers
* Most of hadrian is abstracted over the stage in order to remove the
assumption that the target of all stages is the same platform. This
allows the RTS to be built for two different targets for example.
* Abstracts the bindist creation logic to allow building either normal
or cross bindists. Normal bindists use stage 1 libraries and a stage 2
compiler. Cross bindists use stage 2 libararies and a stage 2
compiler.
* hadrian: Make binary-dist-dir the default build target. This allows us
to have the logic in one place about which libraries/stages to build
with cross compilers. Fixes #24192
New hadrian target:
* `binary-dist-dir-cross`: Build a cross compiler bindist (compiler =
stage 1, libraries = stage 2)
This commit also contains various changes to make stage2 compilers
feasible.
-------------------------
Metric Decrease:
ManyAlternatives
MultiComponentModulesRecomp
MultiLayerModulesRecomp
T10421
T12425
T12707
T13035
T13379
T15703
T16577
T18698a
T18698b
T18923
T1969
T21839c
T3294
T4801
T5030
T5321Fun
T5642
T783
T9198
T9872d
T9961
parsing001
T5321FD
T6048
T12227
T18140
T18282
T9233
T5631
T9630
-------------------------
Co-authored-by: Sven Tennie <sven.tennie(a)gmail.com>
Fix rebase: settings-use-distro-mingw is now staged
- - - - -
7b47a226 by Matthew Pickering at 2026-02-14T08:44:28+01:00
ci: Test cross bindists
We remove the special logic for testing in-tree cross
compilers and instead test cross compiler bindists, like we do for all
other platforms.
- - - - -
63e5c457 by Matthew Pickering at 2026-02-14T08:44:28+01:00
ci: Introduce CROSS_STAGE variable
In preparation for building and testing stage3 bindists we introduce the
CROSS_STAGE variable which is used by a CI job to determine what kind of
bindist the CI job should produce.
At the moment we are only using CROSS_STAGE=2 but in the future we will
have some jobs which set CROSS_STAGE=3 to produce native bindists for a
target, but produced by a cross compiler, which can be tested on by
another CI job on the native platform.
CROSS_STAGE=2: Build a normal cross compiler bindist
CROSS_STAGE=3: Build a stage 3 bindist, one which is a native compiler and library for the target
- - - - -
6a749369 by Matthew Pickering at 2026-02-14T08:44:28+01:00
hadrian: Refactor system-cxx-std-lib rules0
I noticed a few things wrong with the hadrian rules for `system-cxx-std-lib` rules.
* For `text` there is an ad-hoc check to depend on `system-cxx-std-lib` outside of `configurePackage`.
* The `system-cxx-std-lib` dependency is not read from cabal files.
* Recache is not called on the packge database after the `.conf` file is generated, a more natural place for this rule is `registerRules`.
Treating this uniformly like other packages is complicated by it not having any source code or a cabal file. However we can do a bit better by reporting the dependency firstly in `PackageData` and then needing the `.conf` file in the same place as every other package in `configurePackage`.
Fixes #25303
- - - - -
8b155ddb by Sven Tennie at 2026-02-14T08:44:28+01:00
ci: Increase timeout for emulators
Test runs with emulators naturally take longer than on native machines.
Generate jobs.yml
- - - - -
179b678b by Sven Tennie at 2026-02-14T08:44:28+01:00
ghc: Distinguish between having an interpreter and having an internal one
Otherwise, we fail with warnings when compiling tools. Actually, these
are related but different things:
- ghc can run an interpreter (either internal or external)
- ghc is compiled with an internal interpreter
- - - - -
751cd014 by Matthew Pickering at 2026-02-14T08:44:28+01:00
ci: Javascript don't set CROSS_EMULATOR
There is no CROSS_EMULATOR needed to run javascript binaries, so we
don't set the CROSS_EMULATOR to some dummy value.
- - - - -
0ca3c382 by Sven Tennie at 2026-02-14T08:44:28+01:00
Javascript skip T23697
See #22355 about how HSC2HS and the Javascript target don't play well
together.
- - - - -
a64f5a1d by Sven Tennie at 2026-02-14T08:44:28+01:00
Mark T24602 as fragile
It was skipped before (due to CROSS_EMULATOR being set, which changed
for JS), so we don't make things worse by marking it as fragile.
- - - - -
b2965b75 by Sven Tennie at 2026-02-14T08:44:28+01:00
Windows needs NM_STAGE0 as well
The stage0 always needs nm.
- - - - -
535cfbb0 by Sven Tennie at 2026-02-14T08:44:28+01:00
T17912 sometimes works for windows-validate
This seems to be timing related. However, just simply increasing the
timeout (sleep) statement of this test didn't help. Maybe, it has been
flaky on CI before.
- - - - -
9bbde165 by Sven Tennie at 2026-02-14T09:13:02+01:00
Enable stage3 bin-dists
- - - - -
aa7b9581 by Sven Tennie at 2026-02-14T09:13:02+01:00
Generated cross stage 3 CI jobs
- - - - -
bf946286 by Sven Tennie at 2026-02-14T09:13:03+01:00
Hack
- - - - -
af3b253e by Sven Tennie at 2026-02-14T09:13:03+01:00
WIP: Validate script
- - - - -
5b973895 by Sven Tennie at 2026-02-14T09:13:03+01:00
Fix stage3 bindist creation
- - - - -
fe5c9c0c by Sven Tennie at 2026-02-14T09:13:03+01:00
Adjust jobs.yaml
- - - - -
192585ec by Sven Tennie at 2026-02-14T19:11:11+01:00
Fix final ghc-pkg recache run
Sage3 cross-compiler's ghc-pkg cannot run on the build host. Resort to a
prior stage's ghc-pkg.
- - - - -
443 changed files:
- .gitlab-ci.yml
- .gitlab/ci.sh
- .gitlab/darwin/nix/sources.json
- .gitlab/darwin/toolchain.nix
- + .gitlab/generate-ci/cabal.project
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Builtin/Types.hs
- compiler/GHC/CmmToAsm/LA64/CodeGen.hs
- compiler/GHC/CmmToAsm/PPC/CodeGen.hs
- compiler/GHC/CmmToAsm/X86/CodeGen.hs
- compiler/GHC/CmmToLlvm/CodeGen.hs
- compiler/GHC/Core/Coercion.hs
- compiler/GHC/Core/FamInstEnv.hs
- compiler/GHC/Core/InstEnv.hs
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Map/Type.hs
- compiler/GHC/Core/Opt/OccurAnal.hs
- compiler/GHC/Core/Opt/Pipeline.hs
- compiler/GHC/Core/Opt/SetLevels.hs
- compiler/GHC/Core/Opt/Simplify/Env.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/Opt/WorkWrap.hs
- compiler/GHC/Core/Predicate.hs
- compiler/GHC/Core/TyCo/Rep.hs
- compiler/GHC/Core/TyCo/Subst.hs
- compiler/GHC/Core/TyCo/Tidy.hs
- compiler/GHC/Core/TyCon.hs
- compiler/GHC/Core/TyCon/RecWalk.hs
- compiler/GHC/Core/Utils.hs
- compiler/GHC/CoreToStg.hs
- compiler/GHC/CoreToStg/AddImplicitBinds.hs
- compiler/GHC/Data/Maybe.hs
- compiler/GHC/Data/Pair.hs
- compiler/GHC/Driver/Config/Core/Lint.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Hs/Binds.hs
- compiler/GHC/Hs/Decls.hs
- + compiler/GHC/Hs/Decls/Overlap.hs
- compiler/GHC/Hs/Doc.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/Hs/Lit.hs
- compiler/GHC/Hs/Syn/Type.hs
- compiler/GHC/Hs/Type.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore.hs
- compiler/GHC/HsToCore/Docs.hs
- compiler/GHC/HsToCore/Errors/Types.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/HsToCore/Foreign/C.hs
- compiler/GHC/HsToCore/Foreign/Call.hs
- compiler/GHC/HsToCore/Foreign/Decl.hs
- compiler/GHC/HsToCore/Foreign/JavaScript.hs
- compiler/GHC/HsToCore/Foreign/Utils.hs
- compiler/GHC/HsToCore/Foreign/Wasm.hs
- compiler/GHC/HsToCore/GuardedRHSs.hs
- compiler/GHC/HsToCore/Match.hs
- compiler/GHC/HsToCore/Match/Literal.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/Pmc.hs
- compiler/GHC/HsToCore/Pmc/Desugar.hs
- compiler/GHC/HsToCore/Pmc/Solver.hs
- compiler/GHC/HsToCore/Pmc/Solver/Types.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/HsToCore/Ticks.hs
- compiler/GHC/HsToCore/Types.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Iface/Tidy.hs
- compiler/GHC/Iface/Tidy/StaticPtrTable.hs
- compiler/GHC/Linker/MacOS.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Parser/PostProcess/Haddock.hs
- compiler/GHC/Parser/String.hs
- compiler/GHC/Rename/Bind.hs
- compiler/GHC/Rename/Env.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/HsType.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Splice.hs
- compiler/GHC/Rename/Splice.hs-boot
- compiler/GHC/Rename/Unbound.hs
- compiler/GHC/Runtime/Heap/Inspect.hs
- compiler/GHC/Runtime/Interpreter.hs
- compiler/GHC/StgToByteCode.hs
- compiler/GHC/StgToCmm/Foreign.hs
- compiler/GHC/StgToJS/FFI.hs
- compiler/GHC/Tc/Deriv.hs
- compiler/GHC/Tc/Deriv/Utils.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/Bind.hs
- compiler/GHC/Tc/Gen/Default.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Foreign.hs
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Gen/HsType.hs
- compiler/GHC/Tc/Gen/Pat.hs
- compiler/GHC/Tc/Gen/Sig.hs
- compiler/GHC/Tc/Instance/Class.hs
- compiler/GHC/Tc/Instance/Family.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/Tc/Solver.hs
- compiler/GHC/Tc/Solver/Default.hs
- compiler/GHC/Tc/Solver/Dict.hs
- compiler/GHC/Tc/Solver/Equality.hs
- compiler/GHC/Tc/Solver/InertSet.hs
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/Solver/Solve.hs
- compiler/GHC/Tc/TyCl.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/TyCl/Utils.hs
- compiler/GHC/Tc/Types.hs
- compiler/GHC/Tc/Types/BasicTypes.hs
- compiler/GHC/Tc/Types/Constraint.hs
- compiler/GHC/Tc/Types/CtLoc.hs
- compiler/GHC/Tc/Types/ErrCtxt.hs
- compiler/GHC/Tc/Types/Evidence.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Utils/Env.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Tc/Utils/TcMType.hs
- − compiler/GHC/Tc/Utils/TcMType.hs-boot
- compiler/GHC/Tc/Utils/Unify.hs
- compiler/GHC/Tc/Zonk/TcType.hs
- compiler/GHC/Tc/Zonk/Type.hs
- compiler/GHC/ThToHs.hs
- compiler/GHC/Types/Basic.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/ForeignCall.hs
- compiler/GHC/Types/Id/Info.hs
- compiler/GHC/Types/Id/Make.hs
- compiler/GHC/Types/InlinePragma.hs
- compiler/GHC/Types/Name.hs
- compiler/GHC/Types/Name/Cache.hs
- compiler/GHC/Types/RepType.hs
- compiler/GHC/Types/Unique/DSet.hs
- compiler/GHC/Types/Var.hs
- compiler/GHC/Unit/Module/ModIface.hs
- compiler/GHC/Unit/Types.hs
- compiler/GHC/Utils/Binary.hs
- compiler/GHC/Utils/Monad.hs
- compiler/GHC/Utils/Outputable.hs
- compiler/GHC/Utils/Ppr/Colour.hs
- compiler/GHC/Utils/Trace.hs
- compiler/Language/Haskell/Syntax/Basic.hs
- compiler/Language/Haskell/Syntax/Decls.hs
- + compiler/Language/Haskell/Syntax/Decls/Foreign.hs
- + compiler/Language/Haskell/Syntax/Decls/Overlap.hs
- compiler/Language/Haskell/Syntax/Extension.hs
- compiler/Language/Haskell/Syntax/Lit.hs
- compiler/ghc.cabal.in
- configure.ac
- distrib/configure.ac.in
- docs/users_guide/9.16.1-notes.rst
- docs/users_guide/exts/multiway_if.rst
- docs/users_guide/rtd-theme/layout.html
- ghc/GHC/Driver/Session/Mode.hs
- ghc/GHCi/UI.hs
- ghc/GHCi/UI/Info.hs
- ghc/Main.hs
- ghc/ghc-bin.cabal.in
- hadrian/README.md
- hadrian/bindist/config.mk.in
- hadrian/cfg/default.host.target.in
- + hadrian/cfg/system.config.host.in
- hadrian/cfg/system.config.in
- + hadrian/cfg/system.config.target.in
- hadrian/hadrian.cabal
- hadrian/src/Base.hs
- + hadrian/src/BindistConfig.hs
- hadrian/src/Builder.hs
- hadrian/src/Context.hs
- hadrian/src/Expression.hs
- hadrian/src/Flavour.hs
- hadrian/src/Flavour/Type.hs
- hadrian/src/Hadrian/Builder.hs
- hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
- hadrian/src/Hadrian/Haskell/Cabal/Type.hs
- hadrian/src/Hadrian/Haskell/Hash.hs
- hadrian/src/Hadrian/Oracles/TextFile.hs
- hadrian/src/Oracles/Flag.hs
- hadrian/src/Oracles/Flavour.hs
- hadrian/src/Oracles/Setting.hs
- hadrian/src/Oracles/TestSettings.hs
- hadrian/src/Packages.hs
- hadrian/src/Rules.hs
- hadrian/src/Rules/BinaryDist.hs
- hadrian/src/Rules/CabalReinstall.hs
- hadrian/src/Rules/Compile.hs
- hadrian/src/Rules/Documentation.hs
- hadrian/src/Rules/Generate.hs
- hadrian/src/Rules/Gmp.hs
- + hadrian/src/Rules/Libffi.hs
- hadrian/src/Rules/Library.hs
- hadrian/src/Rules/Program.hs
- hadrian/src/Rules/Register.hs
- hadrian/src/Rules/Test.hs
- hadrian/src/Settings.hs
- hadrian/src/Settings/Builders/Cabal.hs
- hadrian/src/Settings/Builders/Cc.hs
- hadrian/src/Settings/Builders/Common.hs
- hadrian/src/Settings/Builders/Configure.hs
- hadrian/src/Settings/Builders/DeriveConstants.hs
- hadrian/src/Settings/Builders/Ghc.hs
- hadrian/src/Settings/Builders/Hsc2Hs.hs
- hadrian/src/Settings/Builders/RunTest.hs
- hadrian/src/Settings/Builders/SplitSections.hs
- hadrian/src/Settings/Default.hs
- hadrian/src/Settings/Flavours/Benchmark.hs
- hadrian/src/Settings/Flavours/Development.hs
- hadrian/src/Settings/Flavours/GhcInGhci.hs
- hadrian/src/Settings/Flavours/Performance.hs
- hadrian/src/Settings/Flavours/Quick.hs
- hadrian/src/Settings/Flavours/QuickCross.hs
- hadrian/src/Settings/Flavours/Quickest.hs
- hadrian/src/Settings/Flavours/Validate.hs
- hadrian/src/Settings/Packages.hs
- hadrian/src/Settings/Program.hs
- hadrian/src/Settings/Warnings.hs
- libraries/Cabal
- libraries/base/base.cabal.in
- libraries/base/changelog.md
- libraries/base/src/Data/Ix.hs
- − libraries/base/src/GHC/Desugar.hs
- + libraries/base/src/System/IO/OS.hs
- libraries/base/tests/IO/all.T
- + libraries/base/tests/IO/osHandles001FileDescriptors.hs
- + libraries/base/tests/IO/osHandles001FileDescriptors.stdout
- + libraries/base/tests/IO/osHandles001WindowsHandles.hs
- + libraries/base/tests/IO/osHandles001WindowsHandles.stdout
- + libraries/base/tests/IO/osHandles002FileDescriptors.hs
- + libraries/base/tests/IO/osHandles002FileDescriptors.stderr
- + libraries/base/tests/IO/osHandles002FileDescriptors.stdin
- + libraries/base/tests/IO/osHandles002FileDescriptors.stdout
- + libraries/base/tests/IO/osHandles002WindowsHandles.hs
- + libraries/base/tests/IO/osHandles002WindowsHandles.stderr
- + libraries/base/tests/IO/osHandles002WindowsHandles.stdin
- + libraries/base/tests/IO/osHandles002WindowsHandles.stdout
- libraries/base/tests/T23454.stderr
- libraries/base/tests/all.T
- libraries/base/tests/perf/Makefile
- libraries/deepseq
- libraries/directory
- libraries/exceptions
- libraries/ghc-internal/ghc-internal.cabal.in
- libraries/ghc-internal/src/GHC/Internal/Data/Data.hs
- − libraries/ghc-internal/src/GHC/Internal/Data/Ix.hs
- libraries/ghc-internal/src/GHC/Internal/Err.hs
- libraries/ghc-internal/src/GHC/Internal/Exts.hs
- libraries/ghc-internal/src/GHC/Internal/Functor/ZipList.hs
- libraries/ghc-internal/src/GHC/Internal/Heap/Closures.hs
- libraries/ghc-internal/src/GHC/Internal/JS/Foreign/Callback.hs
- libraries/ghc-internal/src/GHC/Internal/JS/Prim.hs
- libraries/ghc-internal/src/GHC/Internal/JS/Prim/Internal/Build.hs
- libraries/ghc-internal/src/GHC/Internal/Magic.hs
- libraries/ghc-internal/src/GHC/Internal/Stack/Decode.hs
- + libraries/ghc-internal/src/GHC/Internal/System/IO/OS.hs
- libraries/ghc-internal/src/GHC/Internal/Tuple.hs
- libraries/ghc-internal/src/GHC/Internal/Wasm/Prim/Exports.hs
- libraries/ghc-internal/src/GHC/Internal/Wasm/Prim/Imports.hs
- libraries/ghc-internal/src/GHC/Internal/Wasm/Prim/Types.hs
- libraries/ghc-internal/tests/stack-annotation/all.T
- + libraries/ghc-internal/tests/stack-annotation/ann_frame005.hs
- + libraries/ghc-internal/tests/stack-annotation/ann_frame005.stdout
- libraries/text
- libraries/transformers
- llvm-targets
- m4/fp_cmm_cpp_cmd_with_args.m4
- m4/fp_find_nm.m4
- m4/fptools_set_platform_vars.m4
- m4/prep_target_file.m4
- rts/include/Stg.h
- rts/prim/atomic.c
- − testsuite/driver/kill_extra_files.py
- testsuite/driver/testlib.py
- testsuite/ghc-config/ghc-config.hs
- testsuite/mk/test.mk
- testsuite/tests/backpack/cabal/bkpcabal08/bkpcabal08.stdout
- testsuite/tests/codeGen/should_run/CgStaticPointers.hs
- testsuite/tests/codeGen/should_run/CgStaticPointersNoFullLazyness.hs
- testsuite/tests/count-deps/CountDepsAst.stdout
- testsuite/tests/count-deps/CountDepsParser.stdout
- + testsuite/tests/default/T25825.hs
- testsuite/tests/default/all.T
- testsuite/tests/deriving/should_fail/T1496.stderr
- testsuite/tests/deriving/should_fail/T4846.stderr
- testsuite/tests/deriving/should_fail/T5498.stderr
- testsuite/tests/deriving/should_fail/T6147.stderr
- testsuite/tests/deriving/should_fail/T7148.stderr
- testsuite/tests/deriving/should_fail/T7148a.stderr
- testsuite/tests/deriving/should_fail/T8984.stderr
- testsuite/tests/deriving/should_fail/deriving-via-fail.stderr
- testsuite/tests/deriving/should_fail/deriving-via-fail4.stderr
- testsuite/tests/deriving/should_fail/deriving-via-fail5.stderr
- testsuite/tests/driver/T16318/Makefile
- testsuite/tests/driver/T18125/Makefile
- testsuite/tests/driver/T20030/test1/all.T
- testsuite/tests/driver/T20030/test2/all.T
- testsuite/tests/driver/T20030/test3/all.T
- testsuite/tests/driver/T20030/test4/all.T
- testsuite/tests/driver/T20030/test5/all.T
- testsuite/tests/driver/T20030/test6/all.T
- testsuite/tests/driver/T8526/T8526.script
- testsuite/tests/driver/bytecode-object/Makefile
- testsuite/tests/driver/bytecode-object/bytecode_object19.stdout
- testsuite/tests/driver/dynamicToo/dynamicToo001/Makefile
- testsuite/tests/driver/fat-iface/fat014.script
- testsuite/tests/driver/implicit-dyn-too/Makefile
- testsuite/tests/driver/multipleHomeUnits/all.T
- testsuite/tests/driver/multipleHomeUnits/multipleHomeUnits_recomp_th.stdout
- testsuite/tests/ffi/should_run/all.T
- testsuite/tests/gadt/CasePrune.stderr
- + testsuite/tests/ghc-api/TypeMapStringLiteral.hs
- testsuite/tests/ghc-api/all.T
- testsuite/tests/ghc-e/should_fail/all.T
- testsuite/tests/ghci.debugger/scripts/T26042b.stdout
- testsuite/tests/ghci.debugger/scripts/T26042c.stdout
- testsuite/tests/ghci.debugger/scripts/T26042d2.stdout
- testsuite/tests/ghci.debugger/scripts/T26042f2.stdout
- testsuite/tests/ghci.debugger/scripts/T8487.stdout
- testsuite/tests/ghci.debugger/scripts/break011.stdout
- testsuite/tests/ghci.debugger/scripts/break017.stdout
- testsuite/tests/ghci.debugger/scripts/break025.stdout
- − testsuite/tests/ghci/linking/T11531.stderr
- testsuite/tests/ghci/prog018/prog018.script
- testsuite/tests/ghci/scripts/T13869.script
- testsuite/tests/ghci/scripts/T13997.script
- testsuite/tests/ghci/scripts/T17669.script
- testsuite/tests/ghci/scripts/T18330.script
- testsuite/tests/ghci/scripts/T18330.stdout
- testsuite/tests/ghci/scripts/T1914.script
- testsuite/tests/ghci/scripts/T20150.stdout
- testsuite/tests/ghci/scripts/T20217.script
- testsuite/tests/ghci/scripts/T6105.script
- testsuite/tests/ghci/scripts/T8042.script
- testsuite/tests/ghci/scripts/T8042recomp.script
- testsuite/tests/ghci/should_run/Makefile
- testsuite/tests/indexed-types/should_fail/T9580.stderr
- testsuite/tests/interface-stability/base-exports.stdout
- testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
- testsuite/tests/interface-stability/base-exports.stdout-mingw32
- testsuite/tests/interface-stability/base-exports.stdout-ws-32
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32
- testsuite/tests/interface-stability/ghc-prim-exports.stdout
- testsuite/tests/interface-stability/ghc-prim-exports.stdout-mingw32
- testsuite/tests/javascript/closure/all.T
- testsuite/tests/linear/should_fail/LinearRole.stderr
- testsuite/tests/linters/regex-linters/check-rts-includes.py
- testsuite/tests/parser/should_compile/DumpRenamedAst.stderr
- testsuite/tests/parser/should_compile/T14189.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail8.stderr
- + testsuite/tests/parser/should_fail/T26860ppr.hs
- + testsuite/tests/parser/should_fail/T26860ppr.stderr
- testsuite/tests/parser/should_fail/all.T
- + testsuite/tests/plugins/T23110.hs
- + testsuite/tests/plugins/T23110.script
- + testsuite/tests/plugins/T23110.stdout
- testsuite/tests/plugins/all.T
- testsuite/tests/process/all.T
- testsuite/tests/rename/should_fail/RnStaticPointersFail01.stderr
- testsuite/tests/rename/should_fail/RnStaticPointersFail03.stderr
- + testsuite/tests/rename/should_fail/T26545.hs
- + testsuite/tests/rename/should_fail/T26545.stderr
- testsuite/tests/rename/should_fail/all.T
- testsuite/tests/roles/should_fail/RolesIArray.stderr
- testsuite/tests/rts/T13676.script
- testsuite/tests/showIface/DocsInHiFile1.stdout
- testsuite/tests/showIface/HaddockSpanIssueT24378.stdout
- testsuite/tests/showIface/MagicHashInHaddocks.stdout
- testsuite/tests/simplCore/should_compile/T21391.hs
- + testsuite/tests/simplCore/should_compile/T26805.hs
- + testsuite/tests/simplCore/should_compile/T26805.stderr
- + testsuite/tests/simplCore/should_compile/T26826.hs
- + testsuite/tests/simplCore/should_compile/T26903.hs
- + testsuite/tests/simplCore/should_compile/T26903.stderr
- testsuite/tests/simplCore/should_compile/T8331.stderr
- testsuite/tests/simplCore/should_compile/all.T
- + testsuite/tests/th/T26098A_quote.hs
- + testsuite/tests/th/T26098A_splice.hs
- + testsuite/tests/th/T26098_local.hs
- + testsuite/tests/th/T26098_local.stderr
- + testsuite/tests/th/T26098_quote.hs
- + testsuite/tests/th/T26098_quote.stderr
- + testsuite/tests/th/T26098_splice.hs
- + testsuite/tests/th/T26098_splice.stderr
- testsuite/tests/th/all.T
- + testsuite/tests/typecheck/should_compile/T24464.hs
- + testsuite/tests/typecheck/should_compile/T26805a.hs
- testsuite/tests/typecheck/should_compile/all.T
- testsuite/tests/typecheck/should_fail/T10285.stderr
- testsuite/tests/typecheck/should_fail/T10534.stderr
- testsuite/tests/typecheck/should_fail/T10715b.stderr
- testsuite/tests/typecheck/should_fail/T11347.stderr
- testsuite/tests/typecheck/should_fail/T15801.stderr
- + testsuite/tests/typecheck/should_fail/T15850.hs
- + testsuite/tests/typecheck/should_fail/T15850.stderr
- + testsuite/tests/typecheck/should_fail/T15850_Lib.hs
- + testsuite/tests/typecheck/should_fail/T20289.hs
- + testsuite/tests/typecheck/should_fail/T20289.stderr
- + testsuite/tests/typecheck/should_fail/T20289_A.hs
- testsuite/tests/typecheck/should_fail/T22645.stderr
- testsuite/tests/typecheck/should_fail/T22924a.stderr
- + testsuite/tests/typecheck/should_fail/T23731.hs
- + testsuite/tests/typecheck/should_fail/T23731.stderr
- + testsuite/tests/typecheck/should_fail/T23731b.hs
- + testsuite/tests/typecheck/should_fail/T23731b.stderr
- + testsuite/tests/typecheck/should_fail/T23731b_aux.hs
- + testsuite/tests/typecheck/should_fail/T25679.hs
- + testsuite/tests/typecheck/should_fail/T25679.stderr
- + testsuite/tests/typecheck/should_fail/T25949.hs
- + testsuite/tests/typecheck/should_fail/T25949.stderr
- + testsuite/tests/typecheck/should_fail/T25949_aux.hs
- + testsuite/tests/typecheck/should_fail/T26137.hs
- + testsuite/tests/typecheck/should_fail/T26137.stderr
- testsuite/tests/typecheck/should_fail/TcCoercibleFail.stderr
- testsuite/tests/typecheck/should_fail/TcCoercibleFail3.stderr
- testsuite/tests/typecheck/should_fail/all.T
- + testsuite/tests/typecheck/should_run/T16981.hs
- + testsuite/tests/typecheck/should_run/T16981.stdout
- + testsuite/tests/typecheck/should_run/T24773.hs
- + testsuite/tests/typecheck/should_run/T24773.stdout
- testsuite/tests/typecheck/should_run/all.T
- testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr
- utils/check-exact/ExactPrint.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cc.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cpp.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hoogle.hs
- utils/haddock/haddock-api/src/Haddock/Convert.hs
- utils/haddock/haddock-api/src/Haddock/Interface/LexParseRn.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs
- utils/haddock/haddock-api/src/Haddock/Types.hs
- utils/jsffi/dyld.mjs
- utils/jsffi/post-link.mjs
- + validate-riscv-bindist.sh
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/77ec95ae9e7e73313b4717ed2f0c44…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/77ec95ae9e7e73313b4717ed2f0c44…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/fendor/stack-annotation-ty] 2 commits: Add optional `SrcLoc` to `StackAnnotation` class
by Hannes Siebenhandl (@fendor) 14 Feb '26
by Hannes Siebenhandl (@fendor) 14 Feb '26
14 Feb '26
Hannes Siebenhandl pushed to branch wip/fendor/stack-annotation-ty at Glasgow Haskell Compiler / GHC
Commits:
c32beb60 by fendor at 2026-02-14T10:05:37+01:00
Add optional `SrcLoc` to `StackAnnotation` class
`StackAnnotation` give access to an optional `SrcLoc` field that
stack annotations can use to provide better backtraces in both error
messages and when decoding the callstack.
We update builtin stack annotations such as `StringAnnotation` and
`ShowAnnotation` to also capture the `SrcLoc` of the current `CallStack`
to improve backtraces by default (if stack annotations are used).
This change is backwards compatible with GHC 9.14.1.
- - - - -
13c2f349 by fendor at 2026-02-14T10:05:37+01:00
Allow inlining of annotateStackIO
- - - - -
19 changed files:
- libraries/ghc-experimental/src/GHC/Stack/Annotation/Experimental.hs
- + libraries/ghc-experimental/tests/Makefile
- + libraries/ghc-experimental/tests/all.T
- + libraries/ghc-experimental/tests/backtraces/Makefile
- + libraries/ghc-experimental/tests/backtraces/T26806a.hs
- + libraries/ghc-experimental/tests/backtraces/T26806a.stderr
- + libraries/ghc-experimental/tests/backtraces/T26806b.hs
- + libraries/ghc-experimental/tests/backtraces/T26806b.stderr
- + libraries/ghc-experimental/tests/backtraces/T26806c.hs
- + libraries/ghc-experimental/tests/backtraces/T26806c.stderr
- + libraries/ghc-experimental/tests/backtraces/all.T
- libraries/ghc-internal/src/GHC/Internal/Stack/Annotation.hs
- libraries/ghc-internal/tests/stack-annotation/ann_frame001.stdout
- libraries/ghc-internal/tests/stack-annotation/ann_frame002.stdout
- libraries/ghc-internal/tests/stack-annotation/ann_frame003.stdout
- libraries/ghc-internal/tests/stack-annotation/ann_frame004.stdout
- libraries/ghc-internal/tests/stack-annotation/ann_frame005.stdout
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32
Changes:
=====================================
libraries/ghc-experimental/src/GHC/Stack/Annotation/Experimental.hs
=====================================
@@ -82,9 +82,6 @@ import GHC.Internal.Stack.Annotation
-- the pure variations can behave in ways that are hard to predict.
--
-- See Note [Stack annotations in pure code] for more details.
---
--- At last, stack annotations are tricky to use with 'error'.
--- See Note [Pushing annotation frames on 'error'] for why this is the case.
-- Note [Stack annotations in pure code]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -96,57 +93,50 @@ import GHC.Internal.Stack.Annotation
-- For example:
--
-- @
--- annotateStackShow (5 @Int) (fib 20 + throw (ErrorCall "Oh no!"))
+-- annotateStackShow (5 @Int) (fib 20 + error "Oh no!")
-- @
--
--- Without forcing the result of @(fib 20 + throw (ErrorCall "Oh no!"))@, the computation
+-- Without forcing the result of @(fib 20 + error "Oh no!")@, the computation
-- will simply return a thunk, and the stack annotation would be popped off the stack.
-- Once the thunk is evaluated, the exception is raised, but no stack annotation will be found!
--- If we force the result of @(fib 20 + throw (ErrorCall "Oh no!"))@, then the stack
+-- If we force the result of @(fib 20 + error "Oh no!")@, then the stack
-- annotations remain on the stack, and are displayed in the stack trace.
--
-- Naturally, this only holds if no imprecise exceptions are thrown during evaluation of any
-- nested value, for example in 'annotateStackShow 5 (Just $ throw (ErrorCall "Oh no!"))', the
-- stack trace will not include the value @5@.
--
--- See how we preferred @throw (ErrorCall ...)@ over @error@?
--- See Note [Pushing annotation frames on 'error'] for why we do this.
-
--- Note [Pushing annotation frames on 'error']
--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- Examples so far have not been using 'error' at all.
--- The reason is that 'error' is extraordinarily difficult to use correctly with stack annotation frames.
--- See Note [Capturing the backtrace in throw] for a detailed discussion of how 'throw'
--- manages to capture 'Backtraces'.
---
--- Long story short, 'error' does not do the same thing as 'throw' and is subtly different
--- in terms of evaluation, cause it to bypass the stack annotation frames, especially in
--- pure code.
---
--- However, even in 'IO' code, it is difficult to use 'error' and obtain stack annotation frames
--- close to the call site due to the same issue of laziness and backtrace collection.
---
--- This means, right now, if you want to reliably capture stack frame annotations,
--- in both pure and impure code, prefer 'throw' and 'throwIO' variants over 'error'.
-- ----------------------------------------------------------------------------
-- Annotations
-- ----------------------------------------------------------------------------
+
+-- | A 'String' only annotation with an optional source location.
data StringAnnotation where
- StringAnnotation :: String -> StringAnnotation
+ StringAnnotation :: !(Maybe SrcLoc) -> String -> StringAnnotation
instance StackAnnotation StringAnnotation where
- displayStackAnnotation (StringAnnotation str) = str
+ displayStackAnnotationShort (StringAnnotation _srcLoc str) =
+ str
+
+ stackAnnotationSourceLocation (StringAnnotation srcLoc _str) =
+ srcLoc
-- | Use the 'Show' instance of a type to display as the 'StackAnnotation'.
data ShowAnnotation where
- ShowAnnotation :: forall a . Show a => a -> ShowAnnotation
+ ShowAnnotation :: forall a . Show a => !(Maybe SrcLoc) -> a -> ShowAnnotation
instance StackAnnotation ShowAnnotation where
- displayStackAnnotation (ShowAnnotation showAnno) = show showAnno
+ displayStackAnnotationShort (ShowAnnotation _srcLoc showAnno) =
+ show showAnno
+
+ stackAnnotationSourceLocation (ShowAnnotation srcLoc _showAnno) =
+ srcLoc
-- | A 'CallStack' stack annotation.
+--
+-- Captures the whole 'CallStack'.
newtype CallStackAnnotation = CallStackAnnotation CallStack
instance Show CallStackAnnotation where
@@ -154,9 +144,23 @@ instance Show CallStackAnnotation where
-- | Displays the first entry of the 'CallStack'
instance StackAnnotation CallStackAnnotation where
- displayStackAnnotation (CallStackAnnotation cs) = case getCallStack cs of
+ stackAnnotationSourceLocation (CallStackAnnotation cs) =
+ callStackHeadSrcLoc cs
+
+ displayStackAnnotationShort (CallStackAnnotation cs) =
+ callStackHeadFunctionName cs
+
+callStackHeadSrcLoc :: CallStack -> Maybe SrcLoc
+callStackHeadSrcLoc cs =
+ case getCallStack cs of
+ [] -> Nothing
+ (_, srcLoc):_ -> Just srcLoc
+
+callStackHeadFunctionName :: CallStack -> String
+callStackHeadFunctionName cs =
+ case getCallStack cs of
[] -> "<unknown source location>"
- ((fnName,srcLoc):_) -> fnName ++ ", called at " ++ prettySrcLoc srcLoc
+ (fnName, _):_ -> fnName
-- ----------------------------------------------------------------------------
-- Annotate the CallStack with custom data
@@ -172,7 +176,7 @@ instance StackAnnotation CallStackAnnotation where
--
-- WARNING: forces the evaluation of @b@ to WHNF.
{-# NOINLINE annotateStack #-}
-annotateStack :: forall a b. (Typeable a, StackAnnotation a) => a -> b -> b
+annotateStack :: forall a b. (HasCallStack, Typeable a, StackAnnotation a) => a -> b -> b
annotateStack ann b = unsafePerformIO $
annotateStackIO ann (evaluate b)
@@ -196,9 +200,9 @@ annotateCallStack b = unsafePerformIO $ withFrozenCallStack $
-- information to stack traces.
--
-- WARNING: forces the evaluation of @b@ to WHNF.
-annotateStackString :: forall b . String -> b -> b
+annotateStackString :: forall b . HasCallStack => String -> b -> b
annotateStackString ann =
- annotateStack (StringAnnotation ann)
+ annotateStack (StringAnnotation (callStackHeadSrcLoc ?callStack) ann)
-- | @'annotateStackShow' showable b@ annotates the evaluation stack of @b@
-- with the value @showable@.
@@ -207,37 +211,36 @@ annotateStackString ann =
-- information to stack traces.
--
-- WARNING: forces the evaluation of @b@ to WHNF.
-annotateStackShow :: forall a b . (Typeable a, Show a) => a -> b -> b
+annotateStackShow :: forall a b . (HasCallStack, Typeable a, Show a) => a -> b -> b
annotateStackShow ann =
- annotateStack (ShowAnnotation ann)
+ annotateStack (ShowAnnotation (callStackHeadSrcLoc ?callStack) ann)
-- | @'annotateStackIO' showable b@ annotates the evaluation stack of @b@
-- with the value @showable@.
--
-- When decoding the call stack, the annotation frames can be used to add more
-- information to stack traces.
-annotateStackIO :: forall a b . (Typeable a, StackAnnotation a) => a -> IO b -> IO b
+annotateStackIO :: forall a b . (HasCallStack, Typeable a, StackAnnotation a) => a -> IO b -> IO b
annotateStackIO ann (IO act) =
IO $ \s -> annotateStack# (SomeStackAnnotation ann) act s
-{-# NOINLINE annotateStackIO #-}
-- | @'annotateStackStringIO' msg b@ annotates the evaluation stack of @b@
-- with the value @msg@.
--
-- When decoding the call stack, the annotation frames can be used to add more
-- information to stack traces.
-annotateStackStringIO :: forall b . String -> IO b -> IO b
+annotateStackStringIO :: forall b . HasCallStack => String -> IO b -> IO b
annotateStackStringIO ann =
- annotateStackIO (StringAnnotation ann)
+ annotateStackIO (StringAnnotation (callStackHeadSrcLoc ?callStack) ann)
-- | @'annotateStackShowIO' msg b@ annotates the evaluation stack of @b@
-- with the value @msg@.
--
-- When decoding the call stack, the annotation frames can be used to add more
-- information to stack traces.
-annotateStackShowIO :: forall a b . (Show a) => a -> IO b -> IO b
+annotateStackShowIO :: forall a b . (HasCallStack, Show a) => a -> IO b -> IO b
annotateStackShowIO ann =
- annotateStackIO (ShowAnnotation ann)
+ annotateStackIO (ShowAnnotation (callStackHeadSrcLoc ?callStack) ann)
-- | @'annotateCallStackIO' b@ annotates the evaluation stack of @b@ with the
-- current 'callstack'.
=====================================
libraries/ghc-experimental/tests/Makefile
=====================================
@@ -0,0 +1,7 @@
+# This Makefile runs the tests using GHC's testsuite framework. It
+# assumes the package is part of a GHC build tree with the testsuite
+# installed in ../../../testsuite.
+
+TOP=../../../testsuite
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
=====================================
libraries/ghc-experimental/tests/all.T
=====================================
=====================================
libraries/ghc-experimental/tests/backtraces/Makefile
=====================================
@@ -0,0 +1,7 @@
+# This Makefile runs the tests using GHC's testsuite framework. It
+# assumes the package is part of a GHC build tree with the testsuite
+# installed in ../../../testsuite.
+
+TOP=../../../../testsuite
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
=====================================
libraries/ghc-experimental/tests/backtraces/T26806a.hs
=====================================
@@ -0,0 +1,14 @@
+module Main where
+
+import GHC.Stack.Annotation.Experimental
+import Control.Exception
+import Control.Exception.Backtrace
+
+main :: IO ()
+main = do
+ setBacktraceMechanismState IPEBacktrace True
+ annotateCallStackIO $ do
+ annotateStackShowIO ([1..4] :: [Int]) $ do
+ annotateStackStringIO "Lovely annotation" $ do
+ throwIO $ ErrorCall "Backtrace Test"
+
=====================================
libraries/ghc-experimental/tests/backtraces/T26806a.stderr
=====================================
@@ -0,0 +1,11 @@
+T26806a: Uncaught exception ghc-internal:GHC.Internal.Exception.ErrorCall:
+
+Backtrace Test
+
+IPE backtrace:
+ Lovely annotation, called at T26806a.hs:12:7 in main:Main
+ [1,2,3,4], called at T26806a.hs:11:5 in main:Main
+ annotateCallStackIO, called at T26806a.hs:10:3 in main:Main
+HasCallStack backtrace:
+ throwIO, called at T26806a.hs:13:9 in main:Main
+
=====================================
libraries/ghc-experimental/tests/backtraces/T26806b.hs
=====================================
@@ -0,0 +1,18 @@
+module Main where
+
+import GHC.Stack.Annotation.Experimental
+import Control.Exception
+import Control.Exception.Backtrace
+
+main :: IO ()
+main = do
+ setBacktraceMechanismState IPEBacktrace True
+ print $ foo 500
+
+foo :: Int -> Int
+foo n =
+ annotateCallStack $
+ annotateStackShow ([1..4] :: [Int]) $
+ annotateStackString "Lovely annotation" $
+ throw $ ErrorCall $ "Backtrace Test: " ++ show (n * n * n)
+
=====================================
libraries/ghc-experimental/tests/backtraces/T26806b.stderr
=====================================
@@ -0,0 +1,13 @@
+T26806b: Uncaught exception ghc-internal:GHC.Internal.Exception.ErrorCall:
+
+Backtrace Test: 125000000
+
+IPE backtrace:
+ Lovely annotation, called at T26806b.hs:16:7 in main:Main
+ [1,2,3,4], called at T26806b.hs:15:5 in main:Main
+ annotateCallStack, called at T26806b.hs:14:3 in main:Main
+HasCallStack backtrace:
+ collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:170:37 in ghc-internal:GHC.Internal.Exception
+ toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:90:42 in ghc-internal:GHC.Internal.Exception
+ throw, called at T26806b.hs:17:9 in main:Main
+
=====================================
libraries/ghc-experimental/tests/backtraces/T26806c.hs
=====================================
@@ -0,0 +1,18 @@
+module Main where
+
+import GHC.Stack.Annotation.Experimental
+import Control.Exception
+import Control.Exception.Backtrace
+
+main :: IO ()
+main = do
+ setBacktraceMechanismState IPEBacktrace True
+ print $ foo 500
+
+foo :: Int -> Int
+foo n =
+ annotateCallStack $
+ annotateStackShow ([1..4] :: [Int]) $
+ annotateStackString "Lovely annotation" $
+ error $ "Backtrace Test: " ++ show (n * n * n)
+
=====================================
libraries/ghc-experimental/tests/backtraces/T26806c.stderr
=====================================
@@ -0,0 +1,11 @@
+T26806c: Uncaught exception ghc-internal:GHC.Internal.Exception.ErrorCall:
+
+Backtrace Test: 125000000
+
+IPE backtrace:
+ Lovely annotation, called at T26806c.hs:16:7 in main:Main
+ [1,2,3,4], called at T26806c.hs:15:5 in main:Main
+ annotateCallStack, called at T26806c.hs:14:3 in main:Main
+HasCallStack backtrace:
+ error, called at T26806c.hs:17:9 in main:Main
+
=====================================
libraries/ghc-experimental/tests/backtraces/all.T
=====================================
@@ -0,0 +1,5 @@
+stack_annotation_backtrace_opts = [ when(have_profiling(), extra_ways(['prof'])) , when(js_arch(), skip) , exit_code(1) ]
+
+test('T26806a', stack_annotation_backtrace_opts, compile_and_run, [''])
+test('T26806b', stack_annotation_backtrace_opts, compile_and_run, [''])
+test('T26806c', stack_annotation_backtrace_opts, compile_and_run, [''])
=====================================
libraries/ghc-internal/src/GHC/Internal/Stack/Annotation.hs
=====================================
@@ -4,6 +4,7 @@ module GHC.Internal.Stack.Annotation where
import GHC.Internal.Base
import GHC.Internal.Data.Typeable
+import GHC.Internal.Stack (SrcLoc, prettySrcLoc)
-- ----------------------------------------------------------------------------
-- StackAnnotation
@@ -13,8 +14,38 @@ import GHC.Internal.Data.Typeable
-- as the payload of 'AnnFrame' stack frames.
--
class StackAnnotation a where
+ -- | Display a human readable string for the 'StackAnnotation'.
+ --
+ -- This is supposed to be the long version of 'displayStackAnnotationShort'
+ -- and may contain a source location.
+ --
+ -- If not provided, 'displayStackAnnotation' is derived from 'stackAnnotationSourceLocation'
+ -- and 'displayStackAnnotationShort'.
displayStackAnnotation :: a -> String
+ -- | Get the 'SrcLoc' of the given 'StackAnnotation'.
+ --
+ -- This is optional, 'SrcLoc' are not strictly required for 'StackAnnotation', but
+ -- it is still heavily encouarged to provide a 'SrcLoc' for better IPE backtraces.
+ stackAnnotationSourceLocation :: a -> Maybe SrcLoc
+
+ -- | The description of the StackAnnotation without any metadata such as source locations.
+ --
+ -- Pefer implementing 'displayStackAnnotationShort' over 'displayStackAnnotation'.
+ displayStackAnnotationShort :: a -> String
+
+ {-# MINIMAL displayStackAnnotation | displayStackAnnotationShort #-}
+
+ displayStackAnnotation ann =
+ displayStackAnnotationShort ann
+ ++ case stackAnnotationSourceLocation ann of
+ Nothing -> ""
+ Just srcLoc -> ", called at " ++ prettySrcLoc srcLoc
+
+ stackAnnotationSourceLocation _ann = Nothing
+
+ displayStackAnnotationShort = displayStackAnnotation
+
-- ----------------------------------------------------------------------------
-- Annotations
-- ----------------------------------------------------------------------------
@@ -28,4 +59,11 @@ data SomeStackAnnotation where
SomeStackAnnotation :: forall a. (Typeable a, StackAnnotation a) => a -> SomeStackAnnotation
instance StackAnnotation SomeStackAnnotation where
- displayStackAnnotation (SomeStackAnnotation a) = displayStackAnnotation a
+ displayStackAnnotation (SomeStackAnnotation a) =
+ displayStackAnnotation a
+
+ stackAnnotationSourceLocation (SomeStackAnnotation a) =
+ stackAnnotationSourceLocation a
+
+ displayStackAnnotationShort (SomeStackAnnotation a) =
+ displayStackAnnotationShort a
=====================================
libraries/ghc-internal/tests/stack-annotation/ann_frame001.stdout
=====================================
@@ -1,12 +1,12 @@
Stack annotations:
-- (2,3)
+- (2,3), called at ann_frame001.hs:5:13 in main:Main
47
Stack annotations:
-- "bar"
-- "foo"
-- "tailCallEx"
+- "bar", called at ann_frame001.hs:23:9 in main:Main
+- "foo", called at ann_frame001.hs:21:11 in main:Main
+- "tailCallEx", called at ann_frame001.hs:17:18 in main:Main
Stack annotations:
-- "bar"
-- "foo"
-- "tailCallEx"
+- "bar", called at ann_frame001.hs:23:9 in main:Main
+- "foo", called at ann_frame001.hs:21:11 in main:Main
+- "tailCallEx", called at ann_frame001.hs:17:18 in main:Main
40
=====================================
libraries/ghc-internal/tests/stack-annotation/ann_frame002.stdout
=====================================
@@ -7,5 +7,5 @@ Finish some work
Some more work in bar
17711
Stack annotations:
-- bar
+- bar, called at ann_frame002.hs:23:29 in main:Main
- annotateCallStackIO, called at ann_frame002.hs:23:7 in main:Main
=====================================
libraries/ghc-internal/tests/stack-annotation/ann_frame003.stdout
=====================================
@@ -1,6 +1,6 @@
47
Stack annotations:
-- "bar"
-- "foo"
-- "tailCallEx"
+- "bar", called at ann_frame003.hs:25:9 in main:Main
+- "foo", called at ann_frame003.hs:21:11 in main:Main
+- "tailCallEx", called at ann_frame003.hs:16:18 in main:Main
40
=====================================
libraries/ghc-internal/tests/stack-annotation/ann_frame004.stdout
=====================================
@@ -13,5 +13,5 @@ Stack annotations:
- annotateCallStack, called at ann_frame004.hs:21:17 in main:Main
- annotateCallStack, called at ann_frame004.hs:21:17 in main:Main
- annotateCallStack, called at ann_frame004.hs:13:10 in main:Main
-- bar
+- bar, called at ann_frame004.hs:12:29 in main:Main
- annotateCallStackIO, called at ann_frame004.hs:12:7 in main:Main
=====================================
libraries/ghc-internal/tests/stack-annotation/ann_frame005.stdout
=====================================
@@ -2,9 +2,9 @@
Caught exception: SimpleBoom
Exception context:
- IPE backtrace:
-- throwIO SimpleBoom
-- raising action
-- catch site for throwIO SimpleBoom
+- throwIO SimpleBoom, called at ann_frame005.hs:33:5 in main:Main
+- raising action, called at ann_frame005.hs:32:3 in main:Main
+- catch site for throwIO SimpleBoom, called at ann_frame005.hs:27:5 in main:Main
- annotateCallStackIO, called at ann_frame005.hs:26:3 in main:Main
- HasCallStack backtrace:
- throwIO, called at ann_frame005.hs:34:7 in main:Main
@@ -13,9 +13,9 @@ Handler annotation not present in context
Caught exception: Prelude.undefined
Exception context:
- IPE backtrace:
-- undefined thunk
-- raising undefined action
-- catch site for undefined
+- undefined thunk, called at ann_frame005.hs:41:9 in main:Main
+- raising undefined action, called at ann_frame005.hs:38:3 in main:Main
+- catch site for undefined, called at ann_frame005.hs:27:5 in main:Main
- annotateCallStackIO, called at ann_frame005.hs:26:3 in main:Main
- HasCallStack backtrace:
- undefined, called at ann_frame005.hs:41:48 in main:Main
@@ -24,9 +24,9 @@ Handler annotation not present in context
Caught exception: error from annotateStackString
Exception context:
- IPE backtrace:
-- error thunk
-- raising error action
-- catch site for error
+- error thunk, called at ann_frame005.hs:48:9 in main:Main
+- raising error action, called at ann_frame005.hs:45:3 in main:Main
+- catch site for error, called at ann_frame005.hs:27:5 in main:Main
- annotateCallStackIO, called at ann_frame005.hs:26:3 in main:Main
- HasCallStack backtrace:
- error, called at ann_frame005.hs:48:44 in main:Main
@@ -35,8 +35,8 @@ Handler annotation not present in context
Caught exception: SimpleBoom
Exception context:
- IPE backtrace:
-- raising throwSTM action
-- catch site for throwSTM
+- raising throwSTM action, called at ann_frame005.hs:52:3 in main:Main
+- catch site for throwSTM, called at ann_frame005.hs:27:5 in main:Main
- annotateCallStackIO, called at ann_frame005.hs:26:3 in main:Main
- HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:170:37 in ghc-internal:GHC.Internal.Exception
=====================================
testsuite/tests/interface-stability/ghc-experimental-exports.stdout
=====================================
@@ -6499,25 +6499,27 @@ module GHC.Stack.Annotation.Experimental where
newtype CallStackAnnotation = CallStackAnnotation GHC.Internal.Stack.Types.CallStack
type ShowAnnotation :: *
data ShowAnnotation where
- ShowAnnotation :: forall a. GHC.Internal.Show.Show a => a -> ShowAnnotation
+ ShowAnnotation :: forall a. GHC.Internal.Show.Show a => !(GHC.Internal.Maybe.Maybe GHC.Internal.Stack.Types.SrcLoc) -> a -> ShowAnnotation
type SomeStackAnnotation :: *
data SomeStackAnnotation where
SomeStackAnnotation :: forall a. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> SomeStackAnnotation
type StackAnnotation :: * -> Constraint
class StackAnnotation a where
displayStackAnnotation :: a -> GHC.Internal.Base.String
- {-# MINIMAL displayStackAnnotation #-}
+ stackAnnotationSourceLocation :: a -> GHC.Internal.Maybe.Maybe GHC.Internal.Stack.Types.SrcLoc
+ displayStackAnnotationShort :: a -> GHC.Internal.Base.String
+ {-# MINIMAL displayStackAnnotation | displayStackAnnotationShort #-}
type StringAnnotation :: *
data StringAnnotation where
- StringAnnotation :: GHC.Internal.Base.String -> StringAnnotation
+ StringAnnotation :: !(GHC.Internal.Maybe.Maybe GHC.Internal.Stack.Types.SrcLoc) -> GHC.Internal.Base.String -> StringAnnotation
annotateCallStack :: forall b. GHC.Internal.Stack.Types.HasCallStack => b -> b
annotateCallStackIO :: forall a. GHC.Internal.Stack.Types.HasCallStack => GHC.Internal.Types.IO a -> GHC.Internal.Types.IO a
- annotateStack :: forall a b. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> b -> b
- annotateStackIO :: forall a b. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
- annotateStackShow :: forall a b. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, GHC.Internal.Show.Show a) => a -> b -> b
- annotateStackShowIO :: forall a b. GHC.Internal.Show.Show a => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
- annotateStackString :: forall b. GHC.Internal.Base.String -> b -> b
- annotateStackStringIO :: forall b. GHC.Internal.Base.String -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
+ annotateStack :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> b -> b
+ annotateStackIO :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
+ annotateStackShow :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, GHC.Internal.Show.Show a) => a -> b -> b
+ annotateStackShowIO :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, GHC.Internal.Show.Show a) => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
+ annotateStackString :: forall b. GHC.Internal.Stack.Types.HasCallStack => GHC.Internal.Base.String -> b -> b
+ annotateStackStringIO :: forall b. GHC.Internal.Stack.Types.HasCallStack => GHC.Internal.Base.String -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
module GHC.Stats.Experimental where
-- Safety: Safe
=====================================
testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32
=====================================
@@ -6502,25 +6502,27 @@ module GHC.Stack.Annotation.Experimental where
newtype CallStackAnnotation = CallStackAnnotation GHC.Internal.Stack.Types.CallStack
type ShowAnnotation :: *
data ShowAnnotation where
- ShowAnnotation :: forall a. GHC.Internal.Show.Show a => a -> ShowAnnotation
+ ShowAnnotation :: forall a. GHC.Internal.Show.Show a => !(GHC.Internal.Maybe.Maybe GHC.Internal.Stack.Types.SrcLoc) -> a -> ShowAnnotation
type SomeStackAnnotation :: *
data SomeStackAnnotation where
SomeStackAnnotation :: forall a. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> SomeStackAnnotation
type StackAnnotation :: * -> Constraint
class StackAnnotation a where
displayStackAnnotation :: a -> GHC.Internal.Base.String
- {-# MINIMAL displayStackAnnotation #-}
+ stackAnnotationSourceLocation :: a -> GHC.Internal.Maybe.Maybe GHC.Internal.Stack.Types.SrcLoc
+ displayStackAnnotationShort :: a -> GHC.Internal.Base.String
+ {-# MINIMAL displayStackAnnotation | displayStackAnnotationShort #-}
type StringAnnotation :: *
data StringAnnotation where
- StringAnnotation :: GHC.Internal.Base.String -> StringAnnotation
+ StringAnnotation :: !(GHC.Internal.Maybe.Maybe GHC.Internal.Stack.Types.SrcLoc) -> GHC.Internal.Base.String -> StringAnnotation
annotateCallStack :: forall b. GHC.Internal.Stack.Types.HasCallStack => b -> b
annotateCallStackIO :: forall a. GHC.Internal.Stack.Types.HasCallStack => GHC.Internal.Types.IO a -> GHC.Internal.Types.IO a
- annotateStack :: forall a b. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> b -> b
- annotateStackIO :: forall a b. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
- annotateStackShow :: forall a b. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, GHC.Internal.Show.Show a) => a -> b -> b
- annotateStackShowIO :: forall a b. GHC.Internal.Show.Show a => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
- annotateStackString :: forall b. GHC.Internal.Base.String -> b -> b
- annotateStackStringIO :: forall b. GHC.Internal.Base.String -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
+ annotateStack :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> b -> b
+ annotateStackIO :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
+ annotateStackShow :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, GHC.Internal.Show.Show a) => a -> b -> b
+ annotateStackShowIO :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, GHC.Internal.Show.Show a) => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
+ annotateStackString :: forall b. GHC.Internal.Stack.Types.HasCallStack => GHC.Internal.Base.String -> b -> b
+ annotateStackStringIO :: forall b. GHC.Internal.Stack.Types.HasCallStack => GHC.Internal.Base.String -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
module GHC.Stats.Experimental where
-- Safety: Safe
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d35798664a9e84b65bdb1e04431768…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d35798664a9e84b65bdb1e04431768…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/romes/hadrian-cross-stage2-rebase_SVEN_FINAL] 39 commits: NCG/LA64: adjust register usage to avoid src-register being clobbered
by Sven Tennie (@supersven) 14 Feb '26
by Sven Tennie (@supersven) 14 Feb '26
14 Feb '26
Sven Tennie pushed to branch wip/romes/hadrian-cross-stage2-rebase_SVEN_FINAL at Glasgow Haskell Compiler / GHC
Commits:
2e39a340 by Peng Fan at 2026-02-07T03:42:01-05:00
NCG/LA64: adjust register usage to avoid src-register being clobbered
- - - - -
9faf1b35 by Teo Camarasu at 2026-02-07T03:42:43-05:00
ghc-internal: Delete unnecessary GHC.Internal.Data.Ix
This module merely re-exports GHC.Internal.Ix. It was copied from
`base` when `ghc-internal` was split, but there is no reason to have
this now. So, let's delete it.
Resolves #26848
- - - - -
d112b440 by Sven Tennie at 2026-02-07T10:47:56-05:00
Add cabal.project file to generate-ci
This fixes the HLS setup for our CI code generation script
(generate-ci).
The project file simply makes `generate-ci` of the cabal file
discoverable.
- - - - -
5339f6f0 by Andreas Klebinger at 2026-02-07T10:48:40-05:00
CI: Don't collapse test results.
This puts test output back into the primary test log instead of a
subsection removing the need to expand a section to see test results.
While the intention was good in practice the old behaviour mostly wastes time
by requiring expansion of the section.
Fixes #26882
- - - - -
0e1cd2e0 by Evan Piro at 2026-02-08T10:35:16-08:00
Linker.MacOS reduce dynflags import
- - - - -
1c79a4cd by Michael Alan Dorman at 2026-02-09T08:11:51-05:00
Remove `extra_src_files` variable from `testsuite/driver/testlib.py`
While reading through the test harness code, I noticed this variable
with a TODO attached that referenced #12223. Although that bug is
closed, it strongly implied that this special-case variable that only
affected a single test was expected to be removed at some point.
I also looked at 3415bcaa0b1903b5e12dfaadb5b774718e406eab---where it
was added---whose commit message suggested that it would have been
desirable to remove it, but that there were special circumstances that
meant it had to remain (though it doesn't elucidate what those special
circumstances are).
However, the special circumstances were mentioned as if the test was
in a different location than is currently is, so I decided to try
changing the test to use the standard `extra_files` mechanism, which
works in local testing.
This also seems like a reasonable time to remove the script that was
originally used in the transition, since it doesn't really serve a
purpose anymore.
- - - - -
0020e38a by Matthew Pickering at 2026-02-09T17:29:14-05:00
determinism: Use a stable sort in WithHsDocIdentifiers binary instance
`WithHsDocIdentifiers` is defined as
```
71 data WithHsDocIdentifiers a pass = WithHsDocIdentifiers
72 { hsDocString :: !a
73 , hsDocIdentifiers :: ![Located (IdP pass)]
74 }
```
This list of names is populated from `rnHsDocIdentifiers`, which calls
`lookupGRE`, which calls `lookupOccEnv_AllNameSpaces`, which calls
`nonDetEltsUFM` and returns the results in an order depending on
uniques.
Sorting the list with a stable sort before returning the interface makes
the output deterministic and follows the approach taken by other fields
in `Docs`.
Fixes #26858
- - - - -
89898ce6 by echoumcp1 at 2026-02-09T17:30:01-05:00
Replace putstrln with logMsg in handleSeqHValueStatus
Fixes #26549
- - - - -
7c52c4f9 by John Paul Adrian Glaubitz at 2026-02-10T13:52:43-05:00
rts: Switch prim to use modern atomic compiler builtins
The __sync_*() atomic compiler builtins have been deprecated in GCC
for a while now and also don't provide variants for 64-bit values
such as __sync_fetch_and_add_8().
Thus, replace them with the modern __atomic_*() compiler builtins and
while we're at it, also drop the helper macro CAS_NAND() which is now
no longer needed since we stopped using the __sync_*() compiler builtins
altogether.
Co-authored-by: Ilias Tsitsimpis <iliastsi(a)debian.org>
Fixes #26729
- - - - -
cf60850a by Recursion Ninja at 2026-02-10T13:53:27-05:00
Decoupling L.H.S.Decls from GHC.Types.ForeignCall
- Adding TTG extension point for 'CCallTarget'
- Adding TTG extension point for 'CType'
- Adding TTG extension point for 'Header'
- Moving ForeignCall types that do not need extension
to new L.H.S.Decls.Foreign module
- Replacing 'Bool' parameters with descriptive data-types
to increase clairty and prevent "Boolean Blindness"
- - - - -
11a04cbb by Eric Lee at 2026-02-11T09:20:46-05:00
Derive Semigroup/Monoid for instances believed could be derived in #25871
- - - - -
15d9ce44 by Eric Lee at 2026-02-11T09:20:46-05:00
add Ghc.Data.Pair deriving
- - - - -
c85dc170 by Evan Piro at 2026-02-11T09:21:45-05:00
Linker.MacOS reduce options import
- - - - -
a541dd83 by Chris Wendt at 2026-02-11T16:06:41-05:00
Initialize plugins for `:set +c` in GHCi
Fixes #23110.
- - - - -
0f5a73bc by Cheng Shao at 2026-02-11T16:07:27-05:00
compiler: add Binary Text instance
This patch adds `Binary` instance for strict `Text`, in preparation of
making `Text` usable in certain GHC API use cases (e.g. haddock). This
also introduces `text` as a direct dependency of the `ghc` package.
- - - - -
9e58b8a1 by Cheng Shao at 2026-02-11T16:08:10-05:00
ghc-toolchain: add C11 check
This patch partially reverts commit
b8307eab80c5809df5405d76c822bf86877f5960 that removed C99 check in
autoconf/ghc-toolchain. Now we:
- No longer re-implement `FP_SET_CFLAGS_C11` similar to
`FP_SET_CFLAGS_C99` in the past, since autoconf doesn't provide a
convenient `AC_PROG_CC_C11` function. ghc-toolchain will handle it
anyway.
- The Cmm CPP C99 check is relanded and repurposed for C11.
- The C99 logic in ghc-toolchain is relanded and repurposed for C11.
- The C99 check in Stg.h is corrected to check for C11. The obsolete
_ISOC99_SOURCE trick is dropped.
- Usages of `-std=gnu99` in the testsuite are corrected to use
`-std=gnu11`.
Closes #26908.
- - - - -
4df0adf6 by Simon Peyton Jones at 2026-02-11T21:50:13-05:00
Simplify the treatment of static forms
This MR implements GHC proposal 732: simplify static forms,
https://github.com/ghc-proposals/ghc-proposals/pull/732
thereby addressing #26556.
See `Note [Grand plan for static forms]` in GHC.Iface.Tidy.StaticPtrTable
The main changes are:
* There is a new, simple rule for (static e), namely that the free
term variables of `e` must be bound at top level. The check is
done in the `HsStatic` case of `GHC.Rename.Expr.rnExpr`
* That in turn substantially simplifies the info that the typechecker
carries around in its type environment. Hooray.
* The desugarer emits static bindings to top level directly; see the
`HsStatic` case of `dsExpr`.
* There is no longer any special static-related magic in the FloatOut
pass. And the main Simplifier pipeline no longer needs a special case
to run FloatOut even with -O0. Hooray.
All this forced an unexpected change to the pattern match checker. It
recursively invokes the main Hs desugarer when it wants to take a look
at a term to spot some special cases (notably constructor applications).
We don't want to emit any nested (static e) bindings to top level a
second time! Yikes.
That forced a modest refactor in GHC.HsToCore.Pmc:
* The `dsl_nablas` field of `DsLclEnv` now has a `NoPmc` case, which says
"I'm desugaring just for pattern-match checking purposes".
* When that flag is set we don't emit static binds.
That in turn forces a cascade of refactoring, but the net effect is an
improvement; less risk of duplicated (even exponential?) work.
See Note [Desugaring HsExpr during pattern-match checking].
10% metric decrease, on some architectures, of compile-time max-bytes-used on T15304.
Metric Decrease:
T15304
- - - - -
7922f728 by Teo Camarasu at 2026-02-11T21:50:58-05:00
ghc-internal: avoid depending on GHC.Internal.Exts
This module is mostly just re-exports. It made sense as a user-facing
module, but there's no good reason ghc-internal modules should depend on
it and doing so linearises the module graph
- move considerAccessible to GHC.Internal.Magic
Previously it lived in GHC.Internal.Exts, but it really deserves to live
along with the other magic function, which are already re-exported from .Exts
- move maxTupleSize to GHC.Internal.Tuple
This previously lived in GHC.Internal.Exts but a comment already said it
should be moved to .Tuple
Resolves #26832
- - - - -
b6a4a29b by Eric Lee at 2026-02-11T21:51:55-05:00
Remove unused Semigroup imports to fix GHC 9.14 bootstrapping
- - - - -
99d8c146 by Simon Peyton Jones at 2026-02-12T17:36:59+00:00
Fix subtle bug in cast worker/wrapper
See (CWw4) in Note [Cast worker/wrapper].
The true payload is in the change to the definition of
GHC.Types.Id.Info.hasInlineUnfolding
Everthing else is just documentation.
There is a 2% compile time decrease for T13056;
I'll take the win!
Metric Decrease:
T13056
- - - - -
530e8e58 by Simon Peyton Jones at 2026-02-12T20:17:23-05:00
Add regression tests for four StaticPtr bugs
Tickets #26545, #24464, #24773, #16981 are all solved by the
recently-landed MR
commit 318ee13bcffa6aa8df42ba442ccd92aa0f7e210c
Author: Simon Peyton Jones <simon.peytonjones(a)gmail.com>
Date: Mon Oct 20 23:07:20 2025 +0100
Simplify the treatment of static forms
This MR just adds regression tests for them.
- - - - -
4157160f by Cheng Shao at 2026-02-13T06:27:04-05:00
ci: remove unused hlint-ghc-and-base job definition
This patch removes the unused `hlint-ghc-and-base` job definition,
it's never run since !9806. Note that hadrian lint rules still work
locally, so anyone that wishes to run hlint on the codebase can
continue to do so in their local worktree.
- - - - -
039f1977 by Cheng Shao at 2026-02-13T06:27:47-05:00
wasm: use import.meta.main for proper distinction of nodejs main modules
This patch uses `import.meta.main` for proper distinction of nodejs
main modules, especially when the main module might be installed as a
symlink. Fixes #26916.
- - - - -
eded9001 by Matthew Pickering at 2026-02-14T08:44:28+01:00
Add missing req_interp modifier to T18441fail3 and T18441fail19
These tests require the interpreter but they were failing in a different
way with the javascript backend because the interpreter was disabled and
stderr is ignored by the test.
- - - - -
0961528a by Matthew Pickering at 2026-02-14T08:44:28+01:00
Use explicit syntax rather than pure
- - - - -
e85f8596 by Matthew Pickering at 2026-02-14T08:44:28+01:00
packaging: correctly propagate build/host/target to bindist configure script
At the moment the host and target which we will produce a compiler for
is fixed at the initial configure time. Therefore we need to persist
the choice made at this time into the installation bindist as well so we
look for the right tools, with the right prefixes at install time.
In the future, we want to provide a bit more control about what kind of
bindist we produce so the logic about what the host/target will have to
be written by hadrian rather than persisted by the configure script. In
particular with cross compilers we want to either build a normal stage 2
cross bindist or a stage 3 bindist, which creates a bindist which has a
native compiler for the target platform.
Fixes #21970
- - - - -
1ed68fcf by Matthew Pickering at 2026-02-14T08:44:28+01:00
hadrian: Fill in more of the default.host toolchain file
When you are building a cross compiler this file will be used to build
stage1 and it's libraries, so we need enough information here to work
accurately. There is still more work to be done (see for example, word
size is still fixed).
- - - - -
c37f06dc by Matthew Pickering at 2026-02-14T08:44:28+01:00
hadrian: Disable docs when cross compiling
Before there were a variety of ad-hoc places where doc building was
disabled when cross compiling.
* Some CI jobs sets --docs=none in gen_ci.hs
* Some CI jobs set --docs=none in .gitlab/ci.sh
* There was some logic in hadrian to not need the ["docs"] target when
making a bindist.
Now the situation is simple:
* If you are cross compiling then defaultDocsTargets is empty by
default.
In theory, there is no reason why we can't build documentation for cross
compiler bindists, but this is left to future work to generalise the
documentation building rules to allow this (#24289)
- - - - -
c4dcc945 by Matthew Pickering at 2026-02-14T08:44:28+01:00
hadrian: Build stage 2 cross compilers
* Most of hadrian is abstracted over the stage in order to remove the
assumption that the target of all stages is the same platform. This
allows the RTS to be built for two different targets for example.
* Abstracts the bindist creation logic to allow building either normal
or cross bindists. Normal bindists use stage 1 libraries and a stage 2
compiler. Cross bindists use stage 2 libararies and a stage 2
compiler.
* hadrian: Make binary-dist-dir the default build target. This allows us
to have the logic in one place about which libraries/stages to build
with cross compilers. Fixes #24192
New hadrian target:
* `binary-dist-dir-cross`: Build a cross compiler bindist (compiler =
stage 1, libraries = stage 2)
This commit also contains various changes to make stage2 compilers
feasible.
-------------------------
Metric Decrease:
ManyAlternatives
MultiComponentModulesRecomp
MultiLayerModulesRecomp
T10421
T12425
T12707
T13035
T13379
T15703
T16577
T18698a
T18698b
T18923
T1969
T21839c
T3294
T4801
T5030
T5321Fun
T5642
T783
T9198
T9872d
T9961
parsing001
T5321FD
T6048
T12227
T18140
T18282
T9233
T5631
T9630
-------------------------
Co-authored-by: Sven Tennie <sven.tennie(a)gmail.com>
Fix rebase: settings-use-distro-mingw is now staged
- - - - -
7b47a226 by Matthew Pickering at 2026-02-14T08:44:28+01:00
ci: Test cross bindists
We remove the special logic for testing in-tree cross
compilers and instead test cross compiler bindists, like we do for all
other platforms.
- - - - -
63e5c457 by Matthew Pickering at 2026-02-14T08:44:28+01:00
ci: Introduce CROSS_STAGE variable
In preparation for building and testing stage3 bindists we introduce the
CROSS_STAGE variable which is used by a CI job to determine what kind of
bindist the CI job should produce.
At the moment we are only using CROSS_STAGE=2 but in the future we will
have some jobs which set CROSS_STAGE=3 to produce native bindists for a
target, but produced by a cross compiler, which can be tested on by
another CI job on the native platform.
CROSS_STAGE=2: Build a normal cross compiler bindist
CROSS_STAGE=3: Build a stage 3 bindist, one which is a native compiler and library for the target
- - - - -
6a749369 by Matthew Pickering at 2026-02-14T08:44:28+01:00
hadrian: Refactor system-cxx-std-lib rules0
I noticed a few things wrong with the hadrian rules for `system-cxx-std-lib` rules.
* For `text` there is an ad-hoc check to depend on `system-cxx-std-lib` outside of `configurePackage`.
* The `system-cxx-std-lib` dependency is not read from cabal files.
* Recache is not called on the packge database after the `.conf` file is generated, a more natural place for this rule is `registerRules`.
Treating this uniformly like other packages is complicated by it not having any source code or a cabal file. However we can do a bit better by reporting the dependency firstly in `PackageData` and then needing the `.conf` file in the same place as every other package in `configurePackage`.
Fixes #25303
- - - - -
8b155ddb by Sven Tennie at 2026-02-14T08:44:28+01:00
ci: Increase timeout for emulators
Test runs with emulators naturally take longer than on native machines.
Generate jobs.yml
- - - - -
179b678b by Sven Tennie at 2026-02-14T08:44:28+01:00
ghc: Distinguish between having an interpreter and having an internal one
Otherwise, we fail with warnings when compiling tools. Actually, these
are related but different things:
- ghc can run an interpreter (either internal or external)
- ghc is compiled with an internal interpreter
- - - - -
751cd014 by Matthew Pickering at 2026-02-14T08:44:28+01:00
ci: Javascript don't set CROSS_EMULATOR
There is no CROSS_EMULATOR needed to run javascript binaries, so we
don't set the CROSS_EMULATOR to some dummy value.
- - - - -
0ca3c382 by Sven Tennie at 2026-02-14T08:44:28+01:00
Javascript skip T23697
See #22355 about how HSC2HS and the Javascript target don't play well
together.
- - - - -
a64f5a1d by Sven Tennie at 2026-02-14T08:44:28+01:00
Mark T24602 as fragile
It was skipped before (due to CROSS_EMULATOR being set, which changed
for JS), so we don't make things worse by marking it as fragile.
- - - - -
b2965b75 by Sven Tennie at 2026-02-14T08:44:28+01:00
Windows needs NM_STAGE0 as well
The stage0 always needs nm.
- - - - -
535cfbb0 by Sven Tennie at 2026-02-14T08:44:28+01:00
T17912 sometimes works for windows-validate
This seems to be timing related. However, just simply increasing the
timeout (sleep) statement of this test didn't help. Maybe, it has been
flaky on CI before.
- - - - -
241 changed files:
- .gitlab-ci.yml
- .gitlab/ci.sh
- + .gitlab/generate-ci/cabal.project
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Builtin/Types.hs
- compiler/GHC/CmmToAsm/LA64/CodeGen.hs
- compiler/GHC/CmmToAsm/X86/CodeGen.hs
- compiler/GHC/CmmToLlvm/CodeGen.hs
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Opt/Pipeline.hs
- compiler/GHC/Core/Opt/SetLevels.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/WorkWrap.hs
- compiler/GHC/Core/TyCon.hs
- compiler/GHC/CoreToStg.hs
- compiler/GHC/CoreToStg/AddImplicitBinds.hs
- compiler/GHC/Data/Pair.hs
- compiler/GHC/Driver/Config/Core/Lint.hs
- compiler/GHC/Hs/Binds.hs
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Doc.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/Hs/Syn/Type.hs
- compiler/GHC/Hs/Type.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore.hs
- compiler/GHC/HsToCore/Docs.hs
- compiler/GHC/HsToCore/Errors/Types.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/HsToCore/Foreign/C.hs
- compiler/GHC/HsToCore/Foreign/Call.hs
- compiler/GHC/HsToCore/Foreign/Decl.hs
- compiler/GHC/HsToCore/Foreign/JavaScript.hs
- compiler/GHC/HsToCore/Foreign/Utils.hs
- compiler/GHC/HsToCore/Foreign/Wasm.hs
- compiler/GHC/HsToCore/GuardedRHSs.hs
- compiler/GHC/HsToCore/Match.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/Pmc.hs
- compiler/GHC/HsToCore/Pmc/Desugar.hs
- compiler/GHC/HsToCore/Pmc/Solver.hs
- compiler/GHC/HsToCore/Pmc/Solver/Types.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/HsToCore/Ticks.hs
- compiler/GHC/HsToCore/Types.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Iface/Tidy.hs
- compiler/GHC/Iface/Tidy/StaticPtrTable.hs
- compiler/GHC/Linker/MacOS.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Parser/PostProcess/Haddock.hs
- compiler/GHC/Rename/Bind.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Runtime/Heap/Inspect.hs
- compiler/GHC/Runtime/Interpreter.hs
- compiler/GHC/StgToByteCode.hs
- compiler/GHC/StgToCmm/Foreign.hs
- compiler/GHC/StgToJS/FFI.hs
- compiler/GHC/Tc/Deriv.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/Bind.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Foreign.hs
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Gen/Pat.hs
- compiler/GHC/Tc/Gen/Sig.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/Tc/Solver.hs
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/TyCl.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/TyCl/Utils.hs
- compiler/GHC/Tc/Types.hs
- compiler/GHC/Tc/Types/BasicTypes.hs
- compiler/GHC/Tc/Types/Constraint.hs
- compiler/GHC/Tc/Types/ErrCtxt.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Utils/Env.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Tc/Utils/TcMType.hs
- − compiler/GHC/Tc/Utils/TcMType.hs-boot
- compiler/GHC/Tc/Zonk/TcType.hs
- compiler/GHC/Tc/Zonk/Type.hs
- compiler/GHC/ThToHs.hs
- compiler/GHC/Types/ForeignCall.hs
- compiler/GHC/Types/Id/Info.hs
- compiler/GHC/Types/Id/Make.hs
- compiler/GHC/Types/Unique/DSet.hs
- compiler/GHC/Utils/Binary.hs
- compiler/GHC/Utils/Ppr/Colour.hs
- compiler/Language/Haskell/Syntax/Decls.hs
- + compiler/Language/Haskell/Syntax/Decls/Foreign.hs
- compiler/Language/Haskell/Syntax/Extension.hs
- compiler/ghc.cabal.in
- configure.ac
- distrib/configure.ac.in
- ghc/GHC/Driver/Session/Mode.hs
- ghc/GHCi/UI.hs
- ghc/GHCi/UI/Info.hs
- ghc/Main.hs
- ghc/ghc-bin.cabal.in
- hadrian/README.md
- hadrian/bindist/config.mk.in
- hadrian/cfg/default.host.target.in
- + hadrian/cfg/system.config.host.in
- hadrian/cfg/system.config.in
- + hadrian/cfg/system.config.target.in
- hadrian/hadrian.cabal
- hadrian/src/Base.hs
- + hadrian/src/BindistConfig.hs
- hadrian/src/Builder.hs
- hadrian/src/Context.hs
- hadrian/src/Expression.hs
- hadrian/src/Flavour.hs
- hadrian/src/Flavour/Type.hs
- hadrian/src/Hadrian/Builder.hs
- hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
- hadrian/src/Hadrian/Haskell/Cabal/Type.hs
- hadrian/src/Hadrian/Haskell/Hash.hs
- hadrian/src/Hadrian/Oracles/TextFile.hs
- hadrian/src/Oracles/Flag.hs
- hadrian/src/Oracles/Flavour.hs
- hadrian/src/Oracles/Setting.hs
- hadrian/src/Oracles/TestSettings.hs
- hadrian/src/Packages.hs
- hadrian/src/Rules.hs
- hadrian/src/Rules/BinaryDist.hs
- hadrian/src/Rules/CabalReinstall.hs
- hadrian/src/Rules/Compile.hs
- hadrian/src/Rules/Documentation.hs
- hadrian/src/Rules/Generate.hs
- hadrian/src/Rules/Gmp.hs
- + hadrian/src/Rules/Libffi.hs
- hadrian/src/Rules/Library.hs
- hadrian/src/Rules/Program.hs
- hadrian/src/Rules/Register.hs
- hadrian/src/Rules/Test.hs
- hadrian/src/Settings.hs
- hadrian/src/Settings/Builders/Cabal.hs
- hadrian/src/Settings/Builders/Common.hs
- hadrian/src/Settings/Builders/Configure.hs
- hadrian/src/Settings/Builders/DeriveConstants.hs
- hadrian/src/Settings/Builders/Ghc.hs
- hadrian/src/Settings/Builders/Hsc2Hs.hs
- hadrian/src/Settings/Builders/RunTest.hs
- hadrian/src/Settings/Builders/SplitSections.hs
- hadrian/src/Settings/Default.hs
- hadrian/src/Settings/Flavours/Benchmark.hs
- hadrian/src/Settings/Flavours/Development.hs
- hadrian/src/Settings/Flavours/GhcInGhci.hs
- hadrian/src/Settings/Flavours/Performance.hs
- hadrian/src/Settings/Flavours/Quick.hs
- hadrian/src/Settings/Flavours/QuickCross.hs
- hadrian/src/Settings/Flavours/Quickest.hs
- hadrian/src/Settings/Flavours/Validate.hs
- hadrian/src/Settings/Packages.hs
- hadrian/src/Settings/Program.hs
- hadrian/src/Settings/Warnings.hs
- libraries/base/src/Data/Ix.hs
- libraries/base/tests/IO/all.T
- libraries/base/tests/all.T
- libraries/ghc-internal/ghc-internal.cabal.in
- − libraries/ghc-internal/src/GHC/Internal/Data/Ix.hs
- libraries/ghc-internal/src/GHC/Internal/Exts.hs
- libraries/ghc-internal/src/GHC/Internal/Heap/Closures.hs
- libraries/ghc-internal/src/GHC/Internal/JS/Foreign/Callback.hs
- libraries/ghc-internal/src/GHC/Internal/JS/Prim.hs
- libraries/ghc-internal/src/GHC/Internal/JS/Prim/Internal/Build.hs
- libraries/ghc-internal/src/GHC/Internal/Magic.hs
- libraries/ghc-internal/src/GHC/Internal/Stack/Decode.hs
- libraries/ghc-internal/src/GHC/Internal/Tuple.hs
- libraries/ghc-internal/src/GHC/Internal/Wasm/Prim/Exports.hs
- libraries/ghc-internal/src/GHC/Internal/Wasm/Prim/Imports.hs
- libraries/ghc-internal/src/GHC/Internal/Wasm/Prim/Types.hs
- m4/fp_cmm_cpp_cmd_with_args.m4
- m4/fp_find_nm.m4
- m4/fptools_set_platform_vars.m4
- m4/prep_target_file.m4
- rts/include/Stg.h
- rts/prim/atomic.c
- − testsuite/driver/kill_extra_files.py
- testsuite/driver/testlib.py
- testsuite/ghc-config/ghc-config.hs
- testsuite/tests/codeGen/should_run/CgStaticPointers.hs
- testsuite/tests/codeGen/should_run/CgStaticPointersNoFullLazyness.hs
- testsuite/tests/count-deps/CountDepsAst.stdout
- testsuite/tests/count-deps/CountDepsParser.stdout
- testsuite/tests/ffi/should_run/all.T
- testsuite/tests/ghc-e/should_fail/all.T
- testsuite/tests/ghci/scripts/T20150.stdout
- testsuite/tests/interface-stability/base-exports.stdout
- testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
- testsuite/tests/interface-stability/base-exports.stdout-mingw32
- testsuite/tests/interface-stability/base-exports.stdout-ws-32
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32
- testsuite/tests/interface-stability/ghc-prim-exports.stdout
- testsuite/tests/interface-stability/ghc-prim-exports.stdout-mingw32
- testsuite/tests/javascript/closure/all.T
- testsuite/tests/parser/should_compile/DumpRenamedAst.stderr
- testsuite/tests/parser/should_compile/T14189.stderr
- + testsuite/tests/plugins/T23110.hs
- + testsuite/tests/plugins/T23110.script
- + testsuite/tests/plugins/T23110.stdout
- testsuite/tests/plugins/all.T
- testsuite/tests/process/all.T
- testsuite/tests/rename/should_fail/RnStaticPointersFail01.stderr
- testsuite/tests/rename/should_fail/RnStaticPointersFail03.stderr
- + testsuite/tests/rename/should_fail/T26545.hs
- + testsuite/tests/rename/should_fail/T26545.stderr
- testsuite/tests/rename/should_fail/all.T
- testsuite/tests/showIface/DocsInHiFile1.stdout
- testsuite/tests/showIface/HaddockSpanIssueT24378.stdout
- testsuite/tests/showIface/MagicHashInHaddocks.stdout
- + testsuite/tests/simplCore/should_compile/T26903.hs
- + testsuite/tests/simplCore/should_compile/T26903.stderr
- testsuite/tests/simplCore/should_compile/T8331.stderr
- testsuite/tests/simplCore/should_compile/all.T
- + testsuite/tests/typecheck/should_compile/T24464.hs
- testsuite/tests/typecheck/should_compile/all.T
- + testsuite/tests/typecheck/should_run/T16981.hs
- + testsuite/tests/typecheck/should_run/T16981.stdout
- + testsuite/tests/typecheck/should_run/T24773.hs
- + testsuite/tests/typecheck/should_run/T24773.stdout
- testsuite/tests/typecheck/should_run/all.T
- testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr
- utils/check-exact/ExactPrint.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cc.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cpp.hs
- utils/haddock/haddock-api/src/Haddock/Interface/LexParseRn.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs
- utils/haddock/haddock-api/src/Haddock/Types.hs
- utils/jsffi/dyld.mjs
- utils/jsffi/post-link.mjs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/81f7af42eca52f98af66d2eb95da25…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/81f7af42eca52f98af66d2eb95da25…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
13 Feb '26
Rodrigo Mesquita pushed to branch wip/romes/25636 at Glasgow Haskell Compiler / GHC
Commits:
27c32a9b by Rodrigo Mesquita at 2026-02-13T11:02:45+00:00
NO
- - - - -
44e6d4c6 by Rodrigo Mesquita at 2026-02-13T11:02:49+00:00
Revert "NO"
This reverts commit 27c32a9b61cec37a1eb2d9bc742ae9703be3a9a6.
- - - - -
0c955375 by Rodrigo Mesquita at 2026-02-13T11:03:00+00:00
COMMENTS
- - - - -
992f6b5e by Rodrigo Mesquita at 2026-02-13T18:32:26+00:00
wip: start fixing, but manually packing things is kind of awful. how to do better? [skip ci]
- - - - -
7 changed files:
- compiler/GHC/ByteCode/Asm.hs
- compiler/GHC/ByteCode/Instr.hs
- compiler/GHC/ByteCode/Types.hs
- compiler/GHC/StgToByteCode.hs
- compiler/GHC/StgToCmm/DataCon.hs
- compiler/GHC/StgToCmm/Layout.hs
- libraries/ghci/GHCi/ResolvedBCO.hs
Changes:
=====================================
compiler/GHC/ByteCode/Asm.hs
=====================================
@@ -38,7 +38,7 @@ import GHC.Types.SptEntry
import GHC.Types.Unique.FM
import GHC.Unit.Types
-import GHC.Utils.Outputable ( Outputable(..), text, (<+>), vcat )
+import GHC.Utils.Outputable ( Outputable(..), text, (<+>), vcat, ($$) )
import GHC.Utils.Panic
import GHC.Builtin.Types.Prim ( addrPrimTy )
@@ -77,6 +77,8 @@ import GHC.Exts
import GHC.Core.DataCon
import GHC.Data.FlatBag
import GHC.Types.Id
+import Data.List (unfoldr)
+import GHC.Types.RepType (typePrimRepU)
-- -----------------------------------------------------------------------------
@@ -214,9 +216,11 @@ assembleBCO platform
(ProtoStaticCon { protoStaticConName
, protoStaticCon = dc
, protoStaticConData = args
+ , protoStaticConNonPtrsSize = non_ptr_words
}) = do
- let ptrs = foldr mappendFlatBag emptyFlatBag (mapMaybe idBCOArg args)
- let nonptrs = foldr mappendFlatBag emptyFlatBag (mapMaybe litBCOArg args)
+ let fullword_args = packSubwordArgs platform args
+ let ptrs = foldr mappendFlatBag emptyFlatBag (mapMaybe idBCOArg fullword_args)
+ let nonptrs = foldr mappendFlatBag emptyFlatBag (mapMaybe litBCOArg fullword_args)
pure UnlinkedStaticCon
{ unlinkedStaticConName = protoStaticConName
, unlinkedStaticConDataConName = dataConName dc
@@ -294,6 +298,50 @@ assembleBCO platform
return ul_bco
+-- | Pack sub-word literals (which should appear contiguously in the argument
+-- list) into full words, and leave full-word-sized arguments alone.
+packSubwordArgs :: Platform -> [Either Literal Id] -> [Either Literal Id]
+packSubwordArgs platform = map packWord . groupWords
+ -- Group arguments into lists of total size=platform word size
+ where
+ -- Assumes packed sub-words are always ordered from largest to smallest
+ packWord :: Either [(Literal, Int{-size in bits-})] Id -> Either Literal Id
+ packWord (Right v) = Right v -- already word size
+ packWord (Left litsWithSizes) = Left $ mkLitWord platform packedValue
+ where
+ packedValue = case platformByteOrder platform of
+ BigEndian ->
+ -- For BE, we shift the accumulator left and OR the new value
+ foldl' (\acc (val, sz) -> (acc `unsafeShiftL` sz) .|. val) 0 litsWithSizes
+
+ LittleEndian ->
+ -- For LE, the first element is at shift 0, the next at shift (size of first), etc.
+ let offsets = scanl (+) 0 [ sz | (_, sz) <- litsWithSizes ]
+ in foldl' (\acc ((val, _), shift) -> acc .|. (val `unsafeShiftL` shift)) 0 (zip litsWithSizes offsets)
+
+ groupWords :: [Either Literal Id] -> [Either [(Literal, Int{-size in bits-})] Id]
+ groupWords = unfoldr step
+ where
+ step [] = Nothing
+ step (Right v:xs) = Just (Right v, xs)
+ step (Left l:xs) =
+ let (chunk, rest) = takeWord 0 [] (Left l:xs)
+ in Just (Left chunk, rest)
+
+ takeWord _ _ [] = panic "packSubwordArgs: Input does not align to 64-bit boundary"
+ takeWord !n acc (Right l:ls)
+ -- ptrs are word sized by definition, so the accumulated sub-words must already have formed a full word.
+ = assertPpr (n == ws) (text "packSubwordArgs: Word-sized argument found before accumulated sub-words formed a full word")
+ (reverse acc, Right l:ls)
+ takeWord !n acc (Left l:ls)
+ | n + s < ws = takeWord (n+s) ((l,s*8):acc) ls
+ | n + s == ws = (reverse ((l,s*8):acc), ls)
+ | otherwise = panic "packSubwordArgs: Element crosses 64-bit boundary"
+ where
+ s = primRepSizeB platform (typePrimRepU (literalType l))
+
+ ws = platformWordSizeInBytes platform
+
-- | Construct a word-array containing an @StgLargeBitmap@.
mkBitmapArray :: Word -> [StgWord] -> UArray Int Word
-- Here the return type must be an array of Words, not StgWords,
=====================================
compiler/GHC/ByteCode/Instr.hs
=====================================
@@ -58,8 +58,16 @@ data ProtoBCO
-- We use this to construct the right info table.
protoStaticConData :: [Either Literal Id],
-- ^ The static constructor pointer and non-pointer arguments, sorted
- -- in the order they should appear at runtime (see 'mkVirtConstrOffsets').
- -- The pointers always come first, followed by the non-pointers.
+ -- in the order they should appear at runtime (see
+ -- 'mkVirtHeapOffsetsWithPadding' in 'schemeTopBind').
+ --
+ -- The non-pointer arguments are meant to be laid contiguously in
+ -- memory using the width of each literal individually. The padding is
+ -- given as Literals of value 0 with the appropriate width.
+ protoStaticConNonPtrsSize :: Int,
+ -- ^ How many words needed to store the non-pointer arguments.
+ -- Note that this may be smaller than the number of non-pointer
+ -- arguments, since subword arguments need to be packed.
protoStaticConExpr :: CgStgRhs
-- ^ What the static con came from, for debugging only
}
@@ -333,11 +341,12 @@ data BCInstr
-- Printing bytecode instructions
instance Outputable ProtoBCO where
- ppr (ProtoStaticCon nm con args origin)
+ ppr (ProtoStaticCon nm con args nonPtrsSize origin)
= text "ProtoStaticCon" <+> ppr nm <> colon
$$ nest 3 (pprStgRhsShort shortStgPprOpts origin)
$$ nest 3 (text "constructor: " <+> ppr con)
$$ nest 3 (text "sorted args: " <+> ppr args)
+ $$ nest 3 (text "non-ptrs (packed) size: " <+> int (fromIntegral nonPtrsSize) <+> text "words")
ppr (ProtoBCO { protoBCOName = name
, protoBCOInstrs = instrs
, protoBCOBitmap = bitmap
=====================================
compiler/GHC/ByteCode/Types.hs
=====================================
@@ -262,7 +262,9 @@ data UnlinkedBCO
-- confused with the name of the static constructor itself
-- ('unlinkedStaticConDataConName')
unlinkedStaticConDataConName :: !Name,
- unlinkedStaticConLits :: !(FlatBag BCONPtr), -- non-ptrs
+ unlinkedStaticConLits :: !(FlatBag BCONPtr),
+ -- ^ non-ptrs full words, where sub-word literals have already been
+ -- packed into full words as needed
unlinkedStaticConPtrs :: !(FlatBag BCOPtr), -- ptrs
unlinkedStaticConIsUnlifted :: !Bool
}
@@ -331,7 +333,7 @@ instance Outputable UnlinkedBCO where
= sep [text "StaticCon", ppr nm, text "for",
if unl then text "unlifted" else text "lifted",
ppr dc_nm, text "with",
- ppr (sizeFlatBag lits), text "lits",
+ ppr (sizeFlatBag lits), text "lits", parens (text "(packed) full words"),
ppr (sizeFlatBag ptrs), text "ptrs" ]
instance Binary FFIInfo where
=====================================
compiler/GHC/StgToByteCode.hs
=====================================
@@ -304,16 +304,25 @@ schemeTopBind :: (Id, CgStgRhs) -> BcM ProtoBCO
schemeTopBind (id, rhs@(StgRhsCon _ dc _ _ args _))
= do
profile <- getProfile
- let non_voids = addArgReps (assertNonVoidStgArgs args)
- (_, _, args_offsets)
- -- Compute the expected runtime ordering for the datacon fields
- = mkVirtConstrOffsets profile non_voids
+ let
+ non_voids = addArgReps (assertNonVoidStgArgs args)
+ (tot_wds, -- #ptr_wds + #nonptr_wds
+ ptr_wds, -- #ptr_wds
+ nv_args_w_offsets) =
+ -- Compute the runtime ordering for the datacon fields
+ -- (Subword-sized fields are laid out contiguously, and padding is
+ -- represented as literals of value 0 with the appropriate width)
+ mkVirtHeapOffsetsWithPadding profile StdHeader non_voids
+ contiguous_args_with_pad =
+ litsWithPaddingToLits nv_args_w_offsets
+
return ProtoStaticCon
{ protoStaticConName = getName id
, protoStaticCon = dc
, protoStaticConData = [ case a of StgLitArg l -> Left l
StgVarArg i -> Right i
- | (NonVoid a, _) <- args_offsets ]
+ | NonVoid a <- contiguous_args_with_pad ]
+ , protoStaticConNonPtrsSize = tot_wds - ptr_wds
, protoStaticConExpr = rhs
}
schemeTopBind (id, rhs)
=====================================
compiler/GHC/StgToCmm/DataCon.hs
=====================================
@@ -100,23 +100,7 @@ cgTopRhsCon cfg id con mn args
nv_args_w_offsets) =
mkVirtHeapOffsetsWithPadding profile StdHeader (addArgReps args)
- ; let
- -- Decompose padding into units of length 8, 4, 2, or 1 bytes to
- -- allow the implementation of mk_payload to use widthFromBytes,
- -- which only handles these cases.
- fix_padding (x@(Padding n off) : rest)
- | n == 0 = fix_padding rest
- | n `elem` [1,2,4,8] = x : fix_padding rest
- | testBit n 0 = add_pad 1
- | testBit n 1 = add_pad 2
- | testBit n 2 = add_pad 4
- | otherwise = add_pad 8
- where add_pad m = Padding m off : fix_padding (Padding (n-m) (off+m) : rest)
- fix_padding (x : rest) = x : fix_padding rest
- fix_padding [] = []
-
- mk_payload (Padding len _) = return (CmmInt 0 (widthFromBytes len))
- mk_payload (FieldOff arg _) = do
+ mk_payload arg = do
amode <- getArgAmode arg
case amode of
CmmLit lit -> return lit
@@ -129,8 +113,7 @@ cgTopRhsCon cfg id con mn args
-- needs to poke around inside it.
info_tbl = mkDataConInfoTable profile con (addModuleLoc this_mod mn) True ptr_wds nonptr_wds
-
- ; payload <- mapM mk_payload (fix_padding nv_args_w_offsets)
+ ; payload <- mapM mk_payload (litsWithPaddingToLits nv_args_w_offsets)
-- NB1: nv_args_w_offsets is sorted into ptrs then non-ptrs
-- NB2: all the amodes should be Lits!
-- TODO (osa): Why?
=====================================
compiler/GHC/StgToCmm/Layout.hs
=====================================
@@ -23,6 +23,7 @@ module GHC.StgToCmm.Layout (
mkVirtHeapOffsetsWithPadding,
mkVirtConstrOffsets,
mkVirtConstrSizes,
+ litsWithPaddingToLits,
getHpRelOffset,
ArgRep(..), toArgRep, toArgRepOrV, idArgRep, argRepSizeW, -- re-exported from GHC.StgToCmm.ArgRep
@@ -66,6 +67,7 @@ import Control.Monad
import GHC.StgToCmm.Config (stgToCmmPlatform)
import GHC.StgToCmm.Types
import Data.List.NonEmpty (nonEmpty)
+import GHC.Types.Literal
------------------------------------------------------------------------
-- Call and return sequences
@@ -423,6 +425,10 @@ data FieldOffOrPadding a
| Padding ByteOff -- Length of padding in bytes.
ByteOff -- Offset in bytes.
+instance Outputable a => Outputable (FieldOffOrPadding a) where
+ ppr (FieldOff (NonVoid a) off) = text "Field" <+> ppr a <+> text "at offset" <+> int off
+ ppr (Padding size off) = text "Padding of size" <+> int size <+> text "at offset" <+> int off
+
-- | Used to tell the various @mkVirtHeapOffsets@ functions what kind
-- of header the object has. This will be accounted for in the
-- offsets of the fields returned.
@@ -512,6 +518,25 @@ mkVirtHeapOffsetsWithPadding profile header things =
, field_off
]
+-- | Flatten a list of @'FieldOffOrPadding' StgArg@ into a list of @NonVoid StgArg@
+-- by decompose padding into zero-valued 'StgLitArgs' units of length 8, 4, 2, or 1 bytes.
+litsWithPaddingToLits :: [FieldOffOrPadding StgArg] -> [NonVoid StgArg]
+litsWithPaddingToLits = concatMap $ \case
+ FieldOff (NonVoid arg) _ -> [NonVoid arg]
+ Padding size _ -> map (NonVoid . StgLitArg) (zeroBytes size)
+ where
+ -- Make literals of value 0 for a total of n bytes of padding.
+ zeroBytes :: ByteOff -> [Literal]
+ zeroBytes n
+ | n == 0 = []
+ | n == 1 = [LitNumber LitNumWord8 0]
+ | n == 2 = [LitNumber LitNumWord16 0]
+ | n == 4 = [LitNumber LitNumWord32 0]
+ | n == 8 = [LitNumber LitNumWord64 0]
+ | testBit n 0 = LitNumber LitNumWord8 0 : zeroBytes (n-1)
+ | testBit n 1 = LitNumber LitNumWord16 0 : zeroBytes (n-2)
+ | testBit n 2 = LitNumber LitNumWord32 0 : zeroBytes (n-4)
+ | otherwise = LitNumber LitNumWord64 0 : zeroBytes (n-8)
mkVirtHeapOffsets
:: Profile
=====================================
libraries/ghci/GHCi/ResolvedBCO.hs
=====================================
@@ -45,7 +45,7 @@ data ResolvedBCO
resolvedBCOBitmap :: BCOByteArray Word, -- ^ bitmap
resolvedBCOLits :: BCOByteArray Word,
-- ^ non-ptrs - subword sized entries still take up a full (host) word
- resolvedBCOPtrs :: (SizedSeq ResolvedBCOPtr) -- ^ ptrs
+ resolvedBCOPtrs :: SizedSeq ResolvedBCOPtr -- ^ ptrs
}
-- | A resolved static constructor
-- See Note [Static constructors in Bytecode]
@@ -53,7 +53,18 @@ data ResolvedBCO
resolvedBCOIsLE :: Bool,
resolvedStaticConInfoPtr :: !(RemotePtr Heap.StgInfoTable),
resolvedStaticConArity :: {-# UNPACK #-} !Word,
+ -- ^ how many words are used for the payload of the static constructor
+ -- (size of ptrs and (packed) non-ptrs combined)
resolvedStaticConLits :: BCOByteArray Word,
+ -- ^ Notably, sub-word non-ptr arguments and padding have already been
+ -- packed into full words, and this array only stores the full final
+ -- words to write as the constructor payload.
+ --
+ -- This is opposed to what we do for BCO literals, where we keep
+ -- sub-word literals as full words. For static constructors, the layout
+ -- must match exactly what the NCG also expects, so we must pack
+ -- sub-words accordingly for compatibility between interpreted and
+ -- compiled code.
resolvedStaticConPtrs :: SizedSeq ResolvedBCOPtr,
resolvedStaticConIsUnlifted :: Bool
}
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7b8a4e57fd722b2be6a55915fcb4b3…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7b8a4e57fd722b2be6a55915fcb4b3…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/fendor/stack-annotation-ty] 2 commits: Add optional `SrcLoc` to `StackAnnotation` class
by Hannes Siebenhandl (@fendor) 13 Feb '26
by Hannes Siebenhandl (@fendor) 13 Feb '26
13 Feb '26
Hannes Siebenhandl pushed to branch wip/fendor/stack-annotation-ty at Glasgow Haskell Compiler / GHC
Commits:
fabba06c by fendor at 2026-02-13T17:45:37+01:00
Add optional `SrcLoc` to `StackAnnotation` class
`StackAnnotation` give access to an optional `SrcLoc` field that
stack annotations can use to provide better backtraces in both error
messages and when decoding the callstack.
We update builtin stack annotations such as `StringAnnotation` and
`ShowAnnotation` to also capture the `SrcLoc` of the current `CallStack`
to improve backtraces by default (if stack annotations are used).
This change is backwards compatible with GHC 9.14.1.
- - - - -
d3579866 by fendor at 2026-02-13T17:45:40+01:00
Allow inlining of annotateStackIO
- - - - -
18 changed files:
- libraries/ghc-experimental/src/GHC/Stack/Annotation/Experimental.hs
- + libraries/ghc-experimental/tests/Makefile
- + libraries/ghc-experimental/tests/all.T
- + libraries/ghc-experimental/tests/backtraces/Makefile
- + libraries/ghc-experimental/tests/backtraces/T26806a.hs
- + libraries/ghc-experimental/tests/backtraces/T26806a.stderr
- + libraries/ghc-experimental/tests/backtraces/T26806b.hs
- + libraries/ghc-experimental/tests/backtraces/T26806b.stderr
- + libraries/ghc-experimental/tests/backtraces/T26806c.hs
- + libraries/ghc-experimental/tests/backtraces/T26806c.stderr
- + libraries/ghc-experimental/tests/backtraces/all.T
- libraries/ghc-internal/src/GHC/Internal/Stack/Annotation.hs
- libraries/ghc-internal/tests/stack-annotation/ann_frame001.stdout
- libraries/ghc-internal/tests/stack-annotation/ann_frame002.stdout
- libraries/ghc-internal/tests/stack-annotation/ann_frame003.stdout
- libraries/ghc-internal/tests/stack-annotation/ann_frame004.stdout
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32
Changes:
=====================================
libraries/ghc-experimental/src/GHC/Stack/Annotation/Experimental.hs
=====================================
@@ -82,9 +82,6 @@ import GHC.Internal.Stack.Annotation
-- the pure variations can behave in ways that are hard to predict.
--
-- See Note [Stack annotations in pure code] for more details.
---
--- At last, stack annotations are tricky to use with 'error'.
--- See Note [Pushing annotation frames on 'error'] for why this is the case.
-- Note [Stack annotations in pure code]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -96,57 +93,50 @@ import GHC.Internal.Stack.Annotation
-- For example:
--
-- @
--- annotateStackShow (5 @Int) (fib 20 + throw (ErrorCall "Oh no!"))
+-- annotateStackShow (5 @Int) (fib 20 + error "Oh no!")
-- @
--
--- Without forcing the result of @(fib 20 + throw (ErrorCall "Oh no!"))@, the computation
+-- Without forcing the result of @(fib 20 + error "Oh no!")@, the computation
-- will simply return a thunk, and the stack annotation would be popped off the stack.
-- Once the thunk is evaluated, the exception is raised, but no stack annotation will be found!
--- If we force the result of @(fib 20 + throw (ErrorCall "Oh no!"))@, then the stack
+-- If we force the result of @(fib 20 + error "Oh no!")@, then the stack
-- annotations remain on the stack, and are displayed in the stack trace.
--
-- Naturally, this only holds if no imprecise exceptions are thrown during evaluation of any
-- nested value, for example in 'annotateStackShow 5 (Just $ throw (ErrorCall "Oh no!"))', the
-- stack trace will not include the value @5@.
--
--- See how we preferred @throw (ErrorCall ...)@ over @error@?
--- See Note [Pushing annotation frames on 'error'] for why we do this.
-
--- Note [Pushing annotation frames on 'error']
--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- Examples so far have not been using 'error' at all.
--- The reason is that 'error' is extraordinarily difficult to use correctly with stack annotation frames.
--- See Note [Capturing the backtrace in throw] for a detailed discussion of how 'throw'
--- manages to capture 'Backtraces'.
---
--- Long story short, 'error' does not do the same thing as 'throw' and is subtly different
--- in terms of evaluation, cause it to bypass the stack annotation frames, especially in
--- pure code.
---
--- However, even in 'IO' code, it is difficult to use 'error' and obtain stack annotation frames
--- close to the call site due to the same issue of laziness and backtrace collection.
---
--- This means, right now, if you want to reliably capture stack frame annotations,
--- in both pure and impure code, prefer 'throw' and 'throwIO' variants over 'error'.
-- ----------------------------------------------------------------------------
-- Annotations
-- ----------------------------------------------------------------------------
+
+-- | A 'String' only annotation with an optional source location.
data StringAnnotation where
- StringAnnotation :: String -> StringAnnotation
+ StringAnnotation :: !(Maybe SrcLoc) -> String -> StringAnnotation
instance StackAnnotation StringAnnotation where
- displayStackAnnotation (StringAnnotation str) = str
+ displayStackAnnotationShort (StringAnnotation _srcLoc str) =
+ str
+
+ stackAnnotationSourceLocation (StringAnnotation srcLoc _str) =
+ srcLoc
-- | Use the 'Show' instance of a type to display as the 'StackAnnotation'.
data ShowAnnotation where
- ShowAnnotation :: forall a . Show a => a -> ShowAnnotation
+ ShowAnnotation :: forall a . Show a => !(Maybe SrcLoc) -> a -> ShowAnnotation
instance StackAnnotation ShowAnnotation where
- displayStackAnnotation (ShowAnnotation showAnno) = show showAnno
+ displayStackAnnotationShort (ShowAnnotation _srcLoc showAnno) =
+ show showAnno
+
+ stackAnnotationSourceLocation (ShowAnnotation srcLoc _showAnno) =
+ srcLoc
-- | A 'CallStack' stack annotation.
+--
+-- Captures the whole 'CallStack'.
newtype CallStackAnnotation = CallStackAnnotation CallStack
instance Show CallStackAnnotation where
@@ -154,9 +144,23 @@ instance Show CallStackAnnotation where
-- | Displays the first entry of the 'CallStack'
instance StackAnnotation CallStackAnnotation where
- displayStackAnnotation (CallStackAnnotation cs) = case getCallStack cs of
+ stackAnnotationSourceLocation (CallStackAnnotation cs) =
+ callStackHeadSrcLoc cs
+
+ displayStackAnnotationShort (CallStackAnnotation cs) =
+ callStackHeadFunctionName cs
+
+callStackHeadSrcLoc :: CallStack -> Maybe SrcLoc
+callStackHeadSrcLoc cs =
+ case getCallStack cs of
+ [] -> Nothing
+ (_, srcLoc):_ -> Just srcLoc
+
+callStackHeadFunctionName :: CallStack -> String
+callStackHeadFunctionName cs =
+ case getCallStack cs of
[] -> "<unknown source location>"
- ((fnName,srcLoc):_) -> fnName ++ ", called at " ++ prettySrcLoc srcLoc
+ (fnName, _):_ -> fnName
-- ----------------------------------------------------------------------------
-- Annotate the CallStack with custom data
@@ -172,7 +176,7 @@ instance StackAnnotation CallStackAnnotation where
--
-- WARNING: forces the evaluation of @b@ to WHNF.
{-# NOINLINE annotateStack #-}
-annotateStack :: forall a b. (Typeable a, StackAnnotation a) => a -> b -> b
+annotateStack :: forall a b. (HasCallStack, Typeable a, StackAnnotation a) => a -> b -> b
annotateStack ann b = unsafePerformIO $
annotateStackIO ann (evaluate b)
@@ -196,9 +200,9 @@ annotateCallStack b = unsafePerformIO $ withFrozenCallStack $
-- information to stack traces.
--
-- WARNING: forces the evaluation of @b@ to WHNF.
-annotateStackString :: forall b . String -> b -> b
+annotateStackString :: forall b . HasCallStack => String -> b -> b
annotateStackString ann =
- annotateStack (StringAnnotation ann)
+ annotateStack (StringAnnotation (callStackHeadSrcLoc ?callStack) ann)
-- | @'annotateStackShow' showable b@ annotates the evaluation stack of @b@
-- with the value @showable@.
@@ -207,37 +211,36 @@ annotateStackString ann =
-- information to stack traces.
--
-- WARNING: forces the evaluation of @b@ to WHNF.
-annotateStackShow :: forall a b . (Typeable a, Show a) => a -> b -> b
+annotateStackShow :: forall a b . (HasCallStack, Typeable a, Show a) => a -> b -> b
annotateStackShow ann =
- annotateStack (ShowAnnotation ann)
+ annotateStack (ShowAnnotation (callStackHeadSrcLoc ?callStack) ann)
-- | @'annotateStackIO' showable b@ annotates the evaluation stack of @b@
-- with the value @showable@.
--
-- When decoding the call stack, the annotation frames can be used to add more
-- information to stack traces.
-annotateStackIO :: forall a b . (Typeable a, StackAnnotation a) => a -> IO b -> IO b
+annotateStackIO :: forall a b . (HasCallStack, Typeable a, StackAnnotation a) => a -> IO b -> IO b
annotateStackIO ann (IO act) =
IO $ \s -> annotateStack# (SomeStackAnnotation ann) act s
-{-# NOINLINE annotateStackIO #-}
-- | @'annotateStackStringIO' msg b@ annotates the evaluation stack of @b@
-- with the value @msg@.
--
-- When decoding the call stack, the annotation frames can be used to add more
-- information to stack traces.
-annotateStackStringIO :: forall b . String -> IO b -> IO b
+annotateStackStringIO :: forall b . HasCallStack => String -> IO b -> IO b
annotateStackStringIO ann =
- annotateStackIO (StringAnnotation ann)
+ annotateStackIO (StringAnnotation (callStackHeadSrcLoc ?callStack) ann)
-- | @'annotateStackShowIO' msg b@ annotates the evaluation stack of @b@
-- with the value @msg@.
--
-- When decoding the call stack, the annotation frames can be used to add more
-- information to stack traces.
-annotateStackShowIO :: forall a b . (Show a) => a -> IO b -> IO b
+annotateStackShowIO :: forall a b . (HasCallStack, Show a) => a -> IO b -> IO b
annotateStackShowIO ann =
- annotateStackIO (ShowAnnotation ann)
+ annotateStackIO (ShowAnnotation (callStackHeadSrcLoc ?callStack) ann)
-- | @'annotateCallStackIO' b@ annotates the evaluation stack of @b@ with the
-- current 'callstack'.
=====================================
libraries/ghc-experimental/tests/Makefile
=====================================
@@ -0,0 +1,7 @@
+# This Makefile runs the tests using GHC's testsuite framework. It
+# assumes the package is part of a GHC build tree with the testsuite
+# installed in ../../../testsuite.
+
+TOP=../../../testsuite
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
=====================================
libraries/ghc-experimental/tests/all.T
=====================================
=====================================
libraries/ghc-experimental/tests/backtraces/Makefile
=====================================
@@ -0,0 +1,7 @@
+# This Makefile runs the tests using GHC's testsuite framework. It
+# assumes the package is part of a GHC build tree with the testsuite
+# installed in ../../../testsuite.
+
+TOP=../../../../testsuite
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
=====================================
libraries/ghc-experimental/tests/backtraces/T26806a.hs
=====================================
@@ -0,0 +1,14 @@
+module Main where
+
+import GHC.Stack.Annotation.Experimental
+import Control.Exception
+import Control.Exception.Backtrace
+
+main :: IO ()
+main = do
+ setBacktraceMechanismState IPEBacktrace True
+ annotateCallStackIO $ do
+ annotateStackShowIO ([1..4] :: [Int]) $ do
+ annotateStackStringIO "Lovely annotation" $ do
+ throwIO $ ErrorCall "Backtrace Test"
+
=====================================
libraries/ghc-experimental/tests/backtraces/T26806a.stderr
=====================================
@@ -0,0 +1,11 @@
+T26806a: Uncaught exception ghc-internal:GHC.Internal.Exception.ErrorCall:
+
+Backtrace Test
+
+IPE backtrace:
+ Lovely annotation, called at T26806a.hs:12:7 in main:Main
+ [1,2,3,4], called at T26806a.hs:11:5 in main:Main
+ annotateCallStackIO, called at T26806a.hs:10:3 in main:Main
+HasCallStack backtrace:
+ throwIO, called at T26806a.hs:13:9 in main:Main
+
=====================================
libraries/ghc-experimental/tests/backtraces/T26806b.hs
=====================================
@@ -0,0 +1,18 @@
+module Main where
+
+import GHC.Stack.Annotation.Experimental
+import Control.Exception
+import Control.Exception.Backtrace
+
+main :: IO ()
+main = do
+ setBacktraceMechanismState IPEBacktrace True
+ print $ foo 500
+
+foo :: Int -> Int
+foo n =
+ annotateCallStack $
+ annotateStackShow ([1..4] :: [Int]) $
+ annotateStackString "Lovely annotation" $
+ throw $ ErrorCall $ "Backtrace Test: " ++ show (n * n * n)
+
=====================================
libraries/ghc-experimental/tests/backtraces/T26806b.stderr
=====================================
@@ -0,0 +1,13 @@
+T26806b: Uncaught exception ghc-internal:GHC.Internal.Exception.ErrorCall:
+
+Backtrace Test: 125000000
+
+IPE backtrace:
+ Lovely annotation, called at T26806b.hs:16:7 in main:Main
+ [1,2,3,4], called at T26806b.hs:15:5 in main:Main
+ annotateCallStack, called at T26806b.hs:14:3 in main:Main
+HasCallStack backtrace:
+ collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:170:37 in ghc-internal:GHC.Internal.Exception
+ toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:90:42 in ghc-internal:GHC.Internal.Exception
+ throw, called at T26806b.hs:17:9 in main:Main
+
=====================================
libraries/ghc-experimental/tests/backtraces/T26806c.hs
=====================================
@@ -0,0 +1,18 @@
+module Main where
+
+import GHC.Stack.Annotation.Experimental
+import Control.Exception
+import Control.Exception.Backtrace
+
+main :: IO ()
+main = do
+ setBacktraceMechanismState IPEBacktrace True
+ print $ foo 500
+
+foo :: Int -> Int
+foo n =
+ annotateCallStack $
+ annotateStackShow ([1..4] :: [Int]) $
+ annotateStackString "Lovely annotation" $
+ error $ "Backtrace Test: " ++ show (n * n * n)
+
=====================================
libraries/ghc-experimental/tests/backtraces/T26806c.stderr
=====================================
@@ -0,0 +1,11 @@
+T26806c: Uncaught exception ghc-internal:GHC.Internal.Exception.ErrorCall:
+
+Backtrace Test: 125000000
+
+IPE backtrace:
+ Lovely annotation, called at T26806c.hs:16:7 in main:Main
+ [1,2,3,4], called at T26806c.hs:15:5 in main:Main
+ annotateCallStack, called at T26806c.hs:14:3 in main:Main
+HasCallStack backtrace:
+ error, called at T26806c.hs:17:9 in main:Main
+
=====================================
libraries/ghc-experimental/tests/backtraces/all.T
=====================================
@@ -0,0 +1,5 @@
+stack_annotation_backtrace_opts = [ when(have_profiling(), extra_ways(['prof'])) , when(js_arch(), skip) , exit_code(1) ]
+
+test('T26806a', stack_annotation_backtrace_opts, compile_and_run, [''])
+test('T26806b', stack_annotation_backtrace_opts, compile_and_run, [''])
+test('T26806c', stack_annotation_backtrace_opts, compile_and_run, [''])
=====================================
libraries/ghc-internal/src/GHC/Internal/Stack/Annotation.hs
=====================================
@@ -4,6 +4,7 @@ module GHC.Internal.Stack.Annotation where
import GHC.Internal.Base
import GHC.Internal.Data.Typeable
+import GHC.Internal.Stack (SrcLoc, prettySrcLoc)
-- ----------------------------------------------------------------------------
-- StackAnnotation
@@ -13,8 +14,38 @@ import GHC.Internal.Data.Typeable
-- as the payload of 'AnnFrame' stack frames.
--
class StackAnnotation a where
+ -- | Display a human readable string for the 'StackAnnotation'.
+ --
+ -- This is supposed to be the long version of 'displayStackAnnotationShort'
+ -- and may contain a source location.
+ --
+ -- If not provided, 'displayStackAnnotation' is derived from 'stackAnnotationSourceLocation'
+ -- and 'displayStackAnnotationShort'.
displayStackAnnotation :: a -> String
+ -- | Get the 'SrcLoc' of the given 'StackAnnotation'.
+ --
+ -- This is optional, 'SrcLoc' are not strictly required for 'StackAnnotation', but
+ -- it is still heavily encouarged to provide a 'SrcLoc' for better IPE backtraces.
+ stackAnnotationSourceLocation :: a -> Maybe SrcLoc
+
+ -- | The description of the StackAnnotation without any metadata such as source locations.
+ --
+ -- Pefer implementing 'displayStackAnnotationShort' over 'displayStackAnnotation'.
+ displayStackAnnotationShort :: a -> String
+
+ {-# MINIMAL displayStackAnnotation | displayStackAnnotationShort #-}
+
+ displayStackAnnotation ann =
+ displayStackAnnotationShort ann
+ ++ case stackAnnotationSourceLocation ann of
+ Nothing -> ""
+ Just srcLoc -> ", called at " ++ prettySrcLoc srcLoc
+
+ stackAnnotationSourceLocation _ann = Nothing
+
+ displayStackAnnotationShort = displayStackAnnotation
+
-- ----------------------------------------------------------------------------
-- Annotations
-- ----------------------------------------------------------------------------
@@ -28,4 +59,11 @@ data SomeStackAnnotation where
SomeStackAnnotation :: forall a. (Typeable a, StackAnnotation a) => a -> SomeStackAnnotation
instance StackAnnotation SomeStackAnnotation where
- displayStackAnnotation (SomeStackAnnotation a) = displayStackAnnotation a
+ displayStackAnnotation (SomeStackAnnotation a) =
+ displayStackAnnotation a
+
+ stackAnnotationSourceLocation (SomeStackAnnotation a) =
+ stackAnnotationSourceLocation a
+
+ displayStackAnnotationShort (SomeStackAnnotation a) =
+ displayStackAnnotationShort a
=====================================
libraries/ghc-internal/tests/stack-annotation/ann_frame001.stdout
=====================================
@@ -1,12 +1,12 @@
Stack annotations:
-- (2,3)
+- (2,3), called at ann_frame001.hs:5:13 in main:Main
47
Stack annotations:
-- "bar"
-- "foo"
-- "tailCallEx"
+- "bar", called at ann_frame001.hs:23:9 in main:Main
+- "foo", called at ann_frame001.hs:21:11 in main:Main
+- "tailCallEx", called at ann_frame001.hs:17:18 in main:Main
Stack annotations:
-- "bar"
-- "foo"
-- "tailCallEx"
+- "bar", called at ann_frame001.hs:23:9 in main:Main
+- "foo", called at ann_frame001.hs:21:11 in main:Main
+- "tailCallEx", called at ann_frame001.hs:17:18 in main:Main
40
=====================================
libraries/ghc-internal/tests/stack-annotation/ann_frame002.stdout
=====================================
@@ -7,5 +7,5 @@ Finish some work
Some more work in bar
17711
Stack annotations:
-- bar
+- bar, called at ann_frame002.hs:23:29 in main:Main
- annotateCallStackIO, called at ann_frame002.hs:23:7 in main:Main
=====================================
libraries/ghc-internal/tests/stack-annotation/ann_frame003.stdout
=====================================
@@ -1,6 +1,6 @@
47
Stack annotations:
-- "bar"
-- "foo"
-- "tailCallEx"
+- "bar", called at ann_frame003.hs:25:9 in main:Main
+- "foo", called at ann_frame003.hs:21:11 in main:Main
+- "tailCallEx", called at ann_frame003.hs:16:18 in main:Main
40
=====================================
libraries/ghc-internal/tests/stack-annotation/ann_frame004.stdout
=====================================
@@ -13,5 +13,5 @@ Stack annotations:
- annotateCallStack, called at ann_frame004.hs:21:17 in main:Main
- annotateCallStack, called at ann_frame004.hs:21:17 in main:Main
- annotateCallStack, called at ann_frame004.hs:13:10 in main:Main
-- bar
+- bar, called at ann_frame004.hs:12:29 in main:Main
- annotateCallStackIO, called at ann_frame004.hs:12:7 in main:Main
=====================================
testsuite/tests/interface-stability/ghc-experimental-exports.stdout
=====================================
@@ -6499,25 +6499,27 @@ module GHC.Stack.Annotation.Experimental where
newtype CallStackAnnotation = CallStackAnnotation GHC.Internal.Stack.Types.CallStack
type ShowAnnotation :: *
data ShowAnnotation where
- ShowAnnotation :: forall a. GHC.Internal.Show.Show a => a -> ShowAnnotation
+ ShowAnnotation :: forall a. GHC.Internal.Show.Show a => !(GHC.Internal.Maybe.Maybe GHC.Internal.Stack.Types.SrcLoc) -> a -> ShowAnnotation
type SomeStackAnnotation :: *
data SomeStackAnnotation where
SomeStackAnnotation :: forall a. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> SomeStackAnnotation
type StackAnnotation :: * -> Constraint
class StackAnnotation a where
displayStackAnnotation :: a -> GHC.Internal.Base.String
- {-# MINIMAL displayStackAnnotation #-}
+ stackAnnotationSourceLocation :: a -> GHC.Internal.Maybe.Maybe GHC.Internal.Stack.Types.SrcLoc
+ displayStackAnnotationShort :: a -> GHC.Internal.Base.String
+ {-# MINIMAL displayStackAnnotation | displayStackAnnotationShort #-}
type StringAnnotation :: *
data StringAnnotation where
- StringAnnotation :: GHC.Internal.Base.String -> StringAnnotation
+ StringAnnotation :: !(GHC.Internal.Maybe.Maybe GHC.Internal.Stack.Types.SrcLoc) -> GHC.Internal.Base.String -> StringAnnotation
annotateCallStack :: forall b. GHC.Internal.Stack.Types.HasCallStack => b -> b
annotateCallStackIO :: forall a. GHC.Internal.Stack.Types.HasCallStack => GHC.Internal.Types.IO a -> GHC.Internal.Types.IO a
- annotateStack :: forall a b. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> b -> b
- annotateStackIO :: forall a b. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
- annotateStackShow :: forall a b. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, GHC.Internal.Show.Show a) => a -> b -> b
- annotateStackShowIO :: forall a b. GHC.Internal.Show.Show a => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
- annotateStackString :: forall b. GHC.Internal.Base.String -> b -> b
- annotateStackStringIO :: forall b. GHC.Internal.Base.String -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
+ annotateStack :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> b -> b
+ annotateStackIO :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
+ annotateStackShow :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, GHC.Internal.Show.Show a) => a -> b -> b
+ annotateStackShowIO :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, GHC.Internal.Show.Show a) => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
+ annotateStackString :: forall b. GHC.Internal.Stack.Types.HasCallStack => GHC.Internal.Base.String -> b -> b
+ annotateStackStringIO :: forall b. GHC.Internal.Stack.Types.HasCallStack => GHC.Internal.Base.String -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
module GHC.Stats.Experimental where
-- Safety: Safe
=====================================
testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32
=====================================
@@ -6502,25 +6502,27 @@ module GHC.Stack.Annotation.Experimental where
newtype CallStackAnnotation = CallStackAnnotation GHC.Internal.Stack.Types.CallStack
type ShowAnnotation :: *
data ShowAnnotation where
- ShowAnnotation :: forall a. GHC.Internal.Show.Show a => a -> ShowAnnotation
+ ShowAnnotation :: forall a. GHC.Internal.Show.Show a => !(GHC.Internal.Maybe.Maybe GHC.Internal.Stack.Types.SrcLoc) -> a -> ShowAnnotation
type SomeStackAnnotation :: *
data SomeStackAnnotation where
SomeStackAnnotation :: forall a. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> SomeStackAnnotation
type StackAnnotation :: * -> Constraint
class StackAnnotation a where
displayStackAnnotation :: a -> GHC.Internal.Base.String
- {-# MINIMAL displayStackAnnotation #-}
+ stackAnnotationSourceLocation :: a -> GHC.Internal.Maybe.Maybe GHC.Internal.Stack.Types.SrcLoc
+ displayStackAnnotationShort :: a -> GHC.Internal.Base.String
+ {-# MINIMAL displayStackAnnotation | displayStackAnnotationShort #-}
type StringAnnotation :: *
data StringAnnotation where
- StringAnnotation :: GHC.Internal.Base.String -> StringAnnotation
+ StringAnnotation :: !(GHC.Internal.Maybe.Maybe GHC.Internal.Stack.Types.SrcLoc) -> GHC.Internal.Base.String -> StringAnnotation
annotateCallStack :: forall b. GHC.Internal.Stack.Types.HasCallStack => b -> b
annotateCallStackIO :: forall a. GHC.Internal.Stack.Types.HasCallStack => GHC.Internal.Types.IO a -> GHC.Internal.Types.IO a
- annotateStack :: forall a b. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> b -> b
- annotateStackIO :: forall a b. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
- annotateStackShow :: forall a b. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, GHC.Internal.Show.Show a) => a -> b -> b
- annotateStackShowIO :: forall a b. GHC.Internal.Show.Show a => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
- annotateStackString :: forall b. GHC.Internal.Base.String -> b -> b
- annotateStackStringIO :: forall b. GHC.Internal.Base.String -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
+ annotateStack :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> b -> b
+ annotateStackIO :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
+ annotateStackShow :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, GHC.Internal.Show.Show a) => a -> b -> b
+ annotateStackShowIO :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, GHC.Internal.Show.Show a) => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
+ annotateStackString :: forall b. GHC.Internal.Stack.Types.HasCallStack => GHC.Internal.Base.String -> b -> b
+ annotateStackStringIO :: forall b. GHC.Internal.Stack.Types.HasCallStack => GHC.Internal.Base.String -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
module GHC.Stats.Experimental where
-- Safety: Safe
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/39d9e00bc85a3c2bedd99c804de0ec…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/39d9e00bc85a3c2bedd99c804de0ec…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/fendor/stack-annotation-ty] Add optional `SrcLoc` to `StackAnnotation` class
by Hannes Siebenhandl (@fendor) 13 Feb '26
by Hannes Siebenhandl (@fendor) 13 Feb '26
13 Feb '26
Hannes Siebenhandl pushed to branch wip/fendor/stack-annotation-ty at Glasgow Haskell Compiler / GHC
Commits:
39d9e00b by fendor at 2026-02-13T17:31:03+01:00
Add optional `SrcLoc` to `StackAnnotation` class
`StackAnnotation` give access to an optional `SrcLoc` field that
stack annotations can use to provide better backtraces in both error
messages and when decoding the callstack.
We update builtin stack annotations such as `StringAnnotation` and
`ShowAnnotation` to also capture the `SrcLoc` of the current `CallStack`
to improve backtraces by default (if stack annotations are used).
This change is backwards compatible with GHC 9.14.1.
- - - - -
13 changed files:
- libraries/ghc-experimental/src/GHC/Stack/Annotation/Experimental.hs
- libraries/ghc-experimental/tests/backtraces/T26806a.stderr
- libraries/ghc-experimental/tests/backtraces/T26806b.stderr
- + libraries/ghc-experimental/tests/backtraces/T26806c.hs
- + libraries/ghc-experimental/tests/backtraces/T26806c.stderr
- libraries/ghc-experimental/tests/backtraces/all.T
- libraries/ghc-internal/src/GHC/Internal/Stack/Annotation.hs
- libraries/ghc-internal/tests/stack-annotation/ann_frame001.stdout
- libraries/ghc-internal/tests/stack-annotation/ann_frame002.stdout
- libraries/ghc-internal/tests/stack-annotation/ann_frame003.stdout
- libraries/ghc-internal/tests/stack-annotation/ann_frame004.stdout
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32
Changes:
=====================================
libraries/ghc-experimental/src/GHC/Stack/Annotation/Experimental.hs
=====================================
@@ -82,9 +82,6 @@ import GHC.Internal.Stack.Annotation
-- the pure variations can behave in ways that are hard to predict.
--
-- See Note [Stack annotations in pure code] for more details.
---
--- At last, stack annotations are tricky to use with 'error'.
--- See Note [Pushing annotation frames on 'error'] for why this is the case.
-- Note [Stack annotations in pure code]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -96,57 +93,50 @@ import GHC.Internal.Stack.Annotation
-- For example:
--
-- @
--- annotateStackShow (5 @Int) (fib 20 + throw (ErrorCall "Oh no!"))
+-- annotateStackShow (5 @Int) (fib 20 + error "Oh no!")
-- @
--
--- Without forcing the result of @(fib 20 + throw (ErrorCall "Oh no!"))@, the computation
+-- Without forcing the result of @(fib 20 + error "Oh no!")@, the computation
-- will simply return a thunk, and the stack annotation would be popped off the stack.
-- Once the thunk is evaluated, the exception is raised, but no stack annotation will be found!
--- If we force the result of @(fib 20 + throw (ErrorCall "Oh no!"))@, then the stack
+-- If we force the result of @(fib 20 + error "Oh no!")@, then the stack
-- annotations remain on the stack, and are displayed in the stack trace.
--
-- Naturally, this only holds if no imprecise exceptions are thrown during evaluation of any
-- nested value, for example in 'annotateStackShow 5 (Just $ throw (ErrorCall "Oh no!"))', the
-- stack trace will not include the value @5@.
--
--- See how we preferred @throw (ErrorCall ...)@ over @error@?
--- See Note [Pushing annotation frames on 'error'] for why we do this.
-
--- Note [Pushing annotation frames on 'error']
--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- Examples so far have not been using 'error' at all.
--- The reason is that 'error' is extraordinarily difficult to use correctly with stack annotation frames.
--- See Note [Capturing the backtrace in throw] for a detailed discussion of how 'throw'
--- manages to capture 'Backtraces'.
---
--- Long story short, 'error' does not do the same thing as 'throw' and is subtly different
--- in terms of evaluation, cause it to bypass the stack annotation frames, especially in
--- pure code.
---
--- However, even in 'IO' code, it is difficult to use 'error' and obtain stack annotation frames
--- close to the call site due to the same issue of laziness and backtrace collection.
---
--- This means, right now, if you want to reliably capture stack frame annotations,
--- in both pure and impure code, prefer 'throw' and 'throwIO' variants over 'error'.
-- ----------------------------------------------------------------------------
-- Annotations
-- ----------------------------------------------------------------------------
+
+-- | A 'String' only annotation with an optional source location.
data StringAnnotation where
- StringAnnotation :: String -> StringAnnotation
+ StringAnnotation :: !(Maybe SrcLoc) -> String -> StringAnnotation
instance StackAnnotation StringAnnotation where
- displayStackAnnotation (StringAnnotation str) = str
+ displayStackAnnotationShort (StringAnnotation _srcLoc str) =
+ str
+
+ stackAnnotationSourceLocation (StringAnnotation srcLoc _str) =
+ srcLoc
-- | Use the 'Show' instance of a type to display as the 'StackAnnotation'.
data ShowAnnotation where
- ShowAnnotation :: forall a . Show a => a -> ShowAnnotation
+ ShowAnnotation :: forall a . Show a => !(Maybe SrcLoc) -> a -> ShowAnnotation
instance StackAnnotation ShowAnnotation where
- displayStackAnnotation (ShowAnnotation showAnno) = show showAnno
+ displayStackAnnotationShort (ShowAnnotation _srcLoc showAnno) =
+ show showAnno
+
+ stackAnnotationSourceLocation (ShowAnnotation srcLoc _showAnno) =
+ srcLoc
-- | A 'CallStack' stack annotation.
+--
+-- Captures the whole 'CallStack'.
newtype CallStackAnnotation = CallStackAnnotation CallStack
instance Show CallStackAnnotation where
@@ -154,9 +144,23 @@ instance Show CallStackAnnotation where
-- | Displays the first entry of the 'CallStack'
instance StackAnnotation CallStackAnnotation where
- displayStackAnnotation (CallStackAnnotation cs) = case getCallStack cs of
+ stackAnnotationSourceLocation (CallStackAnnotation cs) =
+ callStackHeadSrcLoc cs
+
+ displayStackAnnotationShort (CallStackAnnotation cs) =
+ callStackHeadFunctionName cs
+
+callStackHeadSrcLoc :: CallStack -> Maybe SrcLoc
+callStackHeadSrcLoc cs =
+ case getCallStack cs of
+ [] -> Nothing
+ (_, srcLoc):_ -> Just srcLoc
+
+callStackHeadFunctionName :: CallStack -> String
+callStackHeadFunctionName cs =
+ case getCallStack cs of
[] -> "<unknown source location>"
- ((fnName,srcLoc):_) -> fnName ++ ", called at " ++ prettySrcLoc srcLoc
+ (fnName, _):_ -> fnName
-- ----------------------------------------------------------------------------
-- Annotate the CallStack with custom data
@@ -172,7 +176,7 @@ instance StackAnnotation CallStackAnnotation where
--
-- WARNING: forces the evaluation of @b@ to WHNF.
{-# NOINLINE annotateStack #-}
-annotateStack :: forall a b. (Typeable a, StackAnnotation a) => a -> b -> b
+annotateStack :: forall a b. (HasCallStack, Typeable a, StackAnnotation a) => a -> b -> b
annotateStack ann b = unsafePerformIO $
annotateStackIO ann (evaluate b)
@@ -196,9 +200,9 @@ annotateCallStack b = unsafePerformIO $ withFrozenCallStack $
-- information to stack traces.
--
-- WARNING: forces the evaluation of @b@ to WHNF.
-annotateStackString :: forall b . String -> b -> b
+annotateStackString :: forall b . HasCallStack => String -> b -> b
annotateStackString ann =
- annotateStack (StringAnnotation ann)
+ annotateStack (StringAnnotation (callStackHeadSrcLoc ?callStack) ann)
-- | @'annotateStackShow' showable b@ annotates the evaluation stack of @b@
-- with the value @showable@.
@@ -207,16 +211,16 @@ annotateStackString ann =
-- information to stack traces.
--
-- WARNING: forces the evaluation of @b@ to WHNF.
-annotateStackShow :: forall a b . (Typeable a, Show a) => a -> b -> b
+annotateStackShow :: forall a b . (HasCallStack, Typeable a, Show a) => a -> b -> b
annotateStackShow ann =
- annotateStack (ShowAnnotation ann)
+ annotateStack (ShowAnnotation (callStackHeadSrcLoc ?callStack) ann)
-- | @'annotateStackIO' showable b@ annotates the evaluation stack of @b@
-- with the value @showable@.
--
-- When decoding the call stack, the annotation frames can be used to add more
-- information to stack traces.
-annotateStackIO :: forall a b . (Typeable a, StackAnnotation a) => a -> IO b -> IO b
+annotateStackIO :: forall a b . (HasCallStack, Typeable a, StackAnnotation a) => a -> IO b -> IO b
annotateStackIO ann (IO act) =
IO $ \s -> annotateStack# (SomeStackAnnotation ann) act s
{-# NOINLINE annotateStackIO #-}
@@ -226,18 +230,18 @@ annotateStackIO ann (IO act) =
--
-- When decoding the call stack, the annotation frames can be used to add more
-- information to stack traces.
-annotateStackStringIO :: forall b . String -> IO b -> IO b
+annotateStackStringIO :: forall b . HasCallStack => String -> IO b -> IO b
annotateStackStringIO ann =
- annotateStackIO (StringAnnotation ann)
+ annotateStackIO (StringAnnotation (callStackHeadSrcLoc ?callStack) ann)
-- | @'annotateStackShowIO' msg b@ annotates the evaluation stack of @b@
-- with the value @msg@.
--
-- When decoding the call stack, the annotation frames can be used to add more
-- information to stack traces.
-annotateStackShowIO :: forall a b . (Show a) => a -> IO b -> IO b
+annotateStackShowIO :: forall a b . (HasCallStack, Show a) => a -> IO b -> IO b
annotateStackShowIO ann =
- annotateStackIO (ShowAnnotation ann)
+ annotateStackIO (ShowAnnotation (callStackHeadSrcLoc ?callStack) ann)
-- | @'annotateCallStackIO' b@ annotates the evaluation stack of @b@ with the
-- current 'callstack'.
=====================================
libraries/ghc-experimental/tests/backtraces/T26806a.stderr
=====================================
@@ -3,8 +3,8 @@ T26806a: Uncaught exception ghc-internal:GHC.Internal.Exception.ErrorCall:
Backtrace Test
IPE backtrace:
- Lovely annotation
- [1,2,3,4]
+ Lovely annotation, called at T26806a.hs:12:7 in main:Main
+ [1,2,3,4], called at T26806a.hs:11:5 in main:Main
annotateCallStackIO, called at T26806a.hs:10:3 in main:Main
HasCallStack backtrace:
throwIO, called at T26806a.hs:13:9 in main:Main
=====================================
libraries/ghc-experimental/tests/backtraces/T26806b.stderr
=====================================
@@ -3,8 +3,8 @@ T26806b: Uncaught exception ghc-internal:GHC.Internal.Exception.ErrorCall:
Backtrace Test: 125000000
IPE backtrace:
- Lovely annotation
- [1,2,3,4]
+ Lovely annotation, called at T26806b.hs:16:7 in main:Main
+ [1,2,3,4], called at T26806b.hs:15:5 in main:Main
annotateCallStack, called at T26806b.hs:14:3 in main:Main
HasCallStack backtrace:
collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:170:37 in ghc-internal:GHC.Internal.Exception
=====================================
libraries/ghc-experimental/tests/backtraces/T26806c.hs
=====================================
@@ -0,0 +1,18 @@
+module Main where
+
+import GHC.Stack.Annotation.Experimental
+import Control.Exception
+import Control.Exception.Backtrace
+
+main :: IO ()
+main = do
+ setBacktraceMechanismState IPEBacktrace True
+ print $ foo 500
+
+foo :: Int -> Int
+foo n =
+ annotateCallStack $
+ annotateStackShow ([1..4] :: [Int]) $
+ annotateStackString "Lovely annotation" $
+ error $ "Backtrace Test: " ++ show (n * n * n)
+
=====================================
libraries/ghc-experimental/tests/backtraces/T26806c.stderr
=====================================
@@ -0,0 +1,11 @@
+T26806c: Uncaught exception ghc-internal:GHC.Internal.Exception.ErrorCall:
+
+Backtrace Test: 125000000
+
+IPE backtrace:
+ Lovely annotation, called at T26806c.hs:16:7 in main:Main
+ [1,2,3,4], called at T26806c.hs:15:5 in main:Main
+ annotateCallStack, called at T26806c.hs:14:3 in main:Main
+HasCallStack backtrace:
+ error, called at T26806c.hs:17:9 in main:Main
+
=====================================
libraries/ghc-experimental/tests/backtraces/all.T
=====================================
@@ -2,3 +2,4 @@ stack_annotation_backtrace_opts = [ when(have_profiling(), extra_ways(['prof']))
test('T26806a', stack_annotation_backtrace_opts, compile_and_run, [''])
test('T26806b', stack_annotation_backtrace_opts, compile_and_run, [''])
+test('T26806c', stack_annotation_backtrace_opts, compile_and_run, [''])
=====================================
libraries/ghc-internal/src/GHC/Internal/Stack/Annotation.hs
=====================================
@@ -4,6 +4,7 @@ module GHC.Internal.Stack.Annotation where
import GHC.Internal.Base
import GHC.Internal.Data.Typeable
+import GHC.Internal.Stack (SrcLoc, prettySrcLoc)
-- ----------------------------------------------------------------------------
-- StackAnnotation
@@ -13,8 +14,38 @@ import GHC.Internal.Data.Typeable
-- as the payload of 'AnnFrame' stack frames.
--
class StackAnnotation a where
+ -- | Display a human readable string for the 'StackAnnotation'.
+ --
+ -- This is supposed to be the long version of 'displayStackAnnotationShort'
+ -- and may contain a source location.
+ --
+ -- If not provided, 'displayStackAnnotation' is derived from 'stackAnnotationSourceLocation'
+ -- and 'displayStackAnnotationShort'.
displayStackAnnotation :: a -> String
+ -- | Get the 'SrcLoc' of the given 'StackAnnotation'.
+ --
+ -- This is optional, 'SrcLoc' are not strictly required for 'StackAnnotation', but
+ -- it is still heavily encouarged to provide a 'SrcLoc' for better IPE backtraces.
+ stackAnnotationSourceLocation :: a -> Maybe SrcLoc
+
+ -- | The description of the StackAnnotation without any metadata such as source locations.
+ --
+ -- Pefer implementing 'displayStackAnnotationShort' over 'displayStackAnnotation'.
+ displayStackAnnotationShort :: a -> String
+
+ {-# MINIMAL displayStackAnnotation | displayStackAnnotationShort #-}
+
+ displayStackAnnotation ann =
+ displayStackAnnotationShort ann
+ ++ case stackAnnotationSourceLocation ann of
+ Nothing -> ""
+ Just srcLoc -> ", called at " ++ prettySrcLoc srcLoc
+
+ stackAnnotationSourceLocation _ann = Nothing
+
+ displayStackAnnotationShort = displayStackAnnotation
+
-- ----------------------------------------------------------------------------
-- Annotations
-- ----------------------------------------------------------------------------
@@ -28,4 +59,11 @@ data SomeStackAnnotation where
SomeStackAnnotation :: forall a. (Typeable a, StackAnnotation a) => a -> SomeStackAnnotation
instance StackAnnotation SomeStackAnnotation where
- displayStackAnnotation (SomeStackAnnotation a) = displayStackAnnotation a
+ displayStackAnnotation (SomeStackAnnotation a) =
+ displayStackAnnotation a
+
+ stackAnnotationSourceLocation (SomeStackAnnotation a) =
+ stackAnnotationSourceLocation a
+
+ displayStackAnnotationShort (SomeStackAnnotation a) =
+ displayStackAnnotationShort a
=====================================
libraries/ghc-internal/tests/stack-annotation/ann_frame001.stdout
=====================================
@@ -1,12 +1,12 @@
Stack annotations:
-- (2,3)
+- (2,3), called at ann_frame001.hs:5:13 in main:Main
47
Stack annotations:
-- "bar"
-- "foo"
-- "tailCallEx"
+- "bar", called at ann_frame001.hs:23:9 in main:Main
+- "foo", called at ann_frame001.hs:21:11 in main:Main
+- "tailCallEx", called at ann_frame001.hs:17:18 in main:Main
Stack annotations:
-- "bar"
-- "foo"
-- "tailCallEx"
+- "bar", called at ann_frame001.hs:23:9 in main:Main
+- "foo", called at ann_frame001.hs:21:11 in main:Main
+- "tailCallEx", called at ann_frame001.hs:17:18 in main:Main
40
=====================================
libraries/ghc-internal/tests/stack-annotation/ann_frame002.stdout
=====================================
@@ -7,5 +7,5 @@ Finish some work
Some more work in bar
17711
Stack annotations:
-- bar
+- bar, called at ann_frame002.hs:23:29 in main:Main
- annotateCallStackIO, called at ann_frame002.hs:23:7 in main:Main
=====================================
libraries/ghc-internal/tests/stack-annotation/ann_frame003.stdout
=====================================
@@ -1,6 +1,6 @@
47
Stack annotations:
-- "bar"
-- "foo"
-- "tailCallEx"
+- "bar", called at ann_frame003.hs:25:9 in main:Main
+- "foo", called at ann_frame003.hs:21:11 in main:Main
+- "tailCallEx", called at ann_frame003.hs:16:18 in main:Main
40
=====================================
libraries/ghc-internal/tests/stack-annotation/ann_frame004.stdout
=====================================
@@ -13,5 +13,5 @@ Stack annotations:
- annotateCallStack, called at ann_frame004.hs:21:17 in main:Main
- annotateCallStack, called at ann_frame004.hs:21:17 in main:Main
- annotateCallStack, called at ann_frame004.hs:13:10 in main:Main
-- bar
+- bar, called at ann_frame004.hs:12:29 in main:Main
- annotateCallStackIO, called at ann_frame004.hs:12:7 in main:Main
=====================================
testsuite/tests/interface-stability/ghc-experimental-exports.stdout
=====================================
@@ -6499,25 +6499,27 @@ module GHC.Stack.Annotation.Experimental where
newtype CallStackAnnotation = CallStackAnnotation GHC.Internal.Stack.Types.CallStack
type ShowAnnotation :: *
data ShowAnnotation where
- ShowAnnotation :: forall a. GHC.Internal.Show.Show a => a -> ShowAnnotation
+ ShowAnnotation :: forall a. GHC.Internal.Show.Show a => !(GHC.Internal.Maybe.Maybe GHC.Internal.Stack.Types.SrcLoc) -> a -> ShowAnnotation
type SomeStackAnnotation :: *
data SomeStackAnnotation where
SomeStackAnnotation :: forall a. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> SomeStackAnnotation
type StackAnnotation :: * -> Constraint
class StackAnnotation a where
displayStackAnnotation :: a -> GHC.Internal.Base.String
- {-# MINIMAL displayStackAnnotation #-}
+ stackAnnotationSourceLocation :: a -> GHC.Internal.Maybe.Maybe GHC.Internal.Stack.Types.SrcLoc
+ displayStackAnnotationShort :: a -> GHC.Internal.Base.String
+ {-# MINIMAL displayStackAnnotation | displayStackAnnotationShort #-}
type StringAnnotation :: *
data StringAnnotation where
- StringAnnotation :: GHC.Internal.Base.String -> StringAnnotation
+ StringAnnotation :: !(GHC.Internal.Maybe.Maybe GHC.Internal.Stack.Types.SrcLoc) -> GHC.Internal.Base.String -> StringAnnotation
annotateCallStack :: forall b. GHC.Internal.Stack.Types.HasCallStack => b -> b
annotateCallStackIO :: forall a. GHC.Internal.Stack.Types.HasCallStack => GHC.Internal.Types.IO a -> GHC.Internal.Types.IO a
- annotateStack :: forall a b. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> b -> b
- annotateStackIO :: forall a b. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
- annotateStackShow :: forall a b. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, GHC.Internal.Show.Show a) => a -> b -> b
- annotateStackShowIO :: forall a b. GHC.Internal.Show.Show a => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
- annotateStackString :: forall b. GHC.Internal.Base.String -> b -> b
- annotateStackStringIO :: forall b. GHC.Internal.Base.String -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
+ annotateStack :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> b -> b
+ annotateStackIO :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
+ annotateStackShow :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, GHC.Internal.Show.Show a) => a -> b -> b
+ annotateStackShowIO :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, GHC.Internal.Show.Show a) => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
+ annotateStackString :: forall b. GHC.Internal.Stack.Types.HasCallStack => GHC.Internal.Base.String -> b -> b
+ annotateStackStringIO :: forall b. GHC.Internal.Stack.Types.HasCallStack => GHC.Internal.Base.String -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
module GHC.Stats.Experimental where
-- Safety: Safe
=====================================
testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32
=====================================
@@ -6502,25 +6502,27 @@ module GHC.Stack.Annotation.Experimental where
newtype CallStackAnnotation = CallStackAnnotation GHC.Internal.Stack.Types.CallStack
type ShowAnnotation :: *
data ShowAnnotation where
- ShowAnnotation :: forall a. GHC.Internal.Show.Show a => a -> ShowAnnotation
+ ShowAnnotation :: forall a. GHC.Internal.Show.Show a => !(GHC.Internal.Maybe.Maybe GHC.Internal.Stack.Types.SrcLoc) -> a -> ShowAnnotation
type SomeStackAnnotation :: *
data SomeStackAnnotation where
SomeStackAnnotation :: forall a. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> SomeStackAnnotation
type StackAnnotation :: * -> Constraint
class StackAnnotation a where
displayStackAnnotation :: a -> GHC.Internal.Base.String
- {-# MINIMAL displayStackAnnotation #-}
+ stackAnnotationSourceLocation :: a -> GHC.Internal.Maybe.Maybe GHC.Internal.Stack.Types.SrcLoc
+ displayStackAnnotationShort :: a -> GHC.Internal.Base.String
+ {-# MINIMAL displayStackAnnotation | displayStackAnnotationShort #-}
type StringAnnotation :: *
data StringAnnotation where
- StringAnnotation :: GHC.Internal.Base.String -> StringAnnotation
+ StringAnnotation :: !(GHC.Internal.Maybe.Maybe GHC.Internal.Stack.Types.SrcLoc) -> GHC.Internal.Base.String -> StringAnnotation
annotateCallStack :: forall b. GHC.Internal.Stack.Types.HasCallStack => b -> b
annotateCallStackIO :: forall a. GHC.Internal.Stack.Types.HasCallStack => GHC.Internal.Types.IO a -> GHC.Internal.Types.IO a
- annotateStack :: forall a b. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> b -> b
- annotateStackIO :: forall a b. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
- annotateStackShow :: forall a b. (ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, GHC.Internal.Show.Show a) => a -> b -> b
- annotateStackShowIO :: forall a b. GHC.Internal.Show.Show a => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
- annotateStackString :: forall b. GHC.Internal.Base.String -> b -> b
- annotateStackStringIO :: forall b. GHC.Internal.Base.String -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
+ annotateStack :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> b -> b
+ annotateStackIO :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, StackAnnotation a) => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
+ annotateStackShow :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, ghc-internal-9.1500.0:GHC.Internal.Data.Typeable.Internal.Typeable a, GHC.Internal.Show.Show a) => a -> b -> b
+ annotateStackShowIO :: forall a b. (GHC.Internal.Stack.Types.HasCallStack, GHC.Internal.Show.Show a) => a -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
+ annotateStackString :: forall b. GHC.Internal.Stack.Types.HasCallStack => GHC.Internal.Base.String -> b -> b
+ annotateStackStringIO :: forall b. GHC.Internal.Stack.Types.HasCallStack => GHC.Internal.Base.String -> GHC.Internal.Types.IO b -> GHC.Internal.Types.IO b
module GHC.Stats.Experimental where
-- Safety: Safe
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/39d9e00bc85a3c2bedd99c804de0ec2…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/39d9e00bc85a3c2bedd99c804de0ec2…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/fendor/freeze-throw] Hide implementation details from base exception stack traces
by Hannes Siebenhandl (@fendor) 13 Feb '26
by Hannes Siebenhandl (@fendor) 13 Feb '26
13 Feb '26
Hannes Siebenhandl pushed to branch wip/fendor/freeze-throw at Glasgow Haskell Compiler / GHC
Commits:
46a61b5b by fendor at 2026-02-13T17:28:56+01:00
Hide implementation details from base exception stack traces
Ensure we hide the implementation details of the exception throwing mechanisms:
* `undefined`
* `throwSTM`
* `throw`
* `throwIO`
* `error`
The `HasCallStackBacktrace` should always have a length of exactly 1,
not showing internal implementation details in the stack trace, as these
are vastly distracting to end users.
CLC proposal [#387](https://github.com/haskell/core-libraries-committee/issues/387)
- - - - -
26 changed files:
- libraries/ghc-internal/src/GHC/Internal/Exception.hs
- libraries/ghc-internal/src/GHC/Internal/STM.hs
- + libraries/ghc-internal/tests/backtraces/T15395.hs
- + libraries/ghc-internal/tests/backtraces/T15395.stdout
- libraries/ghc-internal/tests/backtraces/all.T
- libraries/ghc-internal/tests/stack-annotation/ann_frame005.stdout
- testsuite/tests/arrows/should_compile/T21301.stderr
- testsuite/tests/deSugar/should_fail/DsStrictFail.stderr
- testsuite/tests/deSugar/should_run/T20024.stderr
- testsuite/tests/deSugar/should_run/dsrun005.stderr
- testsuite/tests/deSugar/should_run/dsrun007.stderr
- testsuite/tests/deSugar/should_run/dsrun008.stderr
- testsuite/tests/deriving/should_run/T9576.stderr
- testsuite/tests/ghci/scripts/Defer02.stderr
- testsuite/tests/ghci/scripts/T15325.stderr
- testsuite/tests/patsyn/should_run/ghci.stderr
- testsuite/tests/quotes/LiftErrMsgDefer.stderr
- testsuite/tests/safeHaskell/safeLanguage/SafeLang15.stderr
- testsuite/tests/type-data/should_run/T22332a.stderr
- testsuite/tests/typecheck/should_run/T10284.stderr
- testsuite/tests/typecheck/should_run/T13838.stderr
- testsuite/tests/typecheck/should_run/T9497a-run.stderr
- testsuite/tests/typecheck/should_run/T9497b-run.stderr
- testsuite/tests/typecheck/should_run/T9497c-run.stderr
- testsuite/tests/unsatisfiable/T23816.stderr
- testsuite/tests/unsatisfiable/UnsatDefer.stderr
Changes:
=====================================
libraries/ghc-internal/src/GHC/Internal/Exception.hs
=====================================
@@ -87,7 +87,7 @@ throw e =
-- Note also the absolutely crucial `noinine` in the RHS!
-- See Note [Hiding precise exception signature in throw]
let se :: SomeException
- !se = noinline (unsafePerformIO (toExceptionWithBacktrace e))
+ !se = noinline (unsafePerformIO (withFrozenCallStack $ toExceptionWithBacktrace e))
in raise# se
-- Note [Capturing the backtrace in throw]
@@ -162,7 +162,12 @@ throw e =
-- primops which allow more precise guidance of the demand analyser's heuristic
-- (e.g. #23847).
--- | @since base-4.20.0.0
+-- | Collect a Backtrace and attach it to the 'Exception'.
+--
+-- It is recommended to use 'withFrozenCallStack' when calling this function
+-- in order to avoid leaking implementation details of 'toExceptionWithBacktrace'.
+--
+-- @since base-4.20.0.0
toExceptionWithBacktrace :: (HasCallStack, Exception e)
=> e -> IO SomeException
toExceptionWithBacktrace e
=====================================
libraries/ghc-internal/src/GHC/Internal/STM.hs
=====================================
@@ -28,7 +28,7 @@ import GHC.Internal.Base
import GHC.Internal.Exception (Exception, toExceptionWithBacktrace, fromException, addExceptionContext)
import GHC.Internal.Exception.Context (ExceptionAnnotation)
import GHC.Internal.Exception.Type (WhileHandling(..))
-import GHC.Internal.Stack (HasCallStack)
+import GHC.Internal.Stack (HasCallStack, withFrozenCallStack)
-- TVars are shared memory locations which support atomic memory
-- transactions.
@@ -187,7 +187,7 @@ throwSTM e = do
-- N.B. Typically use of unsafeIOToSTM is very much frowned upon as this
-- is an easy way to end up with nested transactions. However, we can be
-- certain that toExceptionWithBacktrace will not initiate a transaction.
- se <- unsafeIOToSTM (toExceptionWithBacktrace e)
+ se <- unsafeIOToSTM (withFrozenCallStack $ toExceptionWithBacktrace e)
STM $ raiseIO# se
-- | Exception handling within STM actions.
=====================================
libraries/ghc-internal/tests/backtraces/T15395.hs
=====================================
@@ -0,0 +1,85 @@
+{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE TypeApplications #-}
+
+import GHC.Internal.Control.Exception
+import GHC.Internal.Data.Foldable (traverse_)
+import GHC.Internal.Exception.Backtrace
+import GHC.Internal.Exception.Context
+import GHC.Internal.Exception.Type
+import GHC.Internal.STM (atomically, throwSTM)
+import qualified GHC.Internal.Stack as HCS
+import qualified GHC.Internal.Stack.Types as HCS
+import Control.Monad (when)
+import qualified Data.List as List
+import System.Exit (exitFailure)
+
+main :: IO ()
+main = do
+ -- Make sure there are HasCallStackBacktraces
+ setBacktraceMechanismState HasCallStackBacktrace True
+ mapM_ (uncurry runCase)
+ [ ("throw", throwAction)
+ , ("throwIO", throwIOAction)
+ , ("error", errorAction)
+ , ("throwSTM", throwSTMAction)
+ , ("undefined", undefinedAction)
+ ]
+
+runCase :: String -> IO () -> IO ()
+runCase name act = do
+ putStrLn $ "=== Validate stack size of '" ++ name ++ "' has length 1"
+ catchAndVerifyStackTraceLength name act
+ putStrLn ""
+
+throwAction :: IO ()
+throwAction = evaluate $ throw $ ErrorCall "my throw error"
+
+throwIOAction :: IO ()
+throwIOAction = throwIO $ ErrorCall "my throwIO error"
+
+errorAction :: IO ()
+errorAction = error "plain error"
+
+throwSTMAction :: IO ()
+throwSTMAction = atomically $ throwSTM $ ErrorCall "my throwSTM error"
+
+undefinedAction :: IO ()
+undefinedAction = evaluate undefined
+
+catchAndVerifyStackTraceLength :: String -> IO () -> IO ()
+catchAndVerifyStackTraceLength name act = do
+ try act >>= \ case
+ Right _ -> do
+ putStrLn $ "Exception expected but got a result for '" ++ name ++ "'"
+ exitFailure
+ Left exc ->
+ verifyBacktraceSize name exc
+
+verifyBacktraceSize :: String -> SomeException -> IO ()
+verifyBacktraceSize label se = do
+ message <- evaluate (displayException se)
+ putStrLn "==== Caught exception:"
+ putStrLn message
+ putStrLn "==== Exception Backtraces:"
+ let backtraces = getExceptionAnnotations @Backtraces $ someExceptionContext se
+ traverse_ validateBacktrace backtraces
+
+validateBacktrace :: Backtraces -> IO ()
+validateBacktrace bt =
+ case btrHasCallStack bt of
+ Nothing -> pure ()
+ Just cs -> do
+ let stack = HCS.getCallStack cs
+
+ traverse_ mustNotReferenceInternalPackages stack
+ traverse_ (putStrLn . prettyCallSite) stack
+ where
+ prettyCallSite (f, loc) = "- " ++ f ++ ", called at " ++ HCS.prettySrcLoc loc
+
+ mustNotReferenceInternalPackages (_, loc) =
+ case List.find (HCS.srcLocPackage loc ==) internalPackages of
+ Just val -> fail $ "Stack trace must not reference '" ++ val ++ "' package."
+ Nothing -> pure ()
+
+internalPackages :: [String]
+internalPackages = ["base", "ghc", "ghc-internal", "ghc-experimental"]
=====================================
libraries/ghc-internal/tests/backtraces/T15395.stdout
=====================================
@@ -0,0 +1,30 @@
+=== Validate stack size of 'throw' has length 1
+==== Caught exception:
+my throw error
+==== Exception Backtraces:
+- throw, called at T15395.hs:35:26 in main:Main
+
+=== Validate stack size of 'throwIO' has length 1
+==== Caught exception:
+my throwIO error
+==== Exception Backtraces:
+- throwIO, called at T15395.hs:38:17 in main:Main
+
+=== Validate stack size of 'error' has length 1
+==== Caught exception:
+plain error
+==== Exception Backtraces:
+- error, called at T15395.hs:41:15 in main:Main
+
+=== Validate stack size of 'throwSTM' has length 1
+==== Caught exception:
+my throwSTM error
+==== Exception Backtraces:
+- throwSTM, called at T15395.hs:44:31 in main:Main
+
+=== Validate stack size of 'undefined' has length 1
+==== Caught exception:
+Prelude.undefined
+==== Exception Backtraces:
+- undefined, called at T15395.hs:47:28 in main:Main
+
=====================================
libraries/ghc-internal/tests/backtraces/all.T
=====================================
@@ -4,3 +4,7 @@ test('T26507', [ when(have_profiling(), extra_ways(['prof']))
, when(js_arch(), skip)
, when(ghc_with_ipe(), skip) # IPE builds include an IPE backtrace section on stderr.
, exit_code(1)], compile_and_run, [''])
+
+# Stack traces shouldn't expose implementation details
+test('T15395', [ when(have_profiling(), extra_ways(['prof']))
+ , when(js_arch(), skip)], compile_and_run, [''])
=====================================
libraries/ghc-internal/tests/stack-annotation/ann_frame005.stdout
=====================================
@@ -39,7 +39,5 @@ Exception context:
- catch site for throwSTM
- annotateCallStackIO, called at ann_frame005.hs:26:3 in main:Main
- HasCallStack backtrace:
-- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:170:37 in ghc-internal:GHC.Internal.Exception
-- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/STM.hs:190:26 in ghc-internal:GHC.Internal.STM
- throwSTM, called at ann_frame005.hs:55:9 in main:Main
Handler annotation not present in context
=====================================
testsuite/tests/arrows/should_compile/T21301.stderr
=====================================
@@ -4,7 +4,5 @@ T21301.hs:(8,7)-(10,6): Non-exhaustive patterns in case
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:434:30 in ghc-internal:GHC.Internal.Control.Exception.Base
=====================================
testsuite/tests/deSugar/should_fail/DsStrictFail.stderr
=====================================
@@ -4,7 +4,5 @@ DsStrictFail.hs:4:12-23: Non-exhaustive patterns in False
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:434:30 in ghc-internal:GHC.Internal.Control.Exception.Base
=====================================
testsuite/tests/deSugar/should_run/T20024.stderr
=====================================
@@ -4,7 +4,5 @@ T20024.hs:2:12-32: Non-exhaustive guards in pattern binding
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:431:30 in ghc-internal:GHC.Internal.Control.Exception.Base
=====================================
testsuite/tests/deSugar/should_run/dsrun005.stderr
=====================================
@@ -4,7 +4,5 @@ dsrun005.hs:42:1-18: Non-exhaustive patterns in function f
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:434:30 in ghc-internal:GHC.Internal.Control.Exception.Base
=====================================
testsuite/tests/deSugar/should_run/dsrun007.stderr
=====================================
@@ -4,7 +4,5 @@ dsrun007.hs:5:23-25: Missing field in record construction
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:432:30 in ghc-internal:GHC.Internal.Control.Exception.Base
=====================================
testsuite/tests/deSugar/should_run/dsrun008.stderr
=====================================
@@ -4,7 +4,5 @@ dsrun008.hs:2:32-36: Non-exhaustive patterns in (2, x)
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:434:30 in ghc-internal:GHC.Internal.Control.Exception.Base
=====================================
testsuite/tests/deriving/should_run/T9576.stderr
=====================================
@@ -13,7 +13,5 @@ T9576.hs:6:31: error: [GHC-39999]
(deferred type error)
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:435:30 in ghc-internal:GHC.Internal.Control.Exception.Base
=====================================
testsuite/tests/ghci/scripts/Defer02.stderr
=====================================
@@ -71,8 +71,6 @@ Defer01.hs:49:5: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)]
(deferred type error)
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:435:30 in ghc-internal:GHC.Internal.Control.Exception.Base
*** Exception: Defer01.hs:13:5: error: [GHC-83865]
@@ -82,8 +80,6 @@ HasCallStack backtrace:
(deferred type error)
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:435:30 in ghc-internal:GHC.Internal.Control.Exception.Base
*** Exception: Defer01.hs:17:9: error: [GHC-39999]
@@ -93,8 +89,6 @@ HasCallStack backtrace:
(deferred type error)
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:435:30 in ghc-internal:GHC.Internal.Control.Exception.Base
<interactive>:10:11: error: [GHC-83865]
@@ -113,8 +107,6 @@ HasCallStack backtrace:
(deferred type error)
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:435:30 in ghc-internal:GHC.Internal.Control.Exception.Base
*** Exception: Defer01.hs:30:5: error: [GHC-83865]
@@ -127,8 +119,6 @@ HasCallStack backtrace:
(deferred type error)
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:435:30 in ghc-internal:GHC.Internal.Control.Exception.Base
*** Exception: Defer01.hs:33:8: error: [GHC-25897]
@@ -146,8 +136,6 @@ HasCallStack backtrace:
(deferred type error)
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:435:30 in ghc-internal:GHC.Internal.Control.Exception.Base
*** Exception: Defer01.hs:38:17: error: [GHC-83865]
@@ -161,8 +149,6 @@ HasCallStack backtrace:
(deferred type error)
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:435:30 in ghc-internal:GHC.Internal.Control.Exception.Base
*** Exception: Defer01.hs:42:5: error: [GHC-39999]
@@ -172,8 +158,6 @@ HasCallStack backtrace:
(deferred type error)
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:435:30 in ghc-internal:GHC.Internal.Control.Exception.Base
<interactive>:16:8: error: [GHC-18872]
@@ -192,7 +176,5 @@ HasCallStack backtrace:
(deferred type error)
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:435:30 in ghc-internal:GHC.Internal.Control.Exception.Base
=====================================
testsuite/tests/ghci/scripts/T15325.stderr
=====================================
@@ -24,7 +24,5 @@ T15325.hs:11:9: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)]
(deferred type error)
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:435:30 in ghc-internal:GHC.Internal.Control.Exception.Base
=====================================
testsuite/tests/patsyn/should_run/ghci.stderr
=====================================
@@ -2,7 +2,5 @@
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:434:30 in ghc-internal:GHC.Internal.Control.Exception.Base
=====================================
testsuite/tests/quotes/LiftErrMsgDefer.stderr
=====================================
@@ -11,7 +11,5 @@ LiftErrMsgDefer.hs:14:12: warning: [GHC-28914] [-Wdeferred-type-errors (in -Wdef
(deferred type error)
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:435:30 in ghc-internal:GHC.Internal.Control.Exception.Base
=====================================
testsuite/tests/safeHaskell/safeLanguage/SafeLang15.stderr
=====================================
@@ -4,7 +4,5 @@ SafeLang15.hs:22:9-37: Non-exhaustive patterns in Just p'
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:434:30 in ghc-internal:GHC.Internal.Control.Exception.Base
=====================================
testsuite/tests/type-data/should_run/T22332a.stderr
=====================================
@@ -4,7 +4,5 @@ T22332a.hs:18:1-35: Non-exhaustive patterns in Just eq
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:434:30 in ghc-internal:GHC.Internal.Control.Exception.Base
=====================================
testsuite/tests/typecheck/should_run/T10284.stderr
=====================================
@@ -7,7 +7,5 @@ T10284.hs:7:5: error: [GHC-83865]
(deferred type error)
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:435:30 in ghc-internal:GHC.Internal.Control.Exception.Base
=====================================
testsuite/tests/typecheck/should_run/T13838.stderr
=====================================
@@ -9,7 +9,5 @@ T13838.hs:6:1: error: [GHC-83865]
(deferred type error)
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:435:30 in ghc-internal:GHC.Internal.Control.Exception.Base
=====================================
testsuite/tests/typecheck/should_run/T9497a-run.stderr
=====================================
@@ -19,7 +19,5 @@ T9497a-run.hs:2:8: error: [GHC-88464]
(deferred type error)
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:435:30 in ghc-internal:GHC.Internal.Control.Exception.Base
=====================================
testsuite/tests/typecheck/should_run/T9497b-run.stderr
=====================================
@@ -19,7 +19,5 @@ T9497b-run.hs:2:8: error: [GHC-88464]
(deferred type error)
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:435:30 in ghc-internal:GHC.Internal.Control.Exception.Base
=====================================
testsuite/tests/typecheck/should_run/T9497c-run.stderr
=====================================
@@ -19,7 +19,5 @@ T9497c-run.hs:2:8: error: [GHC-88464]
(deferred type error)
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:435:30 in ghc-internal:GHC.Internal.Control.Exception.Base
=====================================
testsuite/tests/unsatisfiable/T23816.stderr
=====================================
@@ -8,7 +8,5 @@ T23816.hs:18:15: error: [GHC-22250]
(deferred type error)
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:435:30 in ghc-internal:GHC.Internal.Control.Exception.Base
=====================================
testsuite/tests/unsatisfiable/UnsatDefer.stderr
=====================================
@@ -7,7 +7,5 @@ UnsatDefer.hs:20:7: error: [GHC-22250]
(deferred type error)
HasCallStack backtrace:
- collectExceptionAnnotation, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
- toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:435:30 in ghc-internal:GHC.Internal.Control.Exception.Base
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/46a61b5b0c6ee70d58f4cff64f18595…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/46a61b5b0c6ee70d58f4cff64f18595…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
Apoorv Ingle pushed to branch wip/ani/kill-SrcCodeOrigin at Glasgow Haskell Compiler / GHC
Commits:
eac62087 by Apoorv Ingle at 2026-02-13T10:28:29-06:00
wip
- - - - -
23 changed files:
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/HsToCore/Ticks.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/Bind.hs
- compiler/GHC/Tc/Gen/Do.hs
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Gen/HsType.hs
- compiler/GHC/Tc/Gen/Match.hs
- compiler/GHC/Tc/Gen/Pat.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/Types/ErrCtxt.hs
- compiler/GHC/Tc/Types/LclEnv.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Tc/Utils/Unify.hs
- compiler/GHC/Tc/Validity.hs
- compiler/GHC/Unit/State.hs-boot
- compiler/GHC/Utils/Logger.hs
Changes:
=====================================
compiler/GHC/Hs/Expr.hs
=====================================
@@ -686,7 +686,7 @@ mkExpandedStmt
-> HsDoFlavour -- ^ source statements do flavour
-> HsExpr GhcRn -- ^ expanded expression
-> HsExpr GhcRn -- ^ suitably wrapped 'XXExprGhcRn'
-mkExpandedStmt oStmt flav eExpr = XExpr (ExpandedThingRn { xrn_orig = StmtErrCtxt (HsDoStmt flav) oStmt
+mkExpandedStmt oStmt flav eExpr = XExpr (ExpandedThingRn { xrn_orig = DoStmtErrCtxt (HsDoStmt flav) oStmt
, xrn_expanded = eExpr })
data XXExprGhcTc
=====================================
compiler/GHC/Hs/Instances.hs
=====================================
@@ -620,13 +620,48 @@ deriving instance Eq (IE GhcTc)
-- ---------------------------------------------------------------------
-deriving instance Data ErrCtxtMsg
-deriving instance Data XXExprGhcRn
+-- deriving instance Data ErrCtxtMsg
+-- deriving instance Data XXExprGhcRn
+con_ExpandedThingRn = mkConstr xXExprGhcRn_T "ExpandedThingRn" [] Prefix
+con_HsRecSelRn = mkConstr xXExprGhcRn_T "HsRecSelRn" [] Prefix
+xXExprGhcRn_T = mkDataType "GHC.Hs.Expr.XXExprGhcRn" []
+
+instance Data XXExprGhcRn where
+ toConstr (ExpandedThingRn{}) = con_ExpandedThingRn
+ toConstr (HsRecSelRn{}) = con_HsRecSelRn
+
+ dataTypeOf _ = xXExprGhcRn_T
+
+ gunfold k z c = error "no gunfold for XXExprGhcRn"
+ gfoldl k z c = error "no gfoldl for XXExprGhcRn"
+
deriving instance Data a => Data (WithUserRdr a)
-- ---------------------------------------------------------------------
-deriving instance Data XXExprGhcTc
+-- deriving instance Data XXExprGhcTc
+con_ExpandedThingTc = mkConstr xXExprGhcTc_T "ExpandedThingTc" [] Prefix
+con_WrapExpr = mkConstr xXExprGhcTc_T "WrapExpr" [] Prefix
+con_ConLikeTc = mkConstr xXExprGhcTc_T "ConLikeTc" [] Prefix
+con_HsTick = mkConstr xXExprGhcTc_T "HsTick" [] Prefix
+con_HsBinTick = mkConstr xXExprGhcTc_T "HsBinTick" [] Prefix
+con_HsRecSelTc = mkConstr xXExprGhcTc_T "HsRecSelTc" [] Prefix
+xXExprGhcTc_T = mkDataType "GHC.Hs.Expr.XXExprGhcTc" []
+
+instance Data XXExprGhcTc where
+ toConstr (ExpandedThingTc{}) = con_ExpandedThingTc
+ toConstr (WrapExpr{}) = con_WrapExpr
+ toConstr (ConLikeTc{}) = con_ConLikeTc
+ toConstr (HsTick{}) = con_HsTick
+ toConstr (HsBinTick{}) = con_HsBinTick
+ toConstr (HsRecSelTc{}) = con_HsRecSelTc
+
+ dataTypeOf _ = xXExprGhcTc_T
+
+
+ gunfold _ _ _ = error "no gunfold for XXExprGhcTc"
+ gfoldl _ _ _ = error "no gfoldl for XXExprGhcTc"
+
deriving instance Data XXPatGhcTc
-- ---------------------------------------------------------------------
=====================================
compiler/GHC/HsToCore/Ticks.hs
=====================================
@@ -47,6 +47,7 @@ import GHC.Types.CostCentre
import GHC.Types.CostCentre.State
import GHC.Types.Tickish
import GHC.Types.ProfAuto
+import GHC.Tc.Types.ErrCtxt
import Control.Monad
import Data.List (isSuffixOf, intersperse)
@@ -414,7 +415,7 @@ addTickLHsExpr e@(L pos e0) = do
d <- getDensity
case d of
TickForBreakPoints | isGoodBreakExpr e0 -> tick_it
- TickForCoverage | XExpr (ExpandedThingTc OrigStmt{} _) <- e0 -- expansion ticks are handled separately
+ TickForCoverage | XExpr (ExpandedThingTc StmtErrCtxt{} _) <- e0 -- expansion ticks are handled separately
-> dont_tick_it
| otherwise -> tick_it
TickCallSites | isCallSite e0 -> tick_it
@@ -483,7 +484,7 @@ addTickLHsExprNever (L pos e0) = do
-- General heuristic: expressions which are calls (do not denote
-- values) are good break points.
isGoodBreakExpr :: HsExpr GhcTc -> Bool
-isGoodBreakExpr (XExpr (ExpandedThingTc (OrigStmt{}) _)) = False
+isGoodBreakExpr (XExpr (ExpandedThingTc (StmtErrCtxt{}) _)) = False
isGoodBreakExpr e = isCallSite e
isCallSite :: HsExpr GhcTc -> Bool
@@ -658,11 +659,11 @@ addTickHsExpr (HsDo srcloc cxt (L l stmts))
ListComp -> Just $ BinBox QualBinBox
_ -> Nothing
-addTickHsExpanded :: SrcCodeOrigin -> HsExpr GhcTc -> TM (HsExpr GhcTc)
+addTickHsExpanded :: ErrCtxtMsg -> HsExpr GhcTc -> TM (HsExpr GhcTc)
addTickHsExpanded o e = liftM (XExpr . ExpandedThingTc o) $ case o of
-- We always want statements to get a tick, so we can step over each one.
-- To avoid duplicates we blacklist SrcSpans we already inserted here.
- OrigStmt (L pos _) _ -> do_tick_black pos
+ DoStmtErrCtxt _ (L pos _) -> do_tick_black pos
_ -> skip
where
skip = addTickHsExpr e
=====================================
compiler/GHC/Iface/Ext/Ast.hs
=====================================
@@ -39,6 +39,7 @@ import GHC.Core.TyCon ( TyCon, tyConClass_maybe )
import GHC.Core.InstEnv
import GHC.Core.Predicate ( isEvId )
import GHC.Tc.Types
+import GHC.Tc.Types.ErrCtxt
import GHC.Tc.Types.Evidence
import GHC.Types.Var ( Id, Var, EvId, varName, varType, varUnique )
import GHC.Types.Var.Env
@@ -755,7 +756,7 @@ instance HiePass p => HasType (LocatedA (HsExpr (GhcPass p))) where
ExprWithTySig _ e _ -> computeLType e
HsPragE _ _ e -> computeLType e
XExpr (ExpandedThingTc thing e)
- | OrigExpr (HsGetField{}) <- thing -- for record-dot-syntax
+ | ExprCtxt (HsGetField{}) <- thing -- for record-dot-syntax
-> Just (hsExprType e)
| otherwise -> computeType e
XExpr (HsTick _ e) -> computeLType e
=====================================
compiler/GHC/Tc/Errors.hs
=====================================
@@ -83,7 +83,6 @@ import qualified GHC.Data.Strict as Strict
import Language.Haskell.Syntax.Basic (FieldLabelString(..))
import Language.Haskell.Syntax (HsExpr (RecordUpd, HsGetField, HsProjection))
-import GHC.Hs.Expr (SrcCodeOrigin(..))
import Control.Monad ( when, foldM, forM_ )
import Data.Bifunctor ( bimap )
=====================================
compiler/GHC/Tc/Errors/Ppr.hs
=====================================
@@ -68,11 +68,11 @@ import GHC.Core.FVs( orphNamesOfTypes )
import GHC.CoreToIface
import GHC.Driver.Flags
--- import GHC.Driver.Backend
+import GHC.Driver.Backend
import GHC.Hs hiding (HoleError)
import GHC.Hs.Decls.Overlap
--- import GHC.Tc.Errors.Types
+import GHC.Tc.Errors.Types
import GHC.Tc.Errors.Types.PromotionErr (pprTermLevelUseCtxt)
import GHC.Tc.Errors.Hole.FitTypes
import GHC.Tc.Types.BasicTypes
@@ -109,7 +109,7 @@ import GHC.Iface.Errors.Types
import GHC.Iface.Errors.Ppr
import GHC.Iface.Syntax
--- import GHC.Unit.State
+import GHC.Unit.State
import GHC.Unit.Module
import GHC.Data.Bag
@@ -7881,6 +7881,18 @@ pprErrCtxtMsg = \case
-> hang (text "In a stmt of" <+> pprAStmtContext ctxt <> colon)
2 (ppr_stmt stmt)
+ DoStmtErrCtxt ctxt stmt
+ -- For [ e | .. ], do not mutter about "stmts"
+ | LastStmt _ e _ _ <- (unLoc stmt)
+ , isComprehensionContext ctxt
+ -> hang (text "In the expression:") 2 (ppr e)
+ | otherwise
+ -> hang (text "In a stmt of" <+> pprAStmtContext ctxt <> colon)
+ 2 (ppr_stmt (unLoc stmt))
+
+ StmtErrCtxtPat _ _ pat ->
+ hang (text "In the pattern:") 2 (ppr pat)
+
DerivInstCtxt pred ->
text "When deriving the instance for" <+> parens (ppr pred)
StandaloneDerivCtxt ty ->
=====================================
compiler/GHC/Tc/Gen/App.hs
=====================================
@@ -973,8 +973,8 @@ addArgCtxt arg_no (app_head, app_head_lspan) (L arg_loc arg) thing_inside
where
addNthFunArgErrCtxt :: HsExpr GhcRn -> HsExpr GhcRn -> Int -> TcM a -> TcM a
addNthFunArgErrCtxt app_head arg arg_no thing_inside
- | XExpr (ExpandedThingRn o _) <- arg
- = addExpansionErrCtxt o (FunAppCtxt (FunAppCtxtExpr app_head arg) arg_no) $
+ | XExpr (ExpandedThingRn _ _) <- arg
+ = addExpansionErrCtxt (FunAppCtxt (FunAppCtxtExpr app_head arg) arg_no) $
thing_inside
| otherwise
= addErrCtxt (FunAppCtxt (FunAppCtxtExpr app_head arg) arg_no) $
=====================================
compiler/GHC/Tc/Gen/Bind.hs
=====================================
@@ -66,7 +66,7 @@ import GHC.Types.SourceText
import GHC.Types.Id
import GHC.Types.Var as Var
import GHC.Types.Var.Set
-import GHC.Types.Var.Env( TidyEnv, TyVarEnv, mkVarEnv, lookupVarEnv )
+import GHC.Types.Var.Env( TyVarEnv, mkVarEnv, lookupVarEnv )
import GHC.Types.Name
import GHC.Types.Name.Set
import GHC.Types.Name.Env
@@ -970,7 +970,7 @@ mkInferredPolyId residual insoluble qtvs inferred_theta poly_name mb_sig_inst mo
, text "insoluble" <+> ppr insoluble ])
; unless insoluble $
- addErrCtxtM (mk_inf_msg poly_name inferred_poly_ty) $
+ addErrCtxtM (InferredTypeCtxt poly_name inferred_poly_ty) $
do { checkEscapingKind inferred_poly_ty
-- See Note [Inferred type with escaping kind]
; checkValidType (InfSigCtxt poly_name) inferred_poly_ty }
@@ -1120,11 +1120,6 @@ chooseInferredQuantifiers residual inferred_theta tau_tvs qtvs
chooseInferredQuantifiers _ _ _ _ (Just sig)
= pprPanic "chooseInferredQuantifiers" (ppr sig)
-mk_inf_msg :: Name -> TcType -> TidyEnv -> ZonkM (TidyEnv, ErrCtxtMsg)
-mk_inf_msg poly_name poly_ty tidy_env
- = do { (tidy_env1, poly_ty) <- zonkTidyTcType tidy_env poly_ty
- ; return (tidy_env1, InferredTypeCtxt poly_name poly_ty) }
-
-- | Warn the user about polymorphic local binders that lack type signatures.
localSigWarn :: Id -> Maybe TcIdSigInst -> TcM ()
localSigWarn id mb_sig
@@ -1909,4 +1904,3 @@ NoGen is good when we have call sites, but not at top level, where the
function may be exported. And it's easier to grok "MonoLocalBinds" as
applying to, well, local bindings.
-}
-
=====================================
compiler/GHC/Tc/Gen/Do.hs
=====================================
@@ -20,7 +20,7 @@ import GHC.Rename.Env ( irrefutableConLikeRn )
import GHC.Tc.Utils.Monad
import GHC.Tc.Utils.TcMType
-
+import GHC.Tc.Types.ErrCtxt
import GHC.Hs
import GHC.Utils.Outputable
@@ -213,7 +213,7 @@ mk_fail_block doFlav pat stmt e (Just (SyntaxExprRn fail_op)) =
fail_op_expr :: DynFlags -> LPat GhcRn -> HsExpr GhcRn -> LHsExpr GhcRn
fail_op_expr dflags pat@(L pat_lspan _) fail_op
- = L pat_lspan $ mkExpandedPatRn (unLoc pat) stmt $ genHsApp fail_op (mk_fail_msg_expr dflags pat)
+ = L pat_lspan $ mkExpandedPatRn doFlav (unLoc pat) stmt $ genHsApp fail_op (mk_fail_msg_expr dflags pat)
mk_fail_msg_expr :: DynFlags -> LPat GhcRn -> LHsExpr GhcRn
mk_fail_msg_expr dflags pat
@@ -481,7 +481,7 @@ It stores the original statement (with location) and the expanded expression
-}
-mkExpandedPatRn :: Pat GhcRn -> ExprLStmt GhcRn -> HsExpr GhcRn -> HsExpr GhcRn
-mkExpandedPatRn oflav pat stmt e = XExpr $ ExpandedThingRn
+mkExpandedPatRn :: HsDoFlavour -> Pat GhcRn -> ExprLStmt GhcRn -> HsExpr GhcRn -> HsExpr GhcRn
+mkExpandedPatRn flav pat stmt e = XExpr $ ExpandedThingRn
{ xrn_orig = StmtErrCtxtPat (HsDoStmt flav) stmt pat
- , xrn_expand = e}
+ , xrn_expanded = e}
=====================================
compiler/GHC/Tc/Gen/Head.hs
=====================================
@@ -1006,7 +1006,8 @@ addFunResCtxt :: HsExpr GhcTc -> [HsExprArg p]
addFunResCtxt fun args fun_res_ty env_ty thing_inside
= do { env_tv <- newFlexiTyVarTy liftedTypeKind
; dumping <- doptM Opt_D_dump_tc_trace
- ; addLandmarkErrCtxtM (\env -> (env, ) <$> mk_msg dumping env_tv) thing_inside }
+ ; msg <- mk_msg dumping env_tv
+ ; addLandmarkErrCtxtM msg thing_inside }
-- NB: use a landmark error context, so that an empty context
-- doesn't suppress some more useful context
where
@@ -1014,13 +1015,12 @@ addFunResCtxt fun args fun_res_ty env_ty thing_inside
= do { mb_env_ty <- readExpType_maybe env_ty
-- by the time the message is rendered, the ExpType
-- will be filled in (except if we're debugging)
- ; fun_res' <- zonkTcType fun_res_ty
; env' <- case mb_env_ty of
- Just env_ty -> zonkTcType env_ty
+ Just env_ty -> return env_ty
Nothing -> do { massert dumping; return env_tv }
; let -- See Note [Splitting nested sigma types in mismatched
-- function types]
- (_, _, fun_tau) = tcSplitNestedSigmaTys fun_res'
+ (_, _, fun_tau) = tcSplitNestedSigmaTys fun_res_ty
(_, _, env_tau) = tcSplitNestedSigmaTys env'
-- env_ty is an ExpRhoTy, but with simple subsumption it
-- is not deeply skolemised, so still use tcSplitNestedSigmaTys
=====================================
compiler/GHC/Tc/Gen/HsType.hs
=====================================
@@ -353,7 +353,7 @@ funsSigCtxt :: [LocatedN Name] -> UserTypeCtxt
funsSigCtxt (L _ name1 : _) = FunSigCtxt name1 NoRRC
funsSigCtxt [] = panic "funSigCtxt"
-addSigCtxt :: UserTypeCtxt -> UserSigType GhcRn -> TcM a -> TcM a
+addSigCtxt :: UserTypeCtxt -> UserSigType -> TcM a -> TcM a
addSigCtxt ctxt hs_ty thing_inside
= setSrcSpan l $
addErrCtxt (UserSigCtxt ctxt hs_ty) $
=====================================
compiler/GHC/Tc/Gen/Match.hs
=====================================
@@ -487,7 +487,7 @@ tcStmtsAndThen ctxt stmt_chk (L loc stmt : stmts) res_ty thing_inside
| otherwise
= do { (stmt', (stmts', thing)) <-
setSrcSpanA loc $
- addErrCtxt (StmtErrCtxt ctxt stmt) $
+ addErrCtxt (StmtErrCtxt ctxt (L loc stmt)) $
stmt_chk ctxt stmt res_ty $ \ res_ty' ->
popErrCtxt $
tcStmtsAndThen ctxt stmt_chk stmts res_ty' $
=====================================
compiler/GHC/Tc/Gen/Pat.hs
=====================================
@@ -39,7 +39,6 @@ import GHC.Core.Multiplicity
import GHC.Tc.Utils.Concrete ( hasFixedRuntimeRep_syntactic )
import GHC.Tc.Utils.Env
import GHC.Tc.Utils.TcMType
-import GHC.Tc.Zonk.TcType
import GHC.Core.TyCo.Ppr ( pprTyVars )
import GHC.Tc.Utils.TcType
import GHC.Tc.Utils.Unify
@@ -1021,7 +1020,8 @@ tcPatSig in_pat_bind sig res_ty
; case NE.nonEmpty sig_tvs of
Nothing -> do {
-- Just do the subsumption check and return
- wrap <- addErrCtxtM (mk_msg sig_ty) $
+ msg <- mk_msg res_ty sig_ty
+ ; wrap <- addErrCtxtM msg $
tcSubTypePat PatSigOrigin PatSigCtxt res_ty sig_ty
; return (sig_ty, [], sig_wcs, wrap)
}
@@ -1035,18 +1035,17 @@ tcPatSig in_pat_bind sig res_ty
(addErr (TcRnCannotBindScopedTyVarInPatSig sig_tvs_ne))
-- Now do a subsumption check of the pattern signature against res_ty
- wrap <- addErrCtxtM (mk_msg sig_ty) $
+ msg <- mk_msg res_ty sig_ty
+ wrap <- addErrCtxtM msg $
tcSubTypePat PatSigOrigin PatSigCtxt res_ty sig_ty
-- Phew!
return (sig_ty, sig_tvs, sig_wcs, wrap)
}
where
- mk_msg sig_ty tidy_env
- = do { (tidy_env, sig_ty) <- zonkTidyTcType tidy_env sig_ty
- ; res_ty <- readExpType res_ty -- should be filled in by now
- ; (tidy_env, res_ty) <- zonkTidyTcType tidy_env res_ty
- ; return (tidy_env, PatSigErrCtxt sig_ty res_ty) }
+ mk_msg res_ty sig_ty
+ = do { res_ty <- readExpType res_ty -- should be filled in by now
+ ; return $ PatSigErrCtxt sig_ty res_ty }
{- *********************************************************************
* *
=====================================
compiler/GHC/Tc/TyCl/Instance.hs
=====================================
@@ -2108,7 +2108,7 @@ tcMethodBodyHelp hs_sig_fn sel_id local_meth_id meth_bind
-- The instance-sig is the focus here; the class-meth-sig
-- is fixed (#18036)
; let orig = InstanceSigOrigin sel_name sig_ty local_meth_ty
- ; hs_wrap <- addErrCtxtM (methSigCtxt sel_name sig_ty local_meth_ty) $
+ ; hs_wrap <- addErrCtxtM (MethSigCtxt sel_name sig_ty meth_ty) $
tcSubTypeSigma orig ctxt sig_ty local_meth_ty
; return (sig_ty, hs_wrap) }
@@ -2176,11 +2176,6 @@ mkMethIds clas tyvars dfun_ev_vars inst_tys sel_id
poly_meth_ty = mkSpecSigmaTy tyvars theta local_meth_ty
theta = map idType dfun_ev_vars
-methSigCtxt :: Name -> TcType -> TcType -> TidyEnv -> ZonkM (TidyEnv, ErrCtxtMsg)
-methSigCtxt sel_name sig_ty meth_ty env0
- = do { (env1, sig_ty) <- zonkTidyTcType env0 sig_ty
- ; (env2, meth_ty) <- zonkTidyTcType env1 meth_ty
- ; return (env2, MethSigCtxt sel_name sig_ty meth_ty) }
{- Note [Instance method signatures]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
=====================================
compiler/GHC/Tc/Types/ErrCtxt.hs
=====================================
@@ -175,10 +175,16 @@ data ErrCtxtMsg
-- | Warning emitted when inferring use of visible dependent quantification.
| VDQWarningCtxt !TcTyCon
- -- | In a statement.
- | StmtErrCtxt !HsStmtContextRn !(ExprLStmt GhcRn)
+ -- | In a statement
+ | forall body.
+ ( Anno (StmtLR GhcRn GhcRn body) ~ SrcSpanAnnA
+ , Outputable body
+ ) => StmtErrCtxt !HsStmtContextRn !(StmtLR GhcRn GhcRn body)
- -- | In patten of the statement. (c.f. MonadFailErrors)
+ -- | In a do statement.
+ | DoStmtErrCtxt !HsStmtContextRn !(ExprLStmt GhcRn)
+
+ -- | In patten of the do statement. (c.f. MonadFailErrors)
| StmtErrCtxtPat !HsStmtContextRn !(ExprLStmt GhcRn) (Pat GhcRn)
-- | In an rebindable syntax expression.
=====================================
compiler/GHC/Tc/Types/LclEnv.hs
=====================================
@@ -36,7 +36,6 @@ module GHC.Tc.Types.LclEnv (
import GHC.Prelude
-import GHC.Hs ( SrcCodeOrigin (..) )
import GHC.Tc.Utils.TcType ( TcLevel )
import GHC.Tc.Errors.Types ( TcRnMessage )
@@ -120,8 +119,8 @@ push the new expression error message on top of the stack. cf. `LclEnv.setLclCtx
type ErrCtxtStack = [ErrCtxt]
-- | Get the original source code
-get_src_code_origin :: ErrCtxtStack -> Maybe SrcCodeOrigin
-get_src_code_origin (MkErrCtxt (ExpansionCodeCtxt origSrcCode) _ : _) = Just origSrcCode
+get_src_code_origin :: ErrCtxtStack -> Maybe ErrCtxtMsg
+get_src_code_origin (MkErrCtxt ExpansionCodeCtxt e : _) = Just e
-- we are in generated code, due to the expansion of the original syntax origSrcCode
get_src_code_origin _ = Nothing
-- we are in user code, so blame the expression in hand
@@ -203,7 +202,7 @@ setLclEnvErrCtxt ctxt = modifyLclCtxt (\env -> env { tcl_err_ctxt = ctxt })
addLclEnvErrCtxt :: ErrCtxt -> TcLclEnv -> TcLclEnv
addLclEnvErrCtxt ec = setLclEnvSrcCodeOrigin ec
-getLclEnvSrcCodeOrigin :: TcLclEnv -> Maybe SrcCodeOrigin
+getLclEnvSrcCodeOrigin :: TcLclEnv -> Maybe ErrCtxtMsg
getLclEnvSrcCodeOrigin = get_src_code_origin . tcl_err_ctxt . tcl_lcl_ctxt
setLclEnvSrcCodeOrigin :: ErrCtxt -> TcLclEnv -> TcLclEnv
@@ -212,18 +211,18 @@ setLclEnvSrcCodeOrigin ec = modifyLclCtxt (setLclCtxtSrcCodeOrigin ec)
-- See Note [ErrCtxtStack Manipulation]
setLclCtxtSrcCodeOrigin :: ErrCtxt -> TcLclCtxt -> TcLclCtxt
setLclCtxtSrcCodeOrigin ec lclCtxt
- | ecs@(MkErrCtxt (ExpansionCodeCtxt{}) _ : _) <- tcl_err_ctxt lclCtxt
- , MkErrCtxt (ExpansionCodeCtxt ExprCtxt{}) _ <- ec
+ | ecs@(MkErrCtxt ExpansionCodeCtxt _ : _) <- tcl_err_ctxt lclCtxt
+ , MkErrCtxt ExpansionCodeCtxt ExprCtxt{} <- ec
= lclCtxt { tcl_err_ctxt = ec : ecs }
- | MkErrCtxt (ExpansionCodeCtxt{}) _ : ecs <- tcl_err_ctxt lclCtxt
- , MkErrCtxt (ExpansionCodeCtxt{}) _ <- ec
+ | MkErrCtxt ExpansionCodeCtxt _ : ecs <- tcl_err_ctxt lclCtxt
+ , MkErrCtxt ExpansionCodeCtxt _ <- ec
= lclCtxt { tcl_err_ctxt = ec : ecs }
| otherwise
= lclCtxt { tcl_err_ctxt = ec : tcl_err_ctxt lclCtxt }
lclCtxtInGeneratedCode :: TcLclCtxt -> Bool
lclCtxtInGeneratedCode lclCtxt
- | (MkErrCtxt (ExpansionCodeCtxt _) _ : _) <- tcl_err_ctxt lclCtxt
+ | (MkErrCtxt ExpansionCodeCtxt _ : _) <- tcl_err_ctxt lclCtxt
= True
| otherwise
= False
=====================================
compiler/GHC/Tc/Types/Origin.hs
=====================================
@@ -51,6 +51,7 @@ module GHC.Tc.Types.Origin (
import GHC.Prelude
import GHC.Tc.Utils.TcType
+import GHC.Tc.Types.ErrCtxt
import GHC.Hs
@@ -836,7 +837,7 @@ exprCtOrigin e@(HsGetField{}) = ExpansionOrigin (ExprCtxt e)
exprCtOrigin (XExpr (ExpandedThingRn o _)) = ExpansionOrigin o
exprCtOrigin (XExpr (HsRecSelRn f)) = OccurrenceOfRecSel $ L (getLoc $ foLabel f) (foExt f)
-srcCodeOriginCtOrigin :: HsExpr GhcRn -> Maybe SrcCodeOrigin -> CtOrigin
+srcCodeOriginCtOrigin :: HsExpr GhcRn -> Maybe ErrCtxtMsg -> CtOrigin
srcCodeOriginCtOrigin e Nothing = exprCtOrigin e
srcCodeOriginCtOrigin _ (Just o) = ExpansionOrigin o
@@ -874,7 +875,7 @@ pprCtOrigin (ExpansionOrigin o)
what = case o of
StmtErrCtxt{} ->
text "a do statement"
- StmtErrCtxtPat _ p ->
+ StmtErrCtxtPat _ _ p ->
text "a do statement" $$
text "with the failable pattern" <+> quotes (ppr p)
ExprCtxt (HsGetField _ _ (L _ f)) ->
@@ -887,6 +888,7 @@ pprCtOrigin (ExpansionOrigin o)
ExprCtxt (HsProjection _ p) -> text "the record selector" <+>
quotes (ppr ((FieldLabelStrings $ fmap noLocA p)))
ExprCtxt e -> text "the expression" <+> (ppr e)
+ _ -> text "shouldn't happen ExpansionOrigin pprCtOrigin"
pprCtOrigin (GivenSCOrigin sk d blk)
= vcat [ ctoHerald <+> pprSkolInfo sk
@@ -1112,6 +1114,7 @@ ppr_br (ExpansionOrigin (ExprCtxt (HsIf{}))) = text "an if-then-else expression"
ppr_br (ExpansionOrigin (ExprCtxt e)) = text "an expression" <+> ppr e
ppr_br (ExpansionOrigin (StmtErrCtxt{})) = text "a do statement"
ppr_br (ExpansionOrigin (StmtErrCtxtPat{})) = text "a do statement"
+ppr_br (ExpansionOrigin{}) = text "shouldn't happen ExpansionOrigin ppr_br"
ppr_br (ExpectedTySyntax o _) = ppr_br o
ppr_br (ExpectedFunTySyntaxOp{}) = text "a rebindable syntax operator"
ppr_br (ExpectedFunTyViewPat{}) = text "a view pattern"
=====================================
compiler/GHC/Tc/Utils/Instantiate.hs
=====================================
@@ -67,7 +67,6 @@ import GHC.Tc.Utils.Concrete ( hasFixedRuntimeRep_syntactic )
import GHC.Tc.Utils.TcMType
import GHC.Tc.Utils.TcType
import GHC.Tc.Errors.Types
-import GHC.Tc.Zonk.Monad ( ZonkM )
import GHC.Rename.Utils( mkRnSyntaxExpr )
@@ -855,7 +854,7 @@ tcSyntaxName orig ty (std_nm, user_nm_expr) = do
-- case of locally-polymorphic methods.
span <- getSrcSpanM
- addErrCtxtM (syntaxNameCtxt user_nm_expr orig sigma1 span) $ do
+ addErrCtxtM (SyntaxNameCtxt user_nm_expr orig sigma1 span) $ do
-- Check that the user-supplied thing has the
-- same type as the standard one.
@@ -864,11 +863,6 @@ tcSyntaxName orig ty (std_nm, user_nm_expr) = do
hasFixedRuntimeRepRes std_nm user_nm_expr sigma1
return (std_nm, unLoc expr)
-syntaxNameCtxt :: HsExpr GhcRn -> CtOrigin -> Type -> SrcSpan
- -> TidyEnv -> ZonkM (TidyEnv, ErrCtxtMsg)
-syntaxNameCtxt name orig ty loc tidy_env =
- return (tidy_env, SyntaxNameCtxt name orig (tidyType tidy_env ty) loc)
-
{-
************************************************************************
* *
=====================================
compiler/GHC/Tc/Utils/Monad.hs
=====================================
@@ -1091,12 +1091,8 @@ setSrcSpan (RealSrcSpan loc _) thing_inside
setSrcSpan _ thing_inside
= thing_inside
-getSrcCodeOrigin :: TcRn (Maybe SrcCodeOrigin)
-getSrcCodeOrigin =
- do inGenCode <- inGeneratedCode
- if inGenCode
- then getLclEnvSrcCodeOrigin <$> getLclEnv
- else return Nothing
+getSrcCodeOrigin :: TcRn (Maybe ErrCtxtMsg)
+getSrcCodeOrigin = getLclEnvSrcCodeOrigin <$> getLclEnv
setSrcSpanA :: EpAnn ann -> TcRn a -> TcRn a
setSrcSpanA l = setSrcSpan (locA l)
@@ -1369,21 +1365,21 @@ setErrCtxt ctxt = updLclEnv (setLclEnvErrCtxt ctxt)
-- See Note [Rebindable syntax and XXExprGhcRn] in GHC.Hs.Expr
addErrCtxt :: ErrCtxtMsg -> TcM a -> TcM a
{-# INLINE addErrCtxt #-} -- Note [Inlining addErrCtxt]
-addErrCtxt msg = addErrCtxtM (\env -> return (env, msg))
+addErrCtxt msg = addErrCtxtM msg
-- See Note [ErrCtxtStack Manipulation]
addExpansionErrCtxt :: ErrCtxtMsg -> TcM a -> TcM a
{-# INLINE addExpansionErrCtxt #-} -- Note [Inlining addErrCtxt]
-addExpansionErrCtxt msg = addExpansionErrCtxtM (\env -> return (env, msg))
+addExpansionErrCtxt msg = addExpansionErrCtxtM msg
-- | Add a message to the error context. This message may do tidying.
-- See Note [Rebindable syntax and XXExprGhcRn] in GHC.Hs.Expr
-addErrCtxtM :: (TidyEnv -> ZonkM (TidyEnv, ErrCtxtMsg)) -> TcM a -> TcM a
+addErrCtxtM :: ErrCtxtMsg -> TcM a -> TcM a
{-# INLINE addErrCtxtM #-} -- Note [Inlining addErrCtxt]
addErrCtxtM ctxt = pushCtxt (MkErrCtxt VanillaUserSrcCode ctxt)
-- See Note [ErrCtxtStack Manipulation]
-addExpansionErrCtxtM :: (TidyEnv -> ZonkM (TidyEnv, ErrCtxtMsg)) -> TcM a -> TcM a
+addExpansionErrCtxtM :: ErrCtxtMsg -> TcM a -> TcM a
{-# INLINE addExpansionErrCtxtM #-} -- Note [Inlining addErrCtxt]
addExpansionErrCtxtM ctxt = pushCtxt (MkErrCtxt ExpansionCodeCtxt ctxt)
@@ -1393,11 +1389,11 @@ addExpansionErrCtxtM ctxt = pushCtxt (MkErrCtxt ExpansionCodeCtxt ctxt)
-- reported.
addLandmarkErrCtxt :: ErrCtxtMsg -> TcM a -> TcM a
{-# INLINE addLandmarkErrCtxt #-} -- Note [Inlining addErrCtxt]
-addLandmarkErrCtxt msg = addLandmarkErrCtxtM (\env -> return (env, msg))
+addLandmarkErrCtxt msg = addLandmarkErrCtxtM msg
-- | Variant of 'addLandmarkErrCtxt' that allows for monadic operations
-- and tidying.
-addLandmarkErrCtxtM :: (TidyEnv -> ZonkM (TidyEnv, ErrCtxtMsg)) -> TcM a -> TcM a
+addLandmarkErrCtxtM :: ErrCtxtMsg -> TcM a -> TcM a
{-# INLINE addLandmarkErrCtxtM #-} -- Note [Inlining addErrCtxt]
addLandmarkErrCtxtM ctxt = pushCtxt (MkErrCtxt LandmarkUserSrcCode ctxt)
@@ -1966,14 +1962,14 @@ mkErrCtxt env ctxts
go :: Bool -> Int -> TidyEnv -> [ErrCtxt] -> TcM [ErrCtxtMsg]
go _ _ _ [] = return []
go dbg n env (MkErrCtxt LandmarkUserSrcCode ctxt : ctxts)
- = do { (env', msg) <- liftZonkM $ ctxt env
- ; rest <- go dbg n env' ctxts
- ; return (msg : rest) }
+ = do { -- (env', msg) <- liftZonkM $ emptyTidyEnv env
+ ; rest <- go dbg n env ctxts
+ ; return (ctxt : rest) }
go dbg n env (MkErrCtxt _ ctxt : ctxts)
| n < mAX_CONTEXTS -- Too verbose || dbg
- = do { (env', msg) <- liftZonkM $ ctxt env
- ; rest <- go dbg (n+1) env' ctxts
- ; return (msg : rest) }
+ = do { -- (env', msg) <- liftZonkM $ emptyTidyEnv env
+ ; rest <- go dbg (n+1) env ctxts
+ ; return (ctxt : rest) }
| otherwise
= go dbg n env ctxts -- need to compute this for zonking
=====================================
compiler/GHC/Tc/Utils/Unify.hs
=====================================
@@ -216,7 +216,7 @@ matchActualFunTy herald mb_thing err_info fun_ty
; return (co, arg_ty, res_ty) }
------------
- mk_ctxt :: TcType -> TidyEnv -> ZonkM (TidyEnv, ErrCtxtMsg)
+ mk_ctxt :: TcType -> ErrCtxtMsg
mk_ctxt _res_ty = mkFunTysMsg herald err_info
{- Note [matchActualFunTy error handling]
@@ -959,15 +959,13 @@ new_check_arg_ty herald arg_pos -- Position for error messages only, 1 for first
mkFunTysMsg :: CtOrigin
-> (VisArity, TcType)
- -> TidyEnv -> ZonkM (TidyEnv, ErrCtxtMsg)
+ -> ErrCtxtMsg
-- See Note [Reporting application arity errors]
-mkFunTysMsg herald (n_vis_args_in_call, fun_ty) env
- = do { (env', fun_ty) <- zonkTidyTcType env fun_ty
-
- ; let (pi_ty_bndrs, _) = splitPiTys fun_ty
+mkFunTysMsg herald (n_vis_args_in_call, fun_ty)
+ = do { let (pi_ty_bndrs, _) = splitPiTys fun_ty
n_fun_args = count isVisiblePiTyBinder pi_ty_bndrs
- ; return (env', FunTysCtxt herald fun_ty n_vis_args_in_call n_fun_args) }
+ ; FunTysCtxt herald fun_ty n_vis_args_in_call n_fun_args }
{- Note [Reporting application arity errors]
@@ -1524,15 +1522,9 @@ addSubTypeCtxt ty_actual ty_expected thing_inside
, isRhoExpTy ty_expected -- TypeEqOrigin stuff (added by the _NC functions)
= thing_inside -- gives enough context by itself
| otherwise
- = addErrCtxtM mk_msg thing_inside
- where
- mk_msg tidy_env
- = do { (tidy_env, ty_actual) <- zonkTidyTcType tidy_env ty_actual
- ; ty_expected <- readExpType ty_expected
- -- A worry: might not be filled if we're debugging. Ugh.
- ; (tidy_env, ty_expected) <- zonkTidyTcType tidy_env ty_expected
- ; return (tidy_env, SubTypeCtxt ty_expected ty_actual) }
-
+ = do ty_expected <- readExpType ty_expected
+ addErrCtxtM (SubTypeCtxt ty_expected ty_actual) $
+ thing_inside
---------------
tc_sub_type :: (TcType -> TcType -> TcM TcCoercionN) -- How to unify
=====================================
compiler/GHC/Tc/Validity.hs
=====================================
@@ -1182,7 +1182,7 @@ applying the instance decl would show up two uses of ?x. #8912.
checkValidTheta :: UserTypeCtxt -> ThetaType -> TcM ()
-- Assumes argument is fully zonked
checkValidTheta ctxt theta
- = addErrCtxtM (checkThetaCtxt ctxt theta) $
+ = addErrCtxtM (ThetaCtxt ctxt theta) $
do { env <- liftZonkM $ tcInitOpenTidyEnv (tyCoVarsOfTypesList theta)
; expand <- initialExpandMode
; check_valid_theta env ctxt expand theta }
@@ -1458,10 +1458,6 @@ Flexibility check:
generalized actually.
-}
-checkThetaCtxt :: UserTypeCtxt -> ThetaType -> TidyEnv -> ZonkM (TidyEnv, ErrCtxtMsg)
-checkThetaCtxt ctxt theta env
- = return (env, ThetaCtxt ctxt (tidyTypes env theta))
-
tyConArityErr :: TyCon -> [TcType] -> TcRnMessage
-- For type-constructor arity errors, be careful to report
-- the number of /visible/ arguments required and supplied,
=====================================
compiler/GHC/Unit/State.hs-boot
=====================================
@@ -4,4 +4,3 @@ data UnitState
data ModuleSuggestion
data ModuleOrigin
data UnusableUnit
-data UnitInfo
\ No newline at end of file
=====================================
compiler/GHC/Utils/Logger.hs
=====================================
@@ -82,10 +82,10 @@ where
import GHC.Prelude
import GHC.Driver.Flags
-import {-# SOURCE #-} GHC.Types.Error
- ( MessageClass (..), Severity (..), ResolvedDiagnosticReason, DiagnosticCode
- , mkLocMessageWarningGroups,getCaretDiagnostic)
-import GHC.Types.Error ()
+import GHC.Types.Error
+ ( MessageClass (..), Severity (..)
+ , mkLocMessageWarningGroups,getCaretDiagnostic )
+-- import GHC.Types.Error ()
import GHC.Types.SrcLoc
import qualified GHC.Utils.Ppr as Pretty
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eac620877dca51c9ba47e85e1a71f8d…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eac620877dca51c9ba47e85e1a71f8d…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/fendor/stack-annotation-ty] 91 commits: base: don't expose GHC.Num.{BigNat, Integer, Natural}
by Hannes Siebenhandl (@fendor) 13 Feb '26
by Hannes Siebenhandl (@fendor) 13 Feb '26
13 Feb '26
Hannes Siebenhandl pushed to branch wip/fendor/stack-annotation-ty at Glasgow Haskell Compiler / GHC
Commits:
30f442a9 by Teo Camarasu at 2026-01-20T13:57:26-05:00
base: don't expose GHC.Num.{BigNat, Integer, Natural}
We no longer expose GHC.Num.{BigNat, Integer, Natural} from base instead users should get these modules from ghc-bignum.
We make this change to insulate end users from changes to GHC's implementation of big numbers.
Implements CLC proposal 359: https://github.com/haskell/core-libraries-committee/issues/359
- - - - -
75a9053d by Teo Camarasu at 2026-01-20T13:58:07-05:00
base: deprecate GHC internals in GHC.Num
Implements CLC proposal: https://github.com/haskell/core-libraries-committee/issues/360
- - - - -
9534b032 by Andreas Klebinger at 2026-01-20T13:58:50-05:00
ghc-experimental: Update Changelog
I tried to reconstruct a high level overview of the changes and when
they were made since we introduced it.
Fixes #26506
Co-authored-by: Teo Camarasu <teofilcamarasu(a)gmail.com>
- - - - -
346f2f5a by Cheng Shao at 2026-01-20T13:59:30-05:00
hadrian: remove RTS options in ghc-in-ghci flavour
This patch removes the RTS options passed to ghc in ghc-in-ghci
flavour, to workaround command line argument handling issue in
hls/hie-boot that results in `-O64M` instead of `+RTS -O64M -RTS`
being passed to ghc. It's not a hadrian bug per se, since ghc's own
ghc-in-ghci multi repl works fine, but we should still make sure HLS
works. Closes #26801.
- - - - -
759fd15a by Andreas Klebinger at 2026-01-21T16:05:28-05:00
Don't build GHC with -Wcompat
Without bumping the boot compiler the warnings it produces are often not
actionable leading to pointless noise.
Fixes #26800
- - - - -
3172db94 by Torsten Schmits at 2026-01-21T16:06:11-05:00
Use the correct field of ModOrigin when formatting error message listing hidden reexports
- - - - -
485c12b2 by Cheng Shao at 2026-01-21T16:06:54-05:00
Revert "hadrian: handle findExecutable "" gracefully"
This reverts commit 1e5752f64a522c4025365856d92f78073a7b3bba. The
underlying issue has been fixed in
https://github.com/haskell/directory/commit/75828696e7145adc09179111a0d631b…
and present since 1.3.9.0, and hadrian directory lower bound is
1.3.9.0, so we can revert our own in house hack now.
- - - - -
5efb58dc by Cheng Shao at 2026-01-21T16:07:36-05:00
rts: fix typo in TICK_ALLOC_RTS
This patch fixes a typo in the `TICK_ALLOC_RTS` macro, the original
`bytes` argument was silently dropped. The Cmm code has its own
version of `TICK_ALLOC_RTS` not affected by this typo, it affected the
C RTS, and went unnoticed because the variable `n` happened to also be
available at its call site. But the number was incorrect. Also fixes
its call site since `WDS()` is not available in C.
- - - - -
c406ea69 by Cheng Shao at 2026-01-21T16:07:36-05:00
rts: remove broken & unused ALLOC_P_TICKY
This patch removes the `ALLOC_P_TICKY` macro from the rts, it's
unused, and its expanded code is already broken.
- - - - -
34a27e20 by Simon Peyton Jones at 2026-01-21T16:08:17-05:00
Make the implicit-parameter class have representational role
This MR addresses #26737, by making the built-in class IP
have a representational role for its second parameter.
See Note [IP: implicit parameter class] in
ghc-internal:GHC.Internal.Classes.IP
In fact, IP is (unfortunately, currently) exposed by
base:GHC.Base, so we ran a quick CLC proposal to
agree the change:
https://github.com/haskell/core-libraries-committee/issues/385
Some (small) compilations get faster because they only need to
load (small) interface file GHC.Internal.Classes.IP.hi,
rather than (large) GHC.Internal.Classes.hi.
Metric Decrease:
T10421
T12150
T12425
T24582
T5837
T5030
- - - - -
ca79475f by Cheng Shao at 2026-01-21T16:09:00-05:00
testsuite: avoid re.sub in favor of simple string replacements
This patch refactors the testsuite driver and avoids the usage of
re.sub in favor of simple string replacements when possible. The
changes are not comprehensive, and there are still a lot of re.sub
usages lingering around the tree, but this already addresses a major
performance bottleneck in the testsuite driver that might has to do
with quadratic or worse slowdown in cpython's regular expression
engine when handling certain regex patterns with large strings.
Especially on i386, and i386 jobs are the bottlenecks of all full-ci
validate pipelines!
Here are the elapsed times of testing x86_64/i386 with -j48 before
this patch:
x86_64: `Build completed in 6m06s`
i386: `Build completed in 1h36m`
And with this patch:
x86_64: `Build completed in 4m55s`
i386: `Build completed in 4m23s`
Fixes #26786.
Co-authored-by: Codex <codex(a)openai.com>
- - - - -
88c93796 by Zubin Duggal at 2026-01-21T16:09:42-05:00
ghc-toolchain: Also configure windres on non-windows platforms.
It may be needed for cross compilation.
Fixes #24588
- - - - -
9788c0ec by Cheng Shao at 2026-01-21T16:10:24-05:00
ghci: print external interpreter trace messages to stderr instead of stdout
This patch makes ghci print external interpreter trace messages to
stderr instead of stdout, which is a much saner choice for diagnostic
information. Closes #26807.
- - - - -
0491f08a by Sylvain Henry at 2026-01-22T03:44:26-05:00
GC: don't use CAS without PARALLEL_GC on
If we're not using the parallel GC, there is no reason to do a costly
CAS. This was flagged as taking time in a perf profile.
- - - - -
211a8f56 by Sylvain Henry at 2026-01-22T03:44:26-05:00
GC: suffix parallel GC with "par" instead of "thr"
Avoid some potential confusion (see discussion in !15351).
- - - - -
77a23cbd by fendor at 2026-01-22T03:45:08-05:00
Remove blanket ignore that covers libraries/
- - - - -
18bf7f5c by Léana Jiang at 2026-01-22T08:58:45-05:00
doc: update Flavour type in hadrian user-settings
- - - - -
3d5a1365 by Cheng Shao at 2026-01-22T08:59:28-05:00
hadrian: add missing notCross predicate for stage0 -O0
There are a few hard-coded hadrian args that pass -O0 when compiling
some heavy modules in stage0, which only makes sense when not
cross-compiling and when cross-compiling we need properly optimized
stage0 packages. So this patch adds the missing `notCross` predicate
in those places.
- - - - -
ee937134 by Matthew Pickering at 2026-01-22T09:00:10-05:00
Fix ghc-experimental GHC.Exception.Backtrace.Experimental module
This module wasn't added to the cabal file so it was never compiled or
included in the library.
- - - - -
1b490f5a by Zubin Duggal at 2026-01-22T09:00:53-05:00
hadrian: Add ghc-{experimental,internal}.cabal to the list of dependencies of the doc target
We need these files to detect the version of these libraries
Fixes #26738
- - - - -
cdb74049 by Cheng Shao at 2026-01-22T14:52:36-05:00
rts: avoid Cmm loop to initialize Array#/SmallArray#
Previously, `newArray#`/`newSmallArray#` called an RTS C function to
allocate the `Array#`/`SmallArray#`, then used a Cmm loop to
initialize the elements. Cmm doesn't have native for-loop so the code
is a bit awkward, and it's less efficient than a C loop, since the C
compiler can effectively vectorize the loop with optimizations.
So this patch moves the loop that initializes the elements to the C
side. `allocateMutArrPtrs`/`allocateSmallMutArrPtrs` now takes a new
`init` argument and initializes the elements if `init` is non-NULL.
- - - - -
4c784f00 by Cheng Shao at 2026-01-22T14:53:19-05:00
Fix testsuite run for +ipe flavour transformer
This patch makes the +ipe flavour transformer pass the entire
testsuite:
- An RTS debug option `-DI` is added, the IPE trace information is now
only printed with `-DI`. The test cases that do require IPE trace
are now run with `-DI`.
- The testsuite config option `ghc_with_ipe` is added, enabled when
running the testsuite with `+ipe`, which skips a few tests that are
sensitive to eventlog output, allocation patterns etc that can fail
under `+ipe`.
This is the first step towards #26799.
Co-authored-by: Codex <codex(a)openai.com>
- - - - -
be8e5236 by Ben Gamari at 2026-01-23T03:28:45-05:00
hadrian: Bump QuickCheck upper bound
This patch bumps QuickCheck upper bound to 2.18. selftest rule
manually tested to work with current latest QuickCheck-2.17.1.0.
- - - - -
5aa328fb by Zubin Duggal at 2026-01-23T03:29:30-05:00
Add genindex to index.rst. This adds a link to the index in the navigation bar.
Fixes #26437
- - - - -
917ab8ff by Oleg Grenrus at 2026-01-23T10:52:55-05:00
Export labelThread from Control.Concurrent
- - - - -
3f5e8d80 by Cheng Shao at 2026-01-23T10:53:37-05:00
ci: only push perf notes on master/release branches
This patch fixes push_perf_notes logic in ci.sh to only push perf
notes on master/release branches. We used to unconditionally push perf
notes even in MRs, but the perf numbers in the wip branches wouldn't
be used as baseline anyway, plus this is causing a space leak in the
ghc-performance-notes repo. See #25317 for the perf notes repo size
problem.
Co-authored-by: Codex <codex(a)openai.com>
- - - - -
414b9593 by Cheng Shao at 2026-01-24T07:11:51-05:00
ci: remove duplicate keys in .gitlab-ci.yml
This patch removes accidentally duplicate keys in `.gitlab-ci.yml`.
The YAML spec doesn't allow duplicate keys in the first place, and
according to GitLab docs
(https://docs.gitlab.com/ci/yaml/yaml_optimization/#anchors) the
latest key overrides the earlier entries.
- - - - -
e5cb5491 by Cheng Shao at 2026-01-24T07:12:34-05:00
hadrian: drop obsolete configure/make builder logic for libffi
This patch drops obsolete hadrian logic around `Configure
libffiPath`/`Make libffiPath` builders, they are no longer needed
after libffi-clib has landed. Closes #26815.
- - - - -
2d160222 by Simon Hengel at 2026-01-24T07:13:17-05:00
Fix typo in roles.rst
- - - - -
56db94f7 by Peter Trommler at 2026-01-26T11:26:18+01:00
PPC NCG: Generate clear right insn at arch width
The clear right immediate (clrrxi) is only available in word and
doubleword width. Generate clrrxi instructions at architecture
width for all MachOp widths.
Fixes #24145
- - - - -
5957a8ad by Wolfgang Jeltsch at 2026-01-27T06:11:40-05:00
Add operations for obtaining operating-system handles
This contribution implements CLC proposal #369. It adds operations for
obtaining POSIX file descriptors and Windows handles that underlie
Haskell handles. Those operating system handles can also be obtained
without such additional operations, but this is more involved and, more
importantly, requires using internals.
- - - - -
86a0510c by Greg Steuck at 2026-01-27T06:12:34-05:00
Move flags to precede patterns for grep and read files directly
This makes the tests pass with non-GNU (i.e. POSIX-complicant) tools.
There's no reason to use cat and pipe where direct file argument works.
- - - - -
50761451 by Cheng Shao at 2026-01-27T21:51:23-05:00
ci: update darwin boot ghc to 9.10.3
This patch updates darwin boot ghc to 9.10.3, along with other related
updates, and pays off some technical debt here:
- Update `nixpkgs` and use the `nixpkgs-25.05-darwin` channel.
- Update the `niv` template.
- Update LLVM to 21 and update `llvm-targets` to reflect LLVM 21
layout changes for arm64/x86_64 darwin targets.
- Use `stdenvNoCC` to prevent nix packaged apple sdk from being used
by boot ghc, and manually set `DEVELOPER_DIR`/`SDKROOT` to enforce
the usage of system-wide command line sdk for macos.
- When building nix derivation for boot ghc, run `configure` via the
`arch` command so that `configure` and its subprocesses pick up the
manually specified architecture.
- Remove the previous horrible hack that obliterates `configure` to
make autoconf test result in true. `configure` now properly does its
job.
- Remove the now obsolete configure args and post install settings
file patching logic.
- Use `scheme-small` for texlive to avoid build failures in certain
unused texlive packages, especially on x86_64-darwin.
- - - - -
94dcd15e by Matthew Pickering at 2026-01-27T21:52:05-05:00
Evaluate backtraces for "error" exceptions at the moment they are thrown
See Note [Capturing the backtrace in throw] and
Note [Hiding precise exception signature in throw] which explain the
implementation.
This commit makes `error` and `throw` behave the same with regard to
backtraces. Previously, exceptions raised by `error` would not contain
useful IPE backtraces.
I did try and implement `error` in terms of `throw` but it started to
involve putting diverging functions into hs-boot files, which seemed to
risky if the compiler wouldn't be able to see if applying a function
would diverge.
CLC proposal: https://github.com/haskell/core-libraries-committee/issues/383
Fixes #26751
- - - - -
ef35e3ea by Teo Camarasu at 2026-01-27T21:52:46-05:00
ghc-internal: move all Data instances to Data.Data
Most instances of Data are defined in GHC.Internal.Data.Data.
Let's move all remaining instance there.
This moves other modules down in the dependency hierarchy allowing for
more parallelism, and it decreases the likelihood that we would need to
load this heavy .hi file if we don't actually need it.
Resolves #26830
Metric Decrease:
T12227
T16875
- - - - -
5e0ec555 by sheaf at 2026-01-28T06:56:38-05:00
Add test case for #25679
This commit adds the T25679 test case. The test now passes, thanks to
commit 1e53277af36d3f0b6ad5491f70ffc5593a49dcfd.
Fixes #25679
- - - - -
f1cd1611 by sheaf at 2026-01-28T06:56:38-05:00
Improve defaulting of representational equalities
This commit makes the defaulting of representational equalities, introduced
in 1e53277a, a little bit more robust. Now, instead of calling the eager
unifier, it calls the full-blown constraint solver, which means that it can
handle some subtle situations, e.g. involving functional dependencies and
type-family injectivity annotations, such as:
type family F a = r | r -> a
type instance F Int = Bool
[W] F beta ~R Bool
- - - - -
25edf516 by sheaf at 2026-01-28T06:56:38-05:00
Improve errors for unsolved representational equalities
This commit adds a new field of CtLoc, CtExplanations, which allows the
typechecker to leave some information about what it has done. For the moment,
it is only used to improve error messages for unsolved representational
equalities. The typechecker will now accumulate, when unifying at
representational role:
- out-of-scope newtype constructors,
- type constructors that have nominal role in a certain argument,
- over-saturated type constructors,
- AppTys, e.g. `c a ~R# c b`, to report that we must assume that 'c' has
nominal role in its parameters,
- data family applications that do not reduce, potentially preventing
newtype unwrapping.
Now, instead of having to re-construct the possible errors after the fact,
we simply consult the CtExplanations field.
Additionally, this commit modifies the typechecker error messages that
concern out-of-scope newtype constructors. The error message now depends
on whether we have an import suggestion to provide to the user:
- If we have an import suggestion for the newtype constructor,
the message will be of the form:
The data constructor MkN of the newtype N is out of scope
Suggested fix: add 'MkN' to the import list in the import of 'M'
- If we don't have any import suggestions, the message will be
of the form:
NB: The type 'N' is an opaque newtype, whose constructor is hidden
Fixes #15850, #20289, #20468, #23731, #25949, #26137
- - - - -
4d0e6da1 by Simon Peyton Jones at 2026-01-28T06:57:19-05:00
Fix two bugs in short-cut constraint solving
There are two main changes here:
* Use `isSolvedWC` rather than `isEmptyWC` in `tryShortCutSolver`
The residual constraint may have some fully-solved, but
still-there implications, and we don't want them to abort short
cut solving! That bug caused #26805.
* In the short-cut solver, we abandon the fully-solved residual
constraint; but we may thereby lose track of Givens that are
needed, and either report them as redundant or prune evidence
bindings that are in fact needed.
This bug stopped the `constraints` package from compiling;
see the trail in !15389.
The second bug led me to (another) significant refactoring
of the mechanism for tracking needed EvIds. See the new
Note [Tracking needed EvIds] in GHC.Tc.Solver.Solve
It's simpler and much less head-scratchy now.
Some particulars:
* An EvBindsVar now tracks NeededEvIds
* We deal with NeededEvIds for an implication only when it is
fully solved. Much simpler!
* `tryShortCutTcS` now takes a `TcM WantedConstraints` rather than
`TcM Bool`, so that is can plumb the needed EvIds correctly.
* Remove `ic_need` and `ic_need_implic` from Implication (hooray),
and add `ics_dm` and `ics_non_dm` to `IC_Solved`.
Pure refactor
* Shorten data constructor `CoercionHole` to `CH`, following
general practice in GHC.
* Rename `EvBindMap` to `EvBindsMap` for consistency
- - - - -
662480b7 by Cheng Shao at 2026-01-28T06:58:00-05:00
ci: use debian validate bindists instead of fedora release bindists in testing stage
This patch changes the `abi-test`, `hadrian-multi` and `perf` jobs in
the full-ci pipeline testing stage to use debian validate bindists
instead of fedora release bindists, to increase pipeline level
parallelism and allow full-ci pipelines to complete earlier. Closes #26818.
- - - - -
39581ec6 by Cheng Shao at 2026-01-28T06:58:40-05:00
ci: run perf test with -j$cores
This patch makes the perf ci job compile Cabal with -j$cores to speed
up the job.
- - - - -
607b287b by Wolfgang Jeltsch at 2026-01-28T15:41:53+02:00
Remove `GHC.Desugar` from `base`
`GHC.Desugar` was deprecated and should have been removed in GHC 9.14.
However, the removal was forgotten, although there was a code block that
was intended to trigger a compilation error when the GHC version in use
was 9.14 or later. This code sadly didn’t work, because the
`__GLASGOW_HASKELL__` macro was misspelled as `__GLASGOW_HASKELL`.
- - - - -
e8f5a45d by sterni at 2026-01-29T04:19:18-05:00
users_guide: fix runtime error during build with Sphinx 9.1.0
Appears that pathto is stricter about what it accepts now.
Tested Sphinx 8.2.3 and 9.1.0 on the ghc-9.10 branch.
Resolves #26810.
Co-authored-by: Martin Weinelt <hexa(a)darmstadt.ccc.de>
- - - - -
ce2d62fb by Jessica Clarke at 2026-01-29T19:48:51-05:00
PPC NCG: Use libcall for 64-bit cmpxchg on 32-bit PowerPC
There is no native instruction for this, and even if there were a
register pair version we could use, the implementation here is assuming
the values fit in a single register, and we end up only using / defining
the low halves of the registers.
Fixes: b4d39adbb5 ("PrimOps: Add CAS op for all int sizes")
Fixes: #23969
- - - - -
43d97761 by Michael Karcher at 2026-01-29T19:49:43-05:00
NCG for PPC: add pattern for CmmRegOff to iselExpr64
Closes #26828
- - - - -
aeeb4a20 by Matthew Pickering at 2026-01-30T11:42:47-05:00
determinism: Use deterministic map for Strings in TyLitMap
When generating typeable evidence the types we need evidence for all
cached in a TypeMap, the order terms are retrieved from a type map
determines the order the bindings appear in the program.
A TypeMap is quite diligent to use deterministic maps, apart from in the
TyLitMap, which uses a UniqFM for storing strings, whose ordering
depends on the Unique of the FastString.
This can cause non-deterministic .hi and .o files.
An unexpected side-effect is the error message but RecordDotSyntaxFail8
changing. I looked into this with Sam and this change caused the
constraints to be solved in a different order which results in a
slightly different error message. I have accepted the new test, since
the output before was non-deterministic and the new output is consistent
with the other messages in that file.
Fixes #26846
- - - - -
9e4d70c2 by Andrew Lelechenko at 2026-01-30T11:43:29-05:00
Upgrade text submodule to 2.1.4
- - - - -
631fa5ae by Recursion Ninja at 2026-01-31T22:30:11+00:00
Decouple `L.S.H.Decls` from importing `GHC.Types.Basic`
Data-types within `GHC.Types.Basic` which describe components of
the AST are migrated to `Language.Haskell.Syntax.Basic`. Related
function definitions are also moved.
Types moved to L.H.S. because they are part of the AST:
* TopLevelFlag
* RuleName
Types moved from L.H.S. to GHC.Hs. because they are not needed in the AST:
* TyConFlavour
* TypeOrData
* NewOrData
Migrated instances:
* `Outputable` instances moved to in `GHC.Utils.Outputable`
* `Binary` instance of `Boxity` moved to to `GHC.Utils.Binary`
* Other `Binary` instances are orphans to be migrated later.
The `OverlapMode` data-type is given a TTG extension point.
The `OverlapFlag` data-type, which depends on `OverlapMode`,
is updated to support `OverlapMode` with a GHC "pass" type paramerter.
In order to avoid module import cycles, `OverlapMode` and `OverlapFlag`
are migrated to new modules (no way around this).
* Migrated `OverlapMode` to new module `Language.Haskell.Syntax.Overlap`
* Migrated `OverlapFlag` to new module `GHC.Hs.Decls.Overlap`
- - - - -
9769cc03 by Simon Hengel at 2026-02-01T04:21:03-05:00
Update the documentation for MultiWayIf (fixes #25376)
(so that it matches the implementation)
- - - - -
5fc9442a by Peter Trommler at 2026-02-01T04:21:44-05:00
hadrian: Fix dependency generation for assembler
Assembler files allow # for comments unless in column 1. A modern
cpp for C treats those a preprocessor directives. We tell gcc that
a .S file is assembler with cpp and not C.
Fixes #26819
- - - - -
269c4087 by Simon Peyton Jones at 2026-02-01T19:38:10-05:00
Include current phase in the range for rule/unfoldings
This MR fixes a bad loop in the compiler: #26826.
The fix is to add (WAR2) to
Note [What is active in the RHS of a RULE or unfolding?]
in GHC.Core.Opt.Simplify.Utils
- - - - -
ddf1434f by Vladislav Zavialov at 2026-02-01T19:38:52-05:00
Refactor: merge HsMultilineString into HsString (#26860)
Before this patch, HsLit defined two separate constructors to represent
single-line and multi-line strings:
data HsLit x
...
| HsString (XHsString x) FastString
| HsMultilineString (XHsMultilineString x) FastString
I found this to be an unnecessary complication and an obstacle to unifying
HsLit with HsTyLit. Now we use HsString for both kinds of literals.
One user-facing change here is `ppr (HsString st s)` behaving differently for
single-line strings containing newlines:
x = "first line \
\asdf\n\
\second line"
Previously, the literal was fed to `ftext` with its newlines, producing an
ill-formed SDoc. This issue is now addressed by using `split` for both
single-line and multi-line strings:
vcat $ map text $ split '\n' (unpackFS src)
See the parser/should_fail/T26860ppr test.
In addition (and unrelatedly to the main payload of this patch),
drop the unused pmPprHsLit helper.
- - - - -
2b4f463c by Simon Peyton Jones at 2026-02-02T17:32:32+00:00
Remove exprIsCheap from doFloatFromRhs
See #26854 and Note [Float when expandable]
This patch simplifies the code, by removing an extra unnecessary test.
- - - - -
9db7f21f by Brandon Chinn at 2026-02-03T09:15:10-05:00
Refactor: make function patterns exhaustive
Also added missing (==) logic for:
* HsMultilineString
* HsInt{8,16,32}
* HsWord{8,16,32}
- - - - -
aa9c5e2c by Hécate Kleidukos at 2026-02-03T15:58:35-05:00
driver: Hide source paths at verbosity level 1 by default
- - - - -
c64cca1e by mangoiv at 2026-02-03T15:59:29-05:00
ExplicitLevelImports: check staging for types just like for values
Previously, imported types were entirely exempted from staging checks as
the implicit stage persistance assumed to be all imported types to be
well staged. ExplicitLevelImports' change specification, however, does
not do such an exemption. Thus we want to introduce such a check, just
like we have for values.
ExplicitLevelImports does not, however, talk about local names - from
its perspective, we could theoretically keep treating locally introduced
types specially - e.g. an ill-staged used in a quote would only emit a
warning, not an error. To allow for a potential future migration away
from such wrinkles as the staging check in notFound
(see Note [Out of scope might be a staging error]) we consistently do
the strict staging check that we also do for value if ExplicitLevelImports
is on.
Closes #26098
- - - - -
5f0dbeb6 by Simon Hengel at 2026-02-03T16:00:12-05:00
Use Haddock formatting in deprecation message of `initNameCache`
- - - - -
01ecb612 by Andreas Klebinger at 2026-02-04T09:56:25-05:00
testsuite: Explicitly use utf-8 encoding in rts-includes linter.
Not doing so caused failures on windows, as python failed to pick a
reasonable encoding even with locale set.
Fixes #26850
- - - - -
ea0d1317 by Zubin Duggal at 2026-02-04T09:57:06-05:00
Bump transformers submodule to 0.6.3.0
Fixes #26790
- - - - -
cbe4300e by Simon Peyton Jones at 2026-02-05T04:31:04-05:00
Fix subtle bug in GHC.Core.Utils.mkTick
This patch fixes a decade-old bug in `mkTick`, which
could generate type-incorrect code! See the diagnosis
in #26772.
The new code is simpler and easier to understand.
(As #26772 says, I think it could be improved further.)
- - - - -
a193a8da by Simon Peyton Jones at 2026-02-05T04:31:04-05:00
Modify a debug-trace in the Simplifier
...just to show a bit more information.
- - - - -
b579dfdc by Simon Peyton Jones at 2026-02-05T04:31:04-05:00
Fix long-standing interaction between ticks and casts
The code for Note [Eliminate Identity Cases] was simply wrong when
ticks and casts interacted. This patch fixes the interaction.
It was shown up when validating #26772, although it's not the exactly
the bug that's reported by #26772. Nor is it easy to reproduce, hence
no regression test.
- - - - -
fac0de1e by Cheng Shao at 2026-02-05T04:31:49-05:00
libraries: bump Cabal submodule to 3.16.1.0
- - - - -
00589122 by Cheng Shao at 2026-02-05T04:31:49-05:00
libraries: bump deepseq submodule to 1.5.2.0
Also:
- Get rid of usage of deprecated `NFData` function instance in the
compiler
- `T21391` still relies on `NFData` function instance, add
`-Wno-deprecations` for the time being.
- - - - -
84474c71 by Cheng Shao at 2026-02-05T04:31:50-05:00
libraries: bump directory submodule to 1.3.10.1
- - - - -
1a9f4662 by Cheng Shao at 2026-02-05T04:31:50-05:00
libraries: bump exceptions submodule to 0.10.12
- - - - -
2e39a340 by Peng Fan at 2026-02-07T03:42:01-05:00
NCG/LA64: adjust register usage to avoid src-register being clobbered
- - - - -
9faf1b35 by Teo Camarasu at 2026-02-07T03:42:43-05:00
ghc-internal: Delete unnecessary GHC.Internal.Data.Ix
This module merely re-exports GHC.Internal.Ix. It was copied from
`base` when `ghc-internal` was split, but there is no reason to have
this now. So, let's delete it.
Resolves #26848
- - - - -
d112b440 by Sven Tennie at 2026-02-07T10:47:56-05:00
Add cabal.project file to generate-ci
This fixes the HLS setup for our CI code generation script
(generate-ci).
The project file simply makes `generate-ci` of the cabal file
discoverable.
- - - - -
5339f6f0 by Andreas Klebinger at 2026-02-07T10:48:40-05:00
CI: Don't collapse test results.
This puts test output back into the primary test log instead of a
subsection removing the need to expand a section to see test results.
While the intention was good in practice the old behaviour mostly wastes time
by requiring expansion of the section.
Fixes #26882
- - - - -
0e1cd2e0 by Evan Piro at 2026-02-08T10:35:16-08:00
Linker.MacOS reduce dynflags import
- - - - -
1c79a4cd by Michael Alan Dorman at 2026-02-09T08:11:51-05:00
Remove `extra_src_files` variable from `testsuite/driver/testlib.py`
While reading through the test harness code, I noticed this variable
with a TODO attached that referenced #12223. Although that bug is
closed, it strongly implied that this special-case variable that only
affected a single test was expected to be removed at some point.
I also looked at 3415bcaa0b1903b5e12dfaadb5b774718e406eab---where it
was added---whose commit message suggested that it would have been
desirable to remove it, but that there were special circumstances that
meant it had to remain (though it doesn't elucidate what those special
circumstances are).
However, the special circumstances were mentioned as if the test was
in a different location than is currently is, so I decided to try
changing the test to use the standard `extra_files` mechanism, which
works in local testing.
This also seems like a reasonable time to remove the script that was
originally used in the transition, since it doesn't really serve a
purpose anymore.
- - - - -
0020e38a by Matthew Pickering at 2026-02-09T17:29:14-05:00
determinism: Use a stable sort in WithHsDocIdentifiers binary instance
`WithHsDocIdentifiers` is defined as
```
71 data WithHsDocIdentifiers a pass = WithHsDocIdentifiers
72 { hsDocString :: !a
73 , hsDocIdentifiers :: ![Located (IdP pass)]
74 }
```
This list of names is populated from `rnHsDocIdentifiers`, which calls
`lookupGRE`, which calls `lookupOccEnv_AllNameSpaces`, which calls
`nonDetEltsUFM` and returns the results in an order depending on
uniques.
Sorting the list with a stable sort before returning the interface makes
the output deterministic and follows the approach taken by other fields
in `Docs`.
Fixes #26858
- - - - -
89898ce6 by echoumcp1 at 2026-02-09T17:30:01-05:00
Replace putstrln with logMsg in handleSeqHValueStatus
Fixes #26549
- - - - -
7c52c4f9 by John Paul Adrian Glaubitz at 2026-02-10T13:52:43-05:00
rts: Switch prim to use modern atomic compiler builtins
The __sync_*() atomic compiler builtins have been deprecated in GCC
for a while now and also don't provide variants for 64-bit values
such as __sync_fetch_and_add_8().
Thus, replace them with the modern __atomic_*() compiler builtins and
while we're at it, also drop the helper macro CAS_NAND() which is now
no longer needed since we stopped using the __sync_*() compiler builtins
altogether.
Co-authored-by: Ilias Tsitsimpis <iliastsi(a)debian.org>
Fixes #26729
- - - - -
cf60850a by Recursion Ninja at 2026-02-10T13:53:27-05:00
Decoupling L.H.S.Decls from GHC.Types.ForeignCall
- Adding TTG extension point for 'CCallTarget'
- Adding TTG extension point for 'CType'
- Adding TTG extension point for 'Header'
- Moving ForeignCall types that do not need extension
to new L.H.S.Decls.Foreign module
- Replacing 'Bool' parameters with descriptive data-types
to increase clairty and prevent "Boolean Blindness"
- - - - -
11a04cbb by Eric Lee at 2026-02-11T09:20:46-05:00
Derive Semigroup/Monoid for instances believed could be derived in #25871
- - - - -
15d9ce44 by Eric Lee at 2026-02-11T09:20:46-05:00
add Ghc.Data.Pair deriving
- - - - -
c85dc170 by Evan Piro at 2026-02-11T09:21:45-05:00
Linker.MacOS reduce options import
- - - - -
a541dd83 by Chris Wendt at 2026-02-11T16:06:41-05:00
Initialize plugins for `:set +c` in GHCi
Fixes #23110.
- - - - -
0f5a73bc by Cheng Shao at 2026-02-11T16:07:27-05:00
compiler: add Binary Text instance
This patch adds `Binary` instance for strict `Text`, in preparation of
making `Text` usable in certain GHC API use cases (e.g. haddock). This
also introduces `text` as a direct dependency of the `ghc` package.
- - - - -
9e58b8a1 by Cheng Shao at 2026-02-11T16:08:10-05:00
ghc-toolchain: add C11 check
This patch partially reverts commit
b8307eab80c5809df5405d76c822bf86877f5960 that removed C99 check in
autoconf/ghc-toolchain. Now we:
- No longer re-implement `FP_SET_CFLAGS_C11` similar to
`FP_SET_CFLAGS_C99` in the past, since autoconf doesn't provide a
convenient `AC_PROG_CC_C11` function. ghc-toolchain will handle it
anyway.
- The Cmm CPP C99 check is relanded and repurposed for C11.
- The C99 logic in ghc-toolchain is relanded and repurposed for C11.
- The C99 check in Stg.h is corrected to check for C11. The obsolete
_ISOC99_SOURCE trick is dropped.
- Usages of `-std=gnu99` in the testsuite are corrected to use
`-std=gnu11`.
Closes #26908.
- - - - -
4df0adf6 by Simon Peyton Jones at 2026-02-11T21:50:13-05:00
Simplify the treatment of static forms
This MR implements GHC proposal 732: simplify static forms,
https://github.com/ghc-proposals/ghc-proposals/pull/732
thereby addressing #26556.
See `Note [Grand plan for static forms]` in GHC.Iface.Tidy.StaticPtrTable
The main changes are:
* There is a new, simple rule for (static e), namely that the free
term variables of `e` must be bound at top level. The check is
done in the `HsStatic` case of `GHC.Rename.Expr.rnExpr`
* That in turn substantially simplifies the info that the typechecker
carries around in its type environment. Hooray.
* The desugarer emits static bindings to top level directly; see the
`HsStatic` case of `dsExpr`.
* There is no longer any special static-related magic in the FloatOut
pass. And the main Simplifier pipeline no longer needs a special case
to run FloatOut even with -O0. Hooray.
All this forced an unexpected change to the pattern match checker. It
recursively invokes the main Hs desugarer when it wants to take a look
at a term to spot some special cases (notably constructor applications).
We don't want to emit any nested (static e) bindings to top level a
second time! Yikes.
That forced a modest refactor in GHC.HsToCore.Pmc:
* The `dsl_nablas` field of `DsLclEnv` now has a `NoPmc` case, which says
"I'm desugaring just for pattern-match checking purposes".
* When that flag is set we don't emit static binds.
That in turn forces a cascade of refactoring, but the net effect is an
improvement; less risk of duplicated (even exponential?) work.
See Note [Desugaring HsExpr during pattern-match checking].
10% metric decrease, on some architectures, of compile-time max-bytes-used on T15304.
Metric Decrease:
T15304
- - - - -
7922f728 by Teo Camarasu at 2026-02-11T21:50:58-05:00
ghc-internal: avoid depending on GHC.Internal.Exts
This module is mostly just re-exports. It made sense as a user-facing
module, but there's no good reason ghc-internal modules should depend on
it and doing so linearises the module graph
- move considerAccessible to GHC.Internal.Magic
Previously it lived in GHC.Internal.Exts, but it really deserves to live
along with the other magic function, which are already re-exported from .Exts
- move maxTupleSize to GHC.Internal.Tuple
This previously lived in GHC.Internal.Exts but a comment already said it
should be moved to .Tuple
Resolves #26832
- - - - -
b6a4a29b by Eric Lee at 2026-02-11T21:51:55-05:00
Remove unused Semigroup imports to fix GHC 9.14 bootstrapping
- - - - -
99d8c146 by Simon Peyton Jones at 2026-02-12T17:36:59+00:00
Fix subtle bug in cast worker/wrapper
See (CWw4) in Note [Cast worker/wrapper].
The true payload is in the change to the definition of
GHC.Types.Id.Info.hasInlineUnfolding
Everthing else is just documentation.
There is a 2% compile time decrease for T13056;
I'll take the win!
Metric Decrease:
T13056
- - - - -
530e8e58 by Simon Peyton Jones at 2026-02-12T20:17:23-05:00
Add regression tests for four StaticPtr bugs
Tickets #26545, #24464, #24773, #16981 are all solved by the
recently-landed MR
commit 318ee13bcffa6aa8df42ba442ccd92aa0f7e210c
Author: Simon Peyton Jones <simon.peytonjones(a)gmail.com>
Date: Mon Oct 20 23:07:20 2025 +0100
Simplify the treatment of static forms
This MR just adds regression tests for them.
- - - - -
4157160f by Cheng Shao at 2026-02-13T06:27:04-05:00
ci: remove unused hlint-ghc-and-base job definition
This patch removes the unused `hlint-ghc-and-base` job definition,
it's never run since !9806. Note that hadrian lint rules still work
locally, so anyone that wishes to run hlint on the codebase can
continue to do so in their local worktree.
- - - - -
039f1977 by Cheng Shao at 2026-02-13T06:27:47-05:00
wasm: use import.meta.main for proper distinction of nodejs main modules
This patch uses `import.meta.main` for proper distinction of nodejs
main modules, especially when the main module might be installed as a
symlink. Fixes #26916.
- - - - -
12b99c69 by fendor at 2026-02-13T16:27:08+01:00
Add regression tests for #26806
- - - - -
7b53243c by fendor at 2026-02-13T17:18:31+01:00
Add optional `SrcLoc` to `StackAnnotation` class
`StackAnnotation` give access to an optional `SrcLoc` field that
stack annotations can use to provide better backtraces in both error
messages and when decoding the callstack.
We update builtin stack annotations such as `StringAnnotation` and
`ShowAnnotation` to also capture the `SrcLoc` of the current `CallStack`
to improve backtraces by default (if stack annotations are used).
This change is backwards compatible with GHC 9.14.1.
- - - - -
453 changed files:
- .gitignore
- .gitlab-ci.yml
- .gitlab/ci.sh
- .gitlab/darwin/nix/sources.json
- .gitlab/darwin/toolchain.nix
- + .gitlab/generate-ci/cabal.project
- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Builtin/Types.hs
- compiler/GHC/CmmToAsm/LA64/CodeGen.hs
- compiler/GHC/CmmToAsm/PPC/CodeGen.hs
- compiler/GHC/CmmToAsm/X86/CodeGen.hs
- compiler/GHC/CmmToLlvm/CodeGen.hs
- compiler/GHC/Core/Coercion.hs
- compiler/GHC/Core/FamInstEnv.hs
- compiler/GHC/Core/InstEnv.hs
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Map/Type.hs
- compiler/GHC/Core/Opt/OccurAnal.hs
- compiler/GHC/Core/Opt/Pipeline.hs
- compiler/GHC/Core/Opt/SetLevels.hs
- compiler/GHC/Core/Opt/Simplify/Env.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/Opt/WorkWrap.hs
- compiler/GHC/Core/Predicate.hs
- compiler/GHC/Core/TyCo/Rep.hs
- compiler/GHC/Core/TyCo/Subst.hs
- compiler/GHC/Core/TyCo/Tidy.hs
- compiler/GHC/Core/TyCon.hs
- compiler/GHC/Core/TyCon/RecWalk.hs
- compiler/GHC/Core/Utils.hs
- compiler/GHC/CoreToStg.hs
- compiler/GHC/CoreToStg/AddImplicitBinds.hs
- compiler/GHC/Data/Maybe.hs
- compiler/GHC/Data/Pair.hs
- compiler/GHC/Driver/Config/Core/Lint.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Hs/Binds.hs
- compiler/GHC/Hs/Decls.hs
- + compiler/GHC/Hs/Decls/Overlap.hs
- compiler/GHC/Hs/Doc.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/Hs/Lit.hs
- compiler/GHC/Hs/Syn/Type.hs
- compiler/GHC/Hs/Type.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore.hs
- compiler/GHC/HsToCore/Docs.hs
- compiler/GHC/HsToCore/Errors/Types.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/HsToCore/Foreign/C.hs
- compiler/GHC/HsToCore/Foreign/Call.hs
- compiler/GHC/HsToCore/Foreign/Decl.hs
- compiler/GHC/HsToCore/Foreign/JavaScript.hs
- compiler/GHC/HsToCore/Foreign/Utils.hs
- compiler/GHC/HsToCore/Foreign/Wasm.hs
- compiler/GHC/HsToCore/GuardedRHSs.hs
- compiler/GHC/HsToCore/Match.hs
- compiler/GHC/HsToCore/Match/Literal.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/Pmc.hs
- compiler/GHC/HsToCore/Pmc/Desugar.hs
- compiler/GHC/HsToCore/Pmc/Solver.hs
- compiler/GHC/HsToCore/Pmc/Solver/Types.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/HsToCore/Ticks.hs
- compiler/GHC/HsToCore/Types.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Iface/Tidy.hs
- compiler/GHC/Iface/Tidy/StaticPtrTable.hs
- compiler/GHC/Linker/MacOS.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Parser/PostProcess/Haddock.hs
- compiler/GHC/Parser/String.hs
- compiler/GHC/Rename/Bind.hs
- compiler/GHC/Rename/Env.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/HsType.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Splice.hs
- compiler/GHC/Rename/Splice.hs-boot
- compiler/GHC/Rename/Unbound.hs
- compiler/GHC/Runtime/Heap/Inspect.hs
- compiler/GHC/Runtime/Interpreter.hs
- compiler/GHC/StgToByteCode.hs
- compiler/GHC/StgToCmm/Foreign.hs
- compiler/GHC/StgToJS/FFI.hs
- compiler/GHC/Tc/Deriv.hs
- compiler/GHC/Tc/Deriv/Utils.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/Bind.hs
- compiler/GHC/Tc/Gen/Default.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Foreign.hs
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Gen/HsType.hs
- compiler/GHC/Tc/Gen/Pat.hs
- compiler/GHC/Tc/Gen/Sig.hs
- compiler/GHC/Tc/Instance/Class.hs
- compiler/GHC/Tc/Instance/Family.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/Tc/Solver.hs
- compiler/GHC/Tc/Solver/Default.hs
- compiler/GHC/Tc/Solver/Dict.hs
- compiler/GHC/Tc/Solver/Equality.hs
- compiler/GHC/Tc/Solver/InertSet.hs
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/Solver/Solve.hs
- compiler/GHC/Tc/TyCl.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/TyCl/Utils.hs
- compiler/GHC/Tc/Types.hs
- compiler/GHC/Tc/Types/BasicTypes.hs
- compiler/GHC/Tc/Types/Constraint.hs
- compiler/GHC/Tc/Types/CtLoc.hs
- compiler/GHC/Tc/Types/ErrCtxt.hs
- compiler/GHC/Tc/Types/Evidence.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Utils/Env.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Tc/Utils/TcMType.hs
- − compiler/GHC/Tc/Utils/TcMType.hs-boot
- compiler/GHC/Tc/Utils/Unify.hs
- compiler/GHC/Tc/Zonk/TcType.hs
- compiler/GHC/Tc/Zonk/Type.hs
- compiler/GHC/ThToHs.hs
- compiler/GHC/Types/Basic.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/ForeignCall.hs
- compiler/GHC/Types/Id/Info.hs
- compiler/GHC/Types/Id/Make.hs
- compiler/GHC/Types/InlinePragma.hs
- compiler/GHC/Types/Name.hs
- compiler/GHC/Types/Name/Cache.hs
- compiler/GHC/Types/RepType.hs
- compiler/GHC/Types/Unique/DSet.hs
- compiler/GHC/Types/Var.hs
- compiler/GHC/Unit/Module/ModIface.hs
- compiler/GHC/Unit/State.hs
- compiler/GHC/Unit/Types.hs
- compiler/GHC/Utils/Binary.hs
- compiler/GHC/Utils/Monad.hs
- compiler/GHC/Utils/Outputable.hs
- compiler/GHC/Utils/Ppr/Colour.hs
- compiler/GHC/Utils/Trace.hs
- compiler/Language/Haskell/Syntax/Basic.hs
- compiler/Language/Haskell/Syntax/Decls.hs
- + compiler/Language/Haskell/Syntax/Decls/Foreign.hs
- + compiler/Language/Haskell/Syntax/Decls/Overlap.hs
- compiler/Language/Haskell/Syntax/Extension.hs
- compiler/Language/Haskell/Syntax/Lit.hs
- compiler/ghc.cabal.in
- configure.ac
- distrib/configure.ac.in
- docs/users_guide/9.16.1-notes.rst
- docs/users_guide/exts/multiway_if.rst
- docs/users_guide/exts/roles.rst
- docs/users_guide/index.rst
- docs/users_guide/rtd-theme/layout.html
- docs/users_guide/runtime_control.rst
- ghc/GHCi/UI/Info.hs
- hadrian/doc/user-settings.md
- hadrian/hadrian.cabal
- hadrian/src/Builder.hs
- hadrian/src/Context.hs
- hadrian/src/Flavour.hs
- hadrian/src/Hadrian/Utilities.hs
- hadrian/src/Rules/Compile.hs
- hadrian/src/Rules/Docspec.hs
- hadrian/src/Rules/Documentation.hs
- hadrian/src/Rules/Lint.hs
- hadrian/src/Settings/Builders/Cc.hs
- hadrian/src/Settings/Builders/Configure.hs
- hadrian/src/Settings/Builders/Ghc.hs
- hadrian/src/Settings/Builders/Make.hs
- hadrian/src/Settings/Builders/RunTest.hs
- hadrian/src/Settings/Flavours/GhcInGhci.hs
- hadrian/src/Settings/Packages.hs
- libraries/Cabal
- libraries/base/base.cabal.in
- libraries/base/changelog.md
- libraries/base/src/Control/Concurrent.hs
- libraries/base/src/Data/Array/Byte.hs
- libraries/base/src/Data/Ix.hs
- − libraries/base/src/GHC/Desugar.hs
- libraries/base/src/GHC/Num.hs
- − libraries/base/src/GHC/Num/BigNat.hs
- − libraries/base/src/GHC/Num/Integer.hs
- − libraries/base/src/GHC/Num/Natural.hs
- libraries/base/src/System/CPUTime/Utils.hs
- + libraries/base/src/System/IO/OS.hs
- libraries/base/src/System/Timeout.hs
- libraries/base/tests/IO/all.T
- + libraries/base/tests/IO/osHandles001FileDescriptors.hs
- + libraries/base/tests/IO/osHandles001FileDescriptors.stdout
- + libraries/base/tests/IO/osHandles001WindowsHandles.hs
- + libraries/base/tests/IO/osHandles001WindowsHandles.stdout
- + libraries/base/tests/IO/osHandles002FileDescriptors.hs
- + libraries/base/tests/IO/osHandles002FileDescriptors.stderr
- + libraries/base/tests/IO/osHandles002FileDescriptors.stdin
- + libraries/base/tests/IO/osHandles002FileDescriptors.stdout
- + libraries/base/tests/IO/osHandles002WindowsHandles.hs
- + libraries/base/tests/IO/osHandles002WindowsHandles.stderr
- + libraries/base/tests/IO/osHandles002WindowsHandles.stdin
- + libraries/base/tests/IO/osHandles002WindowsHandles.stdout
- libraries/base/tests/T23454.stderr
- libraries/base/tests/perf/Makefile
- libraries/deepseq
- libraries/directory
- libraries/exceptions
- libraries/ghc-bignum/ghc-bignum.cabal
- libraries/ghc-compact/tests/all.T
- libraries/ghc-experimental/CHANGELOG.md
- libraries/ghc-experimental/ghc-experimental.cabal.in
- libraries/ghc-experimental/src/GHC/Exception/Backtrace/Experimental.hs
- libraries/ghc-experimental/src/GHC/Stack/Annotation/Experimental.hs
- libraries/ghc-experimental/src/GHC/TypeNats/Experimental.hs
- + libraries/ghc-experimental/tests/Makefile
- + libraries/ghc-experimental/tests/all.T
- + libraries/ghc-experimental/tests/backtraces/Makefile
- + libraries/ghc-experimental/tests/backtraces/T26806a.hs
- + libraries/ghc-experimental/tests/backtraces/T26806a.stderr
- + libraries/ghc-experimental/tests/backtraces/T26806b.hs
- + libraries/ghc-experimental/tests/backtraces/T26806b.stderr
- + libraries/ghc-experimental/tests/backtraces/T26806c.hs
- + libraries/ghc-experimental/tests/backtraces/T26806c.stderr
- + libraries/ghc-experimental/tests/backtraces/all.T
- libraries/ghc-internal/ghc-internal.cabal.in
- libraries/ghc-internal/src/GHC/Internal/Classes.hs
- + libraries/ghc-internal/src/GHC/Internal/Classes/IP.hs
- libraries/ghc-internal/src/GHC/Internal/Data/Data.hs
- − libraries/ghc-internal/src/GHC/Internal/Data/Ix.hs
- libraries/ghc-internal/src/GHC/Internal/Err.hs
- libraries/ghc-internal/src/GHC/Internal/Exts.hs
- libraries/ghc-internal/src/GHC/Internal/Functor/ZipList.hs
- libraries/ghc-internal/src/GHC/Internal/Heap/Closures.hs
- libraries/ghc-internal/src/GHC/Internal/JS/Foreign/Callback.hs
- libraries/ghc-internal/src/GHC/Internal/JS/Prim.hs
- libraries/ghc-internal/src/GHC/Internal/JS/Prim/Internal/Build.hs
- libraries/ghc-internal/src/GHC/Internal/Magic.hs
- libraries/ghc-internal/src/GHC/Internal/Stack/Annotation.hs
- libraries/ghc-internal/src/GHC/Internal/Stack/Decode.hs
- + libraries/ghc-internal/src/GHC/Internal/System/IO/OS.hs
- libraries/ghc-internal/src/GHC/Internal/Tuple.hs
- libraries/ghc-internal/src/GHC/Internal/Wasm/Prim/Exports.hs
- libraries/ghc-internal/src/GHC/Internal/Wasm/Prim/Imports.hs
- libraries/ghc-internal/src/GHC/Internal/Wasm/Prim/Types.hs
- libraries/ghc-internal/tests/backtraces/all.T
- libraries/ghc-internal/tests/stack-annotation/all.T
- libraries/ghc-internal/tests/stack-annotation/ann_frame001.stdout
- libraries/ghc-internal/tests/stack-annotation/ann_frame002.stdout
- libraries/ghc-internal/tests/stack-annotation/ann_frame003.stdout
- libraries/ghc-internal/tests/stack-annotation/ann_frame004.stdout
- + libraries/ghc-internal/tests/stack-annotation/ann_frame005.hs
- + libraries/ghc-internal/tests/stack-annotation/ann_frame005.stdout
- libraries/ghci/GHCi/Server.hs
- libraries/text
- libraries/transformers
- llvm-targets
- m4/fp_cmm_cpp_cmd_with_args.m4
- rts/AllocArray.c
- rts/AllocArray.h
- rts/ClosureTable.c
- rts/Heap.c
- rts/PrimOps.cmm
- rts/RtsFlags.c
- rts/Threads.c
- rts/Trace.c
- rts/Weak.c
- rts/include/Cmm.h
- rts/include/Stg.h
- rts/include/rts/Flags.h
- rts/include/stg/Ticky.h
- rts/prim/atomic.c
- rts/rts.cabal
- rts/sm/Evac.c
- rts/sm/Evac_thr.c → rts/sm/Evac_par.c
- rts/sm/Scav_thr.c → rts/sm/Scav_par.c
- rts/sm/Storage.c
- − testsuite/driver/kill_extra_files.py
- testsuite/driver/runtests.py
- testsuite/driver/testglobals.py
- testsuite/driver/testlib.py
- testsuite/driver/testutil.py
- testsuite/mk/test.mk
- testsuite/tests/backpack/cabal/bkpcabal08/bkpcabal08.stdout
- testsuite/tests/codeGen/should_run/CgStaticPointers.hs
- testsuite/tests/codeGen/should_run/CgStaticPointersNoFullLazyness.hs
- testsuite/tests/count-deps/CountDepsAst.stdout
- testsuite/tests/count-deps/CountDepsParser.stdout
- + testsuite/tests/default/T25825.hs
- testsuite/tests/default/all.T
- testsuite/tests/deriving/should_fail/T1496.stderr
- testsuite/tests/deriving/should_fail/T4846.stderr
- testsuite/tests/deriving/should_fail/T5498.stderr
- testsuite/tests/deriving/should_fail/T6147.stderr
- testsuite/tests/deriving/should_fail/T7148.stderr
- testsuite/tests/deriving/should_fail/T7148a.stderr
- testsuite/tests/deriving/should_fail/T8984.stderr
- testsuite/tests/deriving/should_fail/deriving-via-fail.stderr
- testsuite/tests/deriving/should_fail/deriving-via-fail4.stderr
- testsuite/tests/deriving/should_fail/deriving-via-fail5.stderr
- testsuite/tests/driver/T16318/Makefile
- testsuite/tests/driver/T18125/Makefile
- testsuite/tests/driver/T20030/test1/all.T
- testsuite/tests/driver/T20030/test2/all.T
- testsuite/tests/driver/T20030/test3/all.T
- testsuite/tests/driver/T20030/test4/all.T
- testsuite/tests/driver/T20030/test5/all.T
- testsuite/tests/driver/T20030/test6/all.T
- testsuite/tests/driver/T8526/T8526.script
- testsuite/tests/driver/bytecode-object/Makefile
- testsuite/tests/driver/bytecode-object/bytecode_object19.stdout
- testsuite/tests/driver/dynamicToo/dynamicToo001/Makefile
- testsuite/tests/driver/fat-iface/fat014.script
- testsuite/tests/driver/implicit-dyn-too/Makefile
- testsuite/tests/driver/multipleHomeUnits/all.T
- testsuite/tests/driver/multipleHomeUnits/multipleHomeUnits_recomp_th.stdout
- testsuite/tests/ffi/should_run/all.T
- testsuite/tests/gadt/CasePrune.stderr
- + testsuite/tests/ghc-api/TypeMapStringLiteral.hs
- testsuite/tests/ghc-api/all.T
- testsuite/tests/ghci.debugger/scripts/T26042b.stdout
- testsuite/tests/ghci.debugger/scripts/T26042c.stdout
- testsuite/tests/ghci.debugger/scripts/T26042d2.stdout
- testsuite/tests/ghci.debugger/scripts/T26042f2.stdout
- testsuite/tests/ghci.debugger/scripts/T8487.stdout
- testsuite/tests/ghci.debugger/scripts/break011.stdout
- testsuite/tests/ghci.debugger/scripts/break017.stdout
- testsuite/tests/ghci.debugger/scripts/break025.stdout
- − testsuite/tests/ghci/linking/T11531.stderr
- testsuite/tests/ghci/prog018/prog018.script
- testsuite/tests/ghci/scripts/T13869.script
- testsuite/tests/ghci/scripts/T13997.script
- testsuite/tests/ghci/scripts/T17669.script
- testsuite/tests/ghci/scripts/T18330.script
- testsuite/tests/ghci/scripts/T18330.stdout
- testsuite/tests/ghci/scripts/T1914.script
- testsuite/tests/ghci/scripts/T20150.stdout
- testsuite/tests/ghci/scripts/T20217.script
- testsuite/tests/ghci/scripts/T6105.script
- testsuite/tests/ghci/scripts/T8042.script
- testsuite/tests/ghci/scripts/T8042recomp.script
- testsuite/tests/ghci/should_run/Makefile
- testsuite/tests/indexed-types/should_fail/T9580.stderr
- testsuite/tests/interface-stability/base-exports.stdout
- testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
- testsuite/tests/interface-stability/base-exports.stdout-mingw32
- testsuite/tests/interface-stability/base-exports.stdout-ws-32
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32
- testsuite/tests/interface-stability/ghc-prim-exports.stdout
- testsuite/tests/interface-stability/ghc-prim-exports.stdout-mingw32
- testsuite/tests/linear/should_fail/LinearRole.stderr
- testsuite/tests/linters/regex-linters/check-rts-includes.py
- testsuite/tests/parser/should_compile/DumpRenamedAst.stderr
- testsuite/tests/parser/should_compile/T14189.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail8.stderr
- + testsuite/tests/parser/should_fail/T26860ppr.hs
- + testsuite/tests/parser/should_fail/T26860ppr.stderr
- testsuite/tests/parser/should_fail/all.T
- + testsuite/tests/plugins/T23110.hs
- + testsuite/tests/plugins/T23110.script
- + testsuite/tests/plugins/T23110.stdout
- testsuite/tests/plugins/all.T
- testsuite/tests/process/all.T
- testsuite/tests/rename/should_fail/RnStaticPointersFail01.stderr
- testsuite/tests/rename/should_fail/RnStaticPointersFail03.stderr
- + testsuite/tests/rename/should_fail/T26545.hs
- + testsuite/tests/rename/should_fail/T26545.stderr
- testsuite/tests/rename/should_fail/all.T
- testsuite/tests/roles/should_fail/RolesIArray.stderr
- testsuite/tests/rts/Makefile
- testsuite/tests/rts/T13676.script
- testsuite/tests/rts/all.T
- testsuite/tests/rts/ipe/all.T
- testsuite/tests/showIface/DocsInHiFile1.stdout
- testsuite/tests/showIface/HaddockSpanIssueT24378.stdout
- testsuite/tests/showIface/MagicHashInHaddocks.stdout
- testsuite/tests/simplCore/should_compile/T21391.hs
- + testsuite/tests/simplCore/should_compile/T26805.hs
- + testsuite/tests/simplCore/should_compile/T26805.stderr
- + testsuite/tests/simplCore/should_compile/T26826.hs
- + testsuite/tests/simplCore/should_compile/T26903.hs
- + testsuite/tests/simplCore/should_compile/T26903.stderr
- testsuite/tests/simplCore/should_compile/T8331.stderr
- testsuite/tests/simplCore/should_compile/all.T
- + testsuite/tests/th/T26098A_quote.hs
- + testsuite/tests/th/T26098A_splice.hs
- + testsuite/tests/th/T26098_local.hs
- + testsuite/tests/th/T26098_local.stderr
- + testsuite/tests/th/T26098_quote.hs
- + testsuite/tests/th/T26098_quote.stderr
- + testsuite/tests/th/T26098_splice.hs
- + testsuite/tests/th/T26098_splice.stderr
- testsuite/tests/th/TH_implicitParams.stdout
- testsuite/tests/th/all.T
- + testsuite/tests/typecheck/should_compile/T24464.hs
- + testsuite/tests/typecheck/should_compile/T26737.hs
- + testsuite/tests/typecheck/should_compile/T26805a.hs
- testsuite/tests/typecheck/should_compile/all.T
- testsuite/tests/typecheck/should_fail/T10285.stderr
- testsuite/tests/typecheck/should_fail/T10534.stderr
- testsuite/tests/typecheck/should_fail/T10715b.stderr
- testsuite/tests/typecheck/should_fail/T11347.stderr
- testsuite/tests/typecheck/should_fail/T15801.stderr
- + testsuite/tests/typecheck/should_fail/T15850.hs
- + testsuite/tests/typecheck/should_fail/T15850.stderr
- + testsuite/tests/typecheck/should_fail/T15850_Lib.hs
- + testsuite/tests/typecheck/should_fail/T20289.hs
- + testsuite/tests/typecheck/should_fail/T20289.stderr
- + testsuite/tests/typecheck/should_fail/T20289_A.hs
- testsuite/tests/typecheck/should_fail/T22645.stderr
- testsuite/tests/typecheck/should_fail/T22924a.stderr
- + testsuite/tests/typecheck/should_fail/T23731.hs
- + testsuite/tests/typecheck/should_fail/T23731.stderr
- + testsuite/tests/typecheck/should_fail/T23731b.hs
- + testsuite/tests/typecheck/should_fail/T23731b.stderr
- + testsuite/tests/typecheck/should_fail/T23731b_aux.hs
- + testsuite/tests/typecheck/should_fail/T25679.hs
- + testsuite/tests/typecheck/should_fail/T25679.stderr
- + testsuite/tests/typecheck/should_fail/T25949.hs
- + testsuite/tests/typecheck/should_fail/T25949.stderr
- + testsuite/tests/typecheck/should_fail/T25949_aux.hs
- + testsuite/tests/typecheck/should_fail/T26137.hs
- + testsuite/tests/typecheck/should_fail/T26137.stderr
- testsuite/tests/typecheck/should_fail/TcCoercibleFail.stderr
- testsuite/tests/typecheck/should_fail/TcCoercibleFail3.stderr
- testsuite/tests/typecheck/should_fail/all.T
- + testsuite/tests/typecheck/should_run/T16981.hs
- + testsuite/tests/typecheck/should_run/T16981.stdout
- + testsuite/tests/typecheck/should_run/T24773.hs
- + testsuite/tests/typecheck/should_run/T24773.stdout
- testsuite/tests/typecheck/should_run/all.T
- testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr
- utils/check-exact/ExactPrint.hs
- utils/ghc-toolchain/exe/Main.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cc.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cpp.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hoogle.hs
- utils/haddock/haddock-api/src/Haddock/Convert.hs
- utils/haddock/haddock-api/src/Haddock/Interface/LexParseRn.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs
- utils/haddock/haddock-api/src/Haddock/Types.hs
- utils/jsffi/dyld.mjs
- utils/jsffi/post-link.mjs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/90df50b276e4aed704a32679a9d2df…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/90df50b276e4aed704a32679a9d2df…
You're receiving this email because of your account on gitlab.haskell.org.
1
0