diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2021-10-01 15:59:18 +0100 |
---|---|---|
committer | Matthew Pickering <matthewtpickering@gmail.com> | 2021-10-18 10:15:38 +0100 |
commit | 5257205fec63e7d3f98427eb053d6fab60a352e4 (patch) | |
tree | 76506ca1d9d1a97e33790ac35f75a0aebfa459ad /testsuite/tests/driver/dynamicToo/dynamicTooMake | |
parent | 91188027a32e7687a0132397f32c31acd2c628d5 (diff) | |
download | haskell-wip/dyn-too-fixes.tar.gz |
Remove DT_Failed statewip/dyn-too-fixes
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/dynamicTooMake')
12 files changed, 148 insertions, 0 deletions
diff --git a/testsuite/tests/driver/dynamicToo/dynamicTooMake/Makefile b/testsuite/tests/driver/dynamicToo/dynamicTooMake/Makefile new file mode 100644 index 0000000000..8e24b5a31c --- /dev/null +++ b/testsuite/tests/driver/dynamicToo/dynamicTooMake/Makefile @@ -0,0 +1,28 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +SETUP='$(PWD)/Setup' -v0 +CONFIGURE=$(SETUP) configure $(CABAL_MINIMAL_BUILD) --with-ghc='$(TEST_HC)' --ghc-options='$(TEST_HC_OPTS)' --package-db='$(PWD)/tmp.d' --prefix='$(PWD)/inst' --enable-executable-dynamic + +dynamicTooMake: clean + '$(GHC_PKG)' init tmp.d + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make Setup + # build p + rm -rf p/dist + (cd p; $(CONFIGURE) --enable-shared --ipid "p-0.1") + (cd p; $(SETUP) build) + (cd p; $(SETUP) copy) + (cd p; $(SETUP) register) + (cd p; echo "q = 0" >> Lib.hs) + # build p, but only rebuild hi + (cd p; $(CONFIGURE) --disable-shared --ipid "p-0.1") + (cd p; $(SETUP) build) + (cd p; $(SETUP) copy) + (cd p; $(SETUP) register) + (cd q; $(CONFIGURE) --disable-shared --ipid "q-0.1") + # build q, should be an error as p has mismatched .hi and .dyn_hi files + (cd q; $(SETUP) build) || true + +clean : + $(RM) -r tmp.d inst dist Setup$(exeext) diff --git a/testsuite/tests/driver/dynamicToo/dynamicTooMake/README.md b/testsuite/tests/driver/dynamicToo/dynamicTooMake/README.md new file mode 100644 index 0000000000..5b9ecd01f1 --- /dev/null +++ b/testsuite/tests/driver/dynamicToo/dynamicTooMake/README.md @@ -0,0 +1,5 @@ +Reproducer for broken implementation of DT_Failed + +``` +./run +``` diff --git a/testsuite/tests/driver/dynamicToo/dynamicTooMake/Setup.hs b/testsuite/tests/driver/dynamicToo/dynamicTooMake/Setup.hs new file mode 100644 index 0000000000..9a994af677 --- /dev/null +++ b/testsuite/tests/driver/dynamicToo/dynamicTooMake/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/testsuite/tests/driver/dynamicToo/dynamicTooMake/dynamicTooMake.stderr b/testsuite/tests/driver/dynamicToo/dynamicTooMake/dynamicTooMake.stderr new file mode 100644 index 0000000000..23225fc4fc --- /dev/null +++ b/testsuite/tests/driver/dynamicToo/dynamicTooMake/dynamicTooMake.stderr @@ -0,0 +1,9 @@ +Warning: -rtsopts and -with-rtsopts have no effect with -shared. + Call hs_init_ghc() from your main() function to set these options. + +app/Main.hs:4:1: error: + Dynamic hash doesn't match for ‘Lib’ + Normal interface file from /run/user/1000/ghctest-hbhb_f3v/test spaces/testsuite/tests/driver/dynamicToo/dynamicTooMake/dynamicTooMake.run/inst/lib/x86_64-linux-ghc-9.3.20210922/p-0.1/Lib.hi + Dynamic interface file from /run/user/1000/ghctest-hbhb_f3v/test spaces/testsuite/tests/driver/dynamicToo/dynamicTooMake/dynamicTooMake.run/inst/lib/x86_64-linux-ghc-9.3.20210922/p-0.1/Lib.dyn_hi + You probably need to recompile ‘Lib’ +make: *** [Makefile:26: dynamicTooMake] Error 1 diff --git a/testsuite/tests/driver/dynamicToo/dynamicTooMake/p/CHANGELOG.md b/testsuite/tests/driver/dynamicToo/dynamicTooMake/p/CHANGELOG.md new file mode 100644 index 0000000000..9ede8b27d4 --- /dev/null +++ b/testsuite/tests/driver/dynamicToo/dynamicTooMake/p/CHANGELOG.md @@ -0,0 +1,5 @@ +# Revision history for p + +## 0.1.0.0 -- YYYY-mm-dd + +* First version. Released on an unsuspecting world. diff --git a/testsuite/tests/driver/dynamicToo/dynamicTooMake/p/Lib.hs b/testsuite/tests/driver/dynamicToo/dynamicTooMake/p/Lib.hs new file mode 100644 index 0000000000..4e718cafbf --- /dev/null +++ b/testsuite/tests/driver/dynamicToo/dynamicTooMake/p/Lib.hs @@ -0,0 +1,4 @@ +module Lib where + +{-# NOINLINE l #-} +l = 1 diff --git a/testsuite/tests/driver/dynamicToo/dynamicTooMake/p/p.cabal b/testsuite/tests/driver/dynamicToo/dynamicTooMake/p/p.cabal new file mode 100644 index 0000000000..a0d6c17515 --- /dev/null +++ b/testsuite/tests/driver/dynamicToo/dynamicTooMake/p/p.cabal @@ -0,0 +1,34 @@ +cabal-version: 2.4 +name: p +version: 0.1.0.0 + +-- A short (one-line) description of the package. +-- synopsis: + +-- A longer description of the package. +-- description: + +-- A URL where users can report bugs. +-- bug-reports: + +-- The license under which the package is released. +-- license: +author: Matthew Pickering +maintainer: matthewtpickering@gmail.com + +-- A copyright notice. +-- copyright: +-- category: +extra-source-files: CHANGELOG.md + +library + exposed-modules: Lib + + -- Modules included in this executable, other than Main. + -- other-modules: + + -- LANGUAGE extensions used by modules in this package. + -- other-extensions: + build-depends: base >=4.14.1.0 && <5 + hs-source-dirs: . + default-language: Haskell2010 diff --git a/testsuite/tests/driver/dynamicToo/dynamicTooMake/q/CHANGELOG.md b/testsuite/tests/driver/dynamicToo/dynamicTooMake/q/CHANGELOG.md new file mode 100644 index 0000000000..62632c5376 --- /dev/null +++ b/testsuite/tests/driver/dynamicToo/dynamicTooMake/q/CHANGELOG.md @@ -0,0 +1,5 @@ +# Revision history for q + +## 0.1.0.0 -- YYYY-mm-dd + +* First version. Released on an unsuspecting world. diff --git a/testsuite/tests/driver/dynamicToo/dynamicTooMake/q/app/AppLib.hs b/testsuite/tests/driver/dynamicToo/dynamicTooMake/q/app/AppLib.hs new file mode 100644 index 0000000000..acbae9417c --- /dev/null +++ b/testsuite/tests/driver/dynamicToo/dynamicTooMake/q/app/AppLib.hs @@ -0,0 +1,5 @@ +module AppLib where + +a = 10 + + diff --git a/testsuite/tests/driver/dynamicToo/dynamicTooMake/q/app/Main.hs b/testsuite/tests/driver/dynamicToo/dynamicTooMake/q/app/Main.hs new file mode 100644 index 0000000000..ea2b9aef96 --- /dev/null +++ b/testsuite/tests/driver/dynamicToo/dynamicTooMake/q/app/Main.hs @@ -0,0 +1,8 @@ +module Main where + +import AppLib +import Lib + +main :: IO () +main = print (a + l ) + diff --git a/testsuite/tests/driver/dynamicToo/dynamicTooMake/q/q.cabal b/testsuite/tests/driver/dynamicToo/dynamicTooMake/q/q.cabal new file mode 100644 index 0000000000..723e1082d5 --- /dev/null +++ b/testsuite/tests/driver/dynamicToo/dynamicTooMake/q/q.cabal @@ -0,0 +1,34 @@ +cabal-version: 2.4 +name: q +version: 0.1.0.0 + +-- A short (one-line) description of the package. +-- synopsis: + +-- A longer description of the package. +-- description: + +-- A URL where users can report bugs. +-- bug-reports: + +-- The license under which the package is released. +-- license: +author: Matthew Pickering +maintainer: matthewtpickering@gmail.com + +-- A copyright notice. +-- copyright: +-- category: +extra-source-files: CHANGELOG.md + +library + + -- Modules included in this executable, other than Main. + exposed-modules: AppLib Main + + -- LANGUAGE extensions used by modules in this package. + -- other-extensions: + ghc-options: -dynamic-too + build-depends: base >=4.14.1.0 && < 5, p + hs-source-dirs: app + default-language: Haskell2010 diff --git a/testsuite/tests/driver/dynamicToo/dynamicTooMake/test.T b/testsuite/tests/driver/dynamicToo/dynamicTooMake/test.T new file mode 100644 index 0000000000..f771282e69 --- /dev/null +++ b/testsuite/tests/driver/dynamicToo/dynamicTooMake/test.T @@ -0,0 +1,9 @@ + +test('dynamicTooMake', + [extra_files(['p', 'q', 'Setup.hs']), + when(opsys('mingw32'), expect_broken(7665)), unless(have_vanilla(), skip), + unless(have_dynamic(), skip), + copy_files, + grep_errmsg("Dynamic hash") + ], + makefile_test, []) |