diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2022-12-24 17:30:38 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2023-01-24 05:37:52 -0500 |
commit | 1d1dd3fbfafdb9705076d4c587d5cf47e33b7640 (patch) | |
tree | 514629de18288f32a7d6e52cafa1c4f81e00ce95 /testsuite/tests/driver | |
parent | eee3bf05f8ee29ae6c01a29db9502a390720f3b5 (diff) | |
download | haskell-1d1dd3fbfafdb9705076d4c587d5cf47e33b7640.tar.gz |
Fix recompilation checking for multiple home units
The key part of this change is to store a UnitId in the
`UsageHomeModule` and `UsageHomeModuleInterface`.
* Fine-grained dependency tracking is used if the dependency comes from
any home unit.
* We actually look up the right module when checking whether we need to
recompile in the `UsageHomeModuleInterface` case.
These scenarios are both checked by the new tests (
multipleHomeUnits_recomp and multipleHomeUnits_recomp_th )
Fixes #22675
Diffstat (limited to 'testsuite/tests/driver')
11 files changed, 43 insertions, 0 deletions
diff --git a/testsuite/tests/driver/multipleHomeUnits/Dep.hs b/testsuite/tests/driver/multipleHomeUnits/Dep.hs new file mode 100644 index 0000000000..8f9b621e15 --- /dev/null +++ b/testsuite/tests/driver/multipleHomeUnits/Dep.hs @@ -0,0 +1,3 @@ +module Dep (foo) where + +foo = () diff --git a/testsuite/tests/driver/multipleHomeUnits/Makefile b/testsuite/tests/driver/multipleHomeUnits/Makefile index d244bc6834..bd5805207a 100644 --- a/testsuite/tests/driver/multipleHomeUnits/Makefile +++ b/testsuite/tests/driver/multipleHomeUnits/Makefile @@ -30,4 +30,9 @@ multipleHomeUnits004_recomp: clean multipleHomeUnitsModuleVisibility: clean ! '$(TEST_HC)' $(TEST_HC_OPTS) -fhide-source-paths -unit @unitMV -unit @unitMV-import +multipleHomeUnits_recomp: clean + '$(TEST_HC)' $(TEST_HC_OPTS) -fhide-source-paths -unit @unitRecomp -unit @unitDep + # Doesn't cause recomp when TH is not involved + echo "recomp=()" >> Dep.hs + '$(TEST_HC)' $(TEST_HC_OPTS) -fhide-source-paths -unit @unitRecomp -unit @unitDep diff --git a/testsuite/tests/driver/multipleHomeUnits/Recomp.hs b/testsuite/tests/driver/multipleHomeUnits/Recomp.hs new file mode 100644 index 0000000000..42b93f81d5 --- /dev/null +++ b/testsuite/tests/driver/multipleHomeUnits/Recomp.hs @@ -0,0 +1,5 @@ +module Recomp where + +import Dep + +qux = foo diff --git a/testsuite/tests/driver/multipleHomeUnits/RecompTH.hs b/testsuite/tests/driver/multipleHomeUnits/RecompTH.hs new file mode 100644 index 0000000000..ee7ee96a78 --- /dev/null +++ b/testsuite/tests/driver/multipleHomeUnits/RecompTH.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE TemplateHaskell #-} +module RecompTH where + +import Dep + +qux = $(const [| () |] foo) diff --git a/testsuite/tests/driver/multipleHomeUnits/all.T b/testsuite/tests/driver/multipleHomeUnits/all.T index 97974e19e2..a21459d74f 100644 --- a/testsuite/tests/driver/multipleHomeUnits/all.T +++ b/testsuite/tests/driver/multipleHomeUnits/all.T @@ -59,3 +59,10 @@ test('multipleHomeUnitsPackageImports', test('MHU_OptionsGHC', normal, compile_fail, ['']) test('multipleHomeUnits_loop', [extra_files([ 'a/', 'unitA', 'loop', 'unitLoop'])], multiunit_compile, [['unitA', 'unitLoop'], '-fhide-source-paths']) + +test('multipleHomeUnits_recomp', [copy_files,extra_files([ 'Recomp.hs', 'unitRecomp', 'unitDep', 'Dep.hs'])], makefile_test, []) + +test('multipleHomeUnits_recomp_th', [filter_stdout_lines(r'.*Compiling.*'), copy_files, extra_files(['thRecomp.script', 'unitRecompTH', 'unitDep', 'RecompTH.hs', 'Dep.hs', '../../ghci/shell.hs']) , extra_run_opts('-v1 -unit @unitRecompTH -unit @unitDep')], ghci_script, ['thRecomp.script']) + + + diff --git a/testsuite/tests/driver/multipleHomeUnits/multipleHomeUnits_recomp.stdout b/testsuite/tests/driver/multipleHomeUnits/multipleHomeUnits_recomp.stdout new file mode 100644 index 0000000000..1fbd0c9e1e --- /dev/null +++ b/testsuite/tests/driver/multipleHomeUnits/multipleHomeUnits_recomp.stdout @@ -0,0 +1,3 @@ +[1 of 2] Compiling Dep[dep] +[2 of 2] Compiling Recomp[recomp] +[1 of 2] Compiling Dep[dep] [Source file changed] diff --git a/testsuite/tests/driver/multipleHomeUnits/multipleHomeUnits_recomp_th.stdout b/testsuite/tests/driver/multipleHomeUnits/multipleHomeUnits_recomp_th.stdout new file mode 100644 index 0000000000..4e57668849 --- /dev/null +++ b/testsuite/tests/driver/multipleHomeUnits/multipleHomeUnits_recomp_th.stdout @@ -0,0 +1,8 @@ +GHCi, version 9.7.20230119: https://www.haskell.org/ghc/ :? for help +[1 of 2] Compiling Dep ( Dep.hs, interpreted )[dep] +[2 of 2] Compiling RecompTH ( RecompTH.hs, interpreted )[recomp] +Ok, two modules loaded. +ghci> ghci> ghci> [1 of 2] Compiling Dep ( Dep.hs, interpreted )[dep] [Source file changed] +[2 of 2] Compiling RecompTH ( RecompTH.hs, interpreted )[recomp] [Dep changed (interface)] +Ok, two modules loaded. +ghci> Leaving GHCi. diff --git a/testsuite/tests/driver/multipleHomeUnits/thRecomp.script b/testsuite/tests/driver/multipleHomeUnits/thRecomp.script new file mode 100644 index 0000000000..d16ddc4a16 --- /dev/null +++ b/testsuite/tests/driver/multipleHomeUnits/thRecomp.script @@ -0,0 +1,3 @@ +shell s = System.Process.rawSystem "sh" ["-c", s] >> return () +shell "echo \"recomp=()\" >> Dep.hs" +:r diff --git a/testsuite/tests/driver/multipleHomeUnits/unitDep b/testsuite/tests/driver/multipleHomeUnits/unitDep new file mode 100644 index 0000000000..b11a7baaf0 --- /dev/null +++ b/testsuite/tests/driver/multipleHomeUnits/unitDep @@ -0,0 +1 @@ +-i Dep -outputdir=dep -this-unit-id dep diff --git a/testsuite/tests/driver/multipleHomeUnits/unitRecomp b/testsuite/tests/driver/multipleHomeUnits/unitRecomp new file mode 100644 index 0000000000..f30b19fa5c --- /dev/null +++ b/testsuite/tests/driver/multipleHomeUnits/unitRecomp @@ -0,0 +1 @@ +-i Recomp -outputdir=recomp -this-unit-id recomp -package-id dep diff --git a/testsuite/tests/driver/multipleHomeUnits/unitRecompTH b/testsuite/tests/driver/multipleHomeUnits/unitRecompTH new file mode 100644 index 0000000000..867e522ec4 --- /dev/null +++ b/testsuite/tests/driver/multipleHomeUnits/unitRecompTH @@ -0,0 +1 @@ +-i RecompTH -outputdir=recomp -this-unit-id recomp -package-id dep |