diff options
| author | Matthew Pickering <matthewtpickering@gmail.com> | 2021-10-01 15:59:18 +0100 |
|---|---|---|
| committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-10-19 03:30:16 -0400 |
| commit | 753b921da52c0b7da21856c5fe0bf4604505c7b3 (patch) | |
| tree | 5a8620feabe469d52f349a6e35ee15920ef6b0eb /testsuite/tests/driver/dynamicToo/dynamicToo001boot | |
| parent | 3d6eb85efcebb5854de880d24f9c8011688fb933 (diff) | |
| download | haskell-753b921da52c0b7da21856c5fe0bf4604505c7b3.tar.gz | |
Remove DT_Failed state
At the moment if `-dynamic-too` fails then we rerun the whole pipeline
as if we were just in `-dynamic` mode. I argue this is a misfeature and
we should remove the so-called `DT_Failed` mode.
In what situations do we fall back to `DT_Failed`?
1. If the `dyn_hi` file corresponding to a `hi` file is missing completely.
2. If the interface hash of `dyn_hi` doesn't match the interface hash of `hi`.
What happens in `DT_Failed` mode?
* The whole compiler pipeline is rerun as if the user had just passed `-dynamic`.
* Therefore `dyn_hi/dyn_o` files are used which don't agree with the
`hi/o` files. (As evidenced by `dynamicToo001` test).
* This is very confusing as now a single compiler invocation has
produced further `hi`/`dyn_hi` files which are different to each
other.
Why should we remove it?
* In `--make` mode, which is predominately used `DT_Failed` does not
work (#19782), there can't be users relying on this functionality.
* In `-c` mode, the recovery doesn't fix the root issue, which is the
`dyn_hi` and `hi` files are mismatched. We should instead produce an
error and pass responsibility to the build system using `-c` to ensure
that the prerequisites for `-dynamic-too` (dyn_hi/hi) files are there
before we start compiling.
* It is a misfeature to support use cases like `dynamicToo001` which
allow you to mix different versions of dynamic/non-dynamic interface
files. It's more likely to lead to subtle bugs in your resulting
programs where out-dated build products are used rather than a
deliberate choice.
* In practice, people are usually compiling with `-dynamic-too` rather
than separately with `-dynamic` and `-static`, so the build products
always match and `DT_Failed` is only entered due to compiler bugs (see
!6583)
What should we do instead?
* In `--make` mode, for home packages check during recompilation
checking that `dyn_hi` and `hi` are both present and agree, recompile
the modules if they do not.
* For package modules, when loading the interface check that `dyn_hi`
and `hi` are there and that they agree but fail with an
error message if they are not.
* In `--oneshot` mode, fail with an error message if the right files
aren't already there.
Closes #19782 #20446 #9176 #13616
Diffstat (limited to 'testsuite/tests/driver/dynamicToo/dynamicToo001boot')
7 files changed, 55 insertions, 0 deletions
diff --git a/testsuite/tests/driver/dynamicToo/dynamicToo001boot/A.hs b/testsuite/tests/driver/dynamicToo/dynamicToo001boot/A.hs new file mode 100644 index 0000000000..f76166afab --- /dev/null +++ b/testsuite/tests/driver/dynamicToo/dynamicToo001boot/A.hs @@ -0,0 +1,6 @@ + +module A where + +a :: Char +a = 'a' + diff --git a/testsuite/tests/driver/dynamicToo/dynamicToo001boot/B1.hs-boot b/testsuite/tests/driver/dynamicToo/dynamicToo001boot/B1.hs-boot new file mode 100644 index 0000000000..4cbf619183 --- /dev/null +++ b/testsuite/tests/driver/dynamicToo/dynamicToo001boot/B1.hs-boot @@ -0,0 +1,5 @@ + +module B where + +b :: Char + diff --git a/testsuite/tests/driver/dynamicToo/dynamicToo001boot/B2.hs-boot b/testsuite/tests/driver/dynamicToo/dynamicToo001boot/B2.hs-boot new file mode 100644 index 0000000000..6f0d8a4aec --- /dev/null +++ b/testsuite/tests/driver/dynamicToo/dynamicToo001boot/B2.hs-boot @@ -0,0 +1,4 @@ +module B where + +e :: Char + diff --git a/testsuite/tests/driver/dynamicToo/dynamicToo001boot/C.hs b/testsuite/tests/driver/dynamicToo/dynamicToo001boot/C.hs new file mode 100644 index 0000000000..40fb0f7695 --- /dev/null +++ b/testsuite/tests/driver/dynamicToo/dynamicToo001boot/C.hs @@ -0,0 +1,9 @@ + +module Main where + +import A +import {-# SOURCE #-} B + +main = do print a + print b + diff --git a/testsuite/tests/driver/dynamicToo/dynamicToo001boot/Makefile b/testsuite/tests/driver/dynamicToo/dynamicToo001boot/Makefile new file mode 100644 index 0000000000..94ead80abc --- /dev/null +++ b/testsuite/tests/driver/dynamicToo/dynamicToo001boot/Makefile @@ -0,0 +1,19 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +TEST_HC_OPTS_DYN = -dynamic -hisuf dyn_hi -osuf dyn_o + +.PHONY: dynamicToo001boot +# -dynamic-too should notice that the interface files for B.hs-boot don't match, +# and issue an error. This is to check the path calculations are correct for boot files. +dynamicToo001boot: + "$(TEST_HC)" $(TEST_HC_OPTS) -O -c A.hs + "$(TEST_HC)" $(TEST_HC_OPTS) $(TEST_HC_OPTS_DYN) -O -c A.hs + cp B1.hs-boot B.hs-boot + "$(TEST_HC)" $(TEST_HC_OPTS) -O -c B.hs-boot + cp B2.hs-boot B.hs-boot + "$(TEST_HC)" $(TEST_HC_OPTS) $(TEST_HC_OPTS_DYN) -O -c B.hs-boot + # This step fails because the hash of B1 and B2 is different + "$(TEST_HC)" $(TEST_HC_OPTS) -O -c C.hs -dynamic-too || true + diff --git a/testsuite/tests/driver/dynamicToo/dynamicToo001boot/dynamicToo001boot.stderr b/testsuite/tests/driver/dynamicToo/dynamicToo001boot/dynamicToo001boot.stderr new file mode 100644 index 0000000000..8b17cac27a --- /dev/null +++ b/testsuite/tests/driver/dynamicToo/dynamicToo001boot/dynamicToo001boot.stderr @@ -0,0 +1,6 @@ + +C.hs:5:1: error: + Dynamic hash doesn't match for ‘B’ + Normal interface file from ./B.hi-boot + Dynamic interface file from ./B.dyn_hi-boot + You probably need to recompile ‘B’ diff --git a/testsuite/tests/driver/dynamicToo/dynamicToo001boot/test.T b/testsuite/tests/driver/dynamicToo/dynamicToo001boot/test.T new file mode 100644 index 0000000000..bca0be654f --- /dev/null +++ b/testsuite/tests/driver/dynamicToo/dynamicToo001boot/test.T @@ -0,0 +1,6 @@ + +test('dynamicToo001boot', + [extra_files(['A.hs', 'B1.hs-boot', 'B2.hs-boot', 'C.hs']), + when(opsys('mingw32'), expect_broken(7665)), unless(have_vanilla(), skip), + unless(have_dynamic(), skip)], + makefile_test, []) |
