Commit ebcbfba7 authored by Roland Senn's avatar Roland Senn Committed by Ben Gamari

Introduce flag -keep-hscpp-files

Test Plan: `make test=T10869`

Reviewers: mpickering, thomie, ezyang, bgamari

Reviewed By: thomie, bgamari

Subscribers: rwbarton, carter

GHC Trac Issues: #10869

Differential Revision: https://phabricator.haskell.org/D4861
parent 23774c98
......@@ -762,6 +762,7 @@ getOutputFilename stop_phase output basename dflags next_phase maybe_location
odir = objectDir dflags
osuf = objectSuf dflags
keep_hc = gopt Opt_KeepHcFiles dflags
keep_hscpp = gopt Opt_KeepHscppFiles dflags
keep_s = gopt Opt_KeepSFiles dflags
keep_bc = gopt Opt_KeepLlvmFiles dflags
......@@ -778,6 +779,7 @@ getOutputFilename stop_phase output basename dflags next_phase maybe_location
As _ | keep_s -> True
LlvmOpt | keep_bc -> True
HCc | keep_hc -> True
HsPp _ | keep_hscpp -> True -- See Trac #10869
_other -> False
suffix = myPhaseInputExt next_phase
......
......@@ -618,6 +618,7 @@ data GeneralFlag
| Opt_ImplicitImportQualified
-- keeping stuff
| Opt_KeepHscppFiles
| Opt_KeepHiDiffs
| Opt_KeepHcFiles
| Opt_KeepSFiles
......@@ -2961,6 +2962,10 @@ dynamic_flags_deps = [
(NoArg (setGeneralFlag Opt_KeepHcFiles))
, make_ord_flag defGhcFlag "keep-hc-files"
(NoArg (setGeneralFlag Opt_KeepHcFiles))
, make_ord_flag defGhcFlag "keep-hscpp-file"
(NoArg (setGeneralFlag Opt_KeepHscppFiles))
, make_ord_flag defGhcFlag "keep-hscpp-files"
(NoArg (setGeneralFlag Opt_KeepHscppFiles))
, make_ord_flag defGhcFlag "keep-s-file"
(NoArg (setGeneralFlag Opt_KeepSFiles))
, make_ord_flag defGhcFlag "keep-s-files"
......
......@@ -30,6 +30,7 @@ Language
Compiler
~~~~~~~~
- New :ghc-flag:`-keep-hscpp-files` to keep the output of the CPP pre-processor.
Runtime system
~~~~~~~~~~~~~~
......
......@@ -397,6 +397,19 @@ compilation:
Keep intermediate ``.hi`` files. This is the default. You may use
``-no-keep-hi-files`` if you are not interested in the ``.hi`` files.
.. ghc-flag:: -keep-hscpp-file
-keep-hscpp-files
:shortdesc: Retain intermediate ``.hscpp`` files.
:type: dynamic
:category: keep-intermediates
.. index::
single: temporary files; keeping
Keep the output of the ``CPP`` pre-processor phase as ``.hscpp`` files.
A ``.hscpp`` file is only created, if a module gets compiled and uses the
C pre-processor.
.. ghc-flag:: -keep-llvm-file
-keep-llvm-files
:shortdesc: Retain intermediate LLVM ``.ll`` files.
......
......@@ -619,6 +619,14 @@ T10320:
"$(TEST_HC)" $(TEST_HC_OPTS) -v0 -fforce-recomp -ddump-to-file -ddump-rule-rewrites T10320.hs
[ -f T10320.dump-rule-rewrites ] && [ ! -s T10320.dump-rule-rewrites ]
.PHONY: T10869
T10869:
$(RM) -rf T10869.hi T10869.o T10869.hspp T10869
$(RM) -rf T10869A.hi T10869A.o T10869A.hspp
"$(TEST_HC)" $(TEST_HC_OPTS) -c -keep-hscpp-files T10869A.hs T10869.hs
test -f T10869.hscpp
test -f T10869A.hscpp
.PHONY: T12135
T12135:
$(RM) -rf T12135.o T12135.hi T12135 T12135a T12135b
......
{-# LANGUAGE CPP #-}
module T10869 where
import T10869A
main :: IO()
#if defined(__GLASGOW_HASKELL__)
main = writeMsg
#endif
{-# LANGUAGE CPP #-}
module T10869A (writeMsg) where
writeMsg :: IO ()
#if defined(__GLASGOW_HASKELL__)
writeMsg = putStrLn "Hello HSPP File"
#endif
......@@ -234,6 +234,8 @@ test('T10220', normal, run_command,
test('T10182', [], run_command, ['$MAKE -s --no-print-directory T10182'])
test('T10869', [], run_command, ['$MAKE -s --no-print-directory T10869'])
test('T365',
[pre_cmd('touch test_preprocessor.txt'), unless(opsys('mingw32'), skip)],
compile_fail, [''])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment