diff options
author | roland <rsx@bluewin.ch> | 2018-08-21 12:18:26 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-08-21 18:52:42 -0400 |
commit | ebcbfba7bbf07fa9fbb78b46951892997795bcb8 (patch) | |
tree | e86c442edbcc6403bb7a2bf85c12b889f941ef39 | |
parent | 23774c98f1368b41515cbd5223b87ea6dbf644e1 (diff) | |
download | haskell-ebcbfba7bbf07fa9fbb78b46951892997795bcb8.tar.gz |
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
-rw-r--r-- | compiler/main/DriverPipeline.hs | 2 | ||||
-rw-r--r-- | compiler/main/DynFlags.hs | 5 | ||||
-rw-r--r-- | docs/users_guide/8.8.1-notes.rst | 1 | ||||
-rw-r--r-- | docs/users_guide/separate_compilation.rst | 13 | ||||
-rw-r--r-- | testsuite/tests/driver/Makefile | 8 | ||||
-rw-r--r-- | testsuite/tests/driver/T10869.hs | 9 | ||||
-rw-r--r-- | testsuite/tests/driver/T10869A.hs | 7 | ||||
-rw-r--r-- | testsuite/tests/driver/all.T | 2 |
8 files changed, 47 insertions, 0 deletions
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index 68f69fc707..eff542a80b 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -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 diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index ff4766f425..be148796e3 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -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" diff --git a/docs/users_guide/8.8.1-notes.rst b/docs/users_guide/8.8.1-notes.rst index 2661b330ed..7ea2c87cbe 100644 --- a/docs/users_guide/8.8.1-notes.rst +++ b/docs/users_guide/8.8.1-notes.rst @@ -30,6 +30,7 @@ Language Compiler ~~~~~~~~ +- New :ghc-flag:`-keep-hscpp-files` to keep the output of the CPP pre-processor. Runtime system ~~~~~~~~~~~~~~ diff --git a/docs/users_guide/separate_compilation.rst b/docs/users_guide/separate_compilation.rst index 613e4de191..d17ed2111c 100644 --- a/docs/users_guide/separate_compilation.rst +++ b/docs/users_guide/separate_compilation.rst @@ -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. diff --git a/testsuite/tests/driver/Makefile b/testsuite/tests/driver/Makefile index 727cc44940..540f158b14 100644 --- a/testsuite/tests/driver/Makefile +++ b/testsuite/tests/driver/Makefile @@ -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 diff --git a/testsuite/tests/driver/T10869.hs b/testsuite/tests/driver/T10869.hs new file mode 100644 index 0000000000..e1518544b2 --- /dev/null +++ b/testsuite/tests/driver/T10869.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE CPP #-} + +module T10869 where +import T10869A + +main :: IO() +#if defined(__GLASGOW_HASKELL__) +main = writeMsg +#endif diff --git a/testsuite/tests/driver/T10869A.hs b/testsuite/tests/driver/T10869A.hs new file mode 100644 index 0000000000..14e57772c7 --- /dev/null +++ b/testsuite/tests/driver/T10869A.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE CPP #-} +module T10869A (writeMsg) where + +writeMsg :: IO () +#if defined(__GLASGOW_HASKELL__) +writeMsg = putStrLn "Hello HSPP File" +#endif diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T index 07dc3bf916..be91a261d8 100644 --- a/testsuite/tests/driver/all.T +++ b/testsuite/tests/driver/all.T @@ -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, ['']) |