[Git][ghc/ghc][wip/az/ghc-cpp] 39 commits: compiler: Always load GHC.Data.FastString optimised into GHCi

Alan Zimmerman (@alanz) gitlab at gitlab.haskell.org
Tue Feb 4 20:32:41 UTC 2025



Alan Zimmerman pushed to branch wip/az/ghc-cpp at Glasgow Haskell Compiler / GHC


Commits:
662645f0 by Matthew Pickering at 2025-02-03T11:44:41-05:00
compiler: Always load GHC.Data.FastString optimised into GHCi

The FastString table is shared between the boot compiler and interpreted
compiler. Therefore it's very important the representation of
`FastString` matches in both cases. Otherwise, the interpreter will read
a FastString from the shared variable but place the fields in the wrong
place which leads to segfaults.

Ideally this state would not be shared, but for now we can always
compile both with `-O2` and this leads to a working interpreter.

- - - - -
05e5785a by Peter Trommler at 2025-02-03T11:45:17-05:00
RTS: Fix compile on powerpc64 ELF v1

Cabal does not know about the different ABIs for powerpc64 and compiles
StgCRunAsm.S unconditionally. The old make-based build system excluded
this file from the build and it was OK to signal an error when it was
compiled accidentally.

With this patch we compile StgCRunAsm.S to an empty file, which fixes
the build.

Fixes #25700

- - - - -
cbbb64fb by Matthew Pickering at 2025-02-03T23:40:33-05:00
interpreter: Always print unit and module name in BCO_NAME instruction

Currently the BCO_Name instruction is a bit difficult to use since the
names are not qualified by the module they come from. When you have a
very generic name such as "wildX4", it becomes impossible to work out
which module the identifier comes from.

Fixes #25694

- - - - -
764a43ac by Ben Gamari at 2025-02-03T23:41:10-05:00
upload-ghc-libs: Drop more references to ghc-internal from ghc-boot-th


(cherry picked from commit afec4b75c2d0e9f5c462a86d9f3697acf30355c7)

Co-authored-by: Ben Gamari <bgamari.foss at gmail.com>
- - - - -
9a59b026 by Ben Gamari at 2025-02-04T10:00:18-05:00
gitlab-ci: Don't use .full-ci to run test-primops

test-primops depends upon the existence of validate jobs, yet these do
not exist in the context of nightly jobs, which .full-ci includes.

- - - - -
834be4fb by Alan Zimmerman at 2025-02-04T18:02:19+00: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

- - - - -
37d979cf by Alan Zimmerman at 2025-02-04T18:02:19+00:00
Tidy up before re-visiting the continuation mechanic

- - - - -
54d9f567 by Alan Zimmerman at 2025-02-04T18:02:19+00:00
Switch preprocessor to continuation passing style

Proof of concept, needs tidying up

- - - - -
c9ae16e7 by Alan Zimmerman at 2025-02-04T18:02:19+00:00
Small cleanup

- - - - -
e3383562 by Alan Zimmerman at 2025-02-04T18:02:19+00:00
Get rid of some cruft

- - - - -
ad0b64f3 by Alan Zimmerman at 2025-02-04T18:02:19+00:00
Starting to integrate.

Need to get the pragma recognised and set

- - - - -
dbef56e3 by Alan Zimmerman at 2025-02-04T18:02:19+00:00
Make cppTokens extend to end of line, and process CPP comments

- - - - -
aaaed484 by Alan Zimmerman at 2025-02-04T18:02:19+00:00
Remove unused ITcppDefined

- - - - -
a39b4968 by Alan Zimmerman at 2025-02-04T18:02:19+00:00
Allow spaces between # and keyword for preprocessor directive

- - - - -
261b9356 by Alan Zimmerman at 2025-02-04T18:02:19+00: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.

- - - - -
96347cd5 by Alan Zimmerman at 2025-02-04T18:02:19+00:00
Accumulate CPP continuations, process when ready

Can be simplified further, we only need one CPP token

- - - - -
31511b10 by Alan Zimmerman at 2025-02-04T18:02:19+00:00
Simplify Lexer interface. Only ITcpp

We transfer directive lines through it, then parse them from scratch
in the preprocessor.

- - - - -
b70d94ee by Alan Zimmerman at 2025-02-04T18:02:19+00:00
Deal with directive on last line, with no trailing \n

- - - - -
b9d2983e by Alan Zimmerman at 2025-02-04T18:02:19+00:00
Start parsing and processing the directives

- - - - -
e7cd410f by Alan Zimmerman at 2025-02-04T18:02:19+00:00
Prepare for processing include files

- - - - -
c48dd8ca by Alan Zimmerman at 2025-02-04T18:02:19+00:00
Move PpState into PreProcess

And initParserState, initPragState too

- - - - -
322d9fc8 by Alan Zimmerman at 2025-02-04T18:02:19+00: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

- - - - -
88718e97 by Alan Zimmerman at 2025-02-04T18:02:19+00:00
Split into separate files

- - - - -
69ce6e37 by Alan Zimmerman at 2025-02-04T18:02:19+00:00
Starting on expression parser.

But it hangs. Time for Text.Parsec.Expr

- - - - -
f9d4ab39 by Alan Zimmerman at 2025-02-04T18:02:20+00:00
Start integrating the ghc-cpp work

>From https://github.com/alanz/ghc-cpp

- - - - -
09ef6968 by Alan Zimmerman at 2025-02-04T18:02:20+00:00
WIP

- - - - -
2fe0f7d6 by Alan Zimmerman at 2025-02-04T18:02:20+00:00
Fixup after rebase

- - - - -
c5edd836 by Alan Zimmerman at 2025-02-04T18:02:20+00:00
WIP

- - - - -
4a41bf78 by Alan Zimmerman at 2025-02-04T18:02:20+00:00
Fixup after rebase, including all tests pass

- - - - -
b1609a07 by Alan Zimmerman at 2025-02-04T18:02:20+00:00
Change pragma usage to GHC_CPP from GhcCPP

- - - - -
f868d034 by Alan Zimmerman at 2025-02-04T18:02:20+00:00
Some comments

- - - - -
309947ff by Alan Zimmerman at 2025-02-04T18:02:20+00:00
Reformat

- - - - -
c37309f0 by Alan Zimmerman at 2025-02-04T18:02:20+00:00
Delete unused file

- - - - -
b1c6a4d1 by Alan Zimmerman at 2025-02-04T18:02:20+00:00
Rename module Parse to ParsePP

- - - - -
8bd4c2e5 by Alan Zimmerman at 2025-02-04T18:02:20+00:00
Clarify naming in the parser

- - - - -
b143f90b by Alan Zimmerman at 2025-02-04T18:02:20+00:00
WIP. Switching to alex/happy to be able to work in-tree

Since Parsec is not available

- - - - -
c4490836 by Alan Zimmerman at 2025-02-04T18:02:20+00: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

- - - - -
0056a0d8 by Alan Zimmerman at 2025-02-04T18:02:20+00: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
```

- - - - -
a7efc058 by Alan Zimmerman at 2025-02-04T20:32:03+00:00
Rebase, and all tests pass except whitespace for generated parser

- - - - -


30 changed files:

- .gitlab-ci.yml
- .gitlab/rel_eng/upload_ghc_libs.py
- compiler/GHC.hs
- compiler/GHC/Cmm/Lexer.x
- compiler/GHC/Cmm/Parser.y
- compiler/GHC/Cmm/Parser/Monad.hs
- compiler/GHC/Data/FastString.hs
- compiler/GHC/Driver/Backpack.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Main.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Parser.hs-boot
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Annotation.hs
- compiler/GHC/Parser/HaddockLex.x
- compiler/GHC/Parser/Header.hs
- compiler/GHC/Parser/Lexer.x
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Parser/PostProcess/Haddock.hs
- + compiler/GHC/Parser/PreProcess.hs
- + compiler/GHC/Parser/PreProcess/Eval.hs
- + compiler/GHC/Parser/PreProcess/Lexer.x
- + compiler/GHC/Parser/PreProcess/Macro.hs
- + compiler/GHC/Parser/PreProcess/ParsePP.hs
- + compiler/GHC/Parser/PreProcess/Parser.y
- + compiler/GHC/Parser/PreProcess/ParserM.hs
- + compiler/GHC/Parser/PreProcess/Types.hs
- compiler/GHC/Parser/Utils.hs
- compiler/GHC/StgToByteCode.hs
- compiler/ghc.cabal.in


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/237548092a8cedcc244412f1bf10a6a08f982de1...a7efc05837c7f679c0e67108d5dae368f7a81255

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/237548092a8cedcc244412f1bf10a6a08f982de1...a7efc05837c7f679c0e67108d5dae368f7a81255
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20250204/eb7876ee/attachment-0001.html>


More information about the ghc-commits mailing list