-
e650ec3e
by Ben Gamari at 2025-05-23T03:42:46-04:00
base: Forward port changelog language from 9.12
-
94cd9ca4
by Ben Gamari at 2025-05-23T03:42:46-04:00
base: Fix RestructuredText-isms in changelog
-
7722232c
by Ben Gamari at 2025-05-23T03:42:46-04:00
base: Note strictness changes made in 4.16.0.0
Addresses #25886.
-
3f4b823c
by Ben Gamari at 2025-05-23T03:43:28-04:00
rts/linker: Factor out ProddableBlocks machinery
-
6e23fef2
by Ben Gamari at 2025-05-23T03:43:28-04:00
rts/linker: Improve efficiency of proddable blocks structure
Previously the linker's "proddable blocks" check relied on a simple
linked list of spans. This resulted in extremely poor complexity while
linking objects with lots of small sections (e.g. objects built with
split sections).
Rework the mechanism to instead use a simple interval set implemented
via binary search.
Fixes #26009.
-
ea74860c
by Ben Gamari at 2025-05-23T03:43:28-04:00
testsuite: Add simple functional test for ProddableBlockSet
-
74c4db46
by Ben Gamari at 2025-05-23T03:43:28-04:00
rts/linker/PEi386: Drop check for LOAD_LIBRARY_SEARCH_*_DIRS
The `LOAD_LIBRARY_SEARCH_USER_DIRS` and
`LOAD_LIBRARY_SEARCH_DEFAULT_DIRS` were introduced in Windows Vista and
have been available every since. As we no longer support Windows XP we
can drop this check.
Addresses #26009.
-
972d81d6
by Ben Gamari at 2025-05-23T03:43:28-04:00
rts/linker/PEi386: Clean up code style
-
8a1073a5
by Ben Gamari at 2025-05-23T03:43:28-04:00
rts/Hash: Factor out hashBuffer
This is a useful helper which can be used for non-strings as well.
-
44f509f2
by Ben Gamari at 2025-05-23T03:43:28-04:00
rts/linker/PEi386: Fix incorrect use of break in nested for
Previously the happy path of PEi386 used `break` in a double-`for` loop
resulting in redundant calls to `LoadLibraryEx`.
Fixes #26052.
-
bfb12783
by Ben Gamari at 2025-05-23T03:43:28-04:00
rts: Correctly mark const arguments
-
08469ff8
by Ben Gamari at 2025-05-23T03:43:28-04:00
rts/linker/PEi386: Don't repeatedly load DLLs
Previously every DLL-imported symbol would result in a call to
`LoadLibraryEx`. This ended up constituting over 40% of the runtime of
`ghc --interactive -e 42` on Windows. Avoid this by maintaining a
hash-set of loaded DLL names, skipping the call if we have already
loaded the requested DLL.
Addresses #26009.
-
823d1ccf
by Ben Gamari at 2025-05-23T03:43:28-04:00
rts/linker: Expand comment describing ProddableBlockSet
-
e9de9e0b
by Sylvain Henry at 2025-05-23T15:12:34-04:00
Remove emptyModBreaks
Remove emptyModBreaks and track the absence of ModBreaks with `Maybe
ModBreaks`. It avoids testing for null pointers...
-
17db44c5
by Ben Gamari at 2025-05-23T15:13:16-04:00
base: Expose Backtraces constructor and fields
This was specified in the proposal (CLC #199) yet somehow didn't make it
into the implementation.
Fixes #26049.
-
b331155d
by Alan Zimmerman at 2025-05-24T10:56:53+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
-
6a6f8336
by Alan Zimmerman at 2025-05-24T10:56:53+01:00
Tidy up before re-visiting the continuation mechanic
-
43993211
by Alan Zimmerman at 2025-05-24T10:56:53+01:00
Switch preprocessor to continuation passing style
Proof of concept, needs tidying up
-
825a7b84
by Alan Zimmerman at 2025-05-24T10:56:53+01:00
Small cleanup
-
76c63619
by Alan Zimmerman at 2025-05-24T10:56:53+01:00
Get rid of some cruft
-
1d9960a6
by Alan Zimmerman at 2025-05-24T10:56:53+01:00
Starting to integrate.
Need to get the pragma recognised and set
-
ae452cba
by Alan Zimmerman at 2025-05-24T10:56:53+01:00
Make cppTokens extend to end of line, and process CPP comments
-
3b8658cc
by Alan Zimmerman at 2025-05-24T10:56:53+01:00
Remove unused ITcppDefined
-
27e0296e
by Alan Zimmerman at 2025-05-24T10:56:53+01:00
Allow spaces between # and keyword for preprocessor directive
-
46b6623c
by Alan Zimmerman at 2025-05-24T10:56:53+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.
-
55001b63
by Alan Zimmerman at 2025-05-24T10:56:53+01:00
Accumulate CPP continuations, process when ready
Can be simplified further, we only need one CPP token
-
75cd6f5f
by Alan Zimmerman at 2025-05-24T10:56:53+01:00
Simplify Lexer interface. Only ITcpp
We transfer directive lines through it, then parse them from scratch
in the preprocessor.
-
308129ed
by Alan Zimmerman at 2025-05-24T10:56:53+01:00
Deal with directive on last line, with no trailing \n
-
4fbe856b
by Alan Zimmerman at 2025-05-24T10:56:53+01:00
Start parsing and processing the directives
-
1a263713
by Alan Zimmerman at 2025-05-24T10:56:53+01:00
Prepare for processing include files
-
d731efe8
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Move PpState into PreProcess
And initParserState, initPragState too
-
0c39f394
by Alan Zimmerman at 2025-05-24T10:56:54+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
-
c07b44f4
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Split into separate files
-
45218048
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Starting on expression parser.
But it hangs. Time for Text.Parsec.Expr
-
b59adfd0
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Start integrating the ghc-cpp work
From https://github.com/alanz/ghc-cpp
-
06a7c0ed
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
WIP
-
7002db58
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Fixup after rebase
-
4900171e
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
WIP
-
49bf7922
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Fixup after rebase, including all tests pass
-
cbab1612
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Change pragma usage to GHC_CPP from GhcCPP
-
e7d9a03a
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Some comments
-
9adedee8
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Reformat
-
42579ec6
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Delete unused file
-
3b764ee0
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Rename module Parse to ParsePP
-
4dd44437
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Clarify naming in the parser
-
d85d3140
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
WIP. Switching to alex/happy to be able to work in-tree
Since Parsec is not available
-
a5b5d735
by Alan Zimmerman at 2025-05-24T10:56:54+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
-
da4102a3
by Alan Zimmerman at 2025-05-24T10:56:54+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
```
-
8fe65619
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Rebase, and all tests pass except whitespace for generated parser
-
60387f1b
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
More plumbing. Ready for testing tomorrow.
-
d4b509eb
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Proress. Renamed module State from Types
And at first blush it seems to handle preprocessor scopes properly.
-
f0e80e26
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Insert basic GHC version macros into parser
__GLASGOW_HASKELL__
__GLASGOW_HASKELL_FULL_VERSION__
__GLASGOW_HASKELL_PATCHLEVEL1__
__GLASGOW_HASKELL_PATCHLEVEL2__
-
f141eed9
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Re-sync check-cpp for easy ghci work
-
a0477115
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Get rid of warnings
-
9422b43b
by Alan Zimmerman at 2025-05-24T10:56:54+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
-
5062fe5b
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
WIP. Can crack arguments for #define
Next step it to crack out args in an expansion
-
1843a281
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
WIP on arg parsing.
-
865dde13
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Progress. Still screwing up nested parens.
-
a5d3e335
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Seems to work, but has redundant code
-
e6addc9d
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Remove redundant code
-
26c1d4ea
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Reformat
-
2de9249e
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Expand args, single pass
Still need to repeat until fixpoint
-
980b9fa8
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Fixed point expansion
-
56571b26
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Sync the playground to compiler
-
5274439e
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Working on dumping the GHC_CPP result
But We need to keep the BufSpan in a comment
-
d689071b
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Keep BufSpan in queued comments in GHC.Parser.Lexer
-
ed06be80
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Getting close to being able to print the combined tokens
showing what is in and what is out
-
930e3c73
by Alan Zimmerman at 2025-05-24T10:56:54+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
-
43ce53a7
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Clean up a bit
-
4c7fdd44
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Add -ddump-ghc-cpp option and a test based on it
-
ba0882cd
by Alan Zimmerman at 2025-05-24T10:56:54+01:00
Restore Lexer.x rules, we need them for continuation lines
-
2dcbdc28
by Alan Zimmerman at 2025-05-24T10:56:54+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
-
3ab324c9
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Inserts predefined macros. But does not dump properly
Because the cpp tokens have a trailing newline
-
6c8d9a66
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Remove unnecessary LExer rules
We *need* the ones that explicitly match to the end of the line.
-
f01db2c7
by Alan Zimmerman at 2025-05-24T10:56:55+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.
-
aae100a5
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Reduce duplication in lexer
-
36ecf1de
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Tweaks
-
e21f91eb
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Insert min_version predefined macros into state
The mechanism now works. Still need to flesh out the full set.
-
b9ff7298
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Trying my alternative pragma syntax.
It works, but dumpGhcCpp is broken, I suspect from the ITcpp token
span update.
-
7806b47c
by Alan Zimmerman at 2025-05-24T10:56:55+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
-
0cb5848e
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Remove some tracing
-
4d9ce4da
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Fix test exes for changes
-
4c1a8aa6
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
For GHC_CPP tests, normalise config-time-based macros
-
2dd91346
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
WIP
-
d5dc2164
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
WIP again. What is wrong?
-
54f7ef01
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Revert to dynflags for normal not pragma lexing
-
efde6b0b
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Working on getting check-exact to work properly
-
0584ec31
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Passes CppCommentPlacement test
-
26bdd707
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Starting on exact printing with GHC_CPP
While overriding normal CPP
-
51dbf90c
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Correctly store CPP ignored tokens as comments
By populating the lexeme string in it, based on the bufpos
-
576d82b9
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
WIP
-
e2eb9351
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Simplifying
-
cfa6c9ee
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Update the active state logic
-
e7b67c4c
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Work the new logic into the mainline code
-
f4897a8a
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Process `defined` operator
-
20d71b45
by Alan Zimmerman at 2025-05-24T10:56:55+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.
-
f660cc0f
by Alan Zimmerman at 2025-05-24T10:56:55+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.
-
dff1b130
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Process the ! operator in GHC_CPP expressions
-
0b1a1c8e
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Predefine a constant when GHC_CPP is being used.
-
1b864cbb
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
WIP
-
a122870f
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Skip lines directly in the lexer when required
-
c08e5cfe
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Properly manage location when accepting tokens again
-
5bcb5eaa
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Seems to be working now, for Example9
-
af10cd3a
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Remove tracing
-
7eba8335
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Fix parsing '*' in block comments
Instead of replacing them with '-'
-
c120861f
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Keep the trailing backslash in a ITcpp token
-
aaf6403f
by Alan Zimmerman at 2025-05-24T10:56:55+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
-
4cbc14ce
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Replace remaining identifiers with 0 when evaluating
As per the spec
-
f2efe0a0
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Snapshot before rebase
-
23a08af3
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Skip non-processed lines starting with #
-
070a73ba
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Export generateMacros so we can use it in ghc-exactprint
-
5961854c
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Fix rebase
-
45d09b97
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Expose initParserStateWithMacrosString
-
f68f285b
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Fix buggy lexer cppSkip
It was skipping all lines, not just ones prefixed by #
-
b675bbdc
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Fix evaluation of && to use the correct operator
-
0590858e
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Deal with closing #-} at the start of a line
-
81d303bb
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Add the MIN_VERSION_GLASGOW_HASKELL predefined macro
-
cac17074
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Include MIN_VERSION_GLASGOW_HASKELL in GhcCpp01.stderr
-
99c5d435
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Use a strict map for macro defines
-
09cd7fb3
by Alan Zimmerman at 2025-05-24T10:56:55+01:00
Process TIdentifierLParen
Which only matters at the start of #define
-
9fd72f0b
by Alan Zimmerman at 2025-05-24T10:56:56+01:00
Do not provide TIdentifierLParen paren twice
-
6ec0fa43
by Alan Zimmerman at 2025-05-24T10:56:56+01:00
Handle whitespace between identifier and '(' for directive only
-
167fb4a8
by Alan Zimmerman at 2025-05-24T10:56:56+01:00
Expose some Lexer bitmap manipulation helpers
-
40d267e3
by Alan Zimmerman at 2025-05-24T10:56:56+01:00
Deal with line pragmas as tokens
Blows up for dumpGhcCpp though
-
e6d4be32
by Alan Zimmerman at 2025-05-24T10:56:56+01:00
Allow strings delimited by a single quote too
-
50f024fd
by Alan Zimmerman at 2025-05-24T10:56:56+01:00
Allow leading whitespace on cpp directives
As per https://timsong-cpp.github.io/cppwp/n4140/cpp#1
-
55406057
by Alan Zimmerman at 2025-05-24T10:56:56+01:00
Implement GHC_CPP undef
-
669e08f4
by Alan Zimmerman at 2025-05-24T10:56:56+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
-
24e61f12
by Alan Zimmerman at 2025-05-24T10:56:56+01:00
Fix GhcCpp01 test
The LINE pragma stuff works in ghc-exactprint when specifically
setting flag to emit ITline_pragma tokens
-
a8ebae85
by Alan Zimmerman at 2025-05-24T10:56:56+01:00
Process comments in CPP directives
-
06888106
by Alan Zimmerman at 2025-05-24T10:56:56+01:00
Correctly lex pragmas with finel #-} on a newline
-
85554b54
by Alan Zimmerman at 2025-05-24T10:56:56+01:00
Do not process CPP-style comments
-
e23844a0
by Alan Zimmerman at 2025-05-24T10:56:56+01:00
Allow cpp-style comments when GHC_CPP enabled
-
1754f279
by Alan Zimmerman at 2025-05-24T10:56:56+01:00
Return other pragmas as cpp ignored when GHC_CPP active
-
f10714b5
by Alan Zimmerman at 2025-05-24T10:56:56+01:00
Fix exactprinting default decl
-
c5ad6c90
by Alan Zimmerman at 2025-05-25T15:29:59+01:00
Reorganise getOptionsFromFile for use in ghc-exactprint
We want to be able to inject predefined macro definitions into the
parser preprocessor state for when we do a hackage roundtrip.