Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
f1cb08be
by Hannes Siebenhandl at 2026-10-05T22:05:03-04:00
5 changed files:
- changelog.d/unit-index
- compiler/GHC/Driver/Backpack.hs
- + testsuite/tests/backpack/should_compile/T27835.bkp
- + testsuite/tests/backpack/should_compile/T27835.stderr
- testsuite/tests/backpack/should_compile/all.T
Changes:
| 1 | 1 | section: compiler
|
| 2 | 2 | synopsis: Use global ``UnitIndex`` to deduplicate ``UnitInfo``s over multiple home units
|
| 3 | -issues: #27500 #26423 #27748 #27834
|
|
| 4 | -mrs: !16115 !16598 !16743
|
|
| 3 | +issues: #27500 #26423 #27748 #27834 #27835
|
|
| 4 | +mrs: !16115 !16598 !16743 !16748
|
|
| 5 | 5 | |
| 6 | 6 | description: {
|
| 7 | 7 | The ``UnitState`` used to be duplicated for all ``HomeUnitEnv``, not sharing any of the ``UnitInfo``s.
|
| ... | ... | @@ -441,9 +441,11 @@ addInMemoryDatabase dflags u = do |
| 441 | 441 | }
|
| 442 | 442 | let uic = hscUIC hsc_env
|
| 443 | 443 | liftIO $ cacheExternalUnitDatabase uic newdb
|
| 444 | - -- added at the end because ordering matters
|
|
| 444 | + -- Ordering matters here! We prepend the new unit database, because 'packageDBFlags'
|
|
| 445 | + -- works like a stack, where what's on top takes precedence over what's below (same as right-to-left when given at the CLI).
|
|
| 446 | + -- The new db needs highest precedence to overwrite any other in-memory units that potentially occur in the dbs below it.
|
|
| 445 | 447 | pure dflags
|
| 446 | - { packageDBFlags = packageDBFlags dflags ++ [PackageDB (PkgDbPath (unitDatabasePath newdb))]
|
|
| 448 | + { packageDBFlags = PackageDB (PkgDbPath (unitDatabasePath newdb)) : packageDBFlags dflags
|
|
| 447 | 449 | }
|
| 448 | 450 | |
| 449 | 451 | -- | Register a new virtual unit database containing a single unit
|
| 1 | +unit p where
|
|
| 2 | + module P where
|
|
| 3 | + p :: Int
|
|
| 4 | + p = 42
|
|
| 5 | + |
|
| 6 | +unit q where
|
|
| 7 | + dependency p
|
|
| 8 | + module Q where
|
|
| 9 | + import P
|
|
| 10 | + q :: Int
|
|
| 11 | + q = p + 1 |
| 1 | +[1 of 2] Processing p
|
|
| 2 | + Instantiating p
|
|
| 3 | + [1 of 1] Compiling P ( p/P.hs, T27835.out/p/P.o )
|
|
| 4 | +[2 of 2] Processing q
|
|
| 5 | + Instantiating q
|
|
| 6 | + [1 of 1] Including p
|
|
| 7 | + [1 of 1] Compiling Q ( q/Q.hs, T27835.out/q/Q.o ) |
| ... | ... | @@ -61,3 +61,4 @@ test('T13250', normal, backpack_compile, ['']) |
| 61 | 61 | test('T13323', normal, backpack_compile, [''])
|
| 62 | 62 | test('T20396', normal, backpack_compile, [''])
|
| 63 | 63 | test('T23424', [ignore_stdout, ignore_stderr], backpack_compile, ['-ddump-rn-trace -ddump-if-trace -ddump-tc-trace'])
|
| 64 | +test('T27835', normal, backpack_compile, ['-clear-package-db -global-package-db']) |