diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2022-12-26 09:56:39 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2023-01-24 05:37:52 -0500 |
commit | 6469fea7c78408db679898168a8e9c50c8c7c5ce (patch) | |
tree | e45a73804442376f9560c9c0a58b284dce84b015 | |
parent | 336b2b1c8628b1317de46078e049b529205f2129 (diff) | |
download | haskell-6469fea7c78408db679898168a8e9c50c8c7c5ce.tar.gz |
Don't write o-boot files in Interactive mode
We should not be producing object files when in interactive mode but we
still produced the dummy o-boot files. These never made it into a
`Linkable` but then confused the recompilation checker.
Fixes #22669
-rw-r--r-- | compiler/GHC/Driver/Pipeline/Execute.hs | 42 | ||||
-rw-r--r-- | testsuite/tests/driver/Makefile | 6 | ||||
-rw-r--r-- | testsuite/tests/driver/T22669.hs | 1 | ||||
-rw-r--r-- | testsuite/tests/driver/T22669.hs-boot | 1 | ||||
-rw-r--r-- | testsuite/tests/driver/all.T | 1 |
5 files changed, 36 insertions, 15 deletions
diff --git a/compiler/GHC/Driver/Pipeline/Execute.hs b/compiler/GHC/Driver/Pipeline/Execute.hs index 04b641c5d9..75f33834e2 100644 --- a/compiler/GHC/Driver/Pipeline/Execute.hs +++ b/compiler/GHC/Driver/Pipeline/Execute.hs @@ -578,21 +578,33 @@ runHscBackendPhase pipe_env hsc_env mod_name src_flavour location result = do next_phase = hscPostBackendPhase src_flavour (backend dflags) case result of HscUpdate iface -> - do - case src_flavour of - HsigFile -> do - -- We need to create a REAL but empty .o file - -- because we are going to attempt to put it in a library - let input_fn = expectJust "runPhase" (ml_hs_file location) - basename = dropExtension input_fn - compileEmptyStub dflags hsc_env basename location mod_name - - -- In the case of hs-boot files, generate a dummy .o-boot - -- stamp file for the benefit of Make - HsBootFile -> touchObjectFile logger dflags o_file - HsSrcFile -> panic "HscUpdate not relevant for HscSrcFile" - - return ([], iface, emptyHomeModInfoLinkable, o_file) + if | not (backendGeneratesCode (backend dflags)) -> + panic "HscUpdate not relevant for NoBackend" + | not (backendGeneratesCodeForHsBoot (backend dflags)) -> do + -- In Interpreter way, there is just no linkable for hs-boot files + -- and we don't want to write an empty `o-boot` file when we're not + -- supposed to be writing any .o files (#22669) + return ([], iface, emptyHomeModInfoLinkable, o_file) + | otherwise -> do + case src_flavour of + HsigFile -> do + -- We need to create a REAL but empty .o file + -- because we are going to attempt to put it in a library + let input_fn = expectJust "runPhase" (ml_hs_file location) + basename = dropExtension input_fn + compileEmptyStub dflags hsc_env basename location mod_name + + -- In the case of hs-boot files, generate a dummy .o-boot + -- stamp file for the benefit of Make + HsBootFile -> touchObjectFile logger dflags o_file + HsSrcFile -> panic "HscUpdate not relevant for HscSrcFile" + + -- MP: I wonder if there are any lurking bugs here because we + -- return Linkable == emptyHomeModInfoLinkable, despite the fact that there is a + -- linkable (.o-boot) which we check for in `Iface/Recomp.hs` and + -- then will carry around the linkable if we're doing + -- recompilation. + return ([], iface, emptyHomeModInfoLinkable, o_file) HscRecomp { hscs_guts = cgguts, hscs_mod_location = mod_location, hscs_partial_iface = partial_iface, diff --git a/testsuite/tests/driver/Makefile b/testsuite/tests/driver/Makefile index 7c9625570a..77e87c9e6f 100644 --- a/testsuite/tests/driver/Makefile +++ b/testsuite/tests/driver/Makefile @@ -786,4 +786,10 @@ T22044: # Test the file exists and is preprocessed "$(TEST_HC)" $(TEST_HC_OPTS) -v0 T22044.hs +.PHONY: T22669 +T22669: + echo ":q" | "$(TEST_HC)" $(TEST_HC_OPTS) -v0 --interactive T22669 + ! test -f T22669.o-boot + + diff --git a/testsuite/tests/driver/T22669.hs b/testsuite/tests/driver/T22669.hs new file mode 100644 index 0000000000..33ee925790 --- /dev/null +++ b/testsuite/tests/driver/T22669.hs @@ -0,0 +1 @@ +module T22669 where diff --git a/testsuite/tests/driver/T22669.hs-boot b/testsuite/tests/driver/T22669.hs-boot new file mode 100644 index 0000000000..33ee925790 --- /dev/null +++ b/testsuite/tests/driver/T22669.hs-boot @@ -0,0 +1 @@ +module T22669 where diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T index 5592e51e44..ddc0039b55 100644 --- a/testsuite/tests/driver/all.T +++ b/testsuite/tests/driver/all.T @@ -319,3 +319,4 @@ test('T21869', [js_broken(22261), when(unregisterised(), skip)], makefile_test, test('T22044', normal, makefile_test, []) test('T22048', [only_ways(['normal']), grep_errmsg("_rule")], compile, ["-O -fomit-interface-pragmas -ddump-simpl"]) test('T21722', normal, compile_fail, ['-fno-show-error-context']) +test('T22669', normal, makefile_test, []) |