[commit: ghc] ghc-7.10: Generate .dyn_o files for .hsig files with -dynamic-too (4596beb)
git at git.haskell.org
git at git.haskell.org
Tue Sep 29 16:10:12 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-7.10
Link : http://ghc.haskell.org/trac/ghc/changeset/4596beb46ab12c26f7da272355ee680c87603d2f/ghc
>---------------------------------------------------------------
commit 4596beb46ab12c26f7da272355ee680c87603d2f
Author: Michael Smith <michael at diglumi.com>
Date: Thu Jul 23 11:41:16 2015 +0200
Generate .dyn_o files for .hsig files with -dynamic-too
With -dynamic-too, .dyn_o files were not being generated for .hsig
files. Normally, this is handled in the pipeline; however, the branch
for .hsig files called compileEmptyStub directly instead of going
through runPipeline. When compiling a Cabal package that included .hsig
files, this triggered a linker error later on, as it expected a .dyn_o
file to have been generated for each .hsig.
The fix is to use runPipeline for .hsig files, just as with .hs files.
Alternately, one could duplicate the logic for handling -dynamic-too in
the .hsig branch, but simply calling runPipeline ends up being much
cleaner.
Test Plan: validate
Reviewers: austin, ezyang, bgamari, thomie
Reviewed By: ezyang, thomie
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1084
GHC Trac Issues: #10660
>---------------------------------------------------------------
4596beb46ab12c26f7da272355ee680c87603d2f
compiler/main/DriverPipeline.hs | 13 ++++++++++++-
.../tests/driver/dynamicToo/dynamicToo005/A005.hsig | 5 +++++
testsuite/tests/driver/dynamicToo/dynamicToo005/Makefile | 16 ++++++++++++++++
testsuite/tests/driver/dynamicToo/dynamicToo005/test.T | 8 ++++++++
testsuite/tests/driver/dynamicToo/dynamicToo006/A.hsig | 5 +++++
testsuite/tests/driver/dynamicToo/dynamicToo006/B.hs | 8 ++++++++
.../dynamicToo/{dynamicToo002 => dynamicToo006}/Makefile | 15 ++++++---------
testsuite/tests/driver/dynamicToo/dynamicToo006/test.T | 9 +++++++++
8 files changed, 69 insertions(+), 10 deletions(-)
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 623f356..3079d1f 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -252,7 +252,18 @@ compileOne' m_tc_result mHscMessage
do (iface, changed, details) <-
hscSimpleIface hsc_env tc_result mb_old_hash
hscWriteIface dflags iface changed summary
- compileEmptyStub dflags hsc_env basename location
+
+ -- #10660: Use the pipeline instead of calling
+ -- compileEmptyStub directly, so -dynamic-too gets
+ -- handled properly
+ let mod_name = ms_mod_name summary
+ _ <- runPipeline StopLn hsc_env
+ (output_fn,
+ Just (HscOut src_flavour mod_name HscUpdateSig))
+ (Just basename)
+ Persistent
+ (Just location)
+ Nothing
-- Same as Hs
o_time <- getModificationUTCTime object_filename
diff --git a/testsuite/tests/driver/dynamicToo/dynamicToo005/A005.hsig b/testsuite/tests/driver/dynamicToo/dynamicToo005/A005.hsig
new file mode 100644
index 0000000..75d621c
--- /dev/null
+++ b/testsuite/tests/driver/dynamicToo/dynamicToo005/A005.hsig
@@ -0,0 +1,5 @@
+
+module A005 where
+
+data Maybe a = Nothing | Just a
+
diff --git a/testsuite/tests/driver/dynamicToo/dynamicToo005/Makefile b/testsuite/tests/driver/dynamicToo/dynamicToo005/Makefile
new file mode 100644
index 0000000..617510e
--- /dev/null
+++ b/testsuite/tests/driver/dynamicToo/dynamicToo005/Makefile
@@ -0,0 +1,16 @@
+TOP=../../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+checkExists = [ -f $1 ] || echo $1 missing
+
+.PHONY: dynamicToo005
+# Check that "-c -dynamic-too" works with .hsig
+dynamicToo005:
+ "$(TEST_HC)" $(TEST_HC_OPTS) -dynamic-too -v0 \
+ -sig-of A005=base:Prelude \
+ -c A005.hsig
+ $(call checkExists,A005.o)
+ $(call checkExists,A005.hi)
+ $(call checkExists,A005.dyn_o)
+ $(call checkExists,A005.dyn_hi)
diff --git a/testsuite/tests/driver/dynamicToo/dynamicToo005/test.T b/testsuite/tests/driver/dynamicToo/dynamicToo005/test.T
new file mode 100644
index 0000000..48460f5
--- /dev/null
+++ b/testsuite/tests/driver/dynamicToo/dynamicToo005/test.T
@@ -0,0 +1,8 @@
+
+test('dynamicToo005',
+ [extra_clean(['A005.o', 'A005.hi', 'A005.dyn_o', 'A005.dyn_hi']),
+ unless(have_vanilla(), skip),
+ unless(have_dynamic(), skip)],
+ run_command,
+ ['$MAKE -s --no-print-directory dynamicToo005'])
+
diff --git a/testsuite/tests/driver/dynamicToo/dynamicToo006/A.hsig b/testsuite/tests/driver/dynamicToo/dynamicToo006/A.hsig
new file mode 100644
index 0000000..f79d5d3
--- /dev/null
+++ b/testsuite/tests/driver/dynamicToo/dynamicToo006/A.hsig
@@ -0,0 +1,5 @@
+
+module A where
+
+data Maybe a = Nothing | Just a
+
diff --git a/testsuite/tests/driver/dynamicToo/dynamicToo006/B.hs b/testsuite/tests/driver/dynamicToo/dynamicToo006/B.hs
new file mode 100644
index 0000000..65900e7
--- /dev/null
+++ b/testsuite/tests/driver/dynamicToo/dynamicToo006/B.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
+
+module B where
+
+import A
+
+b :: Maybe a
+b = Nothing
diff --git a/testsuite/tests/driver/dynamicToo/dynamicToo002/Makefile b/testsuite/tests/driver/dynamicToo/dynamicToo006/Makefile
similarity index 58%
copy from testsuite/tests/driver/dynamicToo/dynamicToo002/Makefile
copy to testsuite/tests/driver/dynamicToo/dynamicToo006/Makefile
index 8705c87..497f2c0 100644
--- a/testsuite/tests/driver/dynamicToo/dynamicToo002/Makefile
+++ b/testsuite/tests/driver/dynamicToo/dynamicToo006/Makefile
@@ -4,20 +4,17 @@ include $(TOP)/mk/test.mk
checkExists = [ -f $1 ] || echo $1 missing
-.PHONY: dynamicToo002
-# Check that "--make -dynamic-too" works
-dynamicToo002:
- "$(TEST_HC)" $(TEST_HC_OPTS) -dynamic-too -v0 --make C
+.PHONY: dynamicToo006
+# Check that "--make -dynamic-too" works with .hsig
+dynamicToo006:
+ "$(TEST_HC)" $(TEST_HC_OPTS) -dynamic-too -v0 \
+ -sig-of A=base:Prelude \
+ --make B
$(call checkExists,A.o)
$(call checkExists,B.o)
- $(call checkExists,C.o)
$(call checkExists,A.hi)
$(call checkExists,B.hi)
- $(call checkExists,C.hi)
$(call checkExists,A.dyn_o)
$(call checkExists,B.dyn_o)
- $(call checkExists,C.dyn_o)
$(call checkExists,A.dyn_hi)
$(call checkExists,B.dyn_hi)
- $(call checkExists,C.dyn_hi)
-
diff --git a/testsuite/tests/driver/dynamicToo/dynamicToo006/test.T b/testsuite/tests/driver/dynamicToo/dynamicToo006/test.T
new file mode 100644
index 0000000..72e06ca
--- /dev/null
+++ b/testsuite/tests/driver/dynamicToo/dynamicToo006/test.T
@@ -0,0 +1,9 @@
+
+test('dynamicToo006',
+ [extra_clean(['A.o', 'A.hi', 'A.dyn_o', 'A.dyn_hi',
+ 'B.o', 'B.hi', 'B.dyn_o', 'B.dyn_hi']),
+ unless(have_vanilla(), skip),
+ unless(have_dynamic(), skip)],
+ run_command,
+ ['$MAKE -s --no-print-directory dynamicToo006'])
+
More information about the ghc-commits
mailing list