diff options
-rw-r--r-- | compiler/GHC/Driver/Pipeline.hs | 35 | ||||
-rw-r--r-- | testsuite/tests/lib/integer/T19264.hs | 4 | ||||
-rw-r--r-- | testsuite/tests/lib/integer/T19264b.hs | 1 | ||||
-rw-r--r-- | testsuite/tests/lib/integer/all.T | 3 |
4 files changed, 31 insertions, 12 deletions
diff --git a/compiler/GHC/Driver/Pipeline.hs b/compiler/GHC/Driver/Pipeline.hs index 5f79306e7e..7adde31d73 100644 --- a/compiler/GHC/Driver/Pipeline.hs +++ b/compiler/GHC/Driver/Pipeline.hs @@ -896,22 +896,33 @@ pipeLoop phase input_fn = do case phase of HscOut {} -> do + -- Depending on the dynamic-too state, we first run the + -- backend to generate the non-dynamic objects and then + -- re-run it to generate the dynamic ones. let noDynToo = do (next_phase, output_fn) <- runHookedPhase phase input_fn pipeLoop next_phase output_fn let dynToo = do - -- if Opt_BuildDynamicToo is set and if the platform - -- supports it, we first run the backend to generate - -- the dynamic objects and then re-run it to generate - -- the non-dynamic ones. - let dflags' = setDynamicNow dflags -- set "dynamicNow" - setDynFlags dflags' - (next_phase, output_fn) <- runHookedPhase phase input_fn - _ <- pipeLoop next_phase output_fn - -- TODO: we probably shouldn't ignore the result of - -- the dynamic compilation - setDynFlags dflags -- restore flags without "dynamicNow" set - noDynToo + -- we must run the non-dynamic way before the dynamic + -- one because there may be interfaces loaded only in + -- the backend (e.g., in CorePrep). See #19264 + r <- noDynToo + + -- we must check the dynamic-too state again, because + -- we may have failed to load a dynamic interface in + -- the backend. + dynamicTooState dflags >>= \case + DT_OK -> do + let dflags' = setDynamicNow dflags -- set "dynamicNow" + setDynFlags dflags' + (next_phase, output_fn) <- runHookedPhase phase input_fn + _ <- pipeLoop next_phase output_fn + -- TODO: we probably shouldn't ignore the result of + -- the dynamic compilation + setDynFlags dflags -- restore flags without "dynamicNow" set + return r + _ -> return r + dynamicTooState dflags >>= \case DT_Dont -> noDynToo DT_Failed -> noDynToo diff --git a/testsuite/tests/lib/integer/T19264.hs b/testsuite/tests/lib/integer/T19264.hs new file mode 100644 index 0000000000..87390c47fb --- /dev/null +++ b/testsuite/tests/lib/integer/T19264.hs @@ -0,0 +1,4 @@ +module T19264 where + +import T19264b -- needed (compiled before this module and triggering the failure) +import GHC.Num.BigNat (bigNatFromWordList) diff --git a/testsuite/tests/lib/integer/T19264b.hs b/testsuite/tests/lib/integer/T19264b.hs new file mode 100644 index 0000000000..3bea6669db --- /dev/null +++ b/testsuite/tests/lib/integer/T19264b.hs @@ -0,0 +1 @@ +module T19264b where diff --git a/testsuite/tests/lib/integer/all.T b/testsuite/tests/lib/integer/all.T index c132ca24dd..740fa0e606 100644 --- a/testsuite/tests/lib/integer/all.T +++ b/testsuite/tests/lib/integer/all.T @@ -15,6 +15,9 @@ test('bignumMatch', [], compile, ['']) test('T18813', [], compile_and_run, ['']) test('T19170', [], compile_and_run, ['']) +# skipped on Windows (doesn't support `-dynamic-too`) +test('T19264', [when(opsys('mingw32'),skip),extra_files(['T19264b.hs'])], compile, ['-dynamic-too --make -v0']) + # skip ghci as it doesn't support unboxed tuples test('integerImportExport', [omit_ways(['ghci'])], compile_and_run, ['']) |