diff options
author | Douglas Wilson <douglas.wilson@gmail.com> | 2017-05-20 12:47:41 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-05-20 16:29:18 -0400 |
commit | 53c78be0aab76a3107c4dacbb1d177afacdd37fa (patch) | |
tree | 2ce5906fc856e3c49d6e4657d6c95870e6f55b83 /testsuite/tests/th/should_compile | |
parent | 0102e2b731d33abdff4c3cde6938d1bede8f51cb (diff) | |
download | haskell-53c78be0aab76a3107c4dacbb1d177afacdd37fa.tar.gz |
Compile modules that are needed by template haskell, even with -fno-code.
This patch relates to Trac #8025
The goal here is to enable typechecking of packages that contain some
template haskell. Prior to this patch, compilation of a package with
-fno-code would fail if any functions in the package were called from
within a splice.
downsweep is changed to do an additional pass over the modules,
targetting any ModSummaries transitively depended on by a module that
has LangExt.TemplateHaskell enabled. Those targeted modules have
hscTarget changed from HscNothing to the default target of the platform.
There is a small change to the prevailing_target logic to enable this.
A simple test is added.
I have benchmarked with and without a patched haddock
(available:https://github.com/duog/haddock/tree/wip-no-explicit-th-compi
lation). Running cabal haddock on the wreq package results in a 25%
speedup on my machine:
time output from patched cabal haddock:
real 0m5.780s
user 0m5.304s
sys 0m0.496s
time output from unpatched cabal haddock:
real 0m7.712s
user 0m6.888s
sys 0m0.736s
Reviewers: austin, bgamari, ezyang
Reviewed By: bgamari
Subscribers: bgamari, DanielG, rwbarton, thomie
GHC Trac Issues: #8025
Differential Revision: https://phabricator.haskell.org/D3441
Diffstat (limited to 'testsuite/tests/th/should_compile')
-rw-r--r-- | testsuite/tests/th/should_compile/T8025/A.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/th/should_compile/T8025/B.hs | 5 | ||||
-rw-r--r-- | testsuite/tests/th/should_compile/T8025/Makefile | 3 | ||||
-rw-r--r-- | testsuite/tests/th/should_compile/T8025/all.T | 2 |
4 files changed, 13 insertions, 0 deletions
diff --git a/testsuite/tests/th/should_compile/T8025/A.hs b/testsuite/tests/th/should_compile/T8025/A.hs new file mode 100644 index 0000000000..c0e3083a01 --- /dev/null +++ b/testsuite/tests/th/should_compile/T8025/A.hs @@ -0,0 +1,3 @@ +{-# LANGUAGE TemplateHaskell #-} +module A where +a = [|3|] diff --git a/testsuite/tests/th/should_compile/T8025/B.hs b/testsuite/tests/th/should_compile/T8025/B.hs new file mode 100644 index 0000000000..9bdbc83ac6 --- /dev/null +++ b/testsuite/tests/th/should_compile/T8025/B.hs @@ -0,0 +1,5 @@ +-- B.hs +{-# LANGUAGE TemplateHaskell #-} +module B where +import A +x = $(a) diff --git a/testsuite/tests/th/should_compile/T8025/Makefile b/testsuite/tests/th/should_compile/T8025/Makefile new file mode 100644 index 0000000000..1c39d1c1fe --- /dev/null +++ b/testsuite/tests/th/should_compile/T8025/Makefile @@ -0,0 +1,3 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk diff --git a/testsuite/tests/th/should_compile/T8025/all.T b/testsuite/tests/th/should_compile/T8025/all.T new file mode 100644 index 0000000000..81e6d5e5fd --- /dev/null +++ b/testsuite/tests/th/should_compile/T8025/all.T @@ -0,0 +1,2 @@ +test('T8025', extra_files(['A.hs', 'B.hs']), multimod_compile, + ['A B', '-fno-code -v0'])
\ No newline at end of file |