[GHC] #10869: Option to dump preprocessed source

#10869: Option to dump preprocessed source -------------------------------------+------------------------------------- Reporter: phischu | Owner: Type: feature | Status: new request | Priority: low | Milestone: Component: Driver | Version: 7.10.2 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | -------------------------------------+------------------------------------- It would be awesome if GHC had an option `-ddump-preprocessed` that dumps the source code for each module after preprocessing. I am not sure what the current definition of "preprocessing" is but I mean the output of at least the following tools: happy, alex, c2hs, hsc2hs and cpp. Additionally even if a module was not subject to any preprocessing it should be dumped anyway. Use case: I want to parse module files from packages from hackage with `haskell-src-exts` but find it prohibitively difficult to get the preprocessing right. The idea is that after `cabal install` with ghc options `-ddump-preprocessed -ddump-to-file -dumpdir real_modules` you get a complete working set of haskell modules that can be parsed directly without any preprocessing in folder `real_modules`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10869 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10869: Option to dump preprocessed source -------------------------------------+------------------------------------- Reporter: phischu | Owner: Type: feature request | Status: new Priority: low | Milestone: Component: Driver | Version: 7.10.2 Resolution: | Keywords: easy Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by ezyang): * keywords: => easy -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10869#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10869: Option to dump preprocessed source -------------------------------------+------------------------------------- Reporter: phischu | Owner: Type: feature request | Status: new Priority: low | Milestone: Component: Driver | Version: 7.10.2 Resolution: | Keywords: easy Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by mpickering): I'm fairly sure there is already this option? Maybe it's `-E`.. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10869#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10869: Option to dump preprocessed source -------------------------------------+------------------------------------- Reporter: phischu | Owner: Type: feature request | Status: closed Priority: low | Milestone: Component: Driver | Version: 7.10.2 Resolution: invalid | Keywords: easy Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thomie): * status: new => closed * resolution: => invalid Comment: Replying to [comment:2 mpickering]:
I'm fairly sure there is already this option? Maybe it's `-E`..
Exactly, see: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/modes.html #options-order The option -E runs just the pre-processing passes of the compiler, dumping the result in a file. GHC doesn't run `happy, alex, c2hs or hsc2hs` for you, so I don't think there's anything to do here. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10869#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10869: Option to dump preprocessed source -------------------------------------+------------------------------------- Reporter: phischu | Owner: Type: feature request | Status: closed Priority: low | Milestone: Component: Driver | Version: 7.10.2 Resolution: invalid | Keywords: easy Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by thomie): Or maybe you want `--make` and `-E` to work together? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10869#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10869: Option to dump preprocessed source -------------------------------------+------------------------------------- Reporter: phischu | Owner: Type: feature request | Status: closed Priority: low | Milestone: Component: Driver | Version: 7.10.2 Resolution: invalid | Keywords: easy Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by phischu): I am sorry that the request was not clear. `-E` stops ghc after preprocessing. But I want ghc to work normally but in addition dump the preprocessed source files. So, yes, I kinda want `--make` and `-E` to work together. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10869#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10869: Option to dump preprocessed source -------------------------------------+------------------------------------- Reporter: phischu | Owner: Type: feature request | Status: new Priority: low | Milestone: Component: Driver | Version: 7.10.2 Resolution: | Keywords: easy Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): -------------------------------------+------------------------------------- Changes (by thomie): * status: closed => new * resolution: invalid => -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10869#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10869: Option to dump preprocessed source -------------------------------------+------------------------------------- Reporter: phischu | Owner: RolandSenn Type: feature request | Status: new Priority: low | Milestone: Component: Driver | Version: 7.10.2 Resolution: | Keywords: easy Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RolandSenn): * owner: (none) => RolandSenn Comment: I'll try to implement this: * A new compiler flag `--ddump-preprocessed` will be defined and documented. * With the new flag set, GHC will generate the <module>.hspp file with the same content as the one created with the GHC option `-E`. * Opposite to the `-E` processing, GHC will not stop, but continue its processing normally. * If you specify both `-E` and `--ddump-preprocessed`, there will be the same processing as with only the GHC option `-E`: GHC will stop after producing the <module>.hspp file. No error/warning message will be issued. * A test case will be added. As usual, if you disagree, please do holler... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10869#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10869: Option to dump preprocessed source -------------------------------------+------------------------------------- Reporter: phischu | Owner: RolandSenn Type: feature request | Status: new Priority: low | Milestone: Component: Driver | Version: 7.10.2 Resolution: | Keywords: easy Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RolandSenn): After looking into the code, I decided the following: The requested functionality is not a ''dump'' operation. In a dump operation we have information in memory and write (dump) it out to sysout, syserror or to a file. Here, however, we have the information already in a file and we want to keep the file after GHC processing ends. Hence, this is a ''keep'' operation, and the flag will be called '''keep-hspp-file'''. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10869#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10869: Option to dump preprocessed source -------------------------------------+------------------------------------- Reporter: phischu | Owner: RolandSenn Type: feature request | Status: patch Priority: low | Milestone: Component: Driver | Version: 7.10.2 Resolution: | Keywords: easy Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RolandSenn): * status: new => patch Comment: DRAFT patch uploaded to https://phabricator.haskell.org/D4861 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10869#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10869: Option to dump preprocessed source -------------------------------------+------------------------------------- Reporter: phischu | Owner: RolandSenn Type: feature request | Status: patch Priority: low | Milestone: Component: Driver | Version: 7.10.2 Resolution: | Keywords: easy Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab: D4861 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RolandSenn): * differential: => Phab: D4861 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10869#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10869: Option to dump preprocessed source -------------------------------------+------------------------------------- Reporter: phischu | Owner: RolandSenn Type: feature request | Status: patch Priority: low | Milestone: Component: Driver | Version: 7.10.2 Resolution: | Keywords: easy Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: T10869 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab: D4861 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RolandSenn): * testcase: => T10869 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10869#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10869: Option to dump preprocessed source -------------------------------------+------------------------------------- Reporter: phischu | Owner: RolandSenn Type: feature request | Status: patch Priority: low | Milestone: Component: Driver | Version: 7.10.2 Resolution: | Keywords: easy Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: T10869 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab: D4861 Wiki Page: | -------------------------------------+------------------------------------- Comment (by RolandSenn): Flag is now called **keep-hscpp-file**. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10869#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10869: Option to dump preprocessed source -------------------------------------+------------------------------------- Reporter: phischu | Owner: RolandSenn Type: feature request | Status: patch Priority: low | Milestone: 8.8.1 Component: Driver | Version: 7.10.2 Resolution: | Keywords: easy Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: T10869 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab: D4861 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RolandSenn): * milestone: => 8.8.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10869#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10869: Option to dump preprocessed source -------------------------------------+------------------------------------- Reporter: phischu | Owner: RolandSenn Type: feature request | Status: patch Priority: low | Milestone: 8.8.1 Component: Driver | Version: 7.10.2 Resolution: | Keywords: easy Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: T10869 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4861 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RolandSenn): * differential: Phab: D4861 => Phab:D4861 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10869#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10869: Option to dump preprocessed source
-------------------------------------+-------------------------------------
Reporter: phischu | Owner: RolandSenn
Type: feature request | Status: patch
Priority: low | Milestone: 8.8.1
Component: Driver | Version: 7.10.2
Resolution: | Keywords: easy
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case: T10869
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D4861
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#10869: Option to dump preprocessed source -------------------------------------+------------------------------------- Reporter: phischu | Owner: RolandSenn Type: feature request | Status: closed Priority: low | Milestone: 8.8.1 Component: Driver | Version: 7.10.2 Resolution: fixed | Keywords: easy Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: T10869 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4861 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10869#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC