Skip to content

GitHub ci#2

Open
soulomoon wants to merge 257 commits intomasterfrom
github-ci
Open

GitHub ci#2
soulomoon wants to merge 257 commits intomasterfrom
github-ci

Conversation

@soulomoon
Copy link
Copy Markdown
Owner

No description provided.

mpickering and others added 30 commits April 22, 2025 16:24
…pLevEnv

loadSrcInterface takes a user given `ModuleName` and resolves it to the
module which needs to be loaded (taking into account module
renaming/visibility etc).

loadInterfaceForModule takes a specific module and loads it.

The modules in `ImpDeclSpec` have already been resolved to the actual
module to get the information from during renaming. Therefore we just
need to fetch the precise interface from disk (and not attempt to rename
it again).

Fixes #25951
…stack slots for J_TBL (#25738)

J_TBL result in local jumps, there should not deallocate stack slots
(see Note [extra spill slots].)

J is for non-local jumps, these may need to deallocate stack slots.
The `EvalBreakpoint` is used to communicate that a breakpoint was
encountered during code evaluation.
This `EvalBreakpoint` needs to be converted to an `InternalBreakpointId`
which stores a `Module` to uniquely find the correct `Module` in the
Home Package Table.

The `EvalBreakpoint` used to store only a `ModuleName` which is then
converted to a `Module` based on the currently active home unit.
This is incorrect in the face of multiple home units, the break point
could be in an entirely other home unit!
To fix this, we additionally store the `UnitId` of the `Module` in
`EvalBreakpoint` to later reconstruct the correct `Module`

All of the changes are the consequence of extending `EvalBreakpoint`
with the additional `ShortByteString` of the `UnitId`.

For performance reasons, we store the `ShortByteString` backing the
`UnitId` directly, avoiding marshalling overhead.
In 36cddd2 @alt-romes removed CallStack
output from `GHC.Utils.Panic.Plain.assertPanic'`. While this output is
redundant due to the exception backtrace proposal, we may be
bootstrapping with a compiler which does not yet include this machinery.
Reintroduce the output for now.

Fixes #25898.
This commit introduces the `ExplicitLevelImports` and
`ImplicitStagePersistence` language extensions as proposed in GHC
Proposal #682.

Key Features
------------

- `ExplicitLevelImports` adds two new import modifiers - `splice` and
  `quote` - allowing precise control over the level at which imported
  identifiers are available
- `ImplicitStagePersistence` (enabled by default) preserves existing
  path-based cross-stage persistence behavior
- `NoImplicitStagePersistence` disables implicit cross-stage
  persistence, requiring explicit level imports

Benefits
--------

- Improved compilation performance by reducing unnecessary code generation
- Enhanced IDE experience with faster feedback in `-fno-code` mode
- Better dependency tracking by distinguishing compile-time and runtime dependencies
- Foundation for future cross-compilation improvements

This implementation enables the separation of modules needed at
compile-time from those needed at runtime, allowing for more efficient
compilation pipelines and clearer code organization in projects using
Template Haskell.

Implementation Notes
--------------------

The level which a name is availble at is stored in the 'GRE', in the normal
GlobalRdrEnv. The function `greLevels` returns the levels which a specific GRE
is imported at. The level information for a 'Name' is computed by `getCurrentAndBindLevel`.
The level validity is checked by `checkCrossLevelLifting`.

Instances are checked by `checkWellLevelledDFun`, which computes the level an
instance by calling `checkWellLevelledInstanceWhat`, which sees what is
available at by looking at the module graph.

Modifications to downsweep
--------------------------

Code generation is now only enabled for modules which are needed at
compile time.
See the Note [-fno-code mode] for more information.

Uniform error messages for level errors
---------------------------------------

All error messages to do with levels are now reported uniformly using
the `TcRnBadlyStaged` constructor.

Error messages are uniformly reported in terms of levels.

0 - top-level
1 - quote level
-1 - splice level

The only level hard-coded into the compiler is the top-level in
GHC.Types.ThLevelIndex.topLevelIndex.

Uniformly refer to levels and stages
------------------------------------

There was much confusion about levels vs stages in the compiler.
A level is a semantic concept, used by the typechecker to ensure a
program can be evaluated in a well-staged manner.

A stage is an operational construct, program evaluation proceeds in
stages.

Deprecate -Wbadly-staged-types
------------------------------

`-Wbadly-staged-types` is deprecated in favour of `-Wbadly-levelled-types`.

Lift derivation changed
-----------------------

Derived lift instances will now not generate code with expression
quotations.

Before:

```
data A = A Int deriving Lift

=>
lift (A x) = [| A $(lift x) |]
```

After:

```
lift (A x) = conE 'A `appE` (lift x)
```

This is because if you attempt to derive `Lift` in a module where
`NoImplicitStagePersistence` is enabled, you would get an infinite loop
where a constructor was attempted to be persisted using the instance you
are currently defining.

GHC API Changes
---------------

The ModuleGraph now contains additional information about the type of
the edges (normal, quote or splice) between modules. This is abstracted
using the `ModuleGraphEdge` data type.

Fixes #25828

-------------------------
Metric Increase:
    MultiLayerModulesTH_Make
-------------------------
In particular when we have a pattern binding
    K p1 .. pn = rhs
where K is a pattern synonym.  (It might be nested.)

This small MR fixes #25995.  It's a tiny fix, to an error message,
removing an always-dubious `unkSkol`.

The bug report was in the context of horde-ad, a big program,
and I didn't manage to make a small repro case quickly. I decided
not to bother further.
On the way to #23109 (unary classes) I discovered some infelicities
(or maybe tiny bugs, I forget) in the type-class specialiser.

I also tripped over #25965, an outright bug in the rule matcher

Specifically:

* Refactor: I enhanced `wantCallsFor`, whih previously always said
`True`, to discard calls of class-ops, data constructors etc.  This is
a bit more efficient; and it means we don't need to worry about
filtering them out later.

* Fix: I tidied up some tricky logic that eliminated redundant
  specialisations.  It wasn't working correctly.  See the expanded
  Note [Specialisations already covered], and
  (MP3) in Note [Specialising polymorphic dictionaries].

  See also the new top-level `alreadyCovered`
  function, which now goes via `GHC.Core.Rules.ruleLhsIsMoreSpecific`

  I also added a useful Note [The (CI-KEY) invariant]

* Fix #25965: fixed a tricky bug in the `go_fam_fam` in
  `GHC.Core.Unify.uVarOrFam`, which allows matching to succeed
  without binding all type varibles.

  I enhanced Note [Apartness and type families] some more

* #25703. This ticket "just works" with -fpolymorphic-specialisation;
  but I was surprised that it worked! In this MR I added documentation
  to Note [Interesting dictionary arguments] to explain; and tests to
  ensure it stays fixed.
The key change, which fixed #25440, is to call `recordRewriter` in
GHC.Tc.Solver.Rewrite.rewrite_exact_fam_app.  This missing call meant
that we were secretly rewriting a Wanted with a Wanted, but not really
noticing; and that led to a very bad error message, as you can see
in the ticket.

But of course that led me into rabbit hole of other refactoring around
the RewriteSet code:

* Improve Notes [Wanteds rewrite Wanteds]

* Zonk the RewriterSet in `zonkCtEvidence` rather than only in GHC.Tc.Errors.
  This is tidier anyway (e.g. de-clutters debug output), and helps with the
  next point.

* In GHC.Tc.Solver.Equality.inertsCanDischarge, don't replace a constraint
  with no rewriters with an equal constraint that has many. See
  See (CE4) in Note [Combining equalities]

* Move zonkRewriterSet and friends from GHC.Tc.Zonk.Type into
  GHC.Tc.Zonk.TcType, where they properly belong.

A handful of tests get better error messages.

For some reason T24984 gets 12% less compiler allocation -- good

Metric Decrease:
    T24984
This broke in the refactor in !13128, where the old code parsed escape
codes and collapsed string gaps at the same time, but the new code
collapsed gaps first, then resolved escape codes. The new code used a
naive heuristic to skip escaped backslashes, but didn't account for
"\^\".
1. Add Windows AArch64 cross-compilation support via CI jobs
Introduce new CI configurations for cross-compiling to Windows ARM64 using Debian12Wine, FEX, and MSYS2.
Configure toolchain variables for LLVM MinGW and Wine emulation in CI pipelines.

2. Adjust compiler and RTS for AArch64 Windows compatibility
Reserve register `x18` on Windows and Darwin platforms in AArch64 codegen.
Handle Windows-specific relocations and data sections in AArch64 assembler.
Update PEi386 linker to recognize ARM64 binaries and support exception handling.
Adjust LLVM target definitions and data layouts for new architectures.
Update `ghc-toolchain` and build scripts to handle `TablesNextToCode` on Windows ARM64.

3. Enhance CI scripts and stability
Modify `ci.sh` to handle mingw cross-targets, fixing GHC executable paths and test execution.
Use `diff -w` in tests to ignore whitespace differences, improving cross-platform consistency.

4. Refactor and clean up code
Remove redundant imports in hello.hs test.
Improve error messages and checks for unsupported configurations in the driver.
Add `EXDEV` error code to `errno.js`.
Add async/sync flags to IO logs at `base.js`.
Improve POSIX compatibility for file close at `base.js`: decrease indeterminism for mixed cases of async and sync code.

5. Update dependencies: `Cabal`, `Win32`, `directory`, `process`, `haskeline`, and `unix`.

submodule

Co-authored-by: Cheng Shao <terrorjack@type.dance>
Co-authored-by: Dmitrii Egorov <egorov.d.i@icloud.com>
Co-authored-by: Andrei Borzenkov <root@sandwitch.dev>
Consider example (#25895):

>  do { forever (return ()); blah }

where `forever :: forall a b. IO a -> IO b`.

Nothing constrains `b`, so it will be instantiates with `Any` or
`ZonkAny`.
But we certainly don't want to complain about a discarded do-binding.

Fixes #25895
This makes the code clearer and allows the top-level import context to
be fetched directly from the HomeModInfo through the API (e.g. useful
for the debugger).
Counts the number of OccNames in an OccEnv
This patch addresses #26004.  The root cause was that simplifyInfer
was willing to unify variables "far out".  The fix, in
runTcSWithEvBinds', is to initialise the inert set given-eq level with
the current level. See
    (TGE6) in Note [Tracking Given equalities]
in GHC.Tc.Solver.InertSet

Two loosely related refactors:

* Refactored approximateWCX to return just the free type
  variables of the un-quantified constraints.  That avoids duplication
  of work (these free vars are needed in simplifyInfer) and makes it
  clearer that the constraints themselves are irrelevant.

* A little local refactor of TcSMode, which reduces the number of
  parameters to runTcSWithEvBinds
Previously the predicate to identify LLVM builtin global variables was
checking for `$llvm` rather than `@llvm` as it should.
LLVM now insists that built-in arrays use Appending linkage, not
Internal.

Fixes #25769.
This change avoids violating the invariant of mkTrApp according to which
the argument should not be a fully saturated function type.
This ensures we don't return false negatives for type equality
involving function types.

Fixes #25998
Intended for use with :{ :}, but doesn't look for those characters. Any
consecutive lines with birdtracks will only have initial whitespace
stripped up to the column of the first line.
Currently only firefox is enabled for wasm ghci browser tests, for
some reason testing with chrome works on my machine but gets stuck on
gitlab instance runners. This patch re-enables testing with chrome by
passing `--no-sandbox`, since chrome sandboxing doesn't work in
containers without `--cap-add=SYS_ADMIN`.
This patch fixes multiple bugs (#22581, #25983, #25984, #25991)
in name resolution of subordinate import lists.

Bug #22581
----------
In subordinate import lists, the use of the `type` namespace specifier
used to be ignored. For example, this import statement was incorrectly
accepted:

  import Prelude (Bool(type True))

Now it results in an error message:

  <interactive>:2:17: error: [GHC-51433]
    In the import of ‘Prelude’:
      a data type called ‘Bool’ is exported,
      but its subordinate item ‘True’ is not in the type namespace.

Bug #25983
----------
In subordinate import lists within a `hiding` clause, non-existent
items led to a poor warning message with -Wdodgy-imports. Consider:

  import Prelude hiding (Bool(X))

The warning message for this import statement used to misreport the
cause of the problem:

  <interactive>:3:24: warning: [GHC-56449] [-Wdodgy-imports]
    In the import of ‘Prelude’:
      an item called ‘Bool’ is exported, but it is a type.

Now the warning message is correct:

  <interactive>:2:24: warning: [GHC-10237] [-Wdodgy-imports]
    In the import of ‘Prelude’:
      a data type called ‘Bool’ is exported, but it does not export
      any constructors or record fields called ‘X’.

Bug #25984
----------
In subordinate import lists within a `hiding` clause, non-existent
items resulted in the entire import declaration being discarded.
For example, this program was incorrectly accepted:

  import Prelude hiding (Bool(True,X))
  t = True

Now it results in an error message:

  <interactive>:2:5: error: [GHC-88464]
    Data constructor not in scope: True

Bug #25991
----------
In subordinate import lists, it was not possible to refer to a class
method if there was an associated type of the same name:

  module M_helper where
    class C a b where
      type a # b
      (#) :: a -> b -> ()

  module M where
    import M_helper (C((#)))

This import declaration failed with:

  M.hs:2:28: error: [GHC-10237]
    In the import of ‘M_helper’:
      an item called ‘C’ is exported, but it does not export any children
      (constructors, class methods or field names) called ‘#’.

Now it is accepted.

Summary
-------
The changes required to fix these bugs are almost entirely confined to
GHC.Rename.Names. Other than that, there is a new error constructor
BadImportNonTypeSubordinates with error code [GHC-51433].

Test cases:
  T22581a T22581b T22581c T22581d
  T25983a T25983b T25983c T25983d T25983e T25983f T25983g
  T25984a T25984b
  T25991a T25991b1 T25991b2
Fix #26105, by upgrading the (horrible, hacky) `dropMisleading`
function.

This fix makes things a bit better but does not cure the underlying
problem.
This little MR fixes #26020.  We are on the edge of completeness
for newtype equalities (that doesn't change) but this MR makes GHC
a bit more consistent -- and fixes the bug reported.
This patch marks `freeJSVal` as `INLINE` for the wasm backend. I
noticed that the `freeJSVal` invocations are not inlined when
inspecting STG/Cmm dumps of downstream libraries that use release
build of the wasm backend. The performance benefit of inlining here is
very modest, but so is the cost anyway; if you are using `freeJSVal`
at all then you care about every potential chance to improve
performance :)
This patch adds a zero length fast path for `fromJSString`; when
marshaling a zero-length `JSString` we don't need to allocate an empty
`ByteArray#` at all.
GHC GitLab CI added 30 commits July 25, 2025 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.