[Git][ghc/ghc][wip/check-gc] 346 commits: llvmGen: Fix relaxed ordering

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Wed Aug 23 16:43:21 UTC 2023



Ben Gamari pushed to branch wip/check-gc at Glasgow Haskell Compiler / GHC


Commits:
fb22372e by Ben Gamari at 2022-12-22T15:29:25-05:00
llvmGen: Fix relaxed ordering

Previously I used LLVM's `unordered` ordering for the C11 `relaxed`
ordering. However, this is wrong and should rather use the LLVM
`monotonic` ordering.

Fixes #22640

(cherry picked from commit 1c9819ea4cd625e81ed9915fc23059bfd2a0bc1d)

- - - - -
5bc8709e by Matthew Pickering at 2023-01-03T16:52:35+00:00
head.hackage: Use slow-validate bindist for linting jobs

This enables the SLOW_VALIDATE env var for the linting head.hackage
jobs, namely the jobs enabled manually, by the label or on the nightly
build now use the deb10-numa-slow-validate bindist which has assertions
enabled.

See #22623 for a ticket which was found by using this configuration
already!

The head.hackage jobs triggered by upstream CI are now thusly:

hackage-lint: Can be triggered on any MR, normal validate pipeline or nightly build.
              Runs head.hackage with -dlint and a slow-validate bindist

hackage-label-lint: Trigged on MRs with "user-facing" label, runs the slow-validate
                    head.hackage build with -dlint.

nightly-hackage-lint: Runs automatically on nightly pipelines with slow-validate + dlint config.

nightly-hackage-perf: Runs automaticaly on nightly pipelines with release build and eventlogging enabled.

release-hackage-lint: Runs automatically on release pipelines with -dlint on a release bindist.
(cherry picked from commit cbaebfb9d03d01f15eb6bbeee584a70fc09a15c4)

- - - - -
fdf71893 by Matthew Pickering at 2023-01-03T16:52:41+00:00
ci: Don't run abi-test-nightly on release jobs

The test is not configured to get the correct dependencies for the
release pipelines (and indeed stops the release pipeline being run at
all)

(cherry picked from commit f4850f365cee3d9030a61132931f4aba51f7e52a)

- - - - -
ad8f5f60 by Matthew Pickering at 2023-01-03T16:52:56+00:00
ci: Run head.hackage jobs on upstream-testing branch rather than master

This change allows less priviledged users to trigger head.hackage jobs
because less permissions are needed to trigger jobs on the
upstream-testing branch, which is not protected.

There is a CI job which updates upstream-testing each hour to the state
of the master branch so it should always be relatively up-to-date.

(cherry picked from commit c264b06b4e77976939386a6d373d00118562c376)

- - - - -
611e686b by Andreas Klebinger at 2023-01-06T15:12:40+00:00
Don't consider large byte arrays/compact regions pinned.

Workaround for #22255 which showed how treating large/compact regions
as pinned could cause segfaults.

(cherry picked from commit 914f7fe3756734714a6795fc4bbca96442b01f92)

- - - - -
d98db93c by Ben Gamari at 2023-01-06T15:21:48+00:00
nonmoving: Fix race in marking of blackholes

We must use an acquire-fence when marking to ensure that the indirectee
is visible.

(cherry picked from commit 18d2acd2791a751c0b1894fd72dd0317583619cd)

- - - - -
a169f7a8 by Ben Gamari at 2023-01-06T15:21:48+00:00
nonmoving: Fix segment list races

(cherry picked from commit 11241efa3422fae97aed0abb1857baab2f9018fb)

- - - - -
d276bb54 by Ben Gamari at 2023-01-06T15:21:48+00:00
nonmoving: Use atomic when looking at bd->gen

Since it may have been mutated by a moving GC.

(cherry picked from commit 602455c9ae6e5a2746f43b1811bb3c54efb0a6f5)

- - - - -
63525f89 by Ben Gamari at 2023-01-06T15:21:48+00:00
nonmoving: Eliminate race in bump_static_flag

To ensure that we don't race with a mutator entering a new CAF we take
the SM mutex before touching static_flag. The other option here would be
to instead modify newCAF to use a CAS but the present approach is a bit
safer.

(cherry picked from commit 9d63b160287eb8edfe7ab0b1715f21c1b831bfa5)

- - - - -
e91352e2 by Ben Gamari at 2023-01-06T15:21:48+00:00
nonmoving: Ensure that mutable fields have acquire barrier

(cherry picked from commit 26837523f5a9cdb33a206f8b22eea88ef75c874b)

- - - - -
84bb3747 by Ben Gamari at 2023-01-06T15:21:48+00:00
nonmoving: Fix races in collector status tracking

Mark a number of accesses to do with tracking of the status of the
concurrent collection thread as atomic. No interesting races here,
merely necessary to satisfy TSAN.

(cherry picked from commit 8093264a448940133fc2f1899bab8757eabe4b85)

- - - - -
5922a583 by Ben Gamari at 2023-01-06T15:21:48+00:00
nonmoving: Make segment state updates atomic

(cherry picked from commit 387d4fcc29441098d41340c12e56d9693b5e4c94)

- - - - -
d6eb8ba1 by Ben Gamari at 2023-01-06T15:21:48+00:00
nonmoving: Refactor update remembered set initialization

This avoids a lock inversion between the storage manager mutex and
the stable pointer table mutex by not dropping the SM_MUTEX in
nonmovingCollect. This requires quite a bit of rejiggering but it
does seem like a better strategy.

(cherry picked from commit 543cae0084a72ca767a443d857f9e65a5a79f71d)

- - - - -
40317135 by Ben Gamari at 2023-01-06T15:21:48+00:00
nonmoving: Ensure that we aren't holding locks when closing them

TSAN complains about this sort of thing.

(cherry picked from commit c99367180e49d903f8be649bfdc11e95649c7d1a)

- - - - -
d86a40bc by Ben Gamari at 2023-01-06T15:21:48+00:00
nonmoving: Make bitmap accesses atomic

This is a benign race on any sensible hard since these are byte
accesses. Nevertheless, atomic accesses are necessary to satisfy
TSAN.

(cherry picked from commit 0cd31f7d2c8baea0489770c765a7b8dd5c79679f)

- - - - -
ce02950d by Ben Gamari at 2023-01-06T15:21:48+00:00
nonmoving: Fix benign race in update remembered set check

Relaxed load is fine here since we will take the lock before looking at
the list.

(cherry picked from commit d3fe110aaf7c40c5a4b2ff460abe33ee7fac6d93)

- - - - -
98ec2167 by Ben Gamari at 2023-01-06T15:21:48+00:00
nonmoving: Fix race in shortcutting

We must use an acquire load to read the info table pointer since if we
find an indirection we must be certain that we see the indirectee.

(cherry picked from commit ab6cf893037f073fd3daf619579c84e58362b499)

- - - - -
61f96bb4 by Ben Gamari at 2023-01-06T15:21:48+00:00
nonmoving: Make free list counter accesses atomic

Since these may race with the allocator(s).

(cherry picked from commit 36c9f23c9dc52928b5d2971f38f6e0b15e38528e)

- - - - -
4af109cf by Ben Gamari at 2023-01-06T15:25:59+00:00
compiler: Ensure that GHC toolchain is first in search path

As noted in #22561, it is important that GHC's toolchain look
first for its own headers and libraries to ensure that the
system's are not found instead. If this happens things can
break in surprising ways (e.g. see #22561).

- - - - -
a5118fc5 by Ben Gamari at 2023-01-06T15:28:08+00:00
Bump libffi-tarballs submodule

We will now use libffi-3.4.4.

(cherry picked from commit b2c7523d8987bedf13a7dd682d836ffb76cbe09d)

- - - - -
42ea9cea by Sylvain Henry at 2023-01-06T15:28:38+00:00
JS: fix support for -outputdir (#22641)

The `-outputdir` option wasn't correctly handled with the JS backend
because the same code path was used to handle both objects produced by
the JS backend and foreign .js files. Now we clearly distinguish the
two in the pipeline, fixing the bug.

(cherry picked from commit 99757ce8e32d9809c71b09583aa881943a450086)

- - - - -
b11a4111 by Matthew Pickering at 2023-01-06T15:29:29+00:00
Revert "configure: Drop uses of AC_PROG_CC_C99"

This reverts commit 7c6de18dd3151ead954c210336728e8686c91de6.

Centos7 using a very old version of the toolchain (autotools-2.69) where
the behaviour of these macros has not yet changed. I am reverting this
without haste as it is blocking the 9.6 branch.

Fixes #22704

(cherry picked from commit b2a2db04b24a4654261db8e0db6ad7bac1b3d7cf)

- - - - -
246176a0 by Ben Gamari at 2023-01-06T15:32:27+00:00
hadrian: Ensure that linker scripts are used when merging objects

In #22527 @rui314 inadvertantly pointed out a glaring bug in Hadrian's
implementation of the object merging rules: unlike the old `make` build
system we utterly failed to pass the needed linker scripts. Fix this.

(cherry picked from commit 6d7d4393e15a6d0a2b42ec986ec6bd3df27baaa7)

- - - - -
15014bce by Matthew Pickering at 2023-01-06T15:32:32+00:00
compiler: Add -f[no-]split-sections flags

Here we add a `-fsplit-sections` flag which may some day replace
`-split-sections`. This has the advantage of automatically providing a
`-fno-split-sections` flag, which is useful for our packaging because we
enable `-split-sections` by default but want to disable it in certain
configurations.

(cherry picked from commit 32255d055b768d51deb9d1f49681164cf7492011)

- - - - -
0561d8f2 by Matthew Pickering at 2023-01-06T15:32:32+00:00
hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler

This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b

(cherry picked from commit e640940c55a88d10537682baf530f3772e55459a)

- - - - -
c45ce0f1 by Matthew Pickering at 2023-01-06T15:32:32+00:00
hadrian: Add test:all_deps to build just testsuite dependencies

Fixes #22534

(cherry picked from commit 15bee1239877a4629a245fe457f06e5f96668423)

- - - - -
123adfba by Matthew Pickering at 2023-01-06T15:32:32+00:00
hadrian: Add no_split_sections tranformer

This transformer reverts the effect of `split_sections`, which we intend
to use for platforms which don't support split sections.

In order to achieve this we have to modify the implemntation of the
split_sections transformer to store whether we are enabling
split_sections directly in the `Flavour` definition. This is because
otherwise there's no convenient way to turn off split_sections due to
having to pass additional linker scripts when merging objects.

(cherry picked from commit fec6638e2468c78f136f2363d8b3239a9bfd4f91)

- - - - -
6fad57b3 by Matthew Pickering at 2023-01-06T15:32:32+00:00
check-exact: Fix build with -Werror

(cherry picked from commit 3dc05726dca7e38ca8de8e1175c8f1489b96653e)

- - - - -
2bfb6270 by Matthew Pickering at 2023-01-06T15:32:32+00:00
ci: Build all test dependencies with in-tree compiler

This means that these executables will honour flavour transformers such
as "werror".

Fixes #22555

(cherry picked from commit 53a6ae7a8f819d1105aa190dc9cce215cdbcc6dc)

- - - - -
a9bcd226 by Matthew Pickering at 2023-01-06T15:32:32+00:00
hadrian: Document using GHC environment variable to select boot compiler

Fixes #22340

(cherry picked from commit 32e264c1a11e6356bb045371b87a3736df19e792)

- - - - -
be78e321 by Matthew Pickering at 2023-01-06T15:36:14+00:00
packaging: Build perf builds with -split-sections

In 8f71d958 the make build system was made to use split-sections on
linux systems but it appears this logic never made it to hadrian.
There is the split_sections flavour transformer but this doesn't appear
to be used for perf builds on linux.

This is disbled on deb9 and windows due to #21670

Closes #21135

(cherry picked from commit be9dd9b03479070ba6387c251541f4569392c4bb)

- - - - -
81e37370 by Matthew Pickering at 2023-01-06T15:38:30+00:00
sphinx: Use modern syntax for extlinks

This fixes the following build error:

```
  Command line: /opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -d /private/tmp/extra-dir-55768274273/.doctrees-man -n -w /private/tmp/extra-dir-55768274273/.log docs/users_guide /private/tmp/extra-dir-55768274273
  ===> Command failed with error code: 2

  Exception occurred:
    File "/opt/homebrew/Cellar/sphinx-doc/6.0.0/libexec/lib/python3.11/site-packages/sphinx/ext/extlinks.py", line 101, in role
      title = caption % part
              ~~~~~~~~^~~~~~
  TypeError: not all arguments converted during string formatting
```

I tested on Sphinx-5.1.1 and Sphinx-6.0.0

Thanks for sterni for providing instructions about how to test using
sphinx-6.0.0.

Fixes #22690

(cherry picked from commit 00dc51060881df81258ba3b3bdf447294618a4de)

- - - - -
a7d72a7c by Zubin Duggal at 2023-01-06T15:38:42+00:00
Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface

Involves adding many new NFData instances.

Without forcing Docs, references to the TcGblEnv for each module are retained
by the Docs structure. Usually these are forced when the ModIface is serialised
but not when we aren't writing the interface.

(cherry picked from commit 62b9a7b23b20f5cf0a2de14251c2096098009f10)

- - - - -
86133736 by Matthew Pickering at 2023-01-06T15:39:01+00:00
Store RdrName rather than OccName in Holes

In #20472 it was pointed out that you couldn't defer out of scope but
the implementation collapsed a RdrName into an OccName to stuff it into
a Hole. This leads to the error message for a deferred qualified name
dropping the qualification which affects the quality of the error
message.

This commit adds a bit more structure to a hole, so a hole can replace a
RdrName without losing information about what that RdrName was. This is
important when printing error messages.

I also added a test which checks the Template Haskell deferral of out of
scope qualified names works properly.

Fixes #22130

(cherry picked from commit 6d62f6bfbb5a86131e7cbc30993f3fa510d8b3ab)

- - - - -
fd285b98 by Simon Peyton Jones at 2023-01-06T15:40:45+00:00
Fix unifier bug: failing to decompose over-saturated type family

This simple patch fixes #22647

(cherry picked from commit 317f45c154f6fe25d50ef2f3febcc5883ff1b1ca)

- - - - -
6378106a by Simon Peyton Jones at 2023-01-06T15:40:56+00:00
Refactor mkRuntimeError

This patch fixes #22634.  Because we don't have TYPE/CONSTRAINT
polymorphism, we need two error functions rather than one.

I took the opportunity to rname runtimeError to impossibleError,
to line up with mkImpossibleExpr, and avoid confusion with the
genuine runtime-error-constructing functions.

(cherry picked from commit 02ed7d783244bd95ee897825650426de6f5fb3e2)

- - - - -
d5985060 by Matthew Pickering at 2023-01-06T15:41:20+00:00
hadrian bindist: Install manpages to share/man/man1/ghc.1

When the installation makefile was copied over the manpages were no
longer installed in the correct place. Now we install it into share/man/man1/ghc.1
as the make build system did.

Fixes #22371

(cherry picked from commit 32b32d7fbc5544ad6c435a1ea26e6353ec567a9b)

- - - - -
80601b0e by Matthew Pickering at 2023-01-07T11:37:19+00:00
Disable split sections on aarch64-deb10 build

See #22722

Failure on this job:

https://gitlab.haskell.org/ghc/ghc/-/jobs/1287852

```
Unexpected failures:
   /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test   spaces/testsuite/tests/th/T10828.run  T10828 [exit code non-0] (ext-interp)
   /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test   spaces/testsuite/tests/th/T13123.run  T13123 [exit code non-0] (ext-interp)
   /builds/ghc/ghc/tmp/ghctest-s3d8g1hj/test   spaces/testsuite/tests/th/T20590.run  T20590 [exit code non-0] (ext-interp)
Appending 232 stats to file: /builds/ghc/ghc/performance-metrics.tsv
```

```
Compile failed (exit code 1) errors were:
data family D_0 a_1 :: * -> *
data instance D_0 GHC.Types.Int GHC.Types.Bool :: * where
    DInt_2 :: D_0 GHC.Types.Int GHC.Types.Bool
data E_3 where MkE_4 :: a_5 -> E_3
data Foo_6 a_7 b_8 where
    MkFoo_9, MkFoo'_10 :: a_11 -> Foo_6 a_11 b_12
newtype Bar_13 :: * -> GHC.Types.Bool -> * where
    MkBar_14 :: a_15 -> Bar_13 a_15 b_16
data T10828.T (a_0 :: *) where
    T10828.MkT :: forall (a_1 :: *) . a_1 -> a_1 -> T10828.T a_1
    T10828.MkC :: forall (a_2 :: *) (b_3 :: *) . (GHC.Types.~) a_2
                                                               GHC.Types.Int => {T10828.foo :: a_2,
                                                                                 T10828.bar :: b_3} -> T10828.T GHC.Types.Int
T10828.hs:1:1: error: [GHC-87897]
    Exception when trying to run compile-time code:
      ghc-iserv terminated (-4)
    Code: (do TyConI dec <- runQ $ reify (mkName "T")
              runIO $ putStrLn (pprint dec) >> hFlush stdout
              d <- runQ
                     $ [d| data T' a :: Type
                             where
                               MkT' :: a -> a -> T' a
                               MkC' :: forall a b. (a ~ Int) => {foo :: a, bar :: b} -> T' Int |]
              runIO $ putStrLn (pprint d) >> hFlush stdout
              ....)
*** unexpected failure for T10828(ext-interp)
=====> 7000 of 9215 [0, 1, 0]
=====> 7000 of 9215 [0, 1, 0]
=====> 7000 of 9215 [0, 1, 0]
=====> 7000 of 9215 [0, 1, 0]
Compile failed (exit code 1) errors were:
T13123.hs:1:1: error: [GHC-87897]
    Exception when trying to run compile-time code:
      ghc-iserv terminated (-4)
    Code: ([d| data GADT
                 where MkGADT :: forall k proxy (a :: k). proxy a -> GADT |])
*** unexpected failure for T13123(ext-interp)
=====> 7100 of 9215 [0, 2, 0]
=====> 7100 of 9215 [0, 2, 0]
=====> 7200 of 9215 [0, 2, 0]
Compile failed (exit code 1) errors were:
T20590.hs:1:1: error: [GHC-87897]
    Exception when trying to run compile-time code:
      ghc-iserv terminated (-4)
    Code: ([d| data T where MkT :: forall a. a -> T |])
*** unexpected failure for T20590(ext-interp)
```

Looks fairly worrying to me.

- - - - -
0e8aa04f by Matthew Pickering at 2023-01-07T17:31:37+00:00
T10955: Set DYLD_LIBRARY_PATH for darwin

The correct path to direct the dynamic linker on darwin is
DYLD_LIBRARY_PATH rather than LD_LIBRARY_PATH. On recent versions of OSX
using LD_LIBRARY_PATH seems to have stopped working.

For more reading see:

https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s
(cherry picked from commit a960ca817d6ad0109ea6edda50da3902cc538e86)

- - - - -
95e68d38 by Matthew Pickering at 2023-01-07T17:31:37+00:00
Skip T18623 on darwin (to add to the long list of OSs)

On recent versions of OSX, running `ulimit -v` results in

```
ulimit: setrlimit failed: invalid argument
```

Time is too short to work out what random stuff Apple has been doing
with ulimit, so just skip the test like we do for other platforms.

(cherry picked from commit 734847108420cf826a807c30ad54651659cf3a08)

- - - - -
a587499c by Matthew Pickering at 2023-01-07T17:31:37+00:00
Pass -Wl,-no_fixup_chains to ld64 when appropiate

Recent versions of MacOS use a version of ld where `-fixup_chains` is on by default.
This is incompatible with our usage of `-undefined dynamic_lookup`. Therefore we
explicitly disable `fixup-chains` by passing `-no_fixup_chains` to the linker on
darwin. This results in a warning of the form:

ld: warning: -undefined dynamic_lookup may not work with chained fixups

The manual explains the incompatible nature of these two flags:

     -undefined treatment
             Specifies how undefined symbols are to be treated. Options are: error, warning,
             suppress, or dynamic_lookup.  The default is error. Note: dynamic_lookup that
             depends on lazy binding will not work with chained fixups.

A relevant ticket is #22429

Here are also a few other links which are relevant to the issue:

Official comment: https://developer.apple.com/forums/thread/719961

More relevant links:

https://openradar.appspot.com/radar?id=5536824084660224

https://github.com/python/cpython/issues/97524

Note in release notes: https://developer.apple.com/documentation/xcode-release-notes/xcode-13-releas    e-notes

(cherry picked from commit 8c0ea25fb4a27d4729aabf73f4c00b912bb0c58d)

- - - - -
548380ea by Matthew Pickering at 2023-01-09T12:03:07+00:00
Revert "NCG(x86): Compile add+shift as lea if possible."

This reverts commit 20457d775885d6c3df020d204da9a7acfb3c2e5a.

See #22666 and #21777

- - - - -
48a9e688 by Matthew Pickering at 2023-01-10T08:07:45+00:00
Store bootstrap_llvm_target and use it to set LlvmTarget in bindists

This mirrors some existing logic for the bootstrap_target which
influences how TargetPlatform is set.

As described on #21970 not storing this led to `LlvmTarget` being set incorrectly
and hence the wrong `--target` flag being passed to the C compiler.

Towards #21970

(cherry picked from commit 64286132cc0db4e227637887f98f5a3ecf7d326a)

- - - - -
2a7c7fa7 by Matthew Pickering at 2023-01-10T08:07:45+00:00
Check for FP_LD_NO_FIXUP_CHAINS in installation configure script

Otherwise, when installing from a bindist the C flag isn't passed to the
C compiler.

This completes the fix for #22429

(cherry picked from commit 4724e8d1a66fa0a821d322d9d2d90db7d7604916)

- - - - -
6db7d9da by Sebastian Graf at 2023-01-10T08:07:59+00:00
Handle shadowing in DmdAnal (#22718)

Previously, when we had a shadowing situation like
```hs
f x = ... -- demand signature <1L><1L>

main = ... \f -> f 1 ...
```
we'd happily use the shadowed demand signature at the call site inside the
lambda. Of course, that's wrong and solution is simply to remove the demand
signature from the `AnalEnv` when we enter the lambda.
This patch does so for all binding constructs Core.

In #22718 the issue was caused by LetUp not shadowing away the existing demand
signature for the let binder in the let body. The resulting absent error is
fickle to reproduce; hence no reproduction test case. #17478 would help.

Fixes #22718.

It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that
DmdAnal was exploiting ill-scoped analysis results.

Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate):
    TcPlugin_Rewrite

(cherry picked from commit e3fff7512bbf989386faaa1dccafdad1deabde84)

- - - - -
da3f7b74 by Matthew Pickering at 2023-01-10T16:08:50+00:00
ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3

Fixes #22599

(cherry picked from commit c306d939d2e1b08cbe683bb9829a4b4010948010)

- - - - -
079b443b by Matthew Pickering at 2023-01-10T16:47:59+00:00
darwin ci: Explicitly pass desired build triple to configure

On the zw3rk machines for some reason the build machine was inferred to
be arm64. Setting the build triple appropiately resolve this confusion
and we produce x86 binaries.

(cherry picked from commit 0db496ff1e372b19429fee91a4a569f7021fe1d7)

- - - - -
ed5aaafd by Ben Gamari at 2023-01-10T21:06:13-05:00
configure: Use three-component version number

- - - - -
fd42d718 by Ben Gamari at 2023-01-17T18:36:22-05:00
upload_ghc_libs: More control over which packages to operate on

Here we add a `--skip` flag to `upload_ghc_libs`, making it easier to
limit which packages to upload. This is often necessary when one package
is not uploadable (e.g. see #22740).

- - - - -
67dabd44 by Simon Peyton Jones at 2023-01-17T18:39:18-05:00
Fix void-arg-adding mechanism for worker/wrapper

As #22725 shows, in worker/wrapper we must add the void argument
/last/, not first.  See GHC.Core.Opt.WorkWrap.Utils
Note [Worker/wrapper needs to add void arg last].

That led me to to study GHC.Core.Opt.SpecConstr
Note [SpecConstr needs to add void args first] which suggests the
opposite!  And indeed I think it's the other way round for SpecConstr
-- or more precisely the void arg must precede the "extra_bndrs".

That led me to some refactoring of GHC.Core.Opt.SpecConstr.calcSpecInfo.

(cherry picked from commit 964284fcab6e27fe2fa5c279ea008551cbc15dbb)

- - - - -
8a536475 by Simon Peyton Jones at 2023-01-17T18:40:58-05:00
Add a missing checkEscapingKind

Ticket #22743 pointed out that there is a missing check,
for type-inferred bindings, that the inferred type doesn't
have an escaping kind.

The fix is easy.

(cherry picked from commit 496607fdb77baf12e2fe263104ba5d0d700eee3b)

- - - - -
ee450fb1 by Simon Peyton Jones at 2023-01-17T18:41:22-05:00
Make FloatIn robust to shadowing

This MR fixes #22622. See the new
  Note [Shadowing and name capture]

I did a bit of refactoring in sepBindsByDropPoint too.

The bug doesn't manifest in HEAD, but it did show up in 9.4,
so we should backport this patch to 9.4

(cherry picked from commit 6206cb9287f3f6e70c669660a646a65274870d2b)

- - - - -
5107c031 by Viktor Dukhovni at 2023-01-17T18:41:30-05:00
Avoid unnecessary printf warnings in EventLog.c

Fixes #22778

(cherry picked from commit fc02f3bbb5f47f880465e22999ba9794f658d8f6)

- - - - -
d1a59401 by Bodigrim at 2023-01-17T18:41:42-05:00
Bump submodule parsec to 3.1.16.1

(cherry picked from commit 97bd4d8c03fe74a7642f617db12bbee2215e24e6)

- - - - -
75e879b6 by Ben Gamari at 2023-01-17T18:41:51-05:00
gitlab-ci: Bump Darwin bootstrap toolchain

This updates the bootstrap compiler on Darwin from 8.10.7 to 9.2.5,
ensuring that we have the fix for #21964.

(cherry picked from commit df33c13c802cdb846e1377e61bebaebe8955ff15)

- - - - -
a3cdfa96 by Ben Gamari at 2023-01-17T18:41:53-05:00
gitlab-ci: Pass -w to cabal update

Due to cabal#8447, cabal-install 3.8.1.0 requires a compiler to run
`cabal update`.

(cherry picked from commit 756a66ec0875b675bd3256d46d57419827312426)

- - - - -
cd3339e1 by Bodigrim at 2023-01-17T18:42:01-05:00
Bump submodule bytestring to 0.11.4.0

Metric Decrease:
    T21839c
    T21839r

(cherry picked from commit 9a3d6add05d9227fb047cf6ce7ae35dc11c51718)

- - - - -
82a4c5ad by Andreas Klebinger at 2023-01-17T18:42:19-05:00
Only gc sparks locally when we can ensure marking is done.

When performing GC without work stealing there was no guarantee that
spark pruning was happening after marking of the sparks. This could
cause us to GC live sparks under certain circumstances.

Fixes #22528.

(cherry picked from commit a1491c8791c57a64d94bc08d639d585815c8d4e2)

- - - - -
dd1df967 by Ben Gamari at 2023-01-17T18:43:39-05:00
configure: Fix escaping of `$tooldir`

In !9547 I introduced `$tooldir` directories into GHC's default link and
compilation flags to ensure that our C toolchain finds its own headers
and libraries before others on the system. However, the patch was subtly
wrong in the escaping of `$tooldir`. Fix this.

Fixes #22561.

(cherry picked from commit 9ffd5d57a7cc19bcd6ea0139b00c77639566ba82)

- - - - -
1b9fec7a by Ben Gamari at 2023-01-17T18:43:49-05:00
Revert "rts: Drop racy assertion"

The logic here was inverted. Reverting the commit to avoid confusion
when examining the commit history.

This reverts commit b3eacd64fb36724ed6c5d2d24a81211a161abef1.

(cherry picked from commit db11f3586085901e89705f69aff472e027c0748f)

- - - - -
76738aeb by Ben Gamari at 2023-01-17T18:43:49-05:00
rts: Drop racy assertion

0e274c39bf836d5bb846f5fa08649c75f85326ac added an assertion in
`dirty_MUT_VAR` checking that the MUT_VAR being dirtied was clean.
However, this isn't necessarily the case since another thread may have
raced us to dirty the object.

(cherry picked from commit 3242139fbd18df324460e22619c1a1fb3b258a07)

- - - - -
a886fcc8 by Sebastian Graf at 2023-01-18T12:30:25-05:00
Handle shadowing in DmdAnal (#22718)

Previously, when we had a shadowing situation like
```hs
f x = ... -- demand signature <1L><1L>

main = ... \f -> f 1 ...
```
we'd happily use the shadowed demand signature at the call site inside the
lambda. Of course, that's wrong and solution is simply to remove the demand
signature from the `AnalEnv` when we enter the lambda.
This patch does so for all binding constructs Core.

In #22718 the issue was caused by LetUp not shadowing away the existing demand
signature for the let binder in the let body. The resulting absent error is
fickle to reproduce; hence no reproduction test case. #17478 would help.

Fixes #22718.

It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that
DmdAnal was exploiting ill-scoped analysis results.

Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate):
    TcPlugin_Rewrite

(cherry picked from commit e3fff7512bbf989386faaa1dccafdad1deabde84)

- - - - -
991b9ca5 by Ben Gamari at 2023-01-18T12:31:21-05:00
Accept performance metric changes

Metric Decrease:
    MultiLayerModulesTH_OneShot
    T21839c
    T21839r

- - - - -
db682cb1 by Cheng Shao at 2023-01-25T11:22:52+00:00
Bump hsc2hs submodule

(cherry picked from commit 1142f858d761afc4d09923d52a2aaacf1a8c8679)

- - - - -
bf9d21cf by Cheng Shao at 2023-01-25T11:23:07+00:00
Bump process submodule

(cherry picked from commit d46867297de5f7f26963ed819949a876737d462f)

- - - - -
1768ca30 by Cheng Shao at 2023-01-25T11:25:19+00:00
ci: Bump DOCKER_REV

(cherry picked from commit 84ae657307380d50786206ce0f2b95498a06ed27)

- - - - -
a684181f by Cheng Shao at 2023-01-25T11:25:33+00:00
ci: enable xz parallel compression for x64 jobs

(cherry picked from commit d53598c5b71521d6706fc0f4b5713110195d5578)

- - - - -
75b01e54 by Cheng Shao at 2023-01-25T11:25:41+00:00
ci: use in-image emsdk for js jobs

(cherry picked from commit d31fcbca6cf4bc166904cfd25696503401ad631d)

- - - - -
a38079b5 by Cheng Shao at 2023-01-25T11:25:49+00:00
ci: improve nix-shell for gen_ci.hs and fix some ghc/hlint warnings

- Add a ghc environment including prebuilt dependencies to the
  nix-shell. Get rid of the ad hoc cabal cache and all dependencies
  are now downloaded from the nixos binary cache.
- Make gen_ci.hs a cabal package with HLS integration, to make future
  hacking of gen_ci.hs easier.
- Fix some ghc/hlint warnings after I got HLS to work.
- For the lint-ci-config job, do a shallow clone to save a few minutes
  of unnecessary git checkout time.

(cherry picked from commit 93b9bbc177ca848bc80dc23aea3571c42d640192)

- - - - -
8a79d2a3 by Cheng Shao at 2023-01-25T11:25:59+00:00
ci: source the toolchain env file in wasm jobs

(cherry picked from commit 8acc56c79d21d33fceed9d094fbb1702c3f7cb01)

- - - - -
02fe30d2 by Cheng Shao at 2023-01-25T11:28:40+00:00
ci: add wasm ci jobs via gen_ci.hs

- There is one regular wasm job run in validate pipelines
- Additionally, int-native/unreg wasm jobs run in nightly/release pipelines

Also, remove the legacy handwritten wasm ci jobs in .gitlab-ci.yml.

(cherry picked from commit 87194df0984a85acb3726ed5c69cfae89af56b85)

- - - - -
99d1829e by Matthew Pickering at 2023-01-25T11:46:08+00:00
wasm ci: Remove wasm release jobs

This removes the wasm release jobs, as we do not yet intend to
distribute these binaries.

(cherry picked from commit b6eb9bccd56a11b5e8c208bb5490309317fd5275)

- - - - -
c7cd0f11 by Cheng Shao at 2023-01-25T11:46:08+00:00
Fix typo in recent darwin tests fix

Corrects a typo in !9647. Otherwise T18623 will still fail on darwin
and stall other people's work.

(cherry picked from commit c45a5fffef2c76efbf5d3a009c3f6d0244a63f0d)

- - - - -
19ed3dc9 by Cheng Shao at 2023-01-25T11:46:08+00:00
hadrian: add hi_core flavour transformer

The hi_core flavour transformer enables -fwrite-if-simplified-core for
stage1 libraries, which emit core into interface files to make it
possible to restart code generation. Building boot libs with it makes
it easier to use GHC API to prototype experimental backends that needs
core/stg at link time.

(cherry picked from commit 1fe806d33b7ef5615bec47bacc76a9e84963dd54)

- - - - -
cfb33584 by Cheng Shao at 2023-01-25T11:46:08+00:00
hadrian: add missing docs for recently added flavour transformers

(cherry picked from commit 317cad26585f0e91c8e3bd41ddbc3444b642b16b)

- - - - -
52966198 by Cheng Shao at 2023-01-25T11:46:08+00:00
hadrian: disable alloca for in-tree GMP on wasm32

When building in-tree GMP for wasm32, disable its alloca usage, since
it may potentially cause stack overflow (e.g. #22602).

(cherry picked from commit 0900b58432c0e42263c62b0e151b0268129a290a)

- - - - -
b8f2090a by Cheng Shao at 2023-01-25T11:46:08+00:00
Bump process submodule

Includes a critical fix for wasm32, see
https://github.com/haskell/process/pull/272 for details. Also changes
the existing cross test to include process stuff and avoid future
regression here.

(cherry picked from commit db0f1bfd0cada59d8a8673e98fc40e8b9c11a9c5)

- - - - -
9194c9c0 by Cheng Shao at 2023-01-25T11:46:08+00:00
CmmToC: fix CmmRegOff for 64-bit register on a 32-bit target

We used to print the offset value to a platform word sized integer.
This is incorrect when the offset is negative (e.g. output of cmm
constant folding) and the register is 64-bit but on a 32-bit target,
and may lead to incorrect runtime result (e.g. #22607).

The fix is simple: just treat it as a proper MO_Add, with the correct
width info inferred from the register itself.

Metric Increase:
    T12707
    T13379
    T4801
    T5321FD
    T5321Fun

(cherry picked from commit d151546e59a50158f25c3df6728b00d3c27bb4b9)

- - - - -
b9bbcff4 by Cheng Shao at 2023-01-25T11:46:08+00:00
compiler: fix handling of MO_F_Neg in wasm NCG

In the wasm NCG, we used to compile MO_F_Neg to 0.0-x. It was an
oversight, there actually exists f32.neg/f64.neg opcodes in the wasm
spec and those should be used instead! The old behavior almost works,
expect when GHC compiles the -0.0 literal, which will incorrectly
become 0.0.

(cherry picked from commit bc038c3bd45ee99db9fba23a823a906735740200)

- - - - -
2d921746 by Ben Gamari at 2023-01-25T23:01:09-05:00
Bump Cabal submodule to current state of 3.10 branch

- - - - -
2f6ae973 by Ben Gamari at 2023-01-25T23:01:09-05:00
Bump ghc-tarballs to fix #22497

It turns out that gmp 6.2.1 uses the platform-reserved `x18` register on
AArch64/Darwin. This was fixed in upstream changeset 18164:5f32dbc41afc,
which was merged in 2020. Here I backport this patch although I do hope
that a new release is forthcoming soon.

Bumps gmp-tarballs submodule.

Fixes #22497.

(cherry picked from commit b1089ee68b53ba737a301a2e8e21e27b79143f03)

- - - - -
63a110e4 by Ben Gamari at 2023-01-25T23:01:09-05:00
Bump gmp-tarballs submodule

This backports the upstream fix for CVE-2021-43618, fixing #22789.

(cherry picked from commit b13c6ea5d4b64841164f8cc58d6c6f3de390f2ed)

- - - - -
953badc4 by Matthew Pickering at 2023-01-25T23:01:09-05:00
docs: Update INSTALL.md

Removes references to make.

Fixes #22480

(cherry picked from commit 3097282777a28770f0d597355e33b45d2f11e1d4)

- - - - -
13af98b3 by Ryan Scott at 2023-01-25T23:01:09-05:00
Restore Compose's Read/Show behavior to match Read1/Show1 instances

Fixes #22816.

(cherry picked from commit 1957eda1b25735b143899add93a4cd4f0af3b2ea)

- - - - -
8151ec16 by Matthew Pickering at 2023-01-25T23:01:09-05:00
Fix recompilation checking for multiple home units

The key part of this change is to store a UnitId in the
`UsageHomeModule` and `UsageHomeModuleInterface`.

* Fine-grained dependency tracking is used if the dependency comes from
  any home unit.
* We actually look up the right module when checking whether we need to
  recompile in the `UsageHomeModuleInterface` case.

These scenarios are both checked by the new tests (
multipleHomeUnits_recomp and multipleHomeUnits_recomp_th )

Fixes #22675

(cherry picked from commit c316a99e110c0ecea2d371e6cfe38ea1e51ccb49)

- - - - -
33003591 by Matthew Pickering at 2023-01-25T23:01:09-05:00
Augment target filepath by working directory when checking if module satisfies target

This fixes a spurious warning in -Wmissing-home-modules.

This is a simple oversight where when looking for the target in the
first place we augment the search by the -working-directory flag but
then fail to do so when checking this warning.

Fixes #22676

(cherry picked from commit 8a47f4e0c1b8e91edef635e6ba05f65df62a416f)

- - - - -
5427e388 by Matthew Pickering at 2023-01-25T23:01:09-05:00
Use NodeKey rather than ModuleName in pruneCache

The `pruneCache` function assumes that the list of `CachedInfo` all have unique `ModuleName`, this is not true:

* In normal compilation, the same module name can appear for a file and it's boot file.
* In multiple home unit compilation the same ModuleName can appear in different units

The fix is to use a `NodeKey` as the actual key for the interfaces which includes `ModuleName`, `IsBoot` and `UnitId`.

Fixes #22677

(cherry picked from commit 982e8bbec3e892f6379662017cd97fcd70d98b37)

- - - - -
6e371507 by Matthew Pickering at 2023-01-25T23:01:09-05:00
Recompilation checking: Don't try to find artefacts for Interactive & hs-boot combo

In interactive mode we don't produce any linkables for hs-boot files. So
we also need to not going looking for them when we check to see if we
have all the right objects needed for recompilation.

Ticket #22669

(cherry picked from commit 95cc0bed637e3cd136d9fe135514037cd0638481)

- - - - -
b98464a7 by Matthew Pickering at 2023-01-25T23:01:09-05:00
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

(cherry picked from commit 5609fd913a110b8316125be707e2c30e9dda47cc)

- - - - -
456196df by Matthew Pickering at 2023-01-25T23:01:09-05:00
Improve driver diagnostic messages by including UnitId in message

Currently the driver diagnostics don't give any indication about which unit they correspond to.

For example `-Wmissing-home-modules` can fire multiple times for each different home unit and gives no indication about which unit it's actually reporting about.

Perhaps a longer term fix is to generalise the providence information away from a SrcSpan so that these kind of whole project errors can be reported with an accurate provenance. For now we can just include the `UnitId` in the error message.

Fixes #22678

(cherry picked from commit dccfd125251651681ac03eb42362b0ee5d3da4ce)

- - - - -
cb4f8015 by Matthew Pickering at 2023-01-25T23:01:09-05:00
Key ModSummary cache by UnitId as well as FilePath

Multiple units can refer to the same files without any problem. Just
another assumption which needs to be updated when we may have multiple
home units.

However, there is the invariant that within each unit each file only
maps to one module, so as long as we also key the cache by UnitId then
we are all good.

This led to some confusing behaviour in GHCi when reloading,
multipleHomeUnits_shared distils the essence of what can go wrong.

Fixes #22679

(cherry picked from commit 24cc4ea93215942de1adf83307f7cde9c4856af4)

- - - - -
4b201178 by Matthew Pickering at 2023-01-25T23:01:09-05:00
Finder: Look in current unit before looking in any home package dependencies

In order to preserve existing behaviour it's important to look within the current component before consideirng a module might come from an external component.

This already happened by accident in `downsweep`, (because roots are used to repopulated the cache) but in the `Finder` the logic was the wrong way around.

Fixes #22680

-------------------------
Metric Decrease:
    MultiComponentModules
    MultiComponentModulesRecomp
-------------------------p

(cherry picked from commit e46e68fee52b46beaf9172f8397a35bad63a417a)

- - - - -
6fff446a by Matthew Pickering at 2023-01-25T23:01:10-05:00
Debug: Print full NodeKey when pretty printing ModuleGraphNode

This is helpful when debugging multiple component issues.

(cherry picked from commit a86ff179462b7fc07c3903255856ed05ef149806)

- - - - -
5a3ac440 by Ben Gamari at 2023-01-25T23:01:10-05:00
template-haskell: Bump version to 2.20.0.0

Updates `text` and `exceptions` submodules for bounds bumps.

Addresses #22767.

(cherry picked from commit 3efd1e9934d9896e6c816e6cafb41b6872e3015b)

- - - - -
b1e2cfce by Ben Gamari at 2023-01-25T23:01:58-05:00
gitlab-ci: Add Rocky8 jobs

Addresses #22268.

(cherry picked from commit 658f4446964c01e804ed5cff59fa3ceac3f9619d)

- - - - -
d3f0ddaf by Bodigrim at 2023-01-25T23:01:59-05:00
ghc package does not have to depend on terminfo

(cherry picked from commit 32ab07bf3d6ce45e8ea5b55e8095174a6b42a7f0)

- - - - -
27d21115 by Bodigrim at 2023-01-25T23:02:01-05:00
ghc-pkg does not have to depend on terminfo

(cherry picked from commit 981ff7c4d0e0dd1f4cf721ceb3e99128e442f9fc)

- - - - -
7679d3ef by Luite Stegeman at 2023-01-25T23:02:01-05:00
Add support for sized literals in the bytecode interpreter.

The bytecode interpreter only has branching instructions for
word-sized values. These are used for pattern matching.
Branching instructions for other types (e.g. Int16# or Word8#)
weren't needed, since unoptimized Core or STG never requires
branching on types like this.

It's now possible for optimized STG to reach the bytecode
generator (e.g. fat interface files or certain compiler flag
combinations), which requires dealing with various sized
literals in branches.

This patch improves support for generating bytecode from
optimized STG by adding the following new bytecode
instructions:

    TESTLT_I64
    TESTEQ_I64
    TESTLT_I32
    TESTEQ_I32
    TESTLT_I16
    TESTEQ_I16
    TESTLT_I8
    TESTEQ_I8
    TESTLT_W64
    TESTEQ_W64
    TESTLT_W32
    TESTEQ_W32
    TESTLT_W16
    TESTEQ_W16
    TESTLT_W8
    TESTEQ_W8

Fixes #21945

(cherry picked from commit 28f8c0ebbfe623784988745af75dcf3fdbdd3ca5)

- - - - -
45426a6d by Luite Stegeman at 2023-01-25T23:02:02-05:00
Add PrimCallConv support to GHCi

This adds support for calling Cmm code from bytecode using the native
calling convention, allowing modules that use `foreign import prim`
to be loaded and debugged in GHCi.

This patch introduces a new `PRIMCALL` bytecode instruction and
a helper stack frame `stg_primcall`. The code is based on the
existing functionality for dealing with unboxed tuples in bytecode,
which has been generalised to handle arbitrary calls.

Fixes #22051

(cherry picked from commit b4c14c4ba17b3abf3e7b88e1201ac7ba89fd56c9)

- - - - -
78f701e5 by Ryan Scott at 2023-01-25T23:02:02-05:00
Add missing parenthesizeHsType in cvtSigTypeKind

We need to ensure that the output of `cvtSigTypeKind` is parenthesized (at
precedence `sigPrec`) so that any type signatures with an outermost, explicit
kind signature can parse correctly.

Fixes #22784.

(cherry picked from commit 4efee43db5090aac4dde1293357bdb548ae71c24)

- - - - -
ba512fa1 by Oleg Grenrus at 2023-01-25T23:02:03-05:00
Fix #22728: Not all diagnostics in safe check are fatal

Also add tests for the issue and -Winferred-safe-imports in general

(cherry picked from commit 1b812b6973a25cb1962e2fc543d2c4ed3cf31f3c)

- - - - -
f326c9db by Matthew Pickering at 2023-01-25T23:02:06-05:00
Only store Name in FunRhs rather than Id with knot-tied fields

All the issues here have been caused by #18758.
The goal of the ticket is to be able to talk about things like
`LTyClDecl GhcTc`. In the case of HsMatchContext,
the correct "context" is whatever we want, and in fact storing just a
`Name` is sufficient and correct context, even if the rest of the AST is
storing typechecker Ids.

So this reverts (#20415, !5579) which intended to get closed to #18758 but
didn't really and introduced a few subtle bugs.

Printing of an error message in #22695 would just hang, because we would
attempt to print the `Id` in debug mode to assertain whether it was
empty or not. Printing the Name is fine for the error message.

Another consequence is that when `-dppr-debug` was enabled the compiler would
hang because the debug printing of the Id would try and print fields
which were not populated yet.

This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add
a workaround for the `checkArgs` function which was probably a very
similar bug to #22695.

Fixes #22695

(cherry picked from commit ac39e8e97fbb69e4a786c1c29d6e477e7944f998)

- - - - -
977cfacf by Richard Eisenberg at 2023-01-25T23:02:08-05:00
Refactor the treatment of loopy superclass dicts

This patch completely re-engineers how we deal with loopy superclass
dictionaries in instance declarations. It fixes #20666 and #19690

The highlights are

* Recognise that the loopy-superclass business should use precisely
  the Paterson conditions.  This is much much nicer.  See
  Note [Recursive superclasses] in GHC.Tc.TyCl.Instance

* With that in mind, define "Paterson-smaller" in
  Note [Paterson conditions] in GHC.Tc.Validity, and the new
  data type `PatersonSize` in GHC.Tc.Utils.TcType, along with
  functions to compute and compare PatsonSizes

* Use the new PatersonSize stuff when solving superclass constraints
  See Note [Solving superclass constraints] in GHC.Tc.TyCl.Instance

* In GHC.Tc.Solver.Monad.lookupInInerts, add a missing call to
  prohibitedSuperClassSolve.  This was the original cause of #20666.

* Treat (TypeError "stuff") as having PatersonSize zero. See
  Note [Paterson size for type family applications] in GHC.Tc.Utils.TcType.

* Treat the head of a Wanted quantified constraint in the same way
  as the superclass of an instance decl; this is what fixes #19690.
  See GHC.Tc.Solver.Canonical Note [Solving a Wanted forall-constraint]
  (Thanks to Matthew Craven for this insight.)

  This entailed refactoring the GivenSc constructor of CtOrigin a bit,
  to say whether it comes from an instance decl or quantified constraint.

* Some refactoring way in which redundant constraints are reported; we
  don't want to complain about the extra, apparently-redundant
  constraints that we must add to an instance decl because of the
  loopy-superclass thing.  I moved some work from GHC.Tc.Errors to
  GHC.Tc.Solver.

* Add a new section to the user manual to describe the loopy
  superclass issue and what rules it follows.

(cherry picked from commit aed1974e92366ab8e117734f308505684f70cddf)

- - - - -
78aef3d9 by Matthew Pickering at 2023-01-26T15:40:13-05:00
ci: Change owner of files in source-tarball job

This fixes errors of the form:

```
fatal: detected dubious ownership in repository at '/builds/ghc/ghc'
To add an exception for this directory, call:
	git config --global --add safe.directory /builds/ghc/ghc
inferred 9.7.20230113
checking for GHC Git commit id... fatal: detected dubious ownership in repository at '/builds/ghc/ghc'
To add an exception for this directory, call:
	git config --global --add safe.directory /builds/ghc/ghc
```

(cherry picked from commit 4285ce8a8eaafcef6283719d3bdfb7045382e679)

- - - - -
51343814 by Matthew Pickering at 2023-01-27T08:15:12+00:00
ci: Change owner of files in test-bootstrap job

(cherry picked from commit 00981dc9d5f81f355c3a6276a75c93b87a0a1e6a)

- - - - -
9a91e662 by Matthew Pickering at 2023-01-27T08:15:12+00:00
rel_eng: Add release engineering scripts into ghc tree

It is better to keep these scripts in the tree as they depend on the CI
configuration and so on. By keeping them in tree we can keep them
up-to-date as the CI config changes and also makes it easier to backport
changes to the release script between release branches in future.

The final motivation is that it makes generating GHCUp metadata
possible.

(cherry picked from commit c41aeb303b4e0edbe6acc6476a518958f2656b74)

- - - - -
b8392e1f by Matthew Pickering at 2023-01-27T08:15:12+00:00
ci: Don't use complicated image or clone in not-interruptible job

This job exists only for the meta-reason of not allowing nightly
pipelines to be cancelled. It was taking two minutes to run as in order
to run "true" we would also clone the whole GHC repo.

(cherry picked from commit e9cfc723f3225c56a0acd5eb4288be321fd58070)

- - - - -
78a84385 by Matthew Pickering at 2023-01-27T08:16:54+00:00
Add scripts to generate ghcup metadata on nightly and release pipelines

1. A python script in .gitlab/rel_eng/mk-ghcup-metadata which generates
   suitable metadata for consumption by GHCUp for the relevant
   pipelines.

  - The script generates the metadata just as the ghcup maintainers
    want, without taking into account platform/library combinations. It
    is updated manually when the mapping changes.

  - The script downloads the bindists which ghcup wants to distribute,
    calculates the hash and generates the yaml in the correct structure.

  - The script is documented in the .gitlab/rel_eng/mk-ghcup-metadata/README.mk file

1a. The script requires us to understand the mapping from platform ->
    job. To choose the preferred bindist for each platform the
    .gitlab/gen_ci.hs script is modified to allow outputting a metadata
    file which answers the question about which job produces the
    bindist which we want to distribute to users for a specific
    platform.

2. Pipelines to run on nightly and release jobs to generate metadata

  - ghcup-metadata-nightly: Generates metadata which points directly to
    artifacts in the nightly job.

  - ghcup-metadata-release: Generates metadata suitable for inclusion
    directly in ghcup by pointing to the downloads folder where the
    bindist will be uploaded to.

2a. Trigger jobs which test the generated metadata in the downstream
    `ghccup-ci` repo. See that repo for documentation about what is
    tested and how but essentially we test in a variety of clean images
    that ghcup can download and install the bindists we say exist in our
    metadata.

(cherry picked from commit ef4ffd9d696ff239c16894d4a958e052da7b009e)

- - - - -
f8828f2c by Matthew Pickering at 2023-01-27T08:16:55+00:00
ci: Add ubuntu18_04 nightly and release jobs

This adds release jobs for ubuntu18_04 which uses glibc 2.27 which is
older than the 2.28 which is used by Rocky8 bindists.

Ticket #22268

(cherry picked from commit 0a022207a3204c8952a2564ed88c83f748e8cac1)

- - - - -
d6cdf22c by Matthew Pickering at 2023-01-27T08:16:55+00:00
rel-eng: Add missing rocky8 bindist

We intend to release rocky8 bindist so the fetching script needs to know
about them.

(cherry picked from commit 2e3dbafa57013b250c92b031ce50962d4f5e13a3)

- - - - -
b19c8231 by Matthew Pickering at 2023-01-27T08:16:55+00:00
Store dehydrated data structures in CgModBreaks

This fixes a tricky leak in GHCi where we were retaining old copies of
HscEnvs when reloading. If not all modules were recompiled then these
hydrated fields in break points would retain a reference to the old
HscEnv which could double memory usage.

Fixes #22530

(cherry picked from commit 1262d3f8c03799a04d3c5fcf33d4d4db715ca9a1)

- - - - -
e69e7e00 by Matthew Pickering at 2023-01-27T08:16:55+00:00
Force more in NFData Name instance

Doesn't force the lazy `OccName` field (#19619) which is already known
as a really bad source of leaks.

When we slam the hammer storing Names on disk (in interface files or the
like), all this should be forced as otherwise a `Name` can easily retain
an `Id` and hence the entire world.

Fixes #22833

(cherry picked from commit e27eb80cc7e0c82e07fbd8d9ae8112d9070c4355)

- - - - -
c38610e4 by Matthew Pickering at 2023-01-27T08:16:55+00:00
Force OccName in tidyTopName

This occname has just been derived from an `Id`, so need to force it
promptly so we can release the Id back to the world.

Another symptom of the bug caused by #19619

(cherry picked from commit 3d004d5a961fbbbe11da1050b725468a970bee4b)

- - - - -
2817ae28 by Matthew Pickering at 2023-01-27T08:16:55+00:00
Strict fields in ModNodeKey (otherwise retains HomeModInfo)

Towards #22530

(cherry picked from commit f2a0fea09a88693d876fb891ea7c8c97373c4aa6)

- - - - -
d8d1d1c7 by Alexis King at 2023-01-27T08:16:55+00:00
Handle top-level Addr# literals in the bytecode compiler

Fixes #22376.

(cherry picked from commit 476d98d4fcccb54a37ec2d9c0fed79696237c166)

- - - - -
f1211618 by Simon Peyton Jones at 2023-01-27T08:16:55+00:00
Fix in-scope set in specImports

Nothing deep here; I had failed to bring some
floated dictionary binders into scope.

Exposed by -fspecialise-aggressively

Fixes #22715.

(cherry picked from commit 13a0566b58ecc295883b11f20045b4214d8acd72)

- - - - -
e2342747 by Ben Gamari at 2023-01-27T08:16:55+00:00
base: Make changelog proposal references more consistent

Addresses #22773.

(cherry picked from commit f410d70a5543240015d7404ff529bdcaaec8d675)

- - - - -
ef21780f by Sylvain Henry at 2023-01-27T08:16:55+00:00
Hadrian: correctly detect AR at-file support

Stage0's ar may not support at-files. Take it into account.

Found while cross-compiling from Darwin to Windows.

(cherry picked from commit e987e345c807035e4637ca3eae227ae501e16c42)

- - - - -
7d86db2b by Sylvain Henry at 2023-01-27T08:16:55+00:00
Hadrian: fix Windows cross-compilation

Decision to build either unix or Win32 package must be stage specific
for cross-compilation to be supported.

(cherry picked from commit 48131ee2d8ba7074a4c2763a32c12df105305a75)

- - - - -
e0d9ef66 by Sylvain Henry at 2023-01-27T08:16:55+00:00
Fix RTS build on Windows

This change fixes a cross-compilation issue from ArchLinux to Windows
because these symbols weren't found.

(cherry picked from commit 288fa0179a2f54e4594afe184eac71cc85c46643)

- - - - -
826a3112 by Sylvain Henry at 2023-01-27T08:16:55+00:00
configure: support "windows" as an OS

(cherry picked from commit 2fdf22aebda2307d86872c792633d1856d666c9b)

- - - - -
b6ffad2a by Matthew Pickering at 2023-01-27T08:16:55+00:00
ghcup metadata: Fix subdir for windows bindist

(cherry picked from commit 159426acb90f7db394ec40dfe22d4999a9190e6e)

- - - - -
bee2a616 by Matthew Pickering at 2023-01-27T08:16:55+00:00
ghcup metadata: Remove viPostRemove field from generated metadata

This has been removed from the downstream metadata.

(cherry picked from commit 7915f039a37f6496ec572f33ddb204a5709f7020)

- - - - -
601938b5 by Andrei Borzenkov at 2023-01-27T08:16:55+00:00
Fix printing of promoted MkSolo datacon (#22785)

Problem: In 2463df2f, the Solo data constructor was renamed to MkSolo,
and Solo was turned into a pattern synonym for backwards compatibility.
Since pattern synonyms can not be promoted, the old code that pretty-printed
promoted single-element tuples started producing ill-typed code:
   t :: Proxy ('Solo Int)
This fails with "Pattern synonym ‘Solo’ used as a type"

The solution is to track the distinction between type constructors and data
constructors more carefully when printing single-element tuples.

(cherry picked from commit 14b5982a3aea351e4b01c5804ebd4d4629ba6bab)

- - - - -
3e6ca4d1 by Vladislav Zavialov at 2023-01-27T08:16:55+00:00
Enable -Wstar-is-type by default (#22759)

Following the plan in GHC Proposal #143 "Remove the * kind syntax",
which states:

	In the next release (or 3 years in), enable -fwarn-star-is-type by default.

The "next release" happens to be 9.6.1

I also moved the T21583 test case from should_fail to should_compile,
because the only reason it was failing was -Werror=compat in our test
suite configuration.

(cherry picked from commit e9c0537cfbf7b47c64f592f529e402358b66ca7f)

- - - - -
6d788b11 by Matthew Pickering at 2023-01-27T08:44:42+00:00
ci: Remove FreeBSD job from release pipelines

We no longer attempt to build or distribute this release

- - - - -
9c263aff by Matthew Pickering at 2023-01-27T08:46:57+00:00
rel_eng: Add check to make sure that release jobs are downloaded by fetch-gitlab

This check makes sure that if a job is a prefixed by "release-" then the
script downloads it and understands how to map the job name to the
platform.

- - - - -
0751f56a by Matthew Pickering at 2023-01-27T08:47:41+00:00
rel_eng: Fix the name of the ubuntu-* jobs

These were not uploaded for alpha1

Fixes #22844

- - - - -
e740dd68 by Ben Gamari at 2023-01-27T10:47:19-05:00
upload_ghc_libs: Don't handle `--skip` in `prepare` mode

- - - - -
19a68c78 by Matthew Pickering at 2023-01-28T10:17:37+00:00
gen_ci: Only consider release jobs for job metadata

In particular we do not have a release job for FreeBSD so the generation
of the platform mapping was failing.

- - - - -
f9b50be4 by Andreas Klebinger at 2023-02-01T10:24:41+00:00
ghc-the-library: Retain cafs in both static in dynamic builds.

We use keepCAFsForGHCi.c to force -fkeep-cafs behaviour by using a
__attribute__((constructor)) function.

This broke for static builds where the linker discarded the object file
since it was not reverenced from any exported code. We fix this by
asserting that the flag is enabled using a function in the same module
as the constructor. Which causes the object file to be retained by the
linker, which in turn causes the constructor the be run in static builds.

This changes nothing for dynamic builds using the ghc library. But causes
static to also retain CAFs (as we expect them to).

Fixes #22417.

-------------------------
Metric Decrease:
    T21839r
-------------------------

(cherry picked from commit 08ba87200ff068aa37cac082e61ee7e2d534daf5)

- - - - -
4ed5ea30 by Richard Eisenberg at 2023-02-01T10:43:36+00:00
Do newtype unwrapping in the canonicaliser and rewriter

See Note [Unwrap newtypes first], which has the details.

Close #22519.

(cherry picked from commit 3e827c3f74ef76d90d79ab6c4e71aa954a1a6b90)

- - - - -
31b63c46 by Alan Zimmerman at 2023-02-01T10:48:59+00:00
EPA: exact print HsDocTy

To match ghc-exactprint
https://github.com/alanz/ghc-exactprint/pull/121

(cherry picked from commit 965a273510adfac4f041a31182c2fec82e614e47)

- - - - -
f19eb3ac by Alan Zimmerman at 2023-02-01T10:51:36+00:00
EPA: Add annotation for 'type' in DataDecl

Closes #22765

(cherry picked from commit 97ac8230b0a645aae27b7ee42aa55b0c84735684)

- - - - -
686350e9 by Alan Zimmerman at 2023-02-01T13:18:46+00:00
EPA: Add SourceText to HsOverLabel

To be able to capture string literals with possible escape codes as labels.

Close #22771

(cherry picked from commit fec7c2ea8242773b53b253d9536426f743443944)

- - - - -
9cdab037 by Ben Gamari at 2023-02-01T13:18:46+00:00
rts: Use C11-compliant static assertion syntax

Previously we used `static_assert` which is only available in C23. By
contrast, C11 only provides `_Static_assert`.

Fixes #22777

(cherry picked from commit e480fbc2c6fdcb252847fc537ab7ec50d1dc2dfd)

- - - - -
be39064e by Ben Gamari at 2023-02-01T13:18:46+00:00
Revert "CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043)"

This reverts commit 99aca26b652603bc62953157a48e419f737d352d.

(cherry picked from commit 56c1bd986ac13e3a1fe1149f011480e44f857f5a)

- - - - -
80a6bb73 by nineonine at 2023-02-01T13:18:46+00:00
CApiFFI: add ConstPtr for encoding const-qualified pointer return types

Previously, when using `capi` calling convention in foreign declarations,
code generator failed to handle const-cualified pointer return types.
This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers`
warning.

`Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases -
special treatment was put in place to generate appropritetly qualified C
wrapper that no longer triggers the above mentioned warning.

Fixes #22043.

(cherry picked from commit b3a3534b6f75b34dc4db76e904e071485da6d5cc)

- - - - -
3c21d69d by Ben Gamari at 2023-02-01T13:18:46+00:00
nativeGen/AArch64: Fix debugging output

Previously various panics would rely on a half-written Show
instance, leading to very unhelpful errors. Fix this.

See #22798.

(cherry picked from commit be417a47c7695998dea0adc05489a7b8838a78b6)

- - - - -
ac6c24f7 by Ben Gamari at 2023-02-01T13:18:46+00:00
nativeGen: Teach graph-colouring allocator that x18 is unusable

Previously trivColourable for AArch64 claimed that at 18 registers were
trivially-colourable. This is incorrect as x18 is reserved by the platform on
AArch64/Darwin.

See #22798.

(cherry picked from commit 30989d137b8f3a8fddbfd116e04b48f23c24f86c)

- - - - -
6c212ccc by Ben Gamari at 2023-02-01T13:18:46+00:00
nativeGen/AArch64: Fix graph-colouring allocator

Previously various `Instr` queries used by the graph-colouring allocator
failed to handle a few pseudo-instructions. This manifested in compiler
panicks while compiling `SHA`, which uses `-fregs-graph`.

Fixes #22798.

(cherry picked from commit 7566fd9de38c67360c090f828923d41587af519c)

- - - - -
79241b6d by Ben Gamari at 2023-02-01T13:18:46+00:00
testsuite: Add regression test for #22798

(cherry picked from commit 2cb500a5ee1a31dfe1a2cdd71f175442026eb082)

- - - - -
d9e8c39d by Simon Peyton Jones at 2023-02-01T13:18:46+00:00
Detect family instance orphans correctly

We were treating a type-family instance as a non-orphan if there
was a type constructor on its /right-hand side/ that was local. Boo!
Utterly wrong. With this patch, we correctly check the /left-hand side/
instead!

Fixes #22717

(cherry picked from commit 638277ba7bd2683f539afb0bf469fe75376994e2)

- - - - -
86dc9a79 by Zubin Duggal at 2023-02-01T13:18:46+00:00
bindist configure: Fail if find not found (#22691)

(cherry picked from commit c9967d137cff83c7688e26f87a8b5e196a75ec93)

- - - - -
86d88743 by Oleg Grenrus at 2023-02-01T13:18:47+00:00
Add Foldable1 Solo instance

(cherry picked from commit 082b7d43ee4b8203dc9bca53e5e1f7a45c42eeb8)

- - - - -
2eb49ea6 by Krzysztof Gogolewski at 2023-02-01T13:18:47+00:00
Support "unusable UNPACK pragma" warning with -O0

Fixes #11270

(cherry picked from commit f83374f8649e5d8413e7ed585b0e058690c38563)

- - - - -
632937bb by Ryan Scott at 2023-02-01T13:18:47+00:00
Handle `type data` properly in tyThingParent_maybe

Unlike most other data constructors, data constructors declared with `type data`
are represented in `TyThing`s as `ATyCon` rather than `ADataCon`. The `ATyCon`
case in `tyThingParent_maybe` previously did not consider the possibility of
the underlying `TyCon` being a promoted data constructor, which led to the
oddities observed in #22817. This patch adds a dedicated special case in
`tyThingParent_maybe`'s `ATyCon` case for `type data` data constructors to fix
these oddities.

Fixes #22817.

(cherry picked from commit 20598ef6d9e26e2e0af9ac42a42e7be00d7cc4f3)

- - - - -
2efb886c by Ryan Scott at 2023-02-01T13:18:47+00:00
Fix two bugs in TypeData TH reification

This patch fixes two issues in the way that `type data` declarations were
reified with Template Haskell:

* `type data` data constructors are now properly reified using `DataConI`.
  This is accomplished with a special case in `reifyTyCon`. Fixes #22818.

* `type data` type constructors are now reified in `reifyTyCon` using
  `TypeDataD` instead of `DataD`. Fixes #22819.

(cherry picked from commit 2f1450521b816a7d287b72deba14d59b6ccfbdbf)

- - - - -
fc117e3d by Ben Gamari at 2023-02-01T13:18:47+00:00
configure: Always create the VERSION file

Teach the `configure` script to create the `VERSION` file.
This will serve as the stable interface to allow the user to determine
the version number of a working tree.

Fixes #22322.

(cherry picked from commit a2d814dc84dbdcdb6c1e274b8bd7c212cc98c39e)

- - - - -
6e1498fa by Ben Gamari at 2023-02-01T13:18:47+00:00
hadrian: Sphinx docs require templated cabal files

The package-version discovery logic in
`doc/users_guide/package_versions.py` uses packages' cabal files to
determine package versions. Teach Sphinx about these dependencies in
cases where the cabal files are generated by templates.

(cherry picked from commit f838815c365773a8107bf035a8ec27b8ff6ecc8b)

- - - - -
1f42664c by Ben Gamari at 2023-02-01T13:18:47+00:00
hadrian: Refactor templating logic

This refactors Hadrian's autoconf-style templating logic to be explicit
about which interpolation variables should be substituted in which
files. This clears the way to fix #22714 without incurring rule cycles.

(cherry picked from commit 2e48c19a7faf975318e954faea26f37deb763ac0)

- - - - -
653c7513 by Ben Gamari at 2023-02-01T13:18:47+00:00
hadrian: Substitute LIBRARY_*_VERSION variables

This teaches Hadrian to substitute the `LIBRARY_*_VERSION` variables
in `libraries/prologue.txt`, fixing #22714.

Fixes #22714.

(cherry picked from commit 93f0e3c49cea484bd6e838892ff8702ec51f34c3)

- - - - -
3ac79844 by Simon Peyton Jones at 2023-02-01T13:18:47+00:00
Take account of loop breakers in specLookupRule

The key change is that in GHC.Core.Opt.Specialise.specLookupRule
we were using realIdUnfolding, which ignores the loop-breaker
flag.  When given a loop breaker, rule matching therefore
looped infinitely -- #22802.

In fixing this I refactored a bit.

* Define GHC.Core.InScopeEnv as a data type, and use it.
  (Previously it was a pair: hard to grep for.)

* Put several functions returning an IdUnfoldingFun into
  GHC.Types.Id, namely
     idUnfolding
     alwaysActiveUnfoldingFun,
     whenActiveUnfoldingFun,
     noUnfoldingFun
  and use them.  (The are all loop-breaker aware.)

(cherry picked from commit d0f34f25ceaae9ef0a21f15f811469d0bed9da69)

- - - - -
fb186399 by Bodigrim at 2023-02-01T13:18:47+00:00
Document differences between Data.{Monoid,Semigroup}.{First,Last}

(cherry picked from commit c9ad8852bdd083f8692361134bc247a1eb2bbd77)

- - - - -
fdfd8911 by Cheng Shao at 2023-02-01T13:18:47+00:00
compiler: fix subword literal narrowing logic in the wasm NCG

This patch fixes the W8/W16 literal narrowing logic in the wasm NCG,
which used to lower it to something like i32.const -1, without
properly zeroing-out the unused higher bits. Fixes #22608.

(cherry picked from commit 7e11c6dc25cb9dd14ae33ee9715ddbc8ebf9836e)

- - - - -
adf17604 by Cheng Shao at 2023-02-01T13:18:47+00:00
compiler: fix lowering of CmmBlock in the wasm NCG

The CmmBlock datacon was not handled in lower_CmmLit, since I thought
it would have been eliminated after proc-point splitting. Turns out it
still occurs in very rare occasions, and this patch is needed to fix
T9329 for wasm.

(cherry picked from commit 6ea2aa0293aedea2f873b7b5d9cff5e7b9e2f188)

- - - - -
329097fc by Matthew Pickering at 2023-02-01T13:18:47+00:00
Fixes for cabal-reinstall CI job

* Allow filepath to be reinstalled
* Bump some version bounds to allow newer versions of libraries
* Rework testing logic to avoid "install --lib" and package env files

Fixes #22344

(cherry picked from commit 7cbdaad0396cee561f125c95f3352cebabd8ed99)

- - - - -
5695611e by Cheng Shao at 2023-02-01T13:18:47+00:00
compiler: properly handle ForeignHints in the wasm NCG

Properly handle ForeignHints of ccall arguments/return value, insert
sign extends and truncations when handling signed subwords. Fixes #22852.

(cherry picked from commit 78c07219d5dad9730bbe3ec26ad22912ff22f058)

- - - - -
c4cc32d9 by Cheng Shao at 2023-02-01T13:18:47+00:00
compiler: fix data section alignment in the wasm NCG

Previously we tried to lower the alignment requirement as far as
possible, based on the section kind inferred from the CLabel. For info
tables, .p2align 1 was applied given the GC should only need the
lowest bit to tag forwarding pointers. But this would lead to
unaligned loads/stores, which has a performance penalty even if the
wasm spec permits it. Furthermore, the test suite has shown memory
corruption in a few cases when compacting gc is used.

This patch takes a more conservative approach: all data sections
except C strings align to word size.

(cherry picked from commit da468391872f6be286db37a0f016a37f9f362509)

- - - - -
8f29bdae by Cheng Shao at 2023-02-01T13:18:47+00:00
rts: prevent potential divide-by-zero when tickInterval=0

This patch fixes a few places in RtsFlags.c that may result in
divide-by-zero error when tickInterval=0, which is the default on
wasm. Fixes #22603.

(cherry picked from commit fd8f32bf551c34b95275ebb4fe648680013156f3)

- - - - -
343c856f by Cheng Shao at 2023-02-01T13:18:47+00:00
testsuite: use tgamma for cg007

gamma is a glibc-only deprecated function, use tgamma instead. It's
required for fixing cg007 when testing the wasm unregisterised
codegen.

(cherry picked from commit 7716cbe64862932fd69348b2594a14f2092e1c02)

- - - - -
e377aa49 by Ben Gamari at 2023-02-01T13:18:47+00:00
Bump transformers submodule to 0.6.0.6

Fixes #22862.

(cherry picked from commit 22089f693cf6e662a58a7011adb94d7f768ad2d7)

- - - - -
d91e6233 by Cheng Shao at 2023-02-01T13:18:47+00:00
compiler: properly handle non-word-sized CmmSwitch scrutinees in the wasm NCG

Currently, the wasm NCG has an implicit assumption: all CmmSwitch
scrutinees are 32-bit integers. This is not always true; #22864 is one
counter-example with a 64-bit scrutinee. This patch fixes the logic by
explicitly converting the scrutinee to a word that can be used as a
br_table operand. Fixes #22871. Also includes a regression test.

(cherry picked from commit f0eefa3cf058879246991747dcd18c811402f9e5)

- - - - -
30d3c827 by Ben Gamari at 2023-02-01T13:18:47+00:00
nativeGen/X86: MFENCE is unnecessary for release semantics

In #22764 a user noticed that a program implementing a simple atomic
counter via an STRef regressed significantly due to the introduction of
necessary atomic operations in the MutVar# primops (#22468). This
regression was caused by a bug in the NCG, which emitted an unnecessary
MFENCE instruction for a release-ordered atomic write. MFENCE is rather
only needed to achieve sequentially consistent ordering.

Fixes #22764.

(cherry picked from commit f058e3672b969f301b6b1637f8ab081654ec947a)

- - - - -
cbd60c81 by Matthew Pickering at 2023-02-07T19:27:16-05:00
Disable unfolding sharing for interface files with core definitions

Ticket #22807 pointed out that the RHS sharing was not compatible with
-fignore-interface-pragmas because the flag would remove unfoldings from
identifiers before the `extra-decls` field was populated.

For the 9.6 timescale the only solution is to disable this sharing,
which will make interface files bigger but this is acceptable for the
first release of `-fwrite-if-simplified-core`.

For 9.8 it would be good to fix this by implementing #20056 due to the
large number of other bugs that would fix.

I also improved the error message in tc_iface_binding to avoid the "no match
in record selector" error but it should never happen now as the entire
sharing logic is disabled.

Also added the currently broken test for #22807 which could be fixed by
!6080

Fixes #22807

(cherry picked from commit 0ada454703560b733fe3c920b87496ac1238c29e)

- - - - -
18942043 by Bodigrim at 2023-02-07T19:27:23-05:00
Bump submodule containers to 0.6.7

Metric Decrease:
    ManyConstructors
    T10421
    T12425
    T12707
    T13035
    T13379
    T15164
    T1969
    T783
    T9198
    T9961
    WWRec

(cherry picked from commit 3135819847aae0cdcc6c2fca4a2234fcfed1db93)

- - - - -
86698692 by Andreas Klebinger at 2023-02-07T19:27:30-05:00
Fix CallerCC potentially shadowing other cost centres.

Add a CallerCC cost centre flavour for cost centres added by the
CallerCC pass. This avoids potential accidental shadowing between
CCs added by user annotations and ones added by CallerCC.

(cherry picked from commit bf3f88a1a5b23bdf304baca473c3ee797c5f86bd)

- - - - -
c6c96a3a by Ben Gamari at 2023-02-07T19:27:36-05:00
Revert "Use fix-sized bit-fiddling primops for fixed size boxed types"

This reverts commit 4512ad2d6a8e65ea43c86c816411cb13b822f674.

This was never applied to master/9.6 originally.

(cherry picked from commit a44bdc2720015c03d57f470b759ece7fab29a57a)
(cherry picked from commit 25537dfda4ae59bc0321b229ca9ff924ef64d1fa)

- - - - -
51397a53 by Bodigrim at 2023-02-07T19:27:42-05:00
Fix colors in emacs terminal

(cherry picked from commit 5a54ac0b2b915889950c83e04bf1beb08631891e)

- - - - -
2c7f85fe by Ryan Scott at 2023-02-07T19:27:58-05:00
Windows: Remove mingwex dependency

The clang based toolchain uses ucrt as its math library
and so mingwex is no longer needed.  In fact using mingwex
will cause incompatibilities as the default routines in both
have differing ULPs and string formatting modifiers.

```
$ LIBRARY_PATH=/mingw64/lib ghc/_build/stage1/bin/ghc Bug.hs -fforce-recomp && ./Bug.exe
[1 of 2] Compiling Main             ( Bug.hs, Bug.o )
ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__imp___p__environ'
ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__hscore_get_errno'
ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziError_errnoToIOError_info'
ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziWindows_failIf2_closure'
ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePageziAPI_mkCodePageEncoding_info'
ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePage_currentCodePage_closure'
ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncoding_getForeignEncoding_closure'
ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziString_withCStringLen1_info'
ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziInternals_zdwflushCharReadBuffer_info'
ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziText_hGetBuf1_info'
ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziFingerprint_fingerprintString_closure'
ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_DataziTypeableziInternal_mkTrCon_closure'
ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziException_errorCallWithCallStackException_closure'
ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziErr_error_info'
ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `base_DataziMaybe_fromJust1_info'
ghc.exe:  | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `templatezmhaskell_LanguageziHaskellziTHziSyntax_IntPrimL_con_info'
ghc.exe: ^^ Could not load 'templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure', dependency unresolved. See top entry above.

<no location info>: error:

GHC.ByteCode.Linker.lookupCE
During interactive linking, GHCi couldn't find the following symbol:
  templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session.  Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please report this as a GHC bug:
  https://www.haskell.org/ghc/reportabug
```

(cherry picked from commit de1d15127ac3f41ac3044215b0ea3398a36edc89)

- - - - -
81873448 by Tamar Christina at 2023-02-07T19:27:59-05:00
linker: Fix BFD import libraries

This commit fixes the BFD style import library support in the runtime
linker.  This was accidentally broken during the refactoring to clang
and went unnoticed because clang itself is unable to generate the BFD
style import libraries.

With this change we can not link against both GCC or Clang produced
libraries again and intermix code produced by both compilers.

(cherry picked from commit 48e391952c17ff7eab10b0b1456e3f2a2af28a9b)

- - - - -
18d1c5f9 by Ben Gamari at 2023-02-07T19:29:38-05:00
Bump Windows toolchain

Updates to LLVM 14, hopefully fixing #21964.

(cherry picked from commit b2bb3e62275cc1d9e00a2d5ed511843192133ed5)

- - - - -
2ec1c359 by Luite Stegeman at 2023-02-07T19:29:54-05:00
Fix marking async exceptions in the JS backend

Async exceptions are posted as a pair of the exception and
the thread object. This fixes the marking pass to correctly
follow the two elements of the pair.

Potentially fixes #22836

(cherry picked from commit 77a8234c5d284846e18c0a44ba5ee196059aaea6)

- - - - -
8ab4d956 by sheaf at 2023-02-07T19:30:16-05:00
Don't allow . in overloaded labels

This patch removes . from the list of allowed characters in a non-quoted
overloaded label, as it was realised this steals syntax, e.g. (#.).

Users who want this functionality will have to add quotes around the
label, e.g. `#"17.28"`.

Fixes #22821

(cherry picked from commit b17fb3d96bd2e9f3bf96392f3b3b3e0aed7fe276)

- - - - -
dce53f5c by Ben Gamari at 2023-02-07T19:30:22-05:00
Revert "Use fix-sized equality primops for fixed size boxed types"

This reverts commit 024020c38126f3ce326ff56906d53525bc71690c.

This was never applied to master/9.6 originally.

See #20405 for why using these primops is a bad idea.

(cherry picked from commit b1d109ad542e4c37ae5af6ace71baf2cb509d865)
(cherry picked from commit 929161943f19e1673288adc83d165ddc99865798)

- - - - -
bafa3899 by Sylvain Henry at 2023-02-07T19:37:15-05:00
JS: replace "js" architecture with "javascript"

Despite Cabal supporting any architecture name, `cabal --check` only
supports a few built-in ones. Sadly `cabal --check` is used by Hackage
hence using any non built-in name in a package (e.g. `arch(js)`) is
rejected and the package is prevented from being uploaded on Hackage.

Luckily built-in support for the `javascript` architecture was added for
GHCJS a while ago. In order to allow newer `base` to be uploaded on
Hackage we make the switch from `js` to `javascript` architecture.

Fixes #22740.

Co-authored-by: Ben Gamari <ben at smart-cactus.org>
(cherry picked from commit 6636b670233522f01d002c9b97827d00289dbf5c)

- - - - -
ef79d013 by sheaf at 2023-02-09T12:47:50+00:00
Bump transformers to 0.6.1.0

This allows us to avoid orphans for Foldable1 instances,
fixing #22898.

Updates transformers submodule.

(cherry picked from commit 2ea1a6bc7d7c2946b4a3d1c2c19083e09401f9f1)

- - - - -
b0dee831 by Cheng Shao at 2023-02-09T12:48:05+00:00
testsuite: remove config.use_threads

This patch simplifies the testsuite driver by removing the use_threads
config field. It's just a degenerate case of threads=1.

(cherry picked from commit 633f2799e697ddaf63c4c91820c0b5a7c9b17db7)

- - - - -
5df968c3 by Cheng Shao at 2023-02-09T12:48:10+00:00
testsuite: use concurrent.futures.ThreadPoolExecutor in the driver

The testsuite driver used to create one thread per test case, and
explicitly use semaphore and locks for rate limiting and
synchronization. This is a bad practice in any language, and
occasionally may result in livelock conditions (e.g. #22889). This
patch uses concurrent.futures.ThreadPoolExecutor for scheduling test
case runs, which is simpler and more robust.

(cherry picked from commit ca6673e3cab496bbeed2ced47b40bcf1e0d0b3cd)

- - - - -
03bc710d by Matthew Pickering at 2023-02-09T12:48:15+00:00
Revert "Don't keep exit join points so much"

This reverts commit caced75765472a1a94453f2e5a439dba0d04a265.

It seems the patch "Don't keep exit join points so much" is causing
wide-spread regressions in the bytestring library benchmarks. If I
revert it then the 9.6 numbers are better on average than 9.4.

See https://gitlab.haskell.org/ghc/ghc/-/issues/22893#note_479525

-------------------------
Metric Decrease:
    MultiComponentModules
    MultiComponentModulesRecomp
    MultiLayerModules
    MultiLayerModulesRecomp
    MultiLayerModulesTH_Make
    T12150
    T13386
    T13719
    T21839c
    T3294
    parsing001
-------------------------

(cherry picked from commit 7eac2468a726f217dd97c5e2884f6b552e8ef11d)

- - - - -
71decd09 by sheaf at 2023-02-09T12:49:01+00:00
Fix tyvar scoping within class SPECIALISE pragmas

Type variables from class/instance headers scope over class/instance
method type signatures, but DO NOT scope over the type signatures in
SPECIALISE and SPECIALISE instance pragmas.

The logic in GHC.Rename.Bind.rnMethodBinds correctly accounted for
SPECIALISE inline pragmas, but forgot to apply the same treatment
to method SPECIALISE pragmas, which lead to a Core Lint failure with
an out-of-scope type variable. This patch makes sure we apply the same
logic for both cases.

Fixes #22913

(cherry picked from commit 9ee761bf02cdd11c955454a222c85971d95dce11)

- - - - -
5dfa01e7 by Cheng Shao at 2023-02-09T12:49:30+00:00
docs: 9.6 release notes for wasm backend

(cherry picked from commit 1ffe770c8d8c5c42edcf1558242f39431f72b965)

- - - - -
fcdf9f9b by Simon Peyton Jones at 2023-02-09T11:48:52-05:00
Improve treatment of type applications in patterns

This patch fixes a subtle bug in the typechecking of type
applications in patterns, e.g.
   f (MkT @Int @a x y) = ...

See Note [Type applications in patterns] in GHC.Tc.Gen.Pat.

This fixes #19847, #22383, #19577, #21501

(cherry picked from commit 9f95db54e38b21782d058043abe42fd77abfb9ad)

- - - - -
bea77fc4 by Andreas Klebinger at 2023-02-09T12:05:36-05:00
Fix some correctness issues around tag inference when targeting the bytecode generator.

* Let binders are now always assumed untagged for bytecode.
* Imported referenced are now always assumed to be untagged for bytecode.

Fixes #22840

(cherry picked from commit 382bd7dad9cd53254204f418190368667a127f64)

- - - - -
31a90769 by Matthew Pickering at 2023-02-09T12:05:56-05:00
driver: Use hooks from plugin_hsc_env

This fixes a bug in oneshot mode where hooks modified in a plugin
wouldn't be used in oneshot mode because we neglected to use the right
hsc_env. This was observed by @csabahruska.

(cherry picked from commit cc72e71298ce7e8ef7a2263a531f96d777db1800)

- - - - -
11686fb4 by Aaron Allen at 2023-02-09T12:06:01-05:00
Rework plugin initialisation points

In general this patch pushes plugin initialisation points to earlier in
the pipeline. As plugins can modify the `HscEnv`, it's imperative that
the plugins are initialised as soon as possible and used thereafter.

For example, there are some new tests which modify hsc_logger and other
hooks which failed to fire before (and now do)

One consequence of this change is that the error for specifying the
usage of a HPT plugin from the command line has changed, because it's
now attempted to be loaded at initialisation rather than causing a
cyclic module import.

Closes #21279

Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com>
(cherry picked from commit c31e87bbb13c0139b75acd234fd48eeb40cf50af)

- - - - -
94844882 by Ben Gamari at 2023-02-09T12:06:40-05:00
nativeGen/AArch64: Emit Atomic{Read,Write} inline

Previously the AtomicRead and AtomicWrite operations were emitted as
out-of-line calls. However, these tend to be very important for
performance, especially the RELAXED case (which only exists for
ThreadSanitizer checking).

Fixes #22115.

(cherry picked from commit 6e52fcb915baa1acb38ad2b1f313e8e6a89899f5)

- - - - -
f63da175 by Ben Gamari at 2023-02-10T01:25:53-05:00
testsuite: Drop inapplicable tests

These rely on TypeAbstractions, which is not implemented in 9.6.1.

- - - - -
f0da1dda by Ben Gamari at 2023-02-10T11:20:56-05:00
testsuite: Mark T15633 as fixed when static linking

Fixes #20706

- - - - -
bcc6c918 by Ben Gamari at 2023-02-10T11:23:08-05:00
relnotes: Mention release notes

- - - - -
3e18d493 by Ben Gamari at 2023-02-12T18:05:44-05:00
upload_ghc_libs: More control over which packages to operate on

Here we add a `--skip` flag to `upload_ghc_libs`, making it easier to
limit which packages to upload. This is often necessary when one package
is not uploadable (e.g. see #22740).

- - - - -
2ad167bf by Alan Zimmerman at 2023-02-14T20:53:26+00:00
EPA: Comment between module and where should be in header comments

Do not apply the heuristic to associate a comment with a prior
declaration for the first declaration in the file.

Closes #22919

(cherry picked from commit f22cce70dc7b9da191a023a9677eaea491bb2688)

- - - - -
b9b174fc by Li-yao Xia at 2023-02-20T09:13:24+00:00
base: Move changelog entry to its place

(cherry picked from commit 11de324aae17794c8753a8f7cb50c4140785fe27)

- - - - -
6d1b294d by doyougnu at 2023-02-20T09:13:40+00:00
docs: release notes, user guide: add js backend

Follow up from #21078

(cherry picked from commit 08c0822c74eb97ea8a6673c6a942d9c03a169bc8)

- - - - -
66dea16f by sheaf at 2023-02-20T09:14:35+00:00
No default finalizer exception handler

Commit cfc8e2e2 introduced a mechanism for handling of exceptions
that occur during Handle finalization, and 372cf730 set the default
handler to print out the error to stderr.

However, #21680 pointed out we might not want to set this by default,
as it might pollute users' terminals with unwanted information.
So, for the time being, the default handler discards the exception.

Fixes #21680

(cherry picked from commit 681e0e8ce470ec77a0db071f9fc7ec15995a0bb3)

- - - - -
033c8bf3 by Ben Gamari at 2023-02-20T09:15:24+00:00
base: Note move of GHC.Stack.CCS.whereFrom to GHC.InfoProv in changelog

Fixes #22883.

(cherry picked from commit 34cd308e23206e71b48e205970741746ed66ea8e)

- - - - -
a3b0c1b8 by sheaf at 2023-02-20T09:23:52+00:00
Introduce warning for loopy superclass solve

Commit aed1974e completely re-engineered the treatment of loopy
superclass dictionaries in instance declarations. Unfortunately,
it has the potential to break (albeit in a rather minor way) user code.

To alleviate migration concerns, this commit re-introduces the old
behaviour. Any reliance on this old behaviour triggers a warning,
controlled by `-Wloopy-superclass-solve`. The warning text explains
that GHC might produce bottoming evidence, and provides a migration
strategy.

This allows us to provide a graceful migration period, alerting users
when they are relying on this unsound behaviour.

Fixes #22912 #22891 #20666 #22894 #22905

(cherry picked from commit 9fb4ca89bff9873e5f6a6849fa22a349c94deaae)

- - - - -
c416eaf0 by Simon Peyton Jones at 2023-02-20T09:28:29+00:00
Narrow the dont-decompose-newtype test

Following #22924 this patch narrows the test that stops
us decomposing newtypes.  The key change is the use of
noGivenNewtypeReprEqs in GHC.Tc.Solver.Canonical.canTyConApp.

We went to and fro on the solution, as you can see in #22924.
The result is carefully documented in
  Note [Decomoposing newtype equalities]

On the way I had revert most of
  commit 3e827c3f74ef76d90d79ab6c4e71aa954a1a6b90
  Author: Richard Eisenberg <rae at cs.brynmawr.edu>
  Date:   Mon Dec 5 10:14:02 2022 -0500

    Do newtype unwrapping in the canonicaliser and rewriter

    See Note [Unwrap newtypes first], which has the details.

It turns out that

(a) 3e827c3f makes GHC behave worse on some recursive newtypes
    (see one of the tests on this commit)
(b) the finer-grained test (namely noGivenNewtypeReprEqs) renders
    3e827c3f unnecessary

(cherry picked from commit 12965aba860676ec68cbced86eb18d6ec5cb83b3)

- - - - -
f584311a by Cheng Shao at 2023-02-20T09:29:24+00:00
docs: add a section for the wasm backend

Fixes #22658

(cherry picked from commit 631c6c726d6ab86be1a3aa289e1468a75fb36bf6)

- - - - -
448699f8 by Matthew Pickering at 2023-02-20T09:30:59+00:00
unicode: Don't inline bitmap in generalCategory

generalCategory contains a huge literal string but is marked INLINE,
this will duplicate the string into any use site of generalCategory. In
particular generalCategory is used in functions like isSpace and the
literal gets inlined into this function which makes it massive.

https://github.com/haskell/core-libraries-committee/issues/130

Fixes #22949

-------------------------
Metric Decrease:
    T4029
    T18304
-------------------------

(cherry picked from commit b3ac17ad6d7f504ee7615ca67e02e5e094cf1905)

- - - - -
220504f8 by Cheng Shao at 2023-02-20T09:32:09+00:00
compiler: fix generateCgIPEStub for no-tables-next-to-code builds

generateCgIPEStub already correctly implements the CmmTick finding
logic for when tables-next-to-code is on/off, but it used the wrong
predicate to decide when to switch between the two. Previously it
switches based on whether the codegen is unregisterised, but there do
exist registerised builds that disable tables-next-to-code! This patch
corrects that problem. Fixes #22896.

(cherry picked from commit 3b019a7ac8fc9059cc3213f6f95a2daef97ca442)

- - - - -
6164ceb8 by Sylvain Henry at 2023-02-20T09:32:31+00:00
JS: disable debugging info for heap objects

(cherry picked from commit 324e925be847d3969724be3e1b82c25899aaca27)

- - - - -
8e9b8753 by sheaf at 2023-02-20T09:32:46+00:00
Expand synonyms in RoughMap

We were failing to expand type synonyms in the function
GHC.Core.RoughMap.typeToRoughMatchLookupTc, even though the
RoughMap infrastructure crucially relies on type synonym expansion
to work.

This patch adds the missing type-synonym expansion.

Fixes #22985

(cherry picked from commit 8988eeef193f055d7b67de5aaa00590c63491fb5)

- - - - -
f1751d36 by Matthew Pickering at 2023-02-20T09:33:07+00:00
ghcup-metadata: Use Ubuntu and Rocky bindists

Prefer to use the Ubuntu 20.04 and 18.04 binary distributions on Ubuntu
and Linux Mint. Prefer to use the Rocky 8 binary distribution on
unknown distributions.

(cherry picked from commit c6a967d9545ef5577514466f3fa6894f2899aff8)

- - - - -
cdb5e4f0 by Matthew Pickering at 2023-02-20T09:34:29+00:00
Add INLINABLE pragmas to `generic*` functions in Data.OldList

These functions are

* recursive
* overloaded

So it's important to add an `INLINABLE` pragma to each so that they can be
specialised at the use site when the specific numeric type is known.
Adding these pragmas improves the LazyText replicate benchmark (see https://gitlab.haskell.org/ghc/ghc/-/issues/22886#note_481020)

https://github.com/haskell/core-libraries-committee/issues/129
(cherry picked from commit be0b7209c6aef22798fc4ba7baacd2099b5cb494)

- - - - -
4395197a by Matthew Pickering at 2023-02-20T09:35:04+00:00
ghcup-metadata: Add test artifact

Add the released testsuite tarball to the generated ghcup metadata.

(cherry picked from commit 3dd50e2f4e3f2fac2f75b1223944dcdcc896e508)

- - - - -
573ba966 by Matthew Pickering at 2023-02-20T09:40:37+00:00
Bump supported LLVM range from 10 through 15 to 11 through 16

LLVM 15 turns on the new pass manager by default, which we have yet to
migrate to so for new we pass the `-enable-new-pm-0` flag in our
llvm-passes flag.

LLVM 11 was the first version to support the `-enable-new-pm` flag so we
bump the lowest supported version to 11.

Our CI jobs are using LLVM 12 so they should continue to work despite
this bump to the lower bound.

Fixes #21936

(cherry picked from commit 0cc16aaf89d7dc3963764b7193ceac73e4e3329b)

- - - - -
998b07fa by Matthew Pickering at 2023-02-20T09:40:44+00:00
Bump DOCKER_REV to use alpine image without LLVM installed

alpine_3_12 only supports LLVM 10, which is now outside the supported
version range.

(cherry picked from commit f94f14502a00824d48cef69d362774a9a4bfc6d6)

- - - - -
6c2b9924 by Teo Camarasu at 2023-02-20T09:42:34+00:00
doc: fix gcdetails_block_fragmentation_bytes since annotation

(cherry picked from commit 354aa47d313113855aff9e5c5476fcb56f80e3bf)

- - - - -
21ccdbac by Simon Peyton Jones at 2023-02-20T09:43:59+00:00
Treat existentials correctly in dubiousDataConInstArgTys

Consider (#22849)

 data T a where
   MkT :: forall k (t::k->*) (ix::k). t ix -> T @k a

Then dubiousDataConInstArgTys MkT [Type, Foo] should return
        [Foo (ix::Type)]
NOT     [Foo (ix::k)]

A bit of an obscure case, but it's an outright bug, and the fix is easy.

(cherry picked from commit 955a99ea28a0d06de67f0595d366450281aab0c0)

- - - - -
4902ed26 by sheaf at 2023-02-20T09:45:50+00:00
RTS: declare setKeepCAFs symbol

Commit 08ba8720 failed to declare the dependency of keepCAFsForGHCi on
the symbol setKeepCAFs in the RTS, which led to undefined symbol errors
on Windows, as exhibited by the testcase frontend001.

Thanks to Moritz Angermann and Ryan Scott for the diagnosis and fix.

Fixes #22961

(cherry picked from commit cf564dd71548771394249e9bf959512a21bbcec0)

- - - - -
fba46a03 by Matthew Pickering at 2023-02-20T09:48:25+00:00
release notes: Correct supported LLVM range

Fixes #23006

- - - - -
f7b0ceb3 by Ben Gamari at 2023-02-21T08:55:11-05:00
Bump process submodule to v1.6.17.0

- - - - -
2fda6252 by Ben Gamari at 2023-02-21T08:55:11-05:00
Bump hsc2hs submodule to 0.68.8

- - - - -
a38787f8 by Ben Gamari at 2023-02-21T08:55:11-05:00
Bump array submodule to 0.5.4.0

- - - - -
8cf5a602 by Ben Gamari at 2023-02-21T08:55:11-05:00
Bump Cabal submodule to 3.9 pre-release

- - - - -
24b74785 by Ben Gamari at 2023-02-21T08:55:11-05:00
Bump text submodule

- - - - -
7d7fb9e6 by Ben Gamari at 2023-02-21T08:55:11-05:00
Bump filepath submodule to 1.4.100.1

- - - - -
2156fd5c by Ben Gamari at 2023-02-21T08:55:11-05:00
Bump directory submodule to 1.3.8.1

- - - - -
7b84e510 by Bodigrim at 2023-02-21T08:55:11-05:00
Bump submodule text to 2.0.2

- - - - -
9a747806 by Ben Gamari at 2023-02-21T09:00:02-05:00
Bump deepseq submodule back to 1.4.8.1

- - - - -
850424e8 by Zubin Duggal at 2023-02-22T16:13:26-05:00
ncg/aarch64: Handle MULTILINE_COMMENT identically as COMMENTs

Commit 7566fd9de38c67360c090f828923d41587af519c with the fix for #22798 was
incomplete as it failed to handle MULTILINE_COMMENT pseudo-instructions, and
didn't completly fix the compiler panics when compiling with `-fregs-graph`.

Fixes #23002

(cherry picked from commit 0ea260da3c2b32778758737f6145b2b23ce5f776)

- - - - -
9eae6fbb by Andreas Klebinger at 2023-02-22T16:13:34-05:00
base: Correct @since annotation for FP<->Integral bit cast operations.

Fixes #22708

(cherry picked from commit 348181ddab0493575101784f1833834e03849643)

- - - - -
d11c0ec9 by Matthew Pickering at 2023-02-22T16:14:23-05:00
constant folding: Correct type of decodeDouble_Int64 rule

The first argument is Int64# unconditionally, so we better produce
something of that type. This fixes a core lint error found in the ad
package.

Fixes #23019

(cherry picked from commit 3c9b89adb0c953de02d301623b13541a9fe5feda)

- - - - -
9baeee3c by sheaf at 2023-02-22T16:15:28-05:00
Explicit migration timeline for loopy SC solving

This patch updates the warning message introduced in commit
9fb4ca89bff9873e5f6a6849fa22a349c94deaae to specify an explicit
migration timeline: GHC will no longer support this constraint solving
mechanism starting from GHC 9.10.

Fixes #22912

(cherry picked from commit daee5602f753372bd4b81589aacd3df4a00257e8)

- - - - -
fe681ecf by Ben Gamari at 2023-02-22T16:17:09-05:00
hadrian: Add dependency from lib/settings to mk/config.mk

In 81975ef375de07a0ea5a69596b2077d7f5959182 we attempted to fix #20253
by adding logic to the bindist Makefile to regenerate the `settings`
file from information gleaned by the bindist `configure` script.
However, this fix had no effect as `lib/settings` is shipped in the
binary distribution (to allow in-place use of the binary distribution).
As `lib/settings` already existed and its rule declared no dependencies,
`make` would fail to use the added rule to regenerate it.

Fix this by explicitly declaring a dependency from `lib/settings` on
`mk/config.mk`.

Fixes #22982.

(cherry picked from commit f8876261abebbbac2454e2335f728916ba7c959b)

- - - - -
88b18b0f by Alexis King at 2023-02-22T16:18:12-05:00
rts: Fix `prompt#` when profiling is enabled

This commit also adds a new -Dk RTS option to the debug RTS to assist
debugging continuation captures. Currently, the printed information is
quite minimal, but more can be added in the future if it proves to be
useful when debugging future issues.

fixes #23001

(cherry picked from commit e5794ede9e2af208669438a7f72958aeecbec111)

- - - - -
7dc43beb by Cheng Shao at 2023-02-22T16:18:56-05:00
compiler: fix cost centre profiling breakage in wasm NCG due to incorrect register mapping

The wasm NCG used to map CCCS to a wasm global, based on the
observation that CCCS is a transient register that's already handled
by thread state load/store logic, so it doesn't need to be backed by
the rCCCS field in the register table.

Unfortunately, this is wrong, since even when Cmm execution hasn't
yielded back to the scheduler, the Cmm code may call enterFunCCS,
which does use rCCCS.

This breaks cost centre profiling in a subtle way, resulting in
inaccurate stack traces in some test cases. The fix is simple though:
just remove the CCCS mapping.

(cherry picked from commit 2592ab6924ee34ed0f0d82a7cb0aed393d93bb14)

- - - - -
447a39fc by Matthew Pickering at 2023-02-22T16:19:53-05:00
Add INLINABLE pragmas to `generic*` functions in Data.OldList

These functions are

* recursive
* overloaded

So it's important to add an `INLINABLE` pragma to each so that they can be
specialised at the use site when the specific numeric type is known.
Adding these pragmas improves the LazyText replicate benchmark (see https://gitlab.haskell.org/ghc/ghc/-/issues/22886#note_481020)

https://github.com/haskell/core-libraries-committee/issues/129
(cherry picked from commit be0b7209c6aef22798fc4ba7baacd2099b5cb494)

- - - - -
e0cfea59 by Sylvain Henry at 2023-02-23T14:05:44-05:00
Testsuite: decrease length001 timeout for JS (#22921)

- - - - -
54fc7394 by Luite Stegeman at 2023-02-23T14:05:44-05:00
Check for platform support for JavaScript foreign imports

GHC was accepting `foreign import javascript` declarations
on non-JavaScript platforms. This adds a check so that these
are only supported on an platform that supports the JavaScript
calling convention.

Fixes #22774

(cherry picked from commit 1d7c2e4c9d63a7b392024cfcde299849b8d667a8)

- - - - -
81020431 by Ben Gamari at 2023-02-23T14:05:44-05:00
Bump terminfo submodule to 0.4.1.6

- - - - -
55cfa7c7 by Ben Gamari at 2023-02-23T14:05:44-05:00
Bump unix submodule to preliminary 2.8 release

- - - - -
fba19572 by Ben Gamari at 2023-02-23T14:05:44-05:00
Bump haskeline submodule to 0.8.2.1

- - - - -
feccc865 by Ben Gamari at 2023-02-23T14:05:44-05:00
Bump unix submodule to 2.8.1.0

- - - - -
c00a8a78 by Simon Peyton Jones at 2023-03-02T10:15:53-05:00
Refine the test for naughty record selectors

The test for naughtiness in record selectors is surprisingly subtle.
See the revised Note [Naughty record selectors] in GHC.Tc.TyCl.Utils.

Fixes #23038.

(cherry picked from commit cf118e2fac04b79cc7fa63cff0552190c3885bb9)

- - - - -
3b9bf327 by Simon Peyton Jones at 2023-03-02T10:16:05-05:00
Account for TYPE vs CONSTRAINT in mkSelCo

As #23018 showed, in mkRuntimeRepCo we need to account for coercions
between TYPE and COERCION.

See Note [mkRuntimeRepCo] in GHC.Core.Coercion.

(cherry picked from commit bb500e2a2d039dc75c8bb80d47ea2349b97fbf1b)

- - - - -
0105758b by Sebastian Graf at 2023-03-02T10:16:14-05:00
Revert the main payload of "Make `drop` and `dropWhile` fuse (#18964)"

This reverts the bits affecting fusion of `drop` and `dropWhile` of commit
0f7588b5df1fc7a58d8202761bf1501447e48914 and keeps just the small refactoring
unifying `flipSeqTake` and `flipSeqScanl'` into `flipSeq`.

It also adds a new test for #23021 (which was the reason for reverting) as
well as adds a clarifying comment to T18964.

Fixes #23021, unfixes #18964.

Metric Increase:
    T18964
Metric Decrease:
    T18964

(cherry picked from commit a2a1a1c08bb520b74b00194a83add82b287b38d5)

- - - - -
8f1ba948 by Cheng Shao at 2023-03-02T10:16:21-05:00
ghc-prim: fix hs_cmpxchg64 function prototype

hs_cmpxchg64 must return a StgWord64, otherwise incorrect runtime
results of 64-bit MO_Cmpxchg will appear in 32-bit unregisterised
builds, which go unnoticed at compile-time due to C implicit casting
in .hc files.

(cherry picked from commit 9fa545722f9151781344446dd5501db38cb90dd1)

- - - - -
b821cdbd by Sylvain Henry at 2023-03-02T10:16:55-05:00
JS: fix for overlap with copyMutableByteArray# (#23033)

The code wasn't taking into account some kind of overlap.

cgrun070 has been extended to test the missing case.

(cherry picked from commit 8b77f9bfceb456115f63349ad0ff66a5cea7ab59)

- - - - -
20dfcbed by Simon Peyton Jones at 2023-03-02T10:18:26-05:00
Account for local rules in specImports

As #23024 showed, in GHC.Core.Opt.Specialise.specImports, we were
generating specialisations (a locally-define function) for imported
functions; and then generating specialisations for those
locally-defined functions.  The RULE for the latter should be
attached to the local Id, not put in the rules-for-imported-ids
set.

Fix is easy; similar to what happens in GHC.HsToCore.addExportFlagsAndRules

(cherry picked from commit 0c200ab78c814cb5d1efaf426f0d3d91ceab9f4d)

- - - - -
5451b48c by Simon Peyton Jones at 2023-03-02T10:21:25-05:00
Fix shadowing bug in prepareAlts

As #23012 showed, GHC.Core.Opt.Simplify.Utils.prepareAlts was
using an OutType to construct an InAlt.  When shadowing is in play,
this is outright wrong.

See Note [Shadowing in prepareAlts].

(cherry picked from commit ece092d07f343dcfb4563e4f42d53a2a1e449f1a)

- - - - -
b73b70bf by Simon Peyton Jones at 2023-03-02T10:31:49-05:00
Take more care with unlifted bindings in the specialiser

As #22998 showed, we were floating an unlifted binding to top
level, which breaks a Core invariant.

The fix is easy, albeit a little bit conservative.  See
Note [Care with unlifted bindings] in GHC.Core.Opt.Specialise

(cherry picked from commit 7192ef91c855e1fae6997f75cfde76aafd0b4bcf)

- - - - -
0a0e22f5 by Ben Gamari at 2023-03-02T10:33:54-05:00
rts: Statically assert alignment of Capability

In #22965 we noticed that changes in the size of `Capability` can result
in unsound behavior due to the `align` pragma claiming an alignment
which we don't in practice observe. Avoid this by statically asserting
that the size is a multiple of the alignment.

(cherry picked from commit 485ccddacff5ed8892348905754c02452ac8f523)

- - - - -
72087b1d by Ben Gamari at 2023-03-02T12:31:12-05:00
rts: Introduce stgMallocAlignedBytes

(cherry picked from commit eeb5bd560942a4968980fb341d9ebca33ad3302b)

- - - - -
ac7bbf64 by Ben Gamari at 2023-03-02T12:31:12-05:00
rts: Correctly align Capability allocations

Previously we failed to tell the C allocator that `Capability`s needed
to be aligned, resulting in #22965.

Fixes #22965.
Fixes #22975.

(cherry picked from commit 2cca72cd3e4de25fa81dc6fcc9979e613697a838)

- - - - -
4bda8c6c by Ben Gamari at 2023-03-02T12:31:12-05:00
rts: Drop no-alignment special case for Windows

For reasons that aren't clear, we were previously not giving Capability
the same favorable alignment on Windows that we provided on other
platforms. Fix this.

(cherry picked from commit 05c5b14c5e28c279de0d84472526eccb7f05d00a)

- - - - -
cbdc5d51 by Ben Gamari at 2023-03-02T12:31:12-05:00
nativeGen: Disable asm-shortcutting on Darwin

Asm-shortcutting may produce relative references to symbols defined in
other compilation units. This is not something that MachO relocations
support (see #21972). For this reason we disable the optimisation on
Darwin. We do so without a warning since this flag is enabled by `-O2`.

Another way to address this issue would be to rather implement a
PLT-relocatable jump-table strategy. However, this would only benefit
Darwin and does not seem worth the effort.

Closes #21972.

(cherry picked from commit 8bed166bb79445f90015757fd5baac69a7b835df)

- - - - -
fbc98e66 by Ben Gamari at 2023-03-02T12:31:12-05:00
docs/relnotes: Mention -fprefer-byte-code

Closes #23027.

- - - - -
2faa1799 by Ben Gamari at 2023-03-07T17:08:21-05:00
relnotes: Clean up headings

Thanks to David Christiansen for noticing this.

- - - - -
e3a2b2ec by Ben Gamari at 2023-03-09T15:18:46-05:00
Bump Cabal submodule to 3.10 release

- - - - -
2d7ca624 by Sylvain Henry at 2023-03-09T15:49:33-05:00
linker: fix linking with aligned sections (#23066)

Take section alignment into account instead of assuming 16 bytes (which
is wrong when the section requires 32 bytes, cf #23066).

(cherry picked from commit 4158722a6cff5d19e228356c525946b6c4b83396)

- - - - -
4dab7f8c by MorrowM at 2023-03-09T15:50:48-05:00
Fix documentation for traceWith and friends

(cherry picked from commit 2aa0770845631e4355f55694f49b3e4b66ecf751)

- - - - -
67c80633 by Chris Wendt at 2023-03-09T15:51:03-05:00
Fix typo in docs referring to threadLabel

(cherry picked from commit c6e1f3cdcd59e6834820be3c8dc89b66b27b5f57)

- - - - -
009e2356 by Ben Gamari at 2023-03-09T15:52:31-05:00
Bump hpc submodule with js backend changes

- - - - -
4fc17738 by Ben Gamari at 2023-03-09T15:52:46-05:00
Bump stm submodule with js backend changes

- - - - -
1d02aa2a by Ben Gamari at 2023-03-10T02:06:14-05:00
docs/relnotes: Mention fat interface blog post

- - - - -
1595174f by Ben Gamari at 2023-03-10T02:06:14-05:00
rel-eng: Fix name of Rocky 8 bindist

- - - - -
9706e3de by Ryan Scott at 2023-03-10T02:11:16-05:00
Don't generate datacon wrappers for `type data` declarations

Data constructor wrappers only make sense for _value_-level data constructors,
but data constructors for `type data` declarations only exist at the _type_
level. This patch does the following:

* The criteria in `GHC.Types.Id.Make.mkDataConRep` for whether a data
  constructor receives a wrapper now consider whether or not its parent data
  type was declared with `type data`, omitting a wrapper if this is the case.

* Now that `type data` data constructors no longer receive wrappers, there is a
  spot of code in `refineDefaultAlt` that panics when it encounters a value
  headed by a `type data` type constructor. I've fixed this with a special case
  in `refineDefaultAlt` and expanded `Note [Refine DEFAULT case alternatives]`
  to explain why we do this.

Fixes #22948.

(cherry picked from commit 4327d63594f73939a2b8ab015c1cb44eafd4b460)

- - - - -
d81d0a0e by Ryan Scott at 2023-03-10T02:11:16-05:00
Treat type data declarations as empty when checking pattern-matching coverage

The data constructors for a `type data` declaration don't exist at the value
level, so we don't want GHC to warn users to match on them.

Fixes #22964.

(cherry picked from commit 96dc58b9225d91a7912957c6be5d9c7a95e51718)

- - - - -
34172066 by Ryan Scott at 2023-03-10T02:11:16-05:00
Disallow `tagToEnum#` on `type data` types

We don't want to allow users to conjure up values of a `type data` type using
`tagToEnum#`, as these simply don't exist at the value level.

(cherry picked from commit ff8e99f69b203559b784014ab26c59b5553d128a)

- - - - -
87ab8e35 by Ben Gamari at 2023-03-10T02:34:36-05:00
Bump haddock submodule to 2.28

- - - - -
1f5bce0d by Ben Gamari at 2023-03-10T02:34:36-05:00
Set RELEASE=YES

- - - - -
a58c028a by Ben Gamari at 2023-03-10T09:42:25-05:00
Fix TBA in base changelog

- - - - -
40293d4e by Matthew Pickering at 2023-05-10T16:07:19+01:00
hadrian: Bump index-state to allow building with ghc-9.6

- - - - -
65023412 by Ben Gamari at 2023-05-11T12:49:10-04:00
users guide: Note that base release notes are highlights of changelog

- - - - -
e0f3aec8 by Simon Peyton Jones at 2023-05-15T18:34:25-04:00
Refactor the simplifier a bit to fix #22761

The core change in this commit, which fixes #22761, is that

* In a Core rule, ru_rhs is always occ-analysed.

This means adding a couple of calls to occurAnalyseExpr when
building a Rule, in
* GHC.Core.Rules.mkRule
* GHC.Core.Opt.Simplify.Iteration.simplRules

But diagosing the bug made me stare carefully at the code of the
Simplifier, and I ended up doing some only-loosely-related refactoring.

* I think that RULES could be lost because not every code path
  did addBndrRules

* The code around lambdas was very convoluted

It's mainly moving deck chairs around, but I like it more now.

(cherry picked from commit e45eb82830d6de4d09abb548e190be980dd001b4)

- - - - -
595edd68 by Josh Meredith at 2023-05-15T18:34:25-04:00
JS: Fix implementation of MK_JSVAL

(cherry picked from commit bab232795865e9abb82b75c7e72329778e23a345)

- - - - -
dc291c00 by Josh Meredith at 2023-05-15T18:34:25-04:00
JS: fix implementation of forceBool to use JS backend syntax

(cherry picked from commit 047e9d4f10e4124899887449dc52b9e72a7d3ea6)

- - - - -
3db2b31b by Sebastian Graf at 2023-05-15T18:34:26-04:00
Simplifier: `countValArgs` should not count Type args (#23102)

I observed miscompilations while working on !10088 caused by this.

Fixes #23102.

Metric Decrease:
    T10421

(cherry picked from commit 559a480427a841b5189f2e6a84a38b02a7c2b8a1)

- - - - -
4532771a by Alexis King at 2023-05-15T18:34:26-04:00
bytecode: Fix bitmaps for BCOs used to tag tuples and prim call args

fixes #23068

(cherry picked from commit bed3a292df532935426987e1f0c5eaa4f605407e)

- - - - -
f70b9c49 by Matthew Pickering at 2023-05-16T07:56:09-04:00
docs: Generate docs/index.html with version number

* Generate docs/index.html to include the version of the ghc library

* This also fixes the packageVersions interpolations which were
  - Missing an interpolation for `LIBRARY_ghc_VERSION`
  - Double quoting the version so that "9.7" was being inserted.

Fixes #23121

(cherry picked from commit d7a768a415c3bd575a20b20ae9a3953aa5886ed7)

- - - - -
6cd0f807 by Simon Peyton Jones at 2023-05-16T07:56:09-04:00
Transfer DFunId_ness onto specialised bindings

Whether a binding is a DFunId or not has consequences for the `-fdicts-strict`
flag, essentially if we are doing demand analysis for a DFunId then `-fdicts-strict` does
not apply because the constraint solver can create recursive groups of dictionaries.

In #22549 this was fixed for the "normal" case, see
Note [Do not strictify the argument dictionaries of a dfun].
However the loop still existed if the DFunId was being specialised.

The problem was that the specialiser would specialise a DFunId and
turn it into a VanillaId and so the demand analyser didn't know to
apply special treatment to the binding anymore and the whole recursive
group was optimised to bottom.

The solution is to transfer over the DFunId-ness of the binding in the specialiser so
that the demand analyser knows not to apply the `-fstrict-dicts`.

Fixes #22549

(cherry picked from commit 3b0ea4809d92581a10e0e501a6fbd7339e8922bf)

- - - - -
5637364e by Ben Gamari at 2023-05-16T07:56:09-04:00
nonmoving: Disable slop-zeroing

As noted in #23170, the nonmoving GC can race with a mutator zeroing the
slop of an updated thunk (in much the same way that two mutators would
race). Consequently, we must disable slop-zeroing when the nonmoving GC
is in use.

Closes #23170

(cherry picked from commit d1bb16ed3e18a4f41fcfe31f0bf57dbaf589d6c5)

- - - - -
373ec872 by Krzysztof Gogolewski at 2023-05-16T07:56:09-04:00
Fix unification with oversaturated type families

unify_ty was incorrectly saying that F x y ~ T x are surely apart,
where F x y is an oversaturated type family and T x is a tyconapp.
As a result, the simplifier dropped a live case alternative (#23134).

(cherry picked from commit 7c16f3be6e1ac92f87d752f12ad6c6e7b7fd6207)

- - - - -
ab677901 by Ben Gamari at 2023-05-16T07:56:09-04:00
nativeGen/AArch64: Fix bitmask immediate predicate

Previously the predicate for determining whether a logical instruction
operand could be encoded as a bitmask immediate was far too
conservative. This meant that, e.g., pointer untagged required five
instructions whereas it should only require one.

Fixes #23030.

(cherry picked from commit b8d783d24b9a617ad1e3038abeb75d322703ef65)

- - - - -
7083db5a by Sylvain Henry at 2023-05-16T07:56:09-04:00
JS: fix thread-related primops

(cherry picked from commit d442ac053f9ac7dbcc32318802daf686f377fe3d)

- - - - -
35131c9d by Ben Gamari at 2023-05-16T07:56:09-04:00
rts: Initialize Array# header in listThreads#

Previously the implementation of listThreads# failed to initialize the
header of the created array, leading to various nastiness.

Fixes #23071

(cherry picked from commit 52d3e9b4189440d26bad9c5a15f9420b67b1ca5b)

- - - - -
ac639721 by Ben Gamari at 2023-05-16T07:56:09-04:00
testsuite: Add test for #23071

(cherry picked from commit 1db30fe1dd38dd8ffedfadf3845706fcde02933b)

- - - - -
1fdbbd8d by sheaf at 2023-05-16T07:56:09-04:00
Don't panic in ltPatersonSize

The function GHC.Tc.Utils.TcType.ltPatersonSize would panic when it
encountered a type family on the RHS, as usually these are not allowed
(type families are not allowed on the RHS of class instances or of
quantified constraints). However, it is possible to still encounter
type families on the RHS after doing a bit of constraint solving, as
seen in test case T23171. This could trigger the panic in the call to
ltPatersonSize in GHC.Tc.Solver.Canonical.mk_strict_superclasses, which
is involved in avoiding loopy superclass constraints.

This patch simply changes ltPatersonSize to return "I don't know, because
there's a type family involved" in these cases.

Fixes #23171

(cherry picked from commit df1a581188694479a583270548896245fc23b525)

- - - - -
5292bdf8 by Sylvain Henry at 2023-05-17T11:43:28-04:00
JS: fix getpid (fix #23399)

(cherry picked from commit 2972fd66f91cb51426a1df86b8166a067015e231)

- - - - -
6c5fcaba by Josh Meredith at 2023-05-17T11:43:34-04:00
JS: Implement h$clock_gettime in the JavaScript RTS (#23360)

(cherry picked from commit 5e3f9bb57680a40f6a9531e41dc2617c5f028e5c)

- - - - -
86a9404a by Sylvain Henry at 2023-05-17T11:44:06-04:00
Fix GHCJS OS platform (fix #23346)

(cherry picked from commit 2f571afe1c2aeb3f4dfca2012bc6b713144fd234)

- - - - -
48da24c9 by Simon Peyton Jones at 2023-05-18T16:00:10-04:00
Make GHC.Types.Id.Make.shouldUnpackTy a bit more clever

As #23307, GHC.Types.Id.Make.shouldUnpackTy was leaving money on the
table, failing to unpack arguments that are perfectly unpackable.

The fix is pretty easy; see Note [Recursive unboxing]

(cherry picked from commit 902f0730b4c50f39b7767a346be324c98bf7a8a6)

- - - - -
74b8e5bd by Alexis King at 2023-05-18T16:00:10-04:00
Use a uniform return convention in bytecode for unary results

fixes #22958

(cherry picked from commit d85ed900b271109185251cb0494d51048a4cf213)

- - - - -
4949111f by Alexis King at 2023-05-18T16:00:10-04:00
hadrian: Fix linker script flag for MergeObjects builder

This fixes what appears to have been a typo in !9530. The `-t` flag just
enables tracing on all versions of `ld` I’ve looked at, while `-T` is
used to specify a linker script. It seems that this worked anyway for
some reason on some `ld` implementations (perhaps because they
automatically detect linker scripts), but the missing `-T` argument
causes `gold` to complain.

(cherry picked from commit 59aa4676a49b4f9d09c1cd3cc3b47c3c54b6ed80)

- - - - -
27086298 by Krzysztof Gogolewski at 2023-05-18T16:00:10-04:00
Fix coercion optimisation for SelCo (#23362)

setNominalRole_maybe is supposed to output a nominal coercion.
In the SelCo case, it was not updating the stored role to Nominal,
causing #23362.

(cherry picked from commit d683b2e5b91a39a2bf16796f5800f605a0281004)

- - - - -
5bd85c7d by Ben Gamari at 2023-05-18T16:00:10-04:00
hadrian: Fix mention of non-existent removeFiles function

Previously Hadrian's bindist Makefile referred to a `removeFiles`
function that was previously defined by the `make` build system. Since
the `make` build system is no longer around, this function is now
undefined. Naturally, make being make, this appears to be silently
ignored instead of producing an error.

Fix this by rewriting it to `rm -f`.

Closes #23373.

(cherry picked from commit c6cf9433e3d41e239265eaeff0fd02e6b45d5427)

- - - - -
7607986e by sheaf at 2023-05-18T16:00:10-04:00
Don't panic in mkNewTyConRhs

This function could come across invalid newtype constructors, as we
only perform validity checking of newtypes once we are outside the
knot-tied typechecking loop.
This patch changes this function to fake up a stub type in the case of
an invalid newtype, instead of panicking.

This patch also changes "checkNewDataCon" so that it reports as many
errors as possible at once.

Fixes #23308

(cherry picked from commit c176ad1835ccfe55e2bde875b4a35e9d226ff657)

- - - - -
eaadcaa7 by Ryan Scott at 2023-05-18T16:00:10-04:00
Fix type variable substitution in gen_Newtype_fam_insts

Previously, `gen_Newtype_fam_insts` was substituting the type variable binders
of a type family instance using `substTyVars`, which failed to take type
variable dependencies into account. There is similar code in
`GHC.Tc.TyCl.Class.tcATDefault` that _does_ perform this substitution properly,
so this patch:

1. Factors out this code into a top-level `substATBndrs` function, and
2. Uses `substATBndrs` in `gen_Newtype_fam_insts`.

Fixes #23329.

(cherry picked from commit e8b72ff6e4aee1f889a9168df57bb1b00168fd21)

- - - - -
14414247 by Ben Gamari at 2023-05-18T16:00:10-04:00
nonmoving: Fix style

(cherry picked from commit abb6070f488120aef113b686e91b439fe6c3d272)

- - - - -
4200590a by Ben Gamari at 2023-05-18T16:00:10-04:00
nonmoving: Deduplicate assertion

(cherry picked from commit be2789014b208db5c471ab187e7dba2ebc59f8c8)

- - - - -
80208941 by Ben Gamari at 2023-05-18T16:00:10-04:00
rts: Fix type issues in Sparks.h

Adds explicit casts to satisfy a C++ compiler.

(cherry picked from commit b90346392f5455bc4a6f6d86700296babc429a98)

- - - - -
0a25b9df by Ben Gamari at 2023-05-18T16:00:10-04:00
rts: Use release ordering when storing thread labels

Since this makes the ByteArray# visible from other cores.

(cherry picked from commit da7b2b941d235a284d5685829c235a9e671a0336)

- - - - -
a70c277a by Ben Gamari at 2023-05-18T16:00:10-04:00
rts/BlockAlloc: Allow disabling of internal assertions

These can be quite expensive and it is sometimes useful to compile a
DEBUG RTS without them.

(cherry picked from commit 5b7f65767fbc2967e01a13ee580598e976f5d225)

- - - - -
b4e5489f by Ben Gamari at 2023-05-18T16:00:10-04:00
rts/Sanity: Mark pinned_object_blocks

(cherry picked from commit 6283144fb2e98f4c774950567e55575c1747d136)

- - - - -
2ab18a83 by Ben Gamari at 2023-05-18T16:00:11-04:00
rts/Sanity: Look at nonmoving saved_filled lists

(cherry picked from commit 9b52840412c920a1a1eed26df37262bc6c82c171)

- - - - -
556c2544 by Ben Gamari at 2023-05-18T16:00:11-04:00
Evac: Squash data race in eval_selector_chain

(cherry picked from commit 0edc543834d8172e54020c5272af1cf2d0b3437c)

- - - - -
4023f814 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Clarify implementation

This makes the intent of this implementation a bit clearer.

(cherry picked from commit 7eab831a7d17eda3108da4702a447656cd62334c)

- - - - -
88cc3f94 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Clarify comment

(cherry picked from commit 532262b95b2eaa685a22279a8e54cc2e379e21ef)

- - - - -
f5a48ce6 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Add missing no-op in busy-wait loop

(cherry picked from commit bd9cd84bbbb51f21c7b2b478e1f5971e2659b9fd)

- - - - -
5c4aa7e2 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Don't push empty arrays to update remembered set

Previously the write barrier of resizeSmallArray# incorrectly handled
resizing of zero-sized arrays, pushing an invalid pointer to the update
remembered set.

Fixes #22931.

(cherry picked from commit c4e6bfc801a79b73e94d363db1d3e65076e17981)

- - - - -
661da5ee by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Fix handling of weak pointers

This fixes an interaction between aging and weak pointer handling which
prevented the finalization of some weak pointers. In particular, weak
pointers could have their keys incorrectly marked by the preparatory
collector, preventing their finalization by the subsequent concurrent
collection.

While in the area, we also significantly improve the assertions
regarding weak pointers.

Fixes #22327.

(cherry picked from commit 92227b6022b35d87f6366c75e09ed495b7c3603e)

- - - - -
568b2523 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Sanity check nonmoving large objects and compacts

(cherry picked from commit ba7e7972ae14848a9ac41d5c6200d0aa5727ed72)

- - - - -
ce560ce4 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Sanity check mutable list

Assert that entries in the nonmoving generation's generational
remembered set (a.k.a. mutable list) live in nonmoving generation.

(cherry picked from commit 71b038a1261754c38cf984f7c578621c3217c3bf)

- - - - -
a01dc8ab by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Don't show occupancy if we didn't collect live words

(cherry picked from commit 99d144d56598965daba30aa73e6c598b3245bb0f)

- - - - -
762f6ae1 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Fix tracking of FILLED_SWEEPING segments

Previously we only updated the state of the segment at the head of each
allocator's filled list.

(cherry picked from commit 81d6cc551c7a843002495d3ffd2373ad00a52766)

- - - - -
395b8572 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Assert state of swept segments

(cherry picked from commit 58e53bc4d33dad76b3250997f1a8300d0041f387)

- - - - -
6208cbae by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Handle new closures in nonmovingIsNowAlive

We must conservatively assume that new closures are reachable since we
are not guaranteed to mark such blocks.

(cherry picked from commit 2db92e015655e7fc22e559020572bf23233ffaae)

- - - - -
471b5fdc by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Don't clobber update rem sets of old capabilities

Previously `storageAddCapabilities` (called by `setNumCapabilities`) would
clobber the update remembered sets of existing capabilities when
increasing the capability count. Fix this by only initializing the
update remembered sets of the newly-created capabilities.

Fixes #22927.

(cherry picked from commit e4c3249f00a406a406b6f1190ca8be628b643042)

- - - - -
229ae7e4 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Add missing write barriers in selector optimisation

This fixes the selector optimisation, adding a few write barriers which
are necessary for soundness. See the inline comments for details.

Fixes #22930.

(cherry picked from commit 1b06967176559d6b2b530dd16e127fa4479ae47f)

- - - - -
8f39f2b3 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Post-sweep sanity checking

(cherry picked from commit d4032690a8bf638f6d134cc6592d138eb018f102)

- - - - -
6a25c84f by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Avoid n_caps race

(cherry picked from commit 0baa8752aaefe80ca428fbfa0cbd4e620d67e1a7)

- - - - -
7213e435 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Don't push if nonmoving collector isn't enabled

(cherry picked from commit 5d3232baa78dd6f00fc040f75d8e9a8075bfbc07)

- - - - -
251e2b4a by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Be more paranoid in segment tracking

Previously we left various segment link pointers dangling. None of this
wrong per se, but it did make it harder than necessary to debug.

(cherry picked from commit 0a7eb0aa0bf7e7464e68ab9b6f4176771dcc3590)

- - - - -
81fb5149 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Sync-phase mark budgeting

Here we significantly improve the bound on sync phase pause times by
imposing a limit on the amount of work that we can perform during the
sync. If we find that we have exceeded our marking budget then we allow
the mutators to resume, return to concurrent marking, and try
synchronizing again later.

Fixes #22929.

(cherry picked from commit 7c817c0a4ab857e03d09526a481f63e313598c5b)

- - - - -
d8ad8043 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Allow pinned gen0 objects to be WEAK keys

(cherry picked from commit ce22a3e2f2e8168f80d77807d79214e1cfbccb44)

- - - - -
d6deed34 by Ben Gamari at 2023-05-18T16:00:11-04:00
rts: Reenable assertion

(cherry picked from commit 78746906d133765a9a4219eb34ed01e78f31344c)

- - - - -
d6826083 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Move current segment array into Capability

The current segments are conceptually owned by the mutator, not the
collector. Consequently, it was quite tricky to prove that the mutator
would not race with the collect due to this shared state. It turns out
that such races are possible: when resizing the current segment array
we may concurrently try to take a heap census. This will attempt to walk
the current segment array, causing a data race.

Fix this by moving the current segment array into `Capability`, where it
belongs.

Fixes #22926.

(cherry picked from commit b500867a9eae6381e5c686aaa71ae069398eacb9)

- - - - -
02289f9a by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Fix Note references

Some references to Note [Deadlock detection under the non-moving
collector] were missing an article.

(cherry picked from commit 56e669c11208bba136c44ee7154b59e0d4d39c87)

- - - - -
4b75a239 by Ben Gamari at 2023-05-18T16:00:11-04:00
rts/Sanity: Fix block count assertion with non-moving collector

The nonmoving collector does not use `oldest_gen->blocks` to track its
block list. However, it nevertheless updates `oldest_gen->n_blocks` to
ensure that its size is accounted for by the storage manager.
Consequently, we must not attempt to assert consistency between the two.

(cherry picked from commit 4a7650d75752fcde2fc5bc23913e4116ae2ec582)

- - - - -
4275ccfb by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Don't call prepareUnloadCheck

When the nonmoving GC is in use we do not call `checkUnload` (since we
don't unload code) and therefore should not call `prepareUnloadCheck`,
lest we run into assertions.

(cherry picked from commit 96a5aaede899f95fb06dcdb9d0439bbea0f93e14)

- - - - -
873df322 by Ben Gamari at 2023-05-18T16:00:11-04:00
rts: Encapsulate block allocator spinlock

This makes it a bit easier to add instrumentation on this spinlock
while debugging.

(cherry picked from commit 6c6674cafefbb72f1b9c5b8a005fc62f905c50ea)

- - - - -
8805864d by Ben Gamari at 2023-05-18T16:00:11-04:00
testsuite: Skip some tests when sanity checking is enabled

(cherry picked from commit e84f716798e0d3431aa7ec42b243dc0998cb6444)

- - - - -
f01df851 by Ben Gamari at 2023-05-18T16:00:12-04:00
nonmoving: Fix unregisterised build

(cherry picked from commit 3ae0f368542b24b2ee2cd102cf65db8db705c83c)

- - - - -
3bc83d81 by Ben Gamari at 2023-05-18T16:00:12-04:00
nonmoving: Ensure that sanity checker accounts for saved_filled segments

(cherry picked from commit 4eb9d06b00043e52be3cf828ccb92f0bb4c9e438)

- - - - -
7c5657fc by Ben Gamari at 2023-05-18T16:00:12-04:00
hadrian: Add +boot_nonmoving_gc flavour transformer

For using GHC bootstrapping to validate the non-moving GC.

(cherry picked from commit f0cf384db038ff3b83770dbf11a89ecd20178899)

- - - - -
04e8de8a by Ben Gamari at 2023-05-18T16:00:12-04:00
nonmoving: Move allocator into new source file

(cherry picked from commit 487a8b580581e8f9b40974cf0e0a4e93f95e8665)

- - - - -
a7716f0b by Ben Gamari at 2023-05-18T16:00:12-04:00
nonmoving: Split out nonmovingAllocateGC

(cherry picked from commit 8f374139f0b5f0a39861a7f9432070f78f9fbba0)

- - - - -
01f2fef1 by Ben Gamari at 2023-05-18T16:00:12-04:00
testsuite: Mark ffi023 as broken due to #23089

(cherry picked from commit f1fd3ffbdccf471c43f3c36d6ecb4bd5da33c097)

- - - - -
db8e4d61 by Ben Gamari at 2023-05-18T16:00:12-04:00
testsuite: Skip T7160 in the nonmoving way

Finalization order is different under the nonmoving collector.

(cherry picked from commit a57f12b3f06afe29cbbc6eb0a887bcbe319f17f6)

- - - - -
75fd54fe by Ben Gamari at 2023-05-18T16:00:12-04:00
rts: Capture GC configuration in a struct

The number of distinct arguments passed to GarbageCollect was getting a
bit out of hand.

(cherry picked from commit f6f12a36346e19de7eed330537350d0b7420764a)

- - - - -
19ad1ae5 by Ben Gamari at 2023-05-18T16:00:12-04:00
nonmoving: Non-concurrent collection

(cherry picked from commit ba73a807edbb444c49e0cf21ab2ce89226a77f2e)

- - - - -
15da0925 by Ben Gamari at 2023-05-18T16:00:12-04:00
gitlab-ci: Add job bootstrapping with nonmoving GC

(cherry picked from commit 581e58ac80f98a9f5292ad13a9a984c2f5a1de21)

- - - - -
7b39870b by Ben Gamari at 2023-05-21T14:30:51-04:00
nonmoving: Account for mutator allocations in bytes_allocated

Previously we failed to account direct mutator allocations into the
nonmoving heap against the mutator's allocation limit and
`cap->total_allocated`. This only manifests during CAF evaluation (since
we allocate the CAF's blackhole directly into the nonmoving heap).

Fixes #23312.

(cherry picked from commit b2cdb7dacc095142e29c0f28a956b7fa97cdb4b1)

- - - - -
3d0a7cd3 by Teo Camarasu at 2023-05-21T14:45:11-04:00
Add regression test for #17574

This test currently fails in the nonmoving way

(cherry picked from commit a56141a69842a78d56ec11be85a775eb703219bf)

- - - - -
f0f96536 by Teo Camarasu at 2023-05-21T14:45:20-04:00
fix: account for large and compact object stats with nonmoving gc

Make sure that we keep track of the size of large and compact objects that have been moved onto the nonmoving heap.
We keep track of their size and add it to the amount of live bytes in nonmoving segments to get the total size of the live nonmoving heap.

Resolves #17574

(cherry picked from commit 20c6669fc46c567e00d3cdf22aa84479b6d8dc17)

- - - - -
07243d1b by Ben Gamari at 2023-05-21T15:03:36-04:00
configure: Release 9.6.2

- - - - -
7e70df17 by Ben Gamari at 2023-05-22T20:18:09-04:00
docs: 9.6.2 release notes

- - - - -
9a1dcec1 by Ben Gamari at 2023-05-22T20:18:17-04:00
configure: RELEASE=NO

- - - - -
f3a7152b by Ben Gamari at 2023-08-21T11:08:25-04:00
rts: Ensure that pinned allocations respect block size

Previously, it was possible for pinned, aligned allocation requests to
allocate beyond the end of the pinned accumulator block. Specifically,
we failed to account for the padding needed to achieve the requested
alignment in the "large object" check. With large alignment requests,
this can result in the allocator using the capability's pinned object
accumulator block to service a request which is larger than
`PINNED_EMPTY_SIZE`.

To fix this we reorganize `allocatePinned` to consistently account for
the alignment padding in all large object checks.

Fixes #23400.

- - - - -
6444f0f9 by Ben Gamari at 2023-08-21T11:08:25-04:00
rts/LdvProfile: Drop redundant initialization

- - - - -
52ad08ec by Ben Gamari at 2023-08-23T12:42:35-04:00
C++ compilation

- - - - -
fe0eff6f by Ben Gamari at 2023-08-23T12:42:35-04:00
CheckGC

- - - - -
67c01952 by Ben Gamari at 2023-08-23T12:42:35-04:00
dump heap on GC

- - - - -
4ecbe69a by Ben Gamari at 2023-08-23T12:42:35-04:00
ClosureList

- - - - -


20 changed files:

- .gitlab-ci.yml
- .gitlab/ci.sh
- .gitlab/darwin/nix/sources.json
- .gitlab/darwin/toolchain.nix
- + .gitlab/gen-ci.cabal
- .gitlab/gen_ci.hs
- + .gitlab/generate_job_metadata
- .gitlab/generate_jobs
- .gitlab/hello.hs
- + .gitlab/hie.yaml
- .gitlab/jobs.yaml
- + .gitlab/rel_eng/default.nix
- + .gitlab/rel_eng/fetch-gitlab-artifacts/.gitignore
- + .gitlab/rel_eng/fetch-gitlab-artifacts/README.mkd
- + .gitlab/rel_eng/fetch-gitlab-artifacts/default.nix
- + .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py
- + .gitlab/rel_eng/fetch-gitlab-artifacts/setup.py
- + .gitlab/rel_eng/mk-ghcup-metadata/.gitignore
- + .gitlab/rel_eng/mk-ghcup-metadata/README.mkd
- + .gitlab/rel_eng/mk-ghcup-metadata/default.nix


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b0f07dbc63495f41f7f9b4bf9d54130329a4b80f...4ecbe69acc7521bc60a64e2261a5d8ddf971495d

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b0f07dbc63495f41f7f9b4bf9d54130329a4b80f...4ecbe69acc7521bc60a64e2261a5d8ddf971495d
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/20230823/6146b88b/attachment-0001.html>


More information about the ghc-commits mailing list