Hannes Siebenhandl pushed to branch wip/fendor/one-shot-no-eps at Glasgow Haskell Compiler / GHC
Commits:
-
ec0da2ed
by fendor at 2026-11-30T13:24:11+01:00
11 changed files:
- testsuite/tests/bytecode/T25090/Makefile
- testsuite/tests/bytecode/T25090/all.T
- + testsuite/tests/driver/one-shot-boot/A.hs
- + testsuite/tests/driver/one-shot-boot/B.hs
- + testsuite/tests/driver/one-shot-boot/Fam.hs
- + testsuite/tests/driver/one-shot-boot/M.hs
- + testsuite/tests/driver/one-shot-boot/M.hs-boot
- + testsuite/tests/driver/one-shot-boot/Main.hs
- + testsuite/tests/driver/one-shot-boot/Makefile
- + testsuite/tests/driver/one-shot-boot/all.T
- + testsuite/tests/driver/one-shot-boot/one-shot-boot.stdout
Changes:
| ... | ... | @@ -16,6 +16,22 @@ T25090a: |
| 16 | 16 | '$(TEST_HC)' -fbyte-code-and-object-code -fprefer-byte-code A.o -o exe
|
| 17 | 17 | ./exe
|
| 18 | 18 | |
| 19 | +# Like T25090a, but without .gbc files: the bytecode for the splice has to be
|
|
| 20 | +# compiled from the Core stored in the interface files
|
|
| 21 | +# (-fwrite-if-simplified-core). See Note [Interface Files with Core Definitions].
|
|
| 22 | +T25090c:
|
|
| 23 | + '$(TEST_HC)' -c -fwrite-if-simplified-core C.hs-boot
|
|
| 24 | + '$(TEST_HC)' -c -fwrite-if-simplified-core B.hs
|
|
| 25 | + '$(TEST_HC)' -c -fwrite-if-simplified-core C.hs
|
|
| 26 | + echo 'corrupt' > B.o
|
|
| 27 | + echo 'corrupt' > C.o
|
|
| 28 | + echo 'corrupt' > C.o-boot
|
|
| 29 | + '$(TEST_HC)' -c -fwrite-if-simplified-core D.hs
|
|
| 30 | + echo 'corrupt' > D.o
|
|
| 31 | + '$(TEST_HC)' -c -fwrite-if-simplified-core -fprefer-byte-code A.hs
|
|
| 32 | + '$(TEST_HC)' A.o -o exe
|
|
| 33 | + ./exe
|
|
| 34 | + |
|
| 19 | 35 | T25090b:
|
| 20 | 36 | '$(TEST_HC)' -fbyte-code-and-object-code -fprefer-byte-code A -o exe -v0
|
| 21 | 37 | ./exe |
| ... | ... | @@ -4,7 +4,7 @@ |
| 4 | 4 | # the warning is added to the expected stderr for debugged builds.
|
| 5 | 5 | def test_T25090(name):
|
| 6 | 6 | assert_warn_spec = {'stderr': 'T25090-debug.stderr'}
|
| 7 | - extra_specs = assert_warn_spec if name == 'T25090a' and compiler_debugged() else {}
|
|
| 7 | + extra_specs = assert_warn_spec if name in ('T25090a', 'T25090c') and compiler_debugged() else {}
|
|
| 8 | 8 | return test(name,
|
| 9 | 9 | [extra_files(['A.hs', 'B.hs', 'C.hs-boot', 'C.hs', 'D.hs']),
|
| 10 | 10 | req_th,
|
| ... | ... | @@ -16,3 +16,4 @@ def test_T25090(name): |
| 16 | 16 | |
| 17 | 17 | test_T25090('T25090a')
|
| 18 | 18 | test_T25090('T25090b')
|
| 19 | +test_T25090('T25090c') |
| 1 | +{-# LANGUAGE TypeFamilies #-}
|
|
| 2 | +module A where
|
|
| 3 | + |
|
| 4 | +import Fam
|
|
| 5 | +import {-# SOURCE #-} M (T)
|
|
| 6 | + |
|
| 7 | +-- This instance mentions 'T' from M's boot file.
|
|
| 8 | +type instance F T = Int |
| 1 | +{-# LANGUAGE TypeFamilies #-}
|
|
| 2 | +module B where
|
|
| 3 | + |
|
| 4 | +import Fam
|
|
| 5 | + |
|
| 6 | +-- A second family-instance module for 'F', so that compiling M has to check
|
|
| 7 | +-- the consistency of A's and B's instances. That check forces 'T', which
|
|
| 8 | +-- makes GHC load M.hi-boot while compiling M itself.
|
|
| 9 | +-- See Note [Loading your own hi-boot file] in GHC.Iface.Load.
|
|
| 10 | +type instance F Bool = Char |
| 1 | +{-# LANGUAGE TypeFamilies #-}
|
|
| 2 | +module Fam where
|
|
| 3 | + |
|
| 4 | +type family F a |
| 1 | +{-# LANGUAGE TypeFamilies #-}
|
|
| 2 | +module M where
|
|
| 3 | + |
|
| 4 | +import Fam
|
|
| 5 | +import A ()
|
|
| 6 | +import B ()
|
|
| 7 | + |
|
| 8 | +data T = MkT Int
|
|
| 9 | + |
|
| 10 | +-- Also declared in M.hs-boot: loading M.hi-boot while compiling M must not
|
|
| 11 | +-- cause a duplicate instance error.
|
|
| 12 | +instance Show T where
|
|
| 13 | + show (MkT n) = "MkT " ++ show n
|
|
| 14 | + |
|
| 15 | +-- Not part of M.hs-boot. Needs A's instance of 'F' to typecheck.
|
|
| 16 | +onlyInM :: F T
|
|
| 17 | +onlyInM = 42 |
| 1 | +module M where
|
|
| 2 | + |
|
| 3 | +data T
|
|
| 4 | + |
|
| 5 | +instance Show T |
| 1 | +module Main where
|
|
| 2 | + |
|
| 3 | +import M
|
|
| 4 | + |
|
| 5 | +main :: IO ()
|
|
| 6 | +main = do
|
|
| 7 | + print (onlyInM :: Int)
|
|
| 8 | + print (MkT 1) |
| 1 | +TOP=../../..
|
|
| 2 | +include $(TOP)/mk/boilerplate.mk
|
|
| 3 | +include $(TOP)/mk/test.mk
|
|
| 4 | + |
|
| 5 | +# One-shot compilation of a SOURCE-import cycle where type family instances
|
|
| 6 | +# mention the type from the boot file. Every module is compiled by its own
|
|
| 7 | +# invocation of GHC.
|
|
| 8 | +OneShotBootFamInst:
|
|
| 9 | + '$(TEST_HC)' $(TEST_HC_OPTS) -c Fam.hs
|
|
| 10 | + '$(TEST_HC)' $(TEST_HC_OPTS) -c M.hs-boot
|
|
| 11 | + '$(TEST_HC)' $(TEST_HC_OPTS) -c A.hs
|
|
| 12 | + '$(TEST_HC)' $(TEST_HC_OPTS) -c B.hs
|
|
| 13 | + '$(TEST_HC)' $(TEST_HC_OPTS) -c M.hs
|
|
| 14 | + '$(TEST_HC)' $(TEST_HC_OPTS) -c Main.hs
|
|
| 15 | + '$(TEST_HC)' $(TEST_HC_OPTS) Fam.o A.o B.o M.o Main.o -o main
|
|
| 16 | + ./main
|
|
| 17 | + |
|
| 18 | +# Like OneShotBootFamInst, but M and Main are compiled by the same invocation.
|
|
| 19 | +# Compiling M loads M.hi-boot (see Note [Loading your own hi-boot file]); that
|
|
| 20 | +# must not make Main see the boot interface of M instead of the real one.
|
|
| 21 | +OneShotBootSameInvocation:
|
|
| 22 | + '$(TEST_HC)' $(TEST_HC_OPTS) -c Fam.hs
|
|
| 23 | + '$(TEST_HC)' $(TEST_HC_OPTS) -c M.hs-boot
|
|
| 24 | + '$(TEST_HC)' $(TEST_HC_OPTS) -c A.hs
|
|
| 25 | + '$(TEST_HC)' $(TEST_HC_OPTS) -c B.hs
|
|
| 26 | + '$(TEST_HC)' $(TEST_HC_OPTS) -c M.hs Main.hs
|
|
| 27 | + '$(TEST_HC)' $(TEST_HC_OPTS) Fam.o A.o B.o M.o Main.o -o main
|
|
| 28 | + ./main |
| 1 | +# Compiling M loads M.hi-boot, which triggers a warnPprTrace in debug builds.
|
|
| 2 | +# See Note [Loading your own hi-boot file] in GHC.Iface.Load.
|
|
| 3 | +def test_one_shot_boot(name):
|
|
| 4 | + return test(name,
|
|
| 5 | + [extra_files(['Fam.hs', 'M.hs-boot', 'A.hs', 'B.hs', 'M.hs', 'Main.hs']),
|
|
| 6 | + js_skip,
|
|
| 7 | + when(compiler_debugged(), ignore_stderr),
|
|
| 8 | + use_specs(dict(stdout = 'one-shot-boot.stdout')),
|
|
| 9 | + ],
|
|
| 10 | + makefile_test,
|
|
| 11 | + [])
|
|
| 12 | + |
|
| 13 | +test_one_shot_boot('OneShotBootFamInst')
|
|
| 14 | +test_one_shot_boot('OneShotBootSameInvocation') |
| 1 | +42
|
|
| 2 | +MkT 1 |