diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2021-09-30 11:12:10 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-10-19 03:30:16 -0400 |
commit | df419c1abd7daa3aa0231747582333357b8e9b85 (patch) | |
tree | a73aaf04830425c43afe525f22138ca58550301e /testsuite/tests | |
parent | 8144a92f5a73dd22c0d855d5b2bead930111511c (diff) | |
download | haskell-df419c1abd7daa3aa0231747582333357b8e9b85.tar.gz |
driver: Cleanups related to ModLocation
ModLocation is the data type which tells you the locations of all the
build products which can affect recompilation. It is now computed in one
place and not modified through the pipeline. Important locations will
now just consult ModLocation rather than construct the dynamic object
path incorrectly.
* Add paths for dynamic object and dynamic interface files to
ModLocation.
* Always use the paths from mod location when looking for where to find
any interface or object file.
* Always use the paths in a ModLocation when deciding where to write an
interface and object file.
* Remove `dynamicOutputFile` and `dynamicOutputHi` functions which
*calculated* (incorrectly) the location of `dyn_o` and `dyn_hi` files.
* Don't set `outputFile_` and so-on in `enableCodeGenWhen`, `-o` and
hence `outputFile_` should not affect the location of object files in
`--make` mode. It is now sufficient to just update the ModLocation with
the temporary paths.
* In `hscGenBackendPipeline` don't recompute the `ModLocation` to
account for `-dynamic-too`, the paths are now accurate from the start
of the run.
* Rename `getLocation` to `mkOneShotModLocation`, as that's the only
place it's used. Increase the locality of the definition by moving it
close to the use-site.
* Load the dynamic interface from ml_dyn_hi_file rather than attempting
to reconstruct it in load_dynamic_too.
* Add a variety of tests to check how -o -dyno etc interact with each
other.
Some other clean-ups
* DeIOify mkHomeModLocation and friends, they are all pure functions.
* Move FinderOpts into GHC.Driver.Config.Finder, next to initFinderOpts.
* Be more precise about whether we mean outputFile or outputFile_: there
were many places where outputFile was used but the result shouldn't have
been affected by `-dyno` (for example the filename of the resulting
executable). In these places dynamicNow would never be set but it's
still more precise to not allow for this possibility.
* Typo fixes suffices -> suffixes in the appropiate places.
Diffstat (limited to 'testsuite/tests')
-rw-r--r-- | testsuite/tests/count-deps/CountDepsAst.stdout | 4 | ||||
-rw-r--r-- | testsuite/tests/count-deps/CountDepsParser.stdout | 4 | ||||
-rw-r--r-- | testsuite/tests/driver/T20348/Makefile | 35 | ||||
-rw-r--r-- | testsuite/tests/driver/T20348/all.T | 5 | ||||
-rw-r--r-- | testsuite/tests/driver/recomp-boot-dyn-too/A.hs | 1 | ||||
-rw-r--r-- | testsuite/tests/driver/recomp-boot-dyn-too/A.hs-boot | 1 | ||||
-rw-r--r-- | testsuite/tests/driver/recomp-boot-dyn-too/B1.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/driver/recomp-boot-dyn-too/B2.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/driver/recomp-boot-dyn-too/Makefile | 18 | ||||
-rw-r--r-- | testsuite/tests/driver/recomp-boot-dyn-too/all.T | 4 | ||||
-rw-r--r-- | testsuite/tests/driver/recomp-boot-dyn-too/recomp-boot-dyn-too.stdout | 4 | ||||
-rw-r--r-- | testsuite/tests/regalloc/regalloc_unit_tests.hs | 4 |
12 files changed, 79 insertions, 7 deletions
diff --git a/testsuite/tests/count-deps/CountDepsAst.stdout b/testsuite/tests/count-deps/CountDepsAst.stdout index da2b5b3e5c..9117f0892c 100644 --- a/testsuite/tests/count-deps/CountDepsAst.stdout +++ b/testsuite/tests/count-deps/CountDepsAst.stdout @@ -1,4 +1,4 @@ -Found 278 Language.Haskell.Syntax module dependencies +Found 276 Language.Haskell.Syntax module dependencies GHC.Builtin.Names GHC.Builtin.PrimOps GHC.Builtin.Types @@ -85,7 +85,6 @@ GHC.Data.TrieMap GHC.Driver.Backend GHC.Driver.CmdLine GHC.Driver.Config.Diagnostic -GHC.Driver.Config.Finder GHC.Driver.Config.Logger GHC.Driver.Env GHC.Driver.Env.KnotVars @@ -223,7 +222,6 @@ GHC.Types.Var.Set GHC.Unit GHC.Unit.Env GHC.Unit.External -GHC.Unit.Finder GHC.Unit.Finder.Types GHC.Unit.Home GHC.Unit.Home.ModInfo diff --git a/testsuite/tests/count-deps/CountDepsParser.stdout b/testsuite/tests/count-deps/CountDepsParser.stdout index f67d2eb223..2738d7d33f 100644 --- a/testsuite/tests/count-deps/CountDepsParser.stdout +++ b/testsuite/tests/count-deps/CountDepsParser.stdout @@ -1,4 +1,4 @@ -Found 284 GHC.Parser module dependencies +Found 282 GHC.Parser module dependencies GHC.Builtin.Names GHC.Builtin.PrimOps GHC.Builtin.Types @@ -86,7 +86,6 @@ GHC.Driver.Backend GHC.Driver.Backpack.Syntax GHC.Driver.CmdLine GHC.Driver.Config.Diagnostic -GHC.Driver.Config.Finder GHC.Driver.Config.Logger GHC.Driver.Env GHC.Driver.Env.KnotVars @@ -229,7 +228,6 @@ GHC.Types.Var.Set GHC.Unit GHC.Unit.Env GHC.Unit.External -GHC.Unit.Finder GHC.Unit.Finder.Types GHC.Unit.Home GHC.Unit.Home.ModInfo diff --git a/testsuite/tests/driver/T20348/Makefile b/testsuite/tests/driver/T20348/Makefile index e6903e4cc4..ba1edd021d 100644 --- a/testsuite/tests/driver/T20348/Makefile +++ b/testsuite/tests/driver/T20348/Makefile @@ -24,3 +24,38 @@ T20348: clean # Second run: should not recompile. echo 'second run' '$(TEST_HC)' $(TEST_HC_OPTS) -fno-code -fwrite-interface A.hs + +T20348A: clean + '$(TEST_HC)' $(TEST_HC_OPTS) -c -o A2.o -ohi A2.hi -dynohi A2.dyn_hi A.hs -dynamic-too + $(call checkExists,A2.hi) + $(call checkExists,A2.o) + $(call checkExists,A2.dyn_hi) + $(call checkExists,A2.dyn_o) + +T20348B: clean + '$(TEST_HC)' $(TEST_HC_OPTS) -c -o A2.o -ohi A2.hi A.hs -dynamic-too + $(call checkExists,A2.hi) + $(call checkExists,A2.o) + $(call checkExists,A.dyn_hi) + $(call checkExists,A2.dyn_o) + +T20348C: clean + '$(TEST_HC)' $(TEST_HC_OPTS) -c -o A2.o -dyno A2.dyn_o A.hs -dynamic-too + $(call checkExists,A.hi) + $(call checkExists,A2.o) + $(call checkExists,A.dyn_hi) + $(call checkExists,A2.dyn_o) + +T20348D: clean + '$(TEST_HC)' $(TEST_HC_OPTS) -c -dyno A2.dyn_o A.hs -dynamic-too + $(call checkExists,A.hi) + $(call checkExists,A.o) + $(call checkExists,A.dyn_hi) + $(call checkExists,A2.dyn_o) + +T20348E: clean + '$(TEST_HC)' $(TEST_HC_OPTS) -S -o A2.s A.hs -dynamic-too + $(call checkExists,A2.s) + $(call checkExists,A2.dyn_s) + + diff --git a/testsuite/tests/driver/T20348/all.T b/testsuite/tests/driver/T20348/all.T index 935c8efa8c..e7717ca770 100644 --- a/testsuite/tests/driver/T20348/all.T +++ b/testsuite/tests/driver/T20348/all.T @@ -1,3 +1,8 @@ # N.B. this package requires a dynamically-linked ghc-bin, since it assumes # that TH evaluation will build dynamic objects. test('T20348', [extra_files(['A.hs']), unless(have_dynamic(), skip)], makefile_test, []) +test('T20348A', [extra_files(['A.hs']), unless(have_dynamic(), skip)], makefile_test, []) +test('T20348B', [extra_files(['A.hs']), unless(have_dynamic(), skip)], makefile_test, []) +test('T20348C', [extra_files(['A.hs']), unless(have_dynamic(), skip)], makefile_test, []) +test('T20348D', [extra_files(['A.hs']), unless(have_dynamic(), skip)], makefile_test, []) +test('T20348E', [extra_files(['A.hs']), unless(have_dynamic(), skip)], makefile_test, []) diff --git a/testsuite/tests/driver/recomp-boot-dyn-too/A.hs b/testsuite/tests/driver/recomp-boot-dyn-too/A.hs new file mode 100644 index 0000000000..d843c00b78 --- /dev/null +++ b/testsuite/tests/driver/recomp-boot-dyn-too/A.hs @@ -0,0 +1 @@ +module A where diff --git a/testsuite/tests/driver/recomp-boot-dyn-too/A.hs-boot b/testsuite/tests/driver/recomp-boot-dyn-too/A.hs-boot new file mode 100644 index 0000000000..d843c00b78 --- /dev/null +++ b/testsuite/tests/driver/recomp-boot-dyn-too/A.hs-boot @@ -0,0 +1 @@ +module A where diff --git a/testsuite/tests/driver/recomp-boot-dyn-too/B1.hs b/testsuite/tests/driver/recomp-boot-dyn-too/B1.hs new file mode 100644 index 0000000000..ce9e7e4932 --- /dev/null +++ b/testsuite/tests/driver/recomp-boot-dyn-too/B1.hs @@ -0,0 +1,3 @@ +module B where + +import A diff --git a/testsuite/tests/driver/recomp-boot-dyn-too/B2.hs b/testsuite/tests/driver/recomp-boot-dyn-too/B2.hs new file mode 100644 index 0000000000..b3fc879af1 --- /dev/null +++ b/testsuite/tests/driver/recomp-boot-dyn-too/B2.hs @@ -0,0 +1,3 @@ +module B where + +import {-# SOURCE #-} A diff --git a/testsuite/tests/driver/recomp-boot-dyn-too/Makefile b/testsuite/tests/driver/recomp-boot-dyn-too/Makefile new file mode 100644 index 0000000000..6c3761b3d4 --- /dev/null +++ b/testsuite/tests/driver/recomp-boot-dyn-too/Makefile @@ -0,0 +1,18 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +# Recompilation tests + +clean: + rm -f *.dyn_hi *.dyn_hi-boot *.dyn_o *.dyn_o-boot *.hi *.hi-boot *.o *.o-boot + rm -f B.hs + +# Recompile + +recomp-boot-dyn-too: clean + cp B1.hs B.hs + '$(TEST_HC)' $(TEST_HC_OPTS) --make -dynamic-too B.hs + cp B2.hs B.hs + '$(TEST_HC)' $(TEST_HC_OPTS) --make -dynamic-too B.hs + '$(TEST_HC)' $(TEST_HC_OPTS) --make -dynamic-too B.hs diff --git a/testsuite/tests/driver/recomp-boot-dyn-too/all.T b/testsuite/tests/driver/recomp-boot-dyn-too/all.T new file mode 100644 index 0000000000..8d4d6657c0 --- /dev/null +++ b/testsuite/tests/driver/recomp-boot-dyn-too/all.T @@ -0,0 +1,4 @@ +test('recomp-boot-dyn-too', [ unless(have_dynamic(), skip) + , extra_files(['A.hs', 'B1.hs', 'B2.hs', 'A.hs-boot']) + , when(fast(), skip)], + makefile_test, []) diff --git a/testsuite/tests/driver/recomp-boot-dyn-too/recomp-boot-dyn-too.stdout b/testsuite/tests/driver/recomp-boot-dyn-too/recomp-boot-dyn-too.stdout new file mode 100644 index 0000000000..e8ce474459 --- /dev/null +++ b/testsuite/tests/driver/recomp-boot-dyn-too/recomp-boot-dyn-too.stdout @@ -0,0 +1,4 @@ +[1 of 2] Compiling A ( A.hs, A.o, A.dyn_o ) +[2 of 2] Compiling B ( B.hs, B.o, B.dyn_o ) +[1 of 3] Compiling A[boot] ( A.hs-boot, A.o-boot, A.dyn_o-boot ) +[2 of 3] Compiling B ( B.hs, B.o, B.dyn_o ) [Source file changed] diff --git a/testsuite/tests/regalloc/regalloc_unit_tests.hs b/testsuite/tests/regalloc/regalloc_unit_tests.hs index 994ecde659..7726c79b1f 100644 --- a/testsuite/tests/regalloc/regalloc_unit_tests.hs +++ b/testsuite/tests/regalloc/regalloc_unit_tests.hs @@ -50,6 +50,8 @@ import GHC.Utils.Logger import GHC.Utils.Outputable import GHC.Types.Basic import GHC.Unit.Home +import GHC.Unit.Finder +import GHC.Driver.Config.Finder import GHC.Data.Stream as Stream (collect, yield) @@ -158,7 +160,7 @@ compileCmmForRegAllocStats logger dflags cmmFile ncgImplF us = do thisMod = mkModule (stringToUnit . show . uniqFromSupply $ usc) (mkModuleName . show . uniqFromSupply $ usd) - thisModLoc = ModLocation Nothing (cmmFile ++ ".hi") (cmmFile ++ ".o") (cmmFile ++ ".hie") + thisModLoc = mkHiOnlyModLocation (initFinderOpts dflags) "hi" "dyn_hi" "" cmmFile -- | The register allocator should be able to see that each variable only |