Introduce flag -keep-hspp-files (#10869)
Needs ReviewPublic

Authored by RolandSenn on Sun, Jun 17, 5:39 AM.

Details

Reviewers
mpickering
thomie
ezyang
bgamari
Trac Issues
#10869
Summary

Keep the output of the CPP preprocessor phase as .hspp files. A .hspp file is only created, if a module gets compiled and uses the preprocessor.

Test Plan

Testcase T10869

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Branch
keep-hspp-files
Lint
Lint ErrorsExcuse: Lint errors are in T12971. My changes are in T10869.
SeverityLocationCodeMessage
Errortestsuite/tests/driver/Makefile:669TXT5Bad Charset
Errortestsuite/tests/driver/Makefile:670TXT5Bad Charset
Unit
No Unit Test Coverage
Build Status
Buildable 21368
Build 48355: [GHC] Linux/amd64: Continuous Integration
Build 48354: [GHC] OSX/amd64: Continuous Integration
Build 48353: [GHC] Windows/amd64: Continuous Integration
Build 48352: arc lint + arc unit
RolandSenn created this revision.Sun, Jun 17, 5:39 AM

This is my first contribution to GHC, where I wrote real Haskell code. Therefore this is just a draft version and it needs some additional improvments.

1: CPP processing. See: ./compiler/main/DriverPipeline.hs.runPhase (RealPhase (Cpp sf)) (ca line 940):
When the -keep-hspp-file flag is set, the output file of the CPP preprocessor is copied to the *.hspp file.

2: END processing See: ./compiler/main/DriverPipeline.hs.pipeLoop (ca line 680):
The output of the last compiler phase is copied. With the -E option, GHC processing stops early and copies the output of the CPP phase to the *.hspp file.
If the user specifies both flags -E and -keep-hspp-file, then the file will be copied a first time in my new code during CPP processing and a second time here.
This is bad! Therefore I added code to avoid duplicate copying.
However, with the -E flag set, it would be better to skip the copying during CPP processing.
Unfortunately I was unable to check the -E flag in the CPP processing code! The "Mode Flags" like the -E flag, only exist in ./ghc/Main.hs.
I didn't find anything like gopt for the mode flags!! How can I check them??
I looked at the 'stop_phase' field in the PipeEnv Structure, but with or without the -E flag, it has the same value (Hsc).

Please advice! Many thanks!

bgamari retitled this revision from Docu for flag: keep-hspp-files (#10869) to Introduce flag -keep-hspp-files (#10869).Sun, Jun 17, 8:25 AM
bgamari updated the Trac tickets for this revision.
bgamari requested changes to this revision.Sun, Jun 17, 9:40 AM

Thanks for your contribution @RolandSenn!

The patch itself looks great. However, do you suppose you could amend the differential summary to describe what the patch is doing?

docs/users_guide/separate_compilation.rst
415

Can you wrap the .hspp in quotes? Also, replace "precompiler" with "preprocessor".

This revision now requires changes to proceed.Sun, Jun 17, 9:40 AM
RolandSenn updated this revision to Diff 16989.Sun, Jun 17, 2:39 PM
RolandSenn marked an inline comment as done.Sun, Jun 17, 2:44 PM

I added the requested changes by bgamari and by the linter. Please feel free to request additional changes!

@bgamari : You wrote:

However, do you suppose you could amend the differential summary to describe what the patch is doing?

What do you exactly mean by this? Should I change/improve the description in docs/users_guide/separate_compilation.rst? Or do you simply mean the two little changes (quotes and preprocessor)? Please advice! Many thanks!

@bgamari : You wrote:

However, do you suppose you could amend the differential summary to describe what the patch is doing?

What do you exactly mean by this? Should I change/improve the description in docs/users_guide/separate_compilation.rst? Or do you simply mean the two little changes (quotes and preprocessor)? Please advice! Many thanks!

The differential summary (the bit shown under the "Summary" heading of this page) will become the commit message when this patch is landed. I was simply suggesting that you add a bit of text describing the goal of the patch for posterity.

Hello Ben,
I'll do this. But this week I'm away from my desktop computer. So maybe
it will take till mid next week. 
Thanks and best wishes.   Roland

RolandSenn edited the summary of this revision. (Show Details)Mon, Jun 25, 11:53 AM