-
9995c2b7
by Serge S. Gulin at 2025-05-04T17:13:36+03:00
Support for ARM64 Windows (LLVM-enabled) (fixes #24603)
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>
-
50fa8165
by Javran Cheng at 2025-05-05T05:55:39-04:00
Suppress unused do-binding if discarded variable is Any or ZonkAny.
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
-
e46c6b18
by Rodrigo Mesquita at 2025-05-06T09:01:57-04:00
Refactor mkTopLevImportedEnv out of mkTopLevEnv
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).
-
0ce0d263
by Rodrigo Mesquita at 2025-05-06T09:01:57-04:00
Export sizeOccEnv from GHC.Types.Name.Occurrence
Counts the number of OccNames in an OccEnv
-
165f98d8
by Simon Peyton Jones at 2025-05-06T09:02:39-04:00
Fix a bad untouchability bug im simplifyInfer
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
-
4bedc089
by Alan Zimmerman at 2025-05-06T18:07:57+01:00
GHC-CPP: first rough proof of concept
Processes
#define FOO
#ifdef FOO
x = 1
#endif
Into
[ITcppIgnored [L loc ITcppDefine]
,ITcppIgnored [L loc ITcppIfdef]
,ITvarid "x"
,ITequal
,ITinteger (IL {il_text = SourceText "1", il_neg = False, il_value = 1})
,ITcppIgnored [L loc ITcppEndif]
,ITeof]
In time, ITcppIgnored will be pushed into a comment
-
58ef415b
by Alan Zimmerman at 2025-05-06T18:07:57+01:00
Tidy up before re-visiting the continuation mechanic
-
638a6fc3
by Alan Zimmerman at 2025-05-06T18:07:57+01:00
Switch preprocessor to continuation passing style
Proof of concept, needs tidying up
-
cd688d33
by Alan Zimmerman at 2025-05-06T18:07:57+01:00
Small cleanup
-
6a924b61
by Alan Zimmerman at 2025-05-06T18:07:57+01:00
Get rid of some cruft
-
0ae29cce
by Alan Zimmerman at 2025-05-06T18:07:58+01:00
Starting to integrate.
Need to get the pragma recognised and set
-
40767a46
by Alan Zimmerman at 2025-05-06T18:07:58+01:00
Make cppTokens extend to end of line, and process CPP comments
-
e5c0365b
by Alan Zimmerman at 2025-05-06T18:07:58+01:00
Remove unused ITcppDefined
-
aa1b2743
by Alan Zimmerman at 2025-05-06T18:07:58+01:00
Allow spaces between # and keyword for preprocessor directive
-
4116edcd
by Alan Zimmerman at 2025-05-06T18:07:58+01:00
Process CPP continuation lines
They are emited as separate ITcppContinue tokens.
Perhaps the processing should be more like a comment, and keep on
going to the end.
BUT, the last line needs to be slurped as a whole.
-
1927c7fb
by Alan Zimmerman at 2025-05-06T18:07:58+01:00
Accumulate CPP continuations, process when ready
Can be simplified further, we only need one CPP token
-
163c0f61
by Alan Zimmerman at 2025-05-06T18:07:58+01:00
Simplify Lexer interface. Only ITcpp
We transfer directive lines through it, then parse them from scratch
in the preprocessor.
-
38c83ad6
by Alan Zimmerman at 2025-05-06T18:07:58+01:00
Deal with directive on last line, with no trailing \n
-
37b0f683
by Alan Zimmerman at 2025-05-06T18:07:58+01:00
Start parsing and processing the directives
-
da250161
by Alan Zimmerman at 2025-05-06T18:07:58+01:00
Prepare for processing include files
-
cae69ced
by Alan Zimmerman at 2025-05-06T18:07:58+01:00
Move PpState into PreProcess
And initParserState, initPragState too
-
d84e8056
by Alan Zimmerman at 2025-05-06T18:07:58+01:00
Process nested include files
Also move PpState out of Lexer.x, so it is easy to evolve it in a ghci
session, loading utils/check-cpp/Main.hs
-
6c92a7f9
by Alan Zimmerman at 2025-05-06T18:07:58+01:00
Split into separate files
-
7cd10d14
by Alan Zimmerman at 2025-05-06T18:07:58+01:00
Starting on expression parser.
But it hangs. Time for Text.Parsec.Expr
-
bbd04cae
by Alan Zimmerman at 2025-05-06T18:07:58+01:00
Start integrating the ghc-cpp work
From https://github.com/alanz/ghc-cpp
-
0eb187a4
by Alan Zimmerman at 2025-05-06T18:07:58+01:00
WIP
-
940f5b55
by Alan Zimmerman at 2025-05-06T18:07:58+01:00
Fixup after rebase
-
d0a3d584
by Alan Zimmerman at 2025-05-06T18:07:59+01:00
WIP
-
efa9fe0a
by Alan Zimmerman at 2025-05-06T18:07:59+01:00
Fixup after rebase, including all tests pass
-
fdb1ea18
by Alan Zimmerman at 2025-05-06T18:07:59+01:00
Change pragma usage to GHC_CPP from GhcCPP
-
934145eb
by Alan Zimmerman at 2025-05-06T18:07:59+01:00
Some comments
-
540fade6
by Alan Zimmerman at 2025-05-06T18:07:59+01:00
Reformat
-
12c8fab6
by Alan Zimmerman at 2025-05-06T18:07:59+01:00
Delete unused file
-
27061919
by Alan Zimmerman at 2025-05-06T18:07:59+01:00
Rename module Parse to ParsePP
-
caf7e9bf
by Alan Zimmerman at 2025-05-06T18:07:59+01:00
Clarify naming in the parser
-
fde7bd48
by Alan Zimmerman at 2025-05-06T18:07:59+01:00
WIP. Switching to alex/happy to be able to work in-tree
Since Parsec is not available
-
56fa02d5
by Alan Zimmerman at 2025-05-06T18:07:59+01:00
Layering is now correct
- GHC lexer, emits CPP tokens
- accumulated in Preprocessor state
- Lexed by CPP lexer, CPP command extracted, tokens concated with
spaces (to get rid of token pasting via comments)
- if directive lexed and parsed by CPP lexer/parser, and evaluated
-
69dac201
by Alan Zimmerman at 2025-05-06T18:07:59+01:00
First example working
Loading Example1.hs into ghci, getting the right results
```
{-# LANGUAGE GHC_CPP #-}
module Example1 where
y = 3
x =
"hello"
"bye now"
foo = putStrLn x
```
-
7a654916
by Alan Zimmerman at 2025-05-06T18:07:59+01:00
Rebase, and all tests pass except whitespace for generated parser
-
0dcd84c5
by Alan Zimmerman at 2025-05-06T18:07:59+01:00
More plumbing. Ready for testing tomorrow.
-
f358cb54
by Alan Zimmerman at 2025-05-06T18:07:59+01:00
Proress. Renamed module State from Types
And at first blush it seems to handle preprocessor scopes properly.
-
d0d5c285
by Alan Zimmerman at 2025-05-06T18:07:59+01:00
Insert basic GHC version macros into parser
__GLASGOW_HASKELL__
__GLASGOW_HASKELL_FULL_VERSION__
__GLASGOW_HASKELL_PATCHLEVEL1__
__GLASGOW_HASKELL_PATCHLEVEL2__
-
b7925c05
by Alan Zimmerman at 2025-05-06T18:07:59+01:00
Re-sync check-cpp for easy ghci work
-
9d514f90
by Alan Zimmerman at 2025-05-06T18:07:59+01:00
Get rid of warnings
-
0b5f458f
by Alan Zimmerman at 2025-05-06T18:07:59+01:00
Rework macro processing, in check-cpp
Macros kept at the top level, looked up via name, multiple arity
versions per name can be stored
-
009563f2
by Alan Zimmerman at 2025-05-06T18:07:59+01:00
WIP. Can crack arguments for #define
Next step it to crack out args in an expansion
-
143cf978
by Alan Zimmerman at 2025-05-06T18:07:59+01:00
WIP on arg parsing.
-
ab01dc26
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Progress. Still screwing up nested parens.
-
23ff567d
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Seems to work, but has redundant code
-
8f91f5c3
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Remove redundant code
-
b2d68f7d
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Reformat
-
b96ece80
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Expand args, single pass
Still need to repeat until fixpoint
-
28b5caeb
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Fixed point expansion
-
48e98b88
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Sync the playground to compiler
-
7bd8b7dc
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Working on dumping the GHC_CPP result
But We need to keep the BufSpan in a comment
-
9e9bb4d1
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Keep BufSpan in queued comments in GHC.Parser.Lexer
-
1c269760
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Getting close to being able to print the combined tokens
showing what is in and what is out
-
4d8a2f36
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
First implementation of dumpGhcCpp.
Example output
First dumps all macros in the state, then the source, showing which
lines are in and which are out
------------------------------
- |#define FOO(A,B) A + B
- |#define FOO(A,B,C) A + B + C
- |#if FOO(1,FOO(3,4)) == 8
- |-- a comment
|x = 1
- |#else
- |x = 5
- |#endif
-
18eb7796
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Clean up a bit
-
fc20f4ba
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Add -ddump-ghc-cpp option and a test based on it
-
a82da455
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Restore Lexer.x rules, we need them for continuation lines
-
912eaf11
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Lexer.x: trying to sort out the span for continuations
- We need to match on \n at the end of the line
- We cannot simply back up for it
-
c7000536
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Inserts predefined macros. But does not dump properly
Because the cpp tokens have a trailing newline
-
ad1e7f9e
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Remove unnecessary LExer rules
We *need* the ones that explicitly match to the end of the line.
-
f4ea076a
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Generate correct span for ITcpp
Dump now works, except we do not render trailing `\` for continuation
lines. This is good enough for use in test output.
-
8afb04b8
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Reduce duplication in lexer
-
63398f1f
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Tweaks
-
1ece4cbe
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Insert min_version predefined macros into state
The mechanism now works. Still need to flesh out the full set.
-
6df6abba
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Trying my alternative pragma syntax.
It works, but dumpGhcCpp is broken, I suspect from the ITcpp token
span update.
-
d7b5d614
by Alan Zimmerman at 2025-05-06T18:08:00+01:00
Pragma extraction now works, with both CPP and GHC_CPP
For the following
{-# LANGUAGE CPP #-}
#if __GLASGOW_HASKELL__ >= 913
{-# LANGUAGE GHC_CPP #-}
#endif
We will enable GHC_CPP only
-
043b4500
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
Remove some tracing
-
1166580a
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
Fix test exes for changes
-
fec971d7
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
For GHC_CPP tests, normalise config-time-based macros
-
cbcf2a7f
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
WIP
-
bd7584c6
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
WIP again. What is wrong?
-
c504b628
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
Revert to dynflags for normal not pragma lexing
-
0b66a723
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
Working on getting check-exact to work properly
-
7305118a
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
Passes CppCommentPlacement test
-
4659e186
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
Starting on exact printing with GHC_CPP
While overriding normal CPP
-
546a4023
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
Correctly store CPP ignored tokens as comments
By populating the lexeme string in it, based on the bufpos
-
4bf8249b
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
WIP
-
1fd04489
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
Simplifying
-
ebaea51c
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
Update the active state logic
-
55af33ef
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
Work the new logic into the mainline code
-
761dfa38
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
Process `defined` operator
-
c4930905
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
Manage lexer state while skipping tokens
There is very intricate layout-related state used when lexing. If a
CPP directive blanks out some tokens, store this state when the
blanking starts, and restore it when they are no longer being blanked.
-
2cc75317
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
Track the last token buffer index, for ITCppIgnored
We need to attach the source being skipped in an ITCppIgnored token.
We cannot simply use its BufSpan as an index into the underlying
StringBuffer as it counts unicode chars, not bytes.
So we update the lexer state to store the starting StringBuffer
location for the last token, and use the already-stored length to
extract the correct portion of the StringBuffer being parsed.
-
567d16ec
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
Process the ! operator in GHC_CPP expressions
-
ff29b658
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
Predefine a constant when GHC_CPP is being used.
-
0d9b19fc
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
WIP
-
79cfff97
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
Skip lines directly in the lexer when required
-
2509eea9
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
Properly manage location when accepting tokens again
-
bbb1b32d
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
Seems to be working now, for Example9
-
dab0aec6
by Alan Zimmerman at 2025-05-06T18:08:01+01:00
Remove tracing
-
d979e506
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Fix parsing '*' in block comments
Instead of replacing them with '-'
-
14a22493
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Keep the trailing backslash in a ITcpp token
-
716c4ba1
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Deal with only enabling one section of a group.
A group is an instance of a conditional introduced by
#if/#ifdef/#ifndef,
and ending at the final #endif, including intermediate #elsif sections
-
c6201bdd
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Replace remaining identifiers with 0 when evaluating
As per the spec
-
3015e79a
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Snapshot before rebase
-
4f215d1d
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Skip non-processed lines starting with #
-
32888d20
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Export generateMacros so we can use it in ghc-exactprint
-
f047e6ca
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Fix rebase
-
0632f64b
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Expose initParserStateWithMacrosString
-
f57786ae
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Fix buggy lexer cppSkip
It was skipping all lines, not just ones prefixed by #
-
b010c868
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Fix evaluation of && to use the correct operator
-
d31d438d
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Deal with closing #-} at the start of a line
-
56a08b1c
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Add the MIN_VERSION_GLASGOW_HASKELL predefined macro
-
d9562b7a
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Include MIN_VERSION_GLASGOW_HASKELL in GhcCpp01.stderr
-
a215a5ce
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Use a strict map for macro defines
-
d645f573
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Process TIdentifierLParen
Which only matters at the start of #define
-
7da6441a
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Do not provide TIdentifierLParen paren twice
-
2042c1b0
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Handle whitespace between identifier and '(' for directive only
-
33fec4ca
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Expose some Lexer bitmap manipulation helpers
-
d9b4cf25
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Deal with line pragmas as tokens
Blows up for dumpGhcCpp though
-
079265e4
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Allow strings delimited by a single quote too
-
0f7bad13
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Allow leading whitespace on cpp directives
As per https://timsong-cpp.github.io/cppwp/n4140/cpp#1
-
d8af2caf
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Implement GHC_CPP undef
-
9156970c
by Alan Zimmerman at 2025-05-06T18:08:02+01:00
Sort out expansion of no-arg macros, in a context with args
And make the expansion bottom out, in the case of recursion
-
855c1461
by Alan Zimmerman at 2025-05-06T21:52:14+01:00
Fix GhcCpp01 test
The LINE pragma stuff works in ghc-exactprint when specifically
setting flag to emit ITline_pragma tokens