[Git][ghc/ghc][wip/9.6.4-backports] 26 commits: Fix unusable units and module reexport interaction (#21097)

Zubin (@wz1000) gitlab at gitlab.haskell.org
Fri Dec 15 12:14:27 UTC 2023



Zubin pushed to branch wip/9.6.4-backports at Glasgow Haskell Compiler / GHC


Commits:
1ae57288 by Sylvain Henry at 2023-12-15T17:17:29+05:30
Fix unusable units and module reexport interaction (#21097)

This commit fixes an issue with ModUnusable introduced in df0f148feae.

In mkUnusableModuleNameProvidersMap we traverse the list of unusable
units and generate ModUnusable origin for all the modules they contain:
exposed modules, hidden modules, and also re-exported modules. To do
this we have a two-level map:

  ModuleName -> Unit:ModuleName (aka Module) -> ModuleOrigin

So for each module name "M" in broken unit "u" we have:
  "M" -> u:M -> ModUnusable reason

However in the case of module reexports we were using the *target*
module as a key. E.g. if "u:M" is a reexport for "X" from unit "o":
   "M" -> o:X -> ModUnusable reason

Case 1: suppose a reexport without module renaming (u:M -> o:M) from
unusable unit u:
   "M" -> o:M -> ModUnusable reason

Here it's claiming that the import of M is unusable because a reexport
from u is unusable. But if unit o isn't unusable we could also have in
the map:
   "M" -> o:M -> ModOrigin ...

Issue: the Semigroup instance of ModuleOrigin doesn't handle the case
(ModUnusable <> ModOrigin)

Case 2: similarly we could have 2 unusable units reexporting the same module
without renaming, say (u:M -> o:M) and (v:M -> o:M) with u and v
unusable. It gives:

  "M" -> o:M -> ModUnusable ... (for u)
  "M" -> o:M -> ModUnusable ... (for v)

Issue: the Semigroup instance of ModuleOrigin doesn't handle the case
(ModUnusable <> ModUnusable).

This led to #21097, #16996, #11050.

To fix this, in this commit we make ModUnusable track whether the module
used as key is a reexport or not (for better error messages) and we use
the re-export module as key. E.g. if "u:M" is a reexport for "o:X" and u
is unusable, we now record:

    "M" -> u:M -> ModUnusable reason reexported=True

So now, we have two cases for a reexport u:M -> o:X:
   - u unusable: "M" -> u:M -> ModUnusable ... reexported=True
   - u usable:   "M" -> o:X -> ModOrigin   ... reexportedFrom=u:M

The second case is indexed with o:X because in this case the Semigroup
instance of ModOrigin is used to combine valid expositions of a module
(directly or via reexports).

Note that module lookup functions select usable modules first (those who
have a ModOrigin value), so it doesn't matter if we add new ModUnusable
entries in the map like this:

  "M" -> {
    u:M -> ModUnusable ... reexported=True
    o:M -> ModOrigin ...
  }

The ModOrigin one will be used. Only if there is no ModOrigin or
ModHidden entry will the ModUnusable error be printed. See T21097 for an
example printing several reasons why an import is unusable.

(cherry picked from commit cee81370cd6ef256f66035e3116878d4cb82e28b)

- - - - -
cc1097f3 by Zubin Duggal at 2023-12-15T17:17:29+05:30
driver: Ensure we actually clear the interactive context before reloading

Previously we called discardIC, but immediately after set the session
back to an old HscEnv that still contained the IC

Partially addresses #24107
Fixes #23405

(cherry picked from commit fa148f6ed43f915f2ae40302dda1b8bae39512af)

- - - - -
cd61dd26 by Zubin Duggal at 2023-12-15T17:17:29+05:30
driver: Ensure we force the lookup of old build artifacts before returning the build plan

This prevents us from retaining all previous build artifacts in memory until a
recompile finishes, instead only retaining the exact artifacts we need.

Fixes #24118

(cherry picked from commit a62d4cb25b805dd7e12476db97a667fd542ea006)

- - - - -
33b3ff8a by Zubin Duggal at 2023-12-15T17:17:29+05:30
testsuite: add test for #24118 and #24107

MultiLayerModulesDefsGhci was not able to catch the leak because it uses
:l which discards the previous environment.

Using :r catches both of these leaks
(cherry picked from commit 244d3315352376eb7b946843fb0c512412842d7d)

- - - - -
27fec1c3 by Zubin Duggal at 2023-12-15T17:17:29+05:30
compiler: Add some strictness annotations to ImportSpec and related constructors
This prevents us from retaining entire HscEnvs.

Force these ImportSpecs when forcing the GlobalRdrEltX

Adds an NFData instance for Bag

Fixes #24107

(cherry picked from commit 306cb4e3e02e466f6c5a57c1a65fd2a5d13b3f89)

- - - - -
74fa25f0 by Zubin Duggal at 2023-12-15T17:17:30+05:30
compiler: Force IfGlobalRdrEnv in NFData instance.

(cherry picked from commit 77a3b580f561e62f5ac7ebf6588199575aafd3b4)

- - - - -
2e4b7832 by Pierre Le Marre at 2023-12-15T17:17:30+05:30
Update to Unicode 15.1.0

See: https://www.unicode.org/versions/Unicode15.1.0/
(cherry picked from commit 778c84b61679a8bb9dd83e2c41156abc0f39abd3)

- - - - -
b8eac3cf by Simon Peyton Jones at 2023-12-15T17:17:30+05:30
Add an extra check in kcCheckDeclHeader_sig

Fix #24083 by checking for a implicitly-scoped type variable that is not
actually bound.  See Note [Disconnected type variables] in GHC.Tc.Gen.HsType

For some reason, on aarch64-darwin we saw a 2.8% decrease in compiler
allocations for MultiLayerModulesTH_Make; but 0.0% on other architectures.

Metric Decrease:
    MultiLayerModulesTH_Make

(cherry picked from commit 6dbab1808bfbe484b3fb396aab1d105314f918d8)

- - - - -
110efc98 by Simon Peyton Jones at 2023-12-15T17:17:30+05:30
Second fix to #24083

My earlier fix turns out to be too aggressive for data/type families

See wrinkle (DTV1) in Note [Disconnected type variables]

(cherry picked from commit 2776920e642544477a38d0ed9205d4f0b48a782e)

- - - - -
01b8a66b by Alexis King at 2023-12-15T17:17:30+05:30
Don’t store the async exception masking state in CATCH frames

(cherry picked from commit 8b61dfd6dfc78bfa6bb9449dac9a336e5d668b5e)
(cherry picked from commit e538003c33251c5c843cac1e30b36f88bb859778)

- - - - -
cfbf9aa9 by Zubin Duggal at 2023-12-15T17:17:30+05:30
Bump array submodule to 0.5.6.0

- - - - -
bd31c2bb by Matthew Pickering at 2023-12-15T17:17:30+05:30
libraries: Bump filepath to 1.4.200.1 and unix to 2.8.4.0

Updates filepath submodule
Updates unix submodule

Fixes #24240

(cherry picked from commit 36b9a38cc45a26865c4e45f4949e519a5dede76d)

- - - - -
207f897a by Matthew Pickering at 2023-12-15T17:17:30+05:30
Submodule linter: Allow references to tags

We modify the submodule linter so that if the bumped commit is a
specific tag then the commit is accepted.

Fixes #24241

(cherry picked from commit 91ff0971df64b04938d011fe1562320c5d90849a)

- - - - -
1fa23f43 by Zubin Duggal at 2023-12-15T17:17:30+05:30
hadrian: set -Wno-deprecations for directory and Win32

The filepath bump to 1.4.200.1 introduces a deprecation warning.

See https://gitlab.haskell.org/ghc/ghc/-/issues/24240
    https://github.com/haskell/filepath/pull/206

(cherry picked from commit 86f652dc9a649e59e643609c287a510a565f5408)

- - - - -
76bc5445 by Ben Gamari at 2023-12-15T17:17:30+05:30
Fix thunk update ordering

Previously we attempted to ensure soundness of concurrent thunk update
by synchronizing on the access of the thunk's info table pointer field.
This was believed to be sufficient since the indirectee (which may
expose a closure allocated by another core) would not be examined
until the info table pointer update is complete.

However, it turns out that this can result in data races in the presence
of multiple threads racing a update a single thunk. For instance,
consider this interleaving under the old scheme:

            Thread A                             Thread B
            ---------                            ---------
    t=0     Enter t
      1     Push update frame
      2     Begin evaluation

      4     Pause thread
      5     t.indirectee=tso
      6     Release t.info=BLACKHOLE

      7     ... (e.g. GC)

      8     Resume thread
      9     Finish evaluation
      10    Relaxed t.indirectee=x

      11                                         Load t.info
      12                                         Acquire fence
      13                                         Inspect t.indirectee

      14    Release t.info=BLACKHOLE

Here Thread A enters thunk `t` but is soon paused, resulting in `t`
being lazily blackholed at t=6. Then, at t=10 Thread A finishes
evaluation and updates `t.indirectee` with a relaxed store.

Meanwhile, Thread B enters the blackhole. Under the old scheme this
would introduce an acquire-fence but this would only synchronize with
Thread A at t=6. Consequently, the result of the evaluation, `x`, is not
visible to Thread B, introducing a data race.

We fix this by treating the `indirectee` field as we do all other
mutable fields. This means we must always access this field with
acquire-loads and release-stores.

See #23185.

(cherry picked from commit fa63b5902389aa929af5ec04b93b601fd456633f)
(cherry picked from commit fcfb0850d1960b677a2f6b9bdf45d8ccef169aeb)

- - - - -
2de05890 by Bryan Richter at 2023-12-15T17:17:30+05:30
Work around perf note fetch failure

Addresses #24055.

(cherry picked from commit 63afb701a1638d7bd32c34fb24a9fd3ff897b634)

- - - - -
592e41e2 by Zubin Duggal at 2023-12-15T17:17:30+05:30
Bump haddock submodule to 2.29.2

- - - - -
30d1b643 by Moritz Angermann at 2023-12-15T17:17:40+05:30
Drop hard Xcode dependency

XCODE_VERSION calls out to `xcodebuild`, which is only available
when having `Xcode` installed. The CommandLineTools are not
sufficient. To install Xcode, you must have an apple id to download
the Xcode.xip from apple.

We do not use xcodebuild anywhere in our build explicilty. At best
it appears to be a proxy for checking the linker or the compiler.
These should rather be done with
```
xcrun ld -version
```
or similar, and not by proxy through Xcode. The CLR should be
sufficient for building software on macOS.

(cherry picked from commit a3ee3b99e6889fd68da75c6ea7a14d101f71da56)

- - - - -
5a77075c by Matthew Craven at 2023-12-15T17:39:36+05:30
Make 'wWarningFlagsDeps' include every WarningFlag

Fixes #24071.

(cherry picked from commit a2c0fff61afdb14b5f2624374aa5767e7b238ff4)

- - - - -
31bc8575 by Ben Gamari at 2023-12-15T17:40:16+05:30
rts/eventlog: Fix off-by-one in assertion

Previously we failed to account for the NULL terminator `postString`
asserted that there is enough room in the buffer for the string.

(cherry picked from commit d0b17576148d336b67c7d65bcf742f83001413cb)

- - - - -
a62134f2 by Ben Gamari at 2023-12-15T17:40:25+05:30
rts/eventlog: Honor result of ensureRoomForVariableEvent is

Previously we would keep plugging along, even if isn't enough room for
the event.

(cherry picked from commit a10f9b9bc510051a5b47d31238aad1174f7a1966)

- - - - -
472582dc by Ben Gamari at 2023-12-15T17:40:34+05:30
rts/eventlog: Avoid truncating event sizes

Previously ensureRoomForVariableEvent would truncate the desired size to
16-bits, resulting in #24197.

Fixes #24197.

(cherry picked from commit 0e0f41c0e3d9c67fc669e975060e88bccdc7d823)

- - - - -
65699dd6 by Ben Gamari at 2023-12-15T17:41:37+05:30
rts/EventLog: Place eliminate duplicate strlens

Previously many of the `post*` implementations would first compute the
length of the event's strings in order to determine the event length.
Later we would then end up computing the length yet again in
`postString`. Now we instead pass the string length to `postStringLen`,
avoiding the repeated work.

(cherry picked from commit c350df3ce0e5c207b90eb3e74e04c77826c56283)

- - - - -
39236678 by Ben Gamari at 2023-12-15T17:41:45+05:30
rts/eventlog: Place upper bound on IPE string field lengths

The strings in IPE events may be of unbounded length. Limit the lengths
of these fields to 64k characters to ensure that we don't exceed the
maximum event length.

(cherry picked from commit 9340d9987abe2ebf7f66659ffc48a822586f6edd)

- - - - -
bc444199 by Zubin Duggal at 2023-12-15T17:41:51+05:30
rts: drop unused postString function

(cherry picked from commit 6e03bfdfdb74de2a8b51d3008233392a6f0a9965)

- - - - -
8b9486ae by Zubin Duggal at 2023-12-15T17:43:37+05:30
Bump base to 4.18.2.0 and add changelog

- - - - -


30 changed files:

- .gitlab/test-metrics.sh
- compiler/GHC/Data/Bag.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Make.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Iface/Errors.hs
- compiler/GHC/StgToCmm/Bind.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/HsType.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/Hint.hs
- compiler/GHC/Types/Hint/Ppr.hs
- compiler/GHC/Types/Name/Occurrence.hs
- compiler/GHC/Types/Name/Reader.hs
- compiler/GHC/Unit/Finder.hs
- compiler/GHC/Unit/Finder/Types.hs
- compiler/GHC/Unit/Module/ModIface.hs
- compiler/GHC/Unit/State.hs
- configure.ac
- distrib/configure.ac.in
- hadrian/src/Settings/Warnings.hs
- libraries/array
- libraries/base/GHC/Unicode/Internal/Char/DerivedCoreProperties.hs
- libraries/base/GHC/Unicode/Internal/Char/UnicodeData/GeneralCategory.hs
- libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleLowerCaseMapping.hs
- libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleTitleCaseMapping.hs
- libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleUpperCaseMapping.hs
- libraries/base/GHC/Unicode/Internal/Version.hs
- libraries/base/base.cabal


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/226b52f9626ca182256b083dabce925e30c35aa9...8b9486ae2ccbb105df0a8883b55b27a56f3b23c2

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/226b52f9626ca182256b083dabce925e30c35aa9...8b9486ae2ccbb105df0a8883b55b27a56f3b23c2
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20231215/acb3b1fd/attachment-0001.html>


More information about the ghc-commits mailing list