summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-04-14 08:50:26 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-04-22 16:59:42 -0400
commit7f4d06e6c850c865669871c7fa5249daeb18f2d8 (patch)
treef177df26ba761a9cc0b7554b58218738a76c7131 /testsuite
parentb7980b5d94d34943b3965cf79c4e610f00a9ee7d (diff)
downloadhaskell-7f4d06e6c850c865669871c7fa5249daeb18f2d8.tar.gz
driver: Consider dyn_o files when checking recompilation in -c
When -dynamic-too is enabled, there are two result files, .o and .dyn_o, therefore we should check both to decide whether to set SourceModified or not. The whole recompilation logic is very messy, a more thorough refactor would be beneficial in this area but this is the minimal patch to fix this more high priority problem. Fixes #17968 and hopefully #17534
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/driver/dynamicToo/ARecomp.hs3
-rw-r--r--testsuite/tests/driver/dynamicToo/Makefile30
-rw-r--r--testsuite/tests/driver/dynamicToo/all.T10
3 files changed, 43 insertions, 0 deletions
diff --git a/testsuite/tests/driver/dynamicToo/ARecomp.hs b/testsuite/tests/driver/dynamicToo/ARecomp.hs
new file mode 100644
index 0000000000..c760d18753
--- /dev/null
+++ b/testsuite/tests/driver/dynamicToo/ARecomp.hs
@@ -0,0 +1,3 @@
+module ARecomp where
+
+main = print ()
diff --git a/testsuite/tests/driver/dynamicToo/Makefile b/testsuite/tests/driver/dynamicToo/Makefile
index b1eab7ef30..33b6a5a9cb 100644
--- a/testsuite/tests/driver/dynamicToo/Makefile
+++ b/testsuite/tests/driver/dynamicToo/Makefile
@@ -3,6 +3,7 @@ include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
checkExists = [ -f $1 ] || echo $1 missing
+checkMissing = [ ! -f $1 ] || echo $1 exists
.PHONY: dynamicToo003
# Check that "-c -dynamic-too" works
@@ -13,3 +14,32 @@ dynamicToo003:
$(call checkExists,A003.dyn_o)
$(call checkExists,A003.dyn_hi)
+.PHONY: dynamicTooRecomp
+# Check that recompilation with "-c -dynamic-too" works
+dynamicTooRecomp:
+ "$(TEST_HC)" $(TEST_HC_OPTS) -dynamic-too -v0 -c ARecomp.hs
+ # Remove just dynamic objects
+ $(RM) ARecomp.dyn*
+ # Recompile
+ "$(TEST_HC)" $(TEST_HC_OPTS) -dynamic-too -v0 -c ARecomp.hs
+ # Check everything is there
+ $(call checkExists,ARecomp.o)
+ $(call checkExists,ARecomp.hi)
+ $(call checkExists,ARecomp.dyn_o)
+ $(call checkExists,ARecomp.dyn_hi)
+
+.PHONY: dynamicTooOnlyInterface
+# Check that a missing .dyn_o does not cause recompilation when `-fno-code` `-fwrite-interface`
+# is combined
+dynamicTooOnlyInterface:
+ "$(TEST_HC)" $(TEST_HC_OPTS) -dynamic-too -v0 -c ARecomp.hs
+ # Remove just dynamic objects
+ $(RM) ARecomp.dyn*
+ # Recompile, using -fno-code -fwrite-interface
+ "$(TEST_HC)" $(TEST_HC_OPTS) -fno-code -fwrite-interface -v0 -c ARecomp.hs
+ # Check the right things are there
+ $(call checkExists,ARecomp.o)
+ $(call checkExists,ARecomp.hi)
+ $(call checkMissing,ARecomp.dyn_o)
+ $(call checkMissing,ARecomp.dyn_hi)
+
diff --git a/testsuite/tests/driver/dynamicToo/all.T b/testsuite/tests/driver/dynamicToo/all.T
index 0c890efd70..28fedc7863 100644
--- a/testsuite/tests/driver/dynamicToo/all.T
+++ b/testsuite/tests/driver/dynamicToo/all.T
@@ -3,3 +3,13 @@ test('dynamicToo003',
[extra_files(['A003.hs']),
unless(have_vanilla(), skip), unless(have_dynamic(), skip)],
makefile_test, [])
+
+test('dynamicTooRecomp',
+ [extra_files(['ARecomp.hs']),
+ unless(have_vanilla(), skip), unless(have_dynamic(), skip)],
+ makefile_test, [])
+
+test('dynamicTooOnlyInterface',
+ [extra_files(['ARecomp.hs']),
+ unless(have_vanilla(), skip), unless(have_dynamic(), skip)],
+ makefile_test, [])