-
652cba7e
by Peng Fan at 2025-05-14T04:24:35-04:00
Add LoongArch NCG support
Not supported before.
-
c01f4374
by Lin Runze at 2025-05-14T04:24:35-04:00
ci: Add LoongArch64 cross-compile CI for testing
-
ce6cf240
by Ben Gamari at 2025-05-14T04:25:18-04:00
rts/linker: Don't fail due to RTLD_NOW
In !12264 we started using the NativeObj machinery introduced some time
ago for loading of shared objects. One of the side-effects of this
change is shared objects are now loaded eagerly (i.e. with `RTLD_NOW`).
This is needed by NativeObj to ensure full visibility of the mappings of
the loaded object, which is in turn needed for safe shared object
unloading.
Unfortunately, this change subtly regressed, causing compilation
failures in some programs. Specifically, shared objects which refer to
undefined symbols (e.g. which may be usually provided by either the
executable image or libraries loaded via `dlopen`) will fail to load
with eager binding. This is problematic as GHC loads all package
dependencies while, e.g., evaluating TemplateHaskell splices. This
results in compilation failures in programs depending upon (but not
using at compile-time) packages with undefined symbol references.
To mitigate this NativeObj now first attempts to load an object via
eager binding, reverting to lazy binding (and disabling unloading) on
failure.
See Note [Don't fail due to RTLD_NOW].
Fixes #25943.
-
88ee8bb5
by Sylvain Henry at 2025-05-14T04:26:15-04:00
Deprecate GHC.JS.Prim.Internal.Build (#23432)
Deprecated as per CLC proposal 329 (https://github.com/haskell/core-libraries-committee/issues/329)
-
b4ed465b
by Cheng Shao at 2025-05-14T04:26:57-04:00
libffi: update to 3.4.8
Bumps libffi submodule.
-
a3e71296
by Matthew Pickering at 2025-05-14T04:27:38-04:00
Remove leftover trace
-
2d0ecdc6
by Cheng Shao at 2025-05-14T04:28:19-04:00
Revert "ci: re-enable chrome for wasm ghci browser tests"
This reverts commit fee9b351fa5a35d5778d1252789eacaaf5663ae8.
Unfortunately the chrome test jobs may still timeout on certain
runners (e.g. OpenCape) for unknown reasons.
-
2f63ebb0
by Alan Zimmerman at 2025-05-14T18:19:19+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
-
96b5a640
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
Tidy up before re-visiting the continuation mechanic
-
3252d373
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
Switch preprocessor to continuation passing style
Proof of concept, needs tidying up
-
68621389
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
Small cleanup
-
6ab7e8b1
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
Get rid of some cruft
-
b2718948
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
Starting to integrate.
Need to get the pragma recognised and set
-
12ea9390
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
Make cppTokens extend to end of line, and process CPP comments
-
c911a9ec
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
Remove unused ITcppDefined
-
f396e819
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
Allow spaces between # and keyword for preprocessor directive
-
261da91b
by Alan Zimmerman at 2025-05-14T18:19:19+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.
-
036858d6
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
Accumulate CPP continuations, process when ready
Can be simplified further, we only need one CPP token
-
0bdb4532
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
Simplify Lexer interface. Only ITcpp
We transfer directive lines through it, then parse them from scratch
in the preprocessor.
-
e39f243b
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
Deal with directive on last line, with no trailing \n
-
b42886a2
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
Start parsing and processing the directives
-
352bc688
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
Prepare for processing include files
-
d0b47755
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
Move PpState into PreProcess
And initParserState, initPragState too
-
94bed0ea
by Alan Zimmerman at 2025-05-14T18:19:19+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
-
83b00a80
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
Split into separate files
-
b405a2d9
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
Starting on expression parser.
But it hangs. Time for Text.Parsec.Expr
-
2418a2a0
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
Start integrating the ghc-cpp work
From https://github.com/alanz/ghc-cpp
-
22a64399
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
WIP
-
746b22df
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
Fixup after rebase
-
c5566266
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
WIP
-
bd1a0f1b
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
Fixup after rebase, including all tests pass
-
66987b54
by Alan Zimmerman at 2025-05-14T18:19:19+01:00
Change pragma usage to GHC_CPP from GhcCPP
-
d9a2b76d
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Some comments
-
6f3f52c1
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Reformat
-
764cda90
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Delete unused file
-
ea5f32d7
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Rename module Parse to ParsePP
-
1f2ae7ca
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Clarify naming in the parser
-
9633ea57
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
WIP. Switching to alex/happy to be able to work in-tree
Since Parsec is not available
-
445630a3
by Alan Zimmerman at 2025-05-14T18:19:20+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
-
6325ba58
by Alan Zimmerman at 2025-05-14T18:19:20+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
```
-
b523d99e
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Rebase, and all tests pass except whitespace for generated parser
-
fd66b3a8
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
More plumbing. Ready for testing tomorrow.
-
474ad311
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Proress. Renamed module State from Types
And at first blush it seems to handle preprocessor scopes properly.
-
022c30e5
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Insert basic GHC version macros into parser
__GLASGOW_HASKELL__
__GLASGOW_HASKELL_FULL_VERSION__
__GLASGOW_HASKELL_PATCHLEVEL1__
__GLASGOW_HASKELL_PATCHLEVEL2__
-
a27f36b0
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Re-sync check-cpp for easy ghci work
-
64e50680
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Get rid of warnings
-
109fc742
by Alan Zimmerman at 2025-05-14T18:19:20+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
-
cf5bf32a
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
WIP. Can crack arguments for #define
Next step it to crack out args in an expansion
-
2e0f5a7c
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
WIP on arg parsing.
-
1e203004
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Progress. Still screwing up nested parens.
-
0ef50414
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Seems to work, but has redundant code
-
d2bd34af
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Remove redundant code
-
27fc83c3
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Reformat
-
3892339b
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Expand args, single pass
Still need to repeat until fixpoint
-
de56efc9
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Fixed point expansion
-
1e1dde58
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Sync the playground to compiler
-
9b0c8026
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Working on dumping the GHC_CPP result
But We need to keep the BufSpan in a comment
-
69c6ac89
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Keep BufSpan in queued comments in GHC.Parser.Lexer
-
43b13276
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Getting close to being able to print the combined tokens
showing what is in and what is out
-
09a01436
by Alan Zimmerman at 2025-05-14T18:19:20+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
-
1bbf1d7a
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Clean up a bit
-
bc261c64
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Add -ddump-ghc-cpp option and a test based on it
-
55a5adae
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Restore Lexer.x rules, we need them for continuation lines
-
19d05f60
by Alan Zimmerman at 2025-05-14T18:19:20+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
-
1cbf8b49
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Inserts predefined macros. But does not dump properly
Because the cpp tokens have a trailing newline
-
4421462d
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Remove unnecessary LExer rules
We *need* the ones that explicitly match to the end of the line.
-
f204d7ea
by Alan Zimmerman at 2025-05-14T18:19:20+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.
-
a240d600
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Reduce duplication in lexer
-
e7ec23a8
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Tweaks
-
a5032dfb
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Insert min_version predefined macros into state
The mechanism now works. Still need to flesh out the full set.
-
cf2e55c1
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Trying my alternative pragma syntax.
It works, but dumpGhcCpp is broken, I suspect from the ITcpp token
span update.
-
e04ac38e
by Alan Zimmerman at 2025-05-14T18:19:20+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
-
7c192ee2
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Remove some tracing
-
39606949
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Fix test exes for changes
-
c8ac21b5
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
For GHC_CPP tests, normalise config-time-based macros
-
4752335f
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
WIP
-
fccb48e5
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
WIP again. What is wrong?
-
2f207455
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Revert to dynflags for normal not pragma lexing
-
07f0908a
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Working on getting check-exact to work properly
-
5f18753a
by Alan Zimmerman at 2025-05-14T18:19:20+01:00
Passes CppCommentPlacement test
-
05d23c50
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Starting on exact printing with GHC_CPP
While overriding normal CPP
-
413e8011
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Correctly store CPP ignored tokens as comments
By populating the lexeme string in it, based on the bufpos
-
63ebbea0
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
WIP
-
03b84f2d
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Simplifying
-
96e512ba
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Update the active state logic
-
d4b97464
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Work the new logic into the mainline code
-
8d49b2c1
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Process `defined` operator
-
fba9491d
by Alan Zimmerman at 2025-05-14T18:19:21+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.
-
31eeb8ad
by Alan Zimmerman at 2025-05-14T18:19:21+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.
-
998520b7
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Process the ! operator in GHC_CPP expressions
-
36381727
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Predefine a constant when GHC_CPP is being used.
-
16e87acb
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
WIP
-
3f43657f
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Skip lines directly in the lexer when required
-
bb3a00eb
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Properly manage location when accepting tokens again
-
e839d8e7
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Seems to be working now, for Example9
-
ea5ee1c4
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Remove tracing
-
561ac7f1
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Fix parsing '*' in block comments
Instead of replacing them with '-'
-
ee86e580
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Keep the trailing backslash in a ITcpp token
-
58ad089d
by Alan Zimmerman at 2025-05-14T18:19:21+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
-
4d401a98
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Replace remaining identifiers with 0 when evaluating
As per the spec
-
99c373a5
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Snapshot before rebase
-
3bcdd146
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Skip non-processed lines starting with #
-
60046877
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Export generateMacros so we can use it in ghc-exactprint
-
26984a2a
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Fix rebase
-
3aca4e6e
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Expose initParserStateWithMacrosString
-
3bf073b0
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Fix buggy lexer cppSkip
It was skipping all lines, not just ones prefixed by #
-
9350d1e8
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Fix evaluation of && to use the correct operator
-
2fc71268
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Deal with closing #-} at the start of a line
-
11ac7351
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Add the MIN_VERSION_GLASGOW_HASKELL predefined macro
-
3957dc93
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Include MIN_VERSION_GLASGOW_HASKELL in GhcCpp01.stderr
-
40364d92
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Use a strict map for macro defines
-
b590d71d
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Process TIdentifierLParen
Which only matters at the start of #define
-
1bfc2787
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Do not provide TIdentifierLParen paren twice
-
e968ea61
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Handle whitespace between identifier and '(' for directive only
-
1312a310
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Expose some Lexer bitmap manipulation helpers
-
f2869803
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Deal with line pragmas as tokens
Blows up for dumpGhcCpp though
-
6c3355e3
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Allow strings delimited by a single quote too
-
8c83f87b
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Allow leading whitespace on cpp directives
As per https://timsong-cpp.github.io/cppwp/n4140/cpp#1
-
4ce93134
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Implement GHC_CPP undef
-
92b16e5f
by Alan Zimmerman at 2025-05-14T18:19:21+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
-
f94500fc
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Fix GhcCpp01 test
The LINE pragma stuff works in ghc-exactprint when specifically
setting flag to emit ITline_pragma tokens
-
c1a50d52
by Alan Zimmerman at 2025-05-14T18:19:21+01:00
Process comments in CPP directives
-
06b64dd4
by Alan Zimmerman at 2025-05-15T22:13:54+01:00
Correctly lex pragmas with finel #-} on a newline