[Git][ghc/ghc][wip/tmp] 3334 commits: Fix mention of non-existent "rehydrateIface" function [skip ci]

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Thu Feb 22 03:52:31 UTC 2024



Ben Gamari pushed to branch wip/tmp at Glasgow Haskell Compiler / GHC


Commits:
43da2963 by Matthew Pickering at 2022-03-30T09:55:49+01:00
Fix mention of non-existent "rehydrateIface" function [skip ci]

Fixes #21303

- - - - -
6793a20f by gershomb at 2022-04-01T10:33:46+01:00
Remove wrong claim about naturality law.

This docs change removes a longstanding confusion in the Traversable
docs. The docs say "(The naturality law is implied by parametricity and
thus so is the purity law [1, p15].)". However if one reads the
reference a different "natural" law is implied by parametricity. The
naturality law given as a law here is imposed. Further, the reference
gives examples which violate both laws -- so they cannot be implied by
parametricity. This PR just removes the wrong claim.

- - - - -
5beeff46 by Ben Gamari at 2022-04-01T10:34:39+01:00
Refactor handling of global initializers

GHC uses global initializers for a number of things including
cost-center registration, info-table provenance registration, and setup
of foreign exports. Previously, the global initializer arrays which
referenced these initializers would live in the object file of the C
stub, which would then be merged into the main object file of the
module.

Unfortunately, this approach is no longer tenable with the move to
Clang/LLVM on Windows (see #21019). Specifically, lld's PE backend does
not support object merging (that is, the -r flag). Instead we are now
rather packaging a module's object files into a static library. However,
this is problematic in the case of initializers as there are no
references to the C stub object in the archive, meaning that the linker
may drop the object from the final link.

This patch refactors our handling of global initializers to instead
place initializer arrays within the object file of the module to which
they belong. We do this by introducing a Cmm data declaration containing
the initializer array in the module's Cmm stream. While the initializer
functions themselves remain in separate C stub objects, the reference
from the module's object ensures that they are not dropped from the
final link.

In service of #21068.

- - - - -
3e6fe71b by Matthew Pickering at 2022-04-01T10:35:41+01:00
Fix remaining issues in eventlog types (gen_event_types.py)

*  The size of End concurrent mark phase looks wrong and, it used to be 4 and now it's 0.
*  The size of Task create is wrong, used to be 18 and now 14.
*  The event ticky-ticky entry counter begin sample has the wrong name
*  The event ticky-ticky entry counter being sample has the wrong size, was 0 now 32.

Closes #21070

- - - - -
7847f47a by Ben Gamari at 2022-04-01T10:35:41+01:00
users-guide: Fix a few small issues in eventlog format descriptions

The CONC_MARK_END event description didn't mention its payload.
Clarify the meaning of the CREATE_TASK's payload.

- - - - -
acfd5a4c by Matthew Pickering at 2022-04-01T10:35:53+01:00
ci: Regenerate jobs.yaml

It seems I forgot to update this to reflect the current state of
gen_ci.hs

- - - - -
a952dd80 by Matthew Pickering at 2022-04-01T10:35:59+01:00
ci: Attempt to fix windows cache issues

It appears that running the script directly does nothing (no info is
printed about saving the cache).

- - - - -
fb65e6e3 by Adrian Ratiu at 2022-04-01T10:49:52+01:00
fp_prog_ar.m4: take AR var into consideration

In ChromeOS and Gentoo we want the ability to use LLVM ar
instead of GNU ar even though both are installed, thus we
pass (for eg) AR=llvm-ar to configure.

Unfortunately GNU ar always gets picked regardless of the
AR setting because the check does not consider the AR var
when setting fp_prog_ar, hence this fix.

- - - - -
1daaefdf by Greg Steuck at 2022-04-01T10:50:16+01:00
T13366 requires c++ & c++abi libraries on OpenBSD

Fixes this failure:

=====> 1 of 1 [0, 0, 0]
T13366(normal) 1 of 1 [0, 0, 0] Compile failed (exit code 1) errors were:

<no location info>: error:
    user specified .o/.so/.DLL could not be loaded (File not found)
Whilst trying to load:  (dynamic) stdc++
Additional directories searched: (none)

*** unexpected failure for T13366(normal)

- - - - -
18e6c85b by Jakob Bruenker at 2022-04-01T10:54:28+01:00
new datatypes for parsedResultAction

Previously, the warnings and errors were given and returned as a tuple
(Messages PsWarnings, Messages PsErrors). Now, it's just PsMessages.

This, together with the HsParsedModule the parser plugin gets and
returns, has been wrapped up as ParsedResult.

- - - - -
9727e592 by Morrow at 2022-04-01T10:55:12+01:00
Clarify that runghc interprets the input program

- - - - -
f589dea3 by sheaf at 2022-04-01T10:59:58+01:00
Unify RuntimeRep arguments in ty_co_match

The `ty_co_match` function ignored the implicit RuntimeRep coercions
that occur in a `FunCo`. Even though a comment explained that this
should be fine, #21205 showed that it could result in discarding a
RuntimeRep coercion, and thus discarding an important cast entirely.

With this patch, we first match the kinds in `ty_co_match`.

Fixes #21205

-------------------------
Metric Increase:
    T12227
    T18223
-------------------------

- - - - -
6f4dc372 by Andreas Klebinger at 2022-04-01T11:01:35+01:00
Export MutableByteArray from Data.Array.Byte

This implements CLC proposal #49

- - - - -
5df9f5e7 by ARATA Mizuki at 2022-04-01T11:02:35+01:00
Add test cases for #20640

Closes #20640

- - - - -
8334ff9e by Krzysztof Gogolewski at 2022-04-01T11:03:16+01:00
Minor cleanup

- Remove unused functions exprToCoercion_maybe, applyTypeToArg,
  typeMonoPrimRep_maybe, runtimeRepMonoPrimRep_maybe.
- Replace orValid with a simpler check
- Use splitAtList in applyTysX
- Remove calls to extra_clean in the testsuite; it does not do anything.

Metric Decrease:
    T18223

- - - - -
b2785cfc by Eric Lindblad at 2022-04-01T11:04:07+01:00
hadrian typos

- - - - -
418e6fab by Eric Lindblad at 2022-04-01T11:04:12+01:00
two typos

- - - - -
dd7c7c99 by Phil de Joux at 2022-04-01T11:04:56+01:00
Add tests and docs on plugin args and order.

- - - - -
3e209a62 by MaxHearnden at 2022-04-01T11:05:19+01:00
Change may not to might not
- - - - -
b84380d3 by Matthew Pickering at 2022-04-01T11:07:27+01:00
hadrian: Remove linters-common from bindist

Zubin observed that the bindists contains the utility library
linters-common. There are two options:

1. Make sure only the right files are added into the bindist.. a bit
   tricky due to the non-trivial structure of the lib directory.
2. Remove the bad files once they get copied in.. a bit easier

So I went for option 2 but we perhaps should go for option 1 in the
future.

Fixes #21203

- - - - -
ba9904c1 by Zubin Duggal at 2022-04-01T11:07:31+01:00
hadrian: allow testing linters with out of tree compilers

- - - - -
26547759 by Matthew Pickering at 2022-04-01T11:07:35+01:00
hadrian: Introduce CheckProgram datatype to replace a 7-tuple

- - - - -
df65d732 by Jakob Bruenker at 2022-04-01T11:08:28+01:00
Fix panic when pretty printing HsCmdLam

When pretty printing a HsCmdLam with more than one argument, GHC
panicked because of a missing case. This fixes that.

Closes #21300

- - - - -
ad6cd165 by John Ericson at 2022-04-01T11:10:06+01:00
hadrian: Remove vestigial -this-unit-id support check

This has been dead code since 400ead81e80f66ad7b1260b11b2a92f25ccc3e5a.

- - - - -
8ca7ab81 by Matthew Pickering at 2022-04-01T11:10:23+01:00
hadrian: Fix race involving empty package databases

There was a small chance of a race occuring between the small window of

1. The first package (.conf) file get written into the database
2. hadrian calling "ghc-pkg recache" to refresh the package.conf file

In this window the package database would contain rts.conf but not a
package.cache file, and therefore if ghc was invoked it would error
because it was missing.

To solve this we call "ghc-pkg recache" at when the database is created
by shake by writing the stamp file into the database folder. This also
creates the package.cache file and so avoids the possibility of this
race.

- - - - -
cc4ec64b by Matthew Pickering at 2022-04-01T11:11:05+01:00
hadrian: Add assertion that in/out tree args are the same

There have been a few instances where this calculation was incorrect, so
we add a non-terminal assertion when now checks they the two
computations indeed compute the same thing.

Fixes #21285

- - - - -
691508d8 by Matthew Pickering at 2022-04-01T11:13:10+01:00
hlint: Ignore suggestions in generated HaddockLex file

With the make build system this file ends up in the compiler/
subdirectory so is linted. With hadrian, the file ends up in _build so
it's not linted.

Fixes #21313

- - - - -
f8f152e7 by Krzysztof Gogolewski at 2022-04-01T11:14:08+01:00
Change GHC.Prim to GHC.Exts in docs and tests

Users are supposed to import GHC.Exts rather than GHC.Prim.
Part of #18749.

- - - - -
f8fc6d2e by Matthew Pickering at 2022-04-01T11:15:24+01:00
driver: Improve -Wunused-packages error message (and simplify implementation)

In the past I improved the part of -Wunused-packages which found which
packages were used. Now I improve the part which detects which ones were
specified. The key innovation is to use the explicitUnits field from
UnitState which has the result of resolving the package flags, so we
don't need to mess about with the flag arguments from DynFlags anymore.

The output now always includes the package name and version (and the
flag which exposed it).

```
    The following packages were specified via -package or -package-id flags,
    but were not needed for compilation:
      - bytestring-0.11.2.0 (exposed by flag -package bytestring)
      - ghc-9.3 (exposed by flag -package ghc)
      - process-1.6.13.2 (exposed by flag -package process)
```

Fixes #21307

- - - - -
5e5a12d9 by Matthew Pickering at 2022-04-01T11:15:32+01:00
driver: In oneshot mode, look for interface files in hidir

How things should work:

*  -i is the search path for source files
*  -hidir explicitly sets the search path for interface files and the output location for interface files.
*  -odir sets the search path and output location for object files.

Before in one shot mode we would look for the interface file in the
search locations given by `-i`, but then set the path to be in the
`hidir`, so in unusual situations the finder could find an interface
file in the `-i` dir but later fail because it tried to read the
interface file from the `-hidir`.

A bug identified by #20569

- - - - -
950f58e7 by Matthew Pickering at 2022-04-01T11:15:36+01:00
docs: Update documentation interaction of search path, -hidir and -c mode.

As noted in #20569 the documentation for search path was wrong because
it seemed to indicate that `-i` dirs were important when looking for
interface files in `-c` mode, but they are not important if `-hidir` is
set.

Fixes #20569

- - - - -
d85c7dcb by sheaf at 2022-04-01T11:17:56+01:00
Keep track of promotion ticks in HsOpTy

This patch adds a PromotionFlag field to HsOpTy, which is used
in pretty-printing and when determining whether to emit warnings
with -fwarn-unticked-promoted-constructors.

This allows us to correctly report tick-related warnings for things
like:

  type A = Int : '[]
  type B = [Int, Bool]

Updates haddock submodule

Fixes #19984

- - - - -
32070e6c by Jakob Bruenker at 2022-04-01T20:31:08+02:00
Implement \cases (Proposal 302)

This commit implements proposal 302: \cases - Multi-way lambda
expressions.

This adds a new expression heralded by \cases, which works exactly like
\case, but can match multiple apats instead of a single pat.

Updates submodule haddock to support the ITlcases token.

Closes #20768

- - - - -
c6f77f39 by sheaf at 2022-04-01T20:33:05+02:00
Add a regression test for #21323

This bug was fixed at some point between GHC 9.0 and GHC 9.2;
this patch simply adds a regression test.

- - - - -
3596684e by Jakob Bruenker at 2022-04-01T20:33:05+02:00
Fix error when using empty case in arrow notation

It was previously not possible to use -XEmptyCase in Arrow notation,
since GHC would print "Exception: foldb of empty list".

This is now fixed.

Closes #21301

- - - - -
9a325b59 by Ben Gamari at 2022-04-01T20:33:05+02:00
users-guide: Fix various markup issues

- - - - -
aefb1e6d by sheaf at 2022-04-01T20:36:01+02:00
Ensure implicit parameters are lifted

`tcExpr` typechecked implicit parameters by introducing a metavariable
of kind `TYPE kappa`, without enforcing that `kappa ~ LiftedRep`.
This patch instead creates a metavariable of kind `Type`.

Fixes #21327

- - - - -
ed62dc66 by Ben Gamari at 2022-04-05T11:44:51-04:00
gitlab-ci: Disable cabal-install store caching on Windows

For reasons that remain a mystery, cabal-install seems to consistently
corrupt its cache on Windows. Disable caching for now.

Works around #21347.

- - - - -
5ece5c5a by Ryan Scott at 2022-04-06T13:00:51-04:00
Add /linters/*/dist-install/ to .gitignore

Fixes #21335.

[ci skip]

- - - - -
410c76ee by Ben Gamari at 2022-04-06T13:01:28-04:00
Use static archives as an alternative to object merging

Unfortunately, `lld`'s COFF backend does not currently support object
merging. With ld.bfd having broken support for high image-load base
addresses, it's necessary to find an alternative. Here I introduce
support in the driver for generating static archives, which we use on
Windows instead of object merging.

Closes #21068.

- - - - -
400666c8 by Ben Gamari at 2022-04-06T13:01:28-04:00
rts/linker: Catch archives masquerading as object files

Check the file's header to catch static archive bearing the `.o`
extension, as may happen on Windows after the Clang refactoring.

See #21068

- - - - -
694d39f0 by Ben Gamari at 2022-04-06T13:01:28-04:00
driver: Make object merging optional

On Windows we don't have a linker which supports object joining (i.e.
the `-r` flag). Consequently, `-pgmlm` is now a `Maybe`.

See #21068.

- - - - -
41fcb5cd by Ben Gamari at 2022-04-06T13:01:28-04:00
hadrian: Refactor handling of ar flags

Previously the setup was quite fragile as it had to assume which
arguments were file arguments and which were flags.

- - - - -
3ac80a86 by Ben Gamari at 2022-04-06T13:01:28-04:00
hadrian: Produce ar archives with L modifier on Windows

Since object files may in fact be archive files, we must ensure that
their contents are merged rather than constructing an
archive-of-an-archive.

See #21068.

- - - - -
295c35c5 by Ben Gamari at 2022-04-06T13:01:28-04:00
Add a Note describing lack of object merging on Windows

See #21068.

- - - - -
d2ae0a3a by Ben Gamari at 2022-04-06T13:01:28-04:00
Build ar archives with -L when "joining" objects

Since there may be .o files which are in fact archives.

- - - - -
babb47d2 by Zubin Duggal at 2022-04-06T13:02:04-04:00
Add warnings for file header pragmas that appear in the body of a module (#20385)

Once we are done parsing the header of a module to obtain the options, we
look through the rest of the tokens in order to determine if they contain any
misplaced file header pragmas that would usually be ignored, potentially
resulting in bad error messages.

The warnings are reported immediately so that later errors don't shadow
over potentially helpful warnings.

Metric Increase:
  T13719

- - - - -
3f31825b by Ben Gamari at 2022-04-06T13:02:40-04:00
rts/AdjustorPool: Generalize to allow arbitrary contexts

Unfortunately the i386 adjustor logic needs this.

- - - - -
9b645ee1 by Ben Gamari at 2022-04-06T13:02:40-04:00
adjustors/i386: Use AdjustorPool

In !7511 (closed) I introduced a new allocator for adjustors,
AdjustorPool, which eliminates the address space fragmentation issues
which adjustors can introduce. In that work I focused on amd64 since
that was the platform where I observed issues.

However, in #21132 we noted that the size of adjustors is also a cause
of CI fragility on i386. In this MR I port i386 to use AdjustorPool.
Sadly the complexity of the i386 adjustor code does cause require a bit
of generalization which makes the code a bit more opaque but such is the
world.

Closes #21132.

- - - - -
c657a616 by Ben Gamari at 2022-04-06T13:03:16-04:00
hadrian: Clean up flavour transformer definitions

Previously the `ipe` and `omit_pragmas` transformers were hackily
defined using the textual key-value syntax. Fix this.

- - - - -
9ce273b9 by Ben Gamari at 2022-04-06T13:03:16-04:00
gitlab-ci: Drop dead HACKAGE_INDEX_STATE variable

- - - - -
01845375 by Ben Gamari at 2022-04-06T13:03:16-04:00
gitlab/darwin: Factor out bindists

This makes it a bit easier to bump them.

- - - - -
c41c478e by Ben Gamari at 2022-04-06T13:03:16-04:00
Fix a few new warnings when booting with GHC 9.2.2

-Wuni-incomplete-patterns and apparent improvements in the pattern match
checker surfaced these.

- - - - -
6563cd24 by Ben Gamari at 2022-04-06T13:03:16-04:00
gitlab-ci: Bump bootstrap compiler to 9.2.2

This is necessary to build recent `text` commits.

Bumps Hackage index state for a hashable which builds with GHC 9.2.

- - - - -
a62e983e by Ben Gamari at 2022-04-06T13:03:16-04:00
Bump text submodule to current `master`

Addresses #21295.

- - - - -
88d61031 by Vladislav Zavialov at 2022-04-06T13:03:53-04:00
Refactor OutputableBndrFlag instances

The matching on GhcPass introduced by 95275a5f25a is not necessary.
This patch reverts it to make the code simpler.

- - - - -
f601f002 by GHC GitLab CI at 2022-04-06T15:18:26-04:00
rts: Eliminate use of nested functions

This is a gcc-specific extension.

- - - - -
d4c5f29c by Ben Gamari at 2022-04-06T15:18:26-04:00
driver: Drop hacks surrounding windres invocation

Drop hack for #1828, among others as they appear to be unnecessary when
using `llvm-windres`.

- - - - -
6be2c5a7 by Ben Gamari at 2022-04-06T15:18:26-04:00
Windows/Clang: Build system adaptation

* Bump win32-tarballs to 0.7
* Move Windows toolchain autoconf logic into separate file
* Use clang and LLVM utilities as described in #21019
* Disable object merging as lld doesn't support -r
* Drop --oformat=pe-bigobj-x86-64 arguments from ld flags as LLD detects
  that the output is large on its own.
* Drop gcc wrapper since Clang finds its root fine on its own.

- - - - -
c6fb7aff by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Test that we can build bigobj PE objects

- - - - -
79851c07 by Ben Gamari at 2022-04-06T15:18:26-04:00
Drop -static-libgcc

This flag is not applicable when Clang is used.

- - - - -
1f8a8264 by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Port T16514 to C

Previously this test was C++ which made it a bit of a portability
problem.

- - - - -
d7e650d1 by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Mark Windows as a libc++ platform

- - - - -
d7886c46 by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Mark T9405 as fixed on Windows

I have not seen it fail since moving to clang.

Closes #12714.

- - - - -
4c3fbb4e by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Mark FloatFnInverses as fixed

The new toolchain has fixed it.

Closes #15670.

- - - - -
402c36ba by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Rework T13606 to avoid gcc dependence

Previously we used libgcc_s's import library in T13606. However, now that
we ship with clang we no longer have this library. Instead we now use gdi32.

- - - - -
9934ad54 by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Clean up tests depending on C++ std lib

- - - - -
12fcdef2 by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Split T13366 into two tests

Split up the C and C++ uses since the latter is significantly more
platform-dependent.

- - - - -
3c08a198 by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Fix mk-big-obj

I'm a bit unclear on how this previously worked as it attempted
to build an executable without defining `main`.

- - - - -
7e97cc23 by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Provide module definitions in T10955dyn

Otherwise the linker will export all symbols, including those provided
by the RTS, from the produced shared object. Consequently, attempting
to link against multiple objects simultaneously will cause the linker
to complain that RTS symbols are multiply defined. Avoid this
by limiting the DLL exports with a module definition file.

- - - - -
9a248afa by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite: Mark test-defaulting-plugin as fragile on Windows

Currently llvm-ar does not handle long file paths, resulting in
occassional failures of these tests and #21293.

- - - - -
39371aa4 by Ben Gamari at 2022-04-06T15:18:26-04:00
testsuite/driver: Treat framework failures of fragile tests as non-fatal

Previously we would report framework failures of tests marked as fragile
as failures. Now we rather treat them as fragile test failures, which
are not fatal to the testsuite run. Noticed while investigating #21293.

- - - - -
a1e6661d by Ben Gamari at 2022-04-06T15:18:32-04:00
Bump Cabal submodule

- Disable support for library-for-ghci on Windows as described
  in #21068.
- Teach Cabal to use `ar -L` when available

- - - - -
f7b0f63c by Ben Gamari at 2022-04-06T15:18:37-04:00
Bump process submodule

Fixes missing TEST_CC_OPTS in testsuite tests.

- - - - -
109cee19 by Ben Gamari at 2022-04-06T15:18:37-04:00
hadrian: Disable ghci libraries when object merging is not available

- - - - -
c22fba5c by Ben Gamari at 2022-04-06T15:18:37-04:00
Bump bytestring submodule

- - - - -
6e2744cc by Ben Gamari at 2022-04-06T15:18:37-04:00
Bump text submodule

- - - - -
32333747 by Ben Gamari at 2022-04-06T15:18:37-04:00
hadrian: Build wrappers using ghc rather than cc

- - - - -
59787ba5 by Ben Gamari at 2022-04-06T15:18:37-04:00
linker/PEi386: More descriptive error message

- - - - -
5e3c3c4f by Ben Gamari at 2022-04-06T15:18:37-04:00
testsuite: Mark TH_spliceE5_prof as unbroken on Windows

It was previously failing due to #18721 and now passes with the new
toolchain.

Closes #18721.

- - - - -
9eb0a9d9 by GHC GitLab CI at 2022-04-06T15:23:48-04:00
rts/PEi386: Move some debugging output to -DL

- - - - -
ce874595 by Ben Gamari at 2022-04-06T15:24:01-04:00
nativeGen/x86: Use %rip-relative addressing

On Windows with high-entropy ASLR we must use %rip-relative addressing
to avoid overflowing the signed 32-bit immediate size of x86-64.
Since %rip-relative addressing comes essentially for free and can make
linking significantly easier, we use it on all platforms.

- - - - -
52deee64 by Ben Gamari at 2022-04-06T15:24:01-04:00
Generate LEA for label expressions

- - - - -
105a0056 by Ben Gamari at 2022-04-06T15:24:01-04:00
Refactor is32BitLit to take Platform rather than Bool

- - - - -
ec4526b5 by Ben Gamari at 2022-04-06T15:24:01-04:00
Don't assume that labels are 32-bit on Windows

- - - - -
ffdbe457 by Ben Gamari at 2022-04-06T15:24:01-04:00
nativeGen: Note signed-extended nature of MOV

- - - - -
bfb79697 by Ben Gamari at 2022-04-06T15:30:56-04:00
rts: Move __USE_MINGW_ANSI_STDIO definition to PosixSource.h

It's easier to ensure that this is included first than Rts.h

- - - - -
5ad143fd by Ben Gamari at 2022-04-06T15:30:56-04:00
rts: Fix various #include issues

This fixes various violations of the newly-added RTS includes linter.

- - - - -
a59a66a8 by Ben Gamari at 2022-04-06T15:30:56-04:00
testsuite: Lint RTS #includes

Verifies two important properties of #includes in the RTS:

 * That system headers don't appear inside of a `<BeginPrivate.h>` block
   as this can hide system library symbols, resulting in very
   hard-to-diagnose linker errors

 * That no headers precede `Rts.h`, ensuring that __USE_MINGW_ANSI_STDIO
   is set correctly before system headers are included.

- - - - -
42bf7528 by GHC GitLab CI at 2022-04-06T16:25:04-04:00
rts/PEi386: Fix memory leak

Previously we would leak the section information of the `.bss`
section.

- - - - -
d286a55c by Ben Gamari at 2022-04-06T16:25:25-04:00
rts/linker: Preserve information about symbol types

As noted in #20978, the linker would previously handle overflowed
relocations by creating a jump island. While this is fine in the case of
code symbols, it's very much not okay in the case of data symbols. To
fix this we must keep track of whether each symbol is code or data and
relocate them appropriately. This patch takes the first step in this
direction, adding a symbol type field to the linker's symbol table. It
doesn't yet change relocation behavior to take advantage of this
knowledge.

Fixes #20978.

- - - - -
e689e9d5 by Ben Gamari at 2022-04-06T16:25:25-04:00
rts/PEi386: Fix relocation overflow behavior

This fixes handling of overflowed relocations on PEi386 targets:

 * Refuse to create jump islands for relocations of data symbols
 * Correctly handle the `__imp___acrt_iob_func` symbol, which is an new
   type of symbol: `SYM_TYPE_INDIRECT_DATA`

- - - - -
655e7d8f by GHC GitLab CI at 2022-04-06T16:25:25-04:00
rts: Mark anything that might have an info table as data

Tables-next-to-code mandates that we treat symbols with info tables like
data since we cannot relocate them using a jump island.

See #20983.

- - - - -
7e8cc293 by Ben Gamari at 2022-04-06T16:25:25-04:00
rts/PEi386: Rework linker

This is a significant rework of the PEi386 linker, making the linker
compatible with high image base addresses. Specifically, we now use the
m32 allocator instead of `HeapAllocate`.

In addition I found a number of latent bugs in our handling of import
libraries and relocations. I've added quite a few comments describing
what I've learned about Windows import libraries while fixing these.

Thanks to Tamar Christina (@Phyx) for providing the address space search
logic, countless hours of help while debugging, and his boundless
Windows knowledge.

Co-Authored-By: Tamar Christina <tamar at zhox.com>

- - - - -
ff625218 by Ben Gamari at 2022-04-06T16:25:25-04:00
rts/PEi386: Move allocateBytes to MMap.c

- - - - -
f562b5ca by Ben Gamari at 2022-04-06T16:25:25-04:00
rts/PEi386: Avoid accidentally-quadratic allocation cost

We now preserve the address that we last mapped, allowing us to resume
our search and avoiding quadratic allocation costs. This fixes the
runtime of T10296a, which allocates many adjustors.

- - - - -
3247b7db by Ben Gamari at 2022-04-06T16:25:25-04:00
Move msvcrt dep out of base

- - - - -
fa404335 by Ben Gamari at 2022-04-06T16:25:25-04:00
rts/linker: More descriptive debug output

- - - - -
140f338f by Ben Gamari at 2022-04-06T16:25:25-04:00
rts/PathUtils: Define pathprintf in terms of snwprintf on Windows

swprintf deviates from usual `snprintf` semantics in that it does not
guarantee reasonable behavior when the buffer is NULL (that is,
returning the number of bytes that would have been emitted).

- - - - -
eb60565b by Ben Gamari at 2022-04-06T16:25:25-04:00
rts/linker: Report archive member index

- - - - -
209fd61b by Ben Gamari at 2022-04-06T16:25:25-04:00
rts/linker: Split up object resolution and initialization

Previously the RTS linker would call initializers during the
"resolve" phase of linking. However, this is problematic in the
case of cyclic dependencies between objects. In particular, consider
the case where we have a situation where a static library
contains a set of recursive objects:

 * object A has depends upon symbols in object B
 * object B has an initializer that depends upon object A
 * we try to load object A

The linker would previously:

 1. start resolving object A
 2. encounter the reference to object B, loading it resolve object B
 3. run object B's initializer
 4. the initializer will attempt to call into object A,
    which hasn't been fully resolved (and therefore protected)

Fix this by moving constructor execution to a new linking
phase, which follows resolution.

Fix #21253.

- - - - -
8e8a1021 by Ben Gamari at 2022-04-06T16:25:25-04:00
rts/linker/LoadArchive: Fix leaking file handle

Previously `isArchive` could leak a `FILE` handle if the `fread`
returned a short read.

- - - - -
429ea5d9 by sheaf at 2022-04-07T07:55:52-04:00
Remove Fun pattern from Typeable COMPLETE set

GHC merge request !963 improved warnings in the presence of
COMPLETE annotations. This allows the removal of the Fun pattern
from the complete set.

Doing so expectedly causes some redundant pattern match warnings,
in particular in GHC.Utils.Binary.Typeable and Data.Binary.Class
from the binary library; this commit addresses that.

Updates binary submodule

Fixes #20230

- - - - -
54b18824 by Alan Zimmerman at 2022-04-07T07:56:28-04:00
EPA: handling of con_bndrs in mkGadtDecl

Get rid of unnnecessary case clause that always matched.

Closes #20558

- - - - -
9c838429 by Ben Gamari at 2022-04-07T09:38:53-04:00
testsuite: Mark T10420 as broken on Windows

Due to #21322.

- - - - -
50739d2b by Ben Gamari at 2022-04-07T09:42:42-04:00
rts: Refactor and fix printf attributes on clang

Clang on Windows does not understand the `gnu_printf` attribute; use
`printf` instead.

- - - - -
9eeaeca4 by Ben Gamari at 2022-04-07T09:42:42-04:00
rts: Add missing newline in error message

- - - - -
fcef9a17 by Ben Gamari at 2022-04-07T09:42:42-04:00
configure: Make environ decl check more robust

Some platforms (e.g. Windows/clang64) declare `environ` in `<stdlib.h>`,
not `<unistd.h>`

- - - - -
8162b4f3 by Ben Gamari at 2022-04-07T09:42:42-04:00
rts: Adjust RTS symbol table on Windows for ucrt

- - - - -
633280d7 by Ben Gamari at 2022-04-07T09:43:21-04:00
testsuite: Fix exit code of bounds checking tests on Windows

`abort` exits with 255, not 134, on Windows.

- - - - -
cab4dc01 by Ben Gamari at 2022-04-07T09:43:31-04:00
testsuite: Update expected output from T5435 tests on Windows

I'll admit, I don't currently see *why* this output is reordered
but it is a fairly benign difference and I'm out of time to investigate.

- - - - -
edf5134e by Ben Gamari at 2022-04-07T09:43:35-04:00
testsuite: Mark T20918 as broken on Windows

Our toolchain on Windows doesn't currently have Windows support.

- - - - -
d0ddeff3 by Ben Gamari at 2022-04-07T09:43:39-04:00
testsuite: Mark linker unloading tests as broken on Windows

Due to #20354.

We will need to investigate this prior the release.

- - - - -
5a86da2b by Ben Gamari at 2022-04-07T09:43:43-04:00
testsuite: Mark T9405 as broken on Windows

Due to #21361.

- - - - -
4aa86dcf by Ben Gamari at 2022-04-07T09:44:18-04:00
Merge branches 'wip/windows-high-codegen', 'wip/windows-high-linker', 'wip/windows-clang-2' and 'wip/lint-rts-includes' into wip/windows-clang-join

- - - - -
7206f055 by Ben Gamari at 2022-04-07T09:45:07-04:00
rts/CloneStack: Ensure that Rts.h is #included first

As is necessary on Windows.

- - - - -
9cfcb27b by Ben Gamari at 2022-04-07T09:45:07-04:00
rts: Fallback to ucrtbase not msvcrt

Since we have switched to Clang the toolchain now links against
ucrt rather than msvcrt.

- - - - -
d6665d85 by Ben Gamari at 2022-04-07T09:46:25-04:00
Accept spurious perf test shifts on Windows

Metric Decrease:
    T16875
Metric Increase:
    T12707
    T13379
    T3294
    T4801
    T5321FD
    T5321Fun
    T783

- - - - -
83363c8b by Simon Peyton Jones at 2022-04-07T12:57:21-04:00
Use prepareBinding in tryCastWorkerWrapper

As #21144 showed, tryCastWorkerWrapper was calling prepareRhs, and
then unconditionally floating the bindings, without the checks of
doFloatFromRhs.   That led to floating an unlifted binding into
a Rec group.

This patch refactors prepareBinding to make these checks,
and do them uniformly across all calls.  A nice improvement.

Other changes
* Instead of passing around a RecFlag and a TopLevelFlag; and sometimes
  a (Maybe SimplCont) for join points, define a new Simplifier-specific
  data type BindContext:
      data BindContext = BC_Let  TopLevelFlag RecFlag
                       | BC_Join SimplCont
  and use it consistently.

* Kill off completeNonRecX by inlining it.  It was only called in
  one place.

* Add a wrapper simplImpRules for simplRules.

Compile time on T9630 drops by 4.7%; little else changes.

Metric Decrease:
    T9630

- - - - -
02279a9c by Vladislav Zavialov at 2022-04-07T12:57:59-04:00
Rename [] to List (#21294)

This patch implements a small part of GHC Proposal #475.
The key change is in GHC.Types:

	- data [] a = [] | a : [a]
	+ data List a = [] | a : List a

And the rest of the patch makes sure that List is pretty-printed as []
in various contexts.

Updates the haddock submodule.

- - - - -
08480d2a by Simon Peyton Jones at 2022-04-07T12:58:36-04:00
Fix the free-var test in validDerivPred

The free-var test (now documented as (VD3)) was too narrow,
affecting only class predicates.  #21302 demonstrated that
this wasn't enough!

Fixes #21302.

Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com>

- - - - -
b3d6d23d by Andreas Klebinger at 2022-04-07T12:59:12-04:00
Properly explain where INLINE pragmas can appear.

Fixes #20676

- - - - -
23ef62b3 by Ben Gamari at 2022-04-07T14:28:28-04:00
rts: Fix off-by-one in snwprintf usage

- - - - -
b2dbcc7d by Simon Jakobi at 2022-04-08T03:00:38-04:00
Improve seq[D]VarSet

Previously, the use of size[D]VarSet would involve a traversal of the
entire underlying IntMap. Since IntMaps are already spine-strict,
this is unnecessary.

- - - - -
64ac20a7 by sheaf at 2022-04-08T03:01:16-04:00
Add test for #21338

This no-skolem-info bug was fixed by the no-skolem-info patch
that will be part of GHC 9.4. This patch adds a regression test for
the issue reported in issue #21338.

Fixes #21338.

- - - - -
c32c4db6 by Ben Gamari at 2022-04-08T03:01:53-04:00
rts: Move __USE_MINGW_ANSI_STDIO definition to PosixSource.h

It's easier to ensure that this is included first than Rts.h

- - - - -
56f85d62 by Ben Gamari at 2022-04-08T03:01:53-04:00
rts: Fix various #include issues

This fixes various violations of the newly-added RTS includes linter.

- - - - -
cb1f31f5 by Ben Gamari at 2022-04-08T03:01:53-04:00
testsuite: Lint RTS #includes

Verifies two important properties of #includes in the RTS:

 * That system headers don't appear inside of a `<BeginPrivate.h>` block
   as this can hide system library symbols, resulting in very
   hard-to-diagnose linker errors

 * That no headers precede `Rts.h`, ensuring that __USE_MINGW_ANSI_STDIO
   is set correctly before system headers are included.

- - - - -
c44432db by Krzysztof Gogolewski at 2022-04-08T03:02:29-04:00
Fixes to 9.4 release notes

- Mention -Wforall-identifier
- Improve description of withDict
- Fix formatting

- - - - -
777365f1 by sheaf at 2022-04-08T09:43:35-04:00
Correctly report SrcLoc of redundant constraints

We were accidentally dropping the source location information in
certain circumstances when reporting redundant constraints. This patch
makes sure that we set the TcLclEnv correctly before reporting the
warning.

Fixes #21315

- - - - -
af300a43 by Vladislav Zavialov at 2022-04-08T09:44:11-04:00
Reject illegal quote mark in data con declarations (#17865)

* Non-fatal (i.e. recoverable) parse error
* Checking infix constructors
* Extended the regression test

- - - - -
56254e6b by Ben Gamari at 2022-04-08T09:59:46-04:00
Merge remote-tracking branch 'origin/master'

- - - - -
6e2c3b7c by Matthew Pickering at 2022-04-08T13:55:15-04:00
driver: Introduce HomeModInfoCache abstraction

The HomeModInfoCache is a mutable cache which is updated incrementally
as the driver completes, this makes it robust to exceptions including
(SIGINT)

The interface for the cache is described by the `HomeMOdInfoCache` data
type:

```
data HomeModInfoCache = HomeModInfoCache { hmi_clearCache :: IO [HomeModInfo]
                                         , hmi_addToCache :: HomeModInfo -> IO () }
```

The first operation clears the cache and returns its contents. This is
designed so it's harder to end up in situations where the cache is
retained throughout the execution of upsweep.

The second operation allows a module to be added to the cache.

The one slightly nasty part is in `interpretBuildPlan` where we have to
be careful to ensure that the cache writes happen:

1. In parralel
2. Before the executation continues after upsweep.

This requires some simple, localised MVar wrangling.

Fixes #20780

- - - - -
85f4a3c9 by Andreas Klebinger at 2022-04-08T13:55:50-04:00
Add flag -fprof-manual which controls if GHC should honour manual cost centres.

This allows disabling of manual control centres in code a user doesn't control like
libraries.

Fixes #18867

- - - - -
3415981c by Vladislav Zavialov at 2022-04-08T13:56:27-04:00
HsUniToken for :: in GADT constructors (#19623)

One more step towards the new design of EPA.

Updates the haddock submodule.

- - - - -
23f95735 by sheaf at 2022-04-08T13:57:07-04:00
Docs: datacon eta-expansion, rep-poly checks

The existing notes weren't very clear on how the eta-expansion of
data constructors that occurs in tcInferDataCon/dsConLike interacts
with the representation polymorphism invariants. So we explain with
a few more details how we ensure that the representation-polymorphic
lambdas introduced by tcInferDataCon/dsConLike don't end up causing
problems, by checking they are properly instantiated and then relying
on the simple optimiser to perform beta reduction.

A few additional changes:

  - ConLikeTc just take type variables instead of binders, as we
    never actually used the binders.
  - Removed the FRRApp constructor of FRROrigin; it was no longer used
    now that we use ExpectedFunTyOrigin.
  - Adds a bit of documentation to the constructors
    of ExpectedFunTyOrigin.

- - - - -
d4480490 by Matthew Pickering at 2022-04-08T13:57:43-04:00
ci: Replace "always" with "on_success" to stop build jobs running before hadrian-ghci has finished

See https://docs.gitlab.com/ee/ci/yaml/#when

* always means, always run not matter what
* on_success means, run if the dependencies have built successfully

- - - - -
0736e949 by Vladislav Zavialov at 2022-04-08T13:58:19-04:00
Disallow (->) as a data constructor name (#16999)

The code was misusing isLexCon, which was never meant for validation.
In fact, its documentation states the following:

	Use these functions to figure what kind of name a 'FastString'
	represents; these functions do /not/ check that the identifier
	is valid.

Ha! This sign can't stop me because I can't read.

The fix is to use okConOcc instead. The other checks (isTcOcc or
isDataOcc) seem superfluous, so I also removed those.

- - - - -
e58d5eeb by Simon Peyton Jones at 2022-04-08T13:58:55-04:00
Tiny documentation wibble

This commit
   commit 83363c8b04837ee871a304cf85207cf79b299fb0
   Author: Simon Peyton Jones <simon.peytonjones at gmail.com>
   Date:   Fri Mar 11 16:55:38 2022 +0000

       Use prepareBinding in tryCastWorkerWrapper

refactored completeNonRecX away, but left a Note referring to it.
This MR fixes that Note.

- - - - -
4bb00839 by Matthew Pickering at 2022-04-09T07:40:28-04:00
ci: Fix nightly head.hackage pipelines

This also needs a corresponding commit to head.hackage, I also made the
job explicitly depend on the fedora33 job so that it isn't blocked by a
failing windows job, which causes docs-tarball to fail.

- - - - -
3c48e12a by Matthew Pickering at 2022-04-09T07:40:28-04:00
ci: Remove doc-tarball dependency from perf and perf-nofib jobs

These don't depend on the contents of the tarball so we can run them
straight after the fedora33 job finishes.

- - - - -
27362265 by Matthew Pickering at 2022-04-09T07:41:04-04:00
Bump deepseq to 1.4.7.0

Updates deepseq submodule

Fixes #20653

- - - - -
dcf30da8 by Joachim Breitner at 2022-04-09T13:02:19-04:00
Drop the app invariant

previously, GHC had the "let/app-invariant" which said that the RHS of a
let or the argument of an application must be of lifted type or ok for
speculation. We want this on let to freely float them around, and we
wanted that on app to freely convert between the two (e.g. in
beta-reduction or inlining).

However, the app invariant meant that simple code didn't stay simple and
this got in the way of rules matching. By removing the app invariant,
this thus fixes #20554.

The new invariant is now called "let-can-float invariant", which is
hopefully easier to guess its meaning correctly.

Dropping the app invariant means that everywhere where we effectively do
beta-reduction (in the two simplifiers, but also in `exprIsConApp_maybe`
and other innocent looking places) we now have to check if the argument
must be evaluated (unlifted and side-effecting), and analyses have to be
adjusted to the new semantics of `App`.

Also, `LetFloats` in the simplifier can now also carry such non-floating
bindings.

The fix for DmdAnal, refine by Sebastian, makes functions with unlifted
arguments strict in these arguments, which changes some signatures.

This causes some extra calls to `exprType` and `exprOkForSpeculation`,
so some perf benchmarks regress a bit (while others improve).

Metric Decrease:
    T9020
Metric Increase:
    LargeRecord
    T12545
    T15164
    T16577
    T18223
    T5642
    T9961

Co-authored-by: Sebastian Graf <sebastian.graf at kit.edu>

- - - - -
6c6c5379 by Philip Hazelden at 2022-04-09T13:02:59-04:00
Add functions traceWith, traceShowWith, traceEventWith.

As discussed at
https://github.com/haskell/core-libraries-committee/issues/36

- - - - -
8fafacf7 by Philip Hazelden at 2022-04-09T13:02:59-04:00
Add tests for several trace functions.

- - - - -
20bbf3ac by Philip Hazelden at 2022-04-09T13:02:59-04:00
Update changelog.

- - - - -
47d18b0b by Andreas Klebinger at 2022-04-09T13:03:35-04:00
Add regression test for #19569

- - - - -
5f8d6e65 by sheaf at 2022-04-09T13:04:14-04:00
Fix missing SymCo in pushCoercionIntoLambda

There was a missing SymCo in pushCoercionIntoLambda. Currently
this codepath is only used with rewrite rules, so this bug managed
to slip by, but trying to use pushCoercionIntoLambda in other contexts
revealed the bug.

- - - - -
20eca489 by Vladislav Zavialov at 2022-04-09T13:04:50-04:00
Refactor: simplify lexing of the dot

Before this patch, the lexer did a truly roundabout thing with the dot:

1. look up the varsym in reservedSymsFM and turn it into ITdot
2. under OverloadedRecordDot, turn it into ITvarsym
3. in varsym_(prefix|suffix|...) turn it into ITvarsym, ITdot, or
   ITproj, depending on extensions and whitespace

Turns out, the last step is sufficient to handle the dot correctly.
This patch removes the first two steps.

- - - - -
5440f63e by Hécate Moonlight at 2022-04-12T11:11:06-04:00
Document that DuplicateRecordFields doesn't tolerates ambiguous fields

Fix #19891

- - - - -
0090ad7b by Sebastian Graf at 2022-04-12T11:11:42-04:00
Eta reduction based on evaluation context (#21261)

I completely rewrote our Notes surrounding eta-reduction. The new entry point is
`Note [Eta reduction makes sense]`.

Then I went on to extend the Simplifier to maintain an evaluation context in the
form of a `SubDemand` inside a `SimplCont`. That `SubDemand` is useful for doing
eta reduction according to `Note [Eta reduction based on evaluation context]`,
which describes how Demand analysis, Simplifier and `tryEtaReduce` interact to
facilitate eta reduction in more scenarios.

Thus we fix #21261.

ghc/alloc perf marginally improves (-0.0%). A medium-sized win is when compiling
T3064 (-3%). It seems that haddock improves by 0.6% to 1.0%, too.

Metric Decrease:
    T3064

- - - - -
4d2ee313 by Sebastian Graf at 2022-04-12T17:54:57+02:00
Specialising through specialised method calls (#19644)

In #19644, we discovered that the ClassOp/DFun rules from
Note [ClassOp/DFun selection] inhibit transitive specialisation in a scenario
like
```
class C a where m :: Show b => a -> b -> ...; n :: ...
instance C Int where m = ... -- $cm :: Show b => Int -> b -> ...
f :: forall a b. (C a, Show b) => ...
f $dC $dShow = ... m @a $dC @b $dShow ...
main = ... f @Int @Bool ...
```
After we specialise `f` for `Int`, we'll see `m @a $dC @b $dShow` in the body of
`$sf`. But before this patch, Specialise doesn't apply the ClassOp/DFun rule to
rewrite to a call of the instance method for `C Int`, e.g., `$cm @Bool $dShow`.
As a result, Specialise couldn't further specialise `$cm` for `Bool`.

There's a better example in `Note [Specialisation modulo dictionary selectors]`.

This patch enables proper Specialisation, as follows:

1. In the App case of `specExpr`, try to apply the CalssOp/DictSel rule on the
   head of the application
2. Attach an unfolding to freshly-bound dictionary ids such as `$dC` and
   `$dShow` in `bindAuxiliaryDict`

NB: Without (2), (1) would be pointless, because `lookupRule` wouldn't be able
to look into the RHS of `$dC` to see the DFun.

(2) triggered #21332, because the Specialiser floats around dictionaries without
accounting for them in the `SpecEnv`'s `InScopeSet`, triggering a panic when
rewriting dictionary unfoldings.

Fixes #19644 and #21332.

- - - - -
b06f4f47 by Sebastian Graf at 2022-04-12T17:54:58+02:00
Specialise: Check `typeDeterminesValue` before specialising on an interesting dictionary

I extracted the checks from `Note [Type determines value]` into its own
function, so that we share the logic properly. Then I made sure that we
actually call `typeDeterminesValue` everywhere we check for `interestingDict`.

- - - - -
a42dbc55 by Matthew Pickering at 2022-04-13T06:24:52-04:00
Refine warning about defining rules in SAFE modules

This change makes it clear that it's the definition rather than any
usage which is a problem, and that rules defined in other modules will
still be  used to do rewrites.

Fixes #20923

- - - - -
df893f66 by Andreas Klebinger at 2022-04-14T08:18:37-04:00
StgLint: Lint constructor applications and strict workers for arity.

This will mean T9208 when run with lint will return a lint error instead
of resulting in a panic.

Fixes #21117

- - - - -
426ec446 by sheaf at 2022-04-14T08:19:16-04:00
Hadrian: use a set to keep track of ways

The order in which ways are provided doesn't matter,
so we use a data structure with the appropriate semantics to
represent ways.

Fixes #21378

- - - - -
7c639b9a by Dylan Yudaken at 2022-04-15T13:55:59-04:00
Only enable PROF_SPIN in DEBUG

- - - - -
96b9e5ea by Ben Gamari at 2022-04-15T13:56:34-04:00
testsuite: Add test for #21390

- - - - -
d8392f6a by Ben Gamari at 2022-04-15T13:56:34-04:00
rts: Ensure that the interpreter doesn't disregard tags

Previously the interpreter's handling of `RET_BCO` stack frames would
throw away the tag of the returned closure. This resulted in #21390.

- - - - -
83c67f76 by Alan Zimmerman at 2022-04-20T11:49:28-04:00
Add -dkeep-comments flag to keep comments in the parser

This provides a way to set the Opt_KeepRawTokenStream from the command
line, allowing exact print annotation users to see exactly what is
produced for a given parsed file, when used in conjunction with
-ddump-parsed-ast

Discussed in #19706, but this commit does not close the issue.

- - - - -
a5ea65c9 by Krzysztof Gogolewski at 2022-04-20T11:50:04-04:00
Remove LevityInfo

Every Id was storing a boolean whether it could be levity-polymorphic.
This information is no longer needed since representation-checking
has been moved to the typechecker.

- - - - -
49bd7584 by Andreas Klebinger at 2022-04-20T11:50:39-04:00
Fix a shadowing issue in StgUnarise.

For I assume performance reasons we don't record no-op replacements
during unarise. This lead to problems with code like this:

    f = \(Eta_B0 :: VoidType) x1 x2 ->
       ... let foo = \(Eta_B0 :: LiftedType) -> g x y Eta_B0
           in ...

Here we would record the outer Eta_B0 as void rep, but would not
shadow Eta_B0 inside `foo` because this arg is single-rep and so
doesn't need to replaced. But this means when looking at occurence
sites we would check the env and assume it's void rep based on the
entry we made for the (no longer in scope) outer `Eta_B0`.

Fixes #21396 and the ticket has a few more details.

- - - - -
0c02c919 by Simon Peyton Jones at 2022-04-20T11:51:15-04:00
Fix substitution in bindAuxiliaryDict

In GHC.Core.Opt.Specialise.bindAuxiliaryDict we were unnecessarily
calling `extendInScope` to bring into scope variables that were
/already/ in scope.  Worse, GHC.Core.Subst.extendInScope strangely
deleted the newly-in-scope variables from the substitution -- and that
was fatal in #21391.

I removed the redundant calls to extendInScope.

More ambitiously, I changed GHC.Core.Subst.extendInScope (and cousins)
to stop deleting variables from the substitution.  I even changed the
names of the function to extendSubstInScope (and cousins) and audited
all the calls to check that deleting from the substitution was wrong.
In fact there are very few such calls, and they are all about
introducing a fresh non-in-scope variable.  These are "OutIds"; it is
utterly wrong to mess with the "InId" substitution.

I have not added a Note, because I'm deleting wrong code, and it'd be
distracting to document a bug.

- - - - -
0481a6af by Cheng Shao at 2022-04-21T11:06:06+00:00
[ci skip] Drop outdated TODO in RtsAPI.c

- - - - -
1e062a8a by Ben Gamari at 2022-04-22T02:12:59-04:00
rts: Introduce ip_STACK_FRAME

While debugging it is very useful to be able to determine whether a
given info table is a stack frame or not. We have spare bits in the
closure flags array anyways, use one for this information.

- - - - -
08a6a2ee by Ben Gamari at 2022-04-22T02:12:59-04:00
rts: Mark closureFlags array as const

- - - - -
8f9b8282 by Krzysztof Gogolewski at 2022-04-22T02:13:35-04:00
Check for zero-bit types in sizeExpr

Fixes #20940

Metric Decrease:
    T18698a

- - - - -
fcf22883 by Andreas Klebinger at 2022-04-22T02:14:10-04:00
Include the way string in the file name for dump files.

This can be disabled by `-fno-dump-with-ways` if not desired.
Finally we will be able to look at both profiled and non-profiled dumps
when compiling with dump flags and we compile in both ways.

- - - - -
252394ce by Andrew Lelechenko at 2022-04-22T02:14:48-04:00
Improve error messages from GHC.IO.Encoding.Failure

- - - - -
250f57c1 by Andrew Lelechenko at 2022-04-22T02:14:48-04:00
Update test baselines to match new error messages from GHC.IO.Encoding.Failure

- - - - -
5ac9b321 by Ben Gamari at 2022-04-22T02:15:25-04:00
get-win32-tarballs: Drop i686 architecture

As of #18487 we no longer support 32-bit Windows.

Fixes #21372.

- - - - -
dd5fecb0 by Ben Gamari at 2022-04-22T02:16:00-04:00
hadrian: Don't rely on xxx not being present in installation path

Previously Hadrian's installation makefile would assume that the string
`xxx` did not appear in the installation path. This would of course
break for some users.

Fixes #21402.

- - - - -
09e98859 by Ben Gamari at 2022-04-22T02:16:35-04:00
testsuite: Ensure that GHC doesn't pick up environment files

Here we set GHC_ENVIRONMENT="-" to ensure that GHC invocations of tests
don't pick up a user's local package environment.

Fixes #21365.

Metric Decrease:
    T10421
    T12234
    T12425
    T13035
    T16875
    T9198

- - - - -
76bb8cb3 by Ben Gamari at 2022-04-22T02:17:11-04:00
hadrian: Enable -dlint in devel2 flavour

Previously only -dcore-lint was enabled.

- - - - -
f435d55f by Krzysztof Gogolewski at 2022-04-22T08:00:18-04:00
Fixes to rubbish literals

* In CoreToStg, the application 'RUBBISH[rep] x' was simplified
  to 'RUBBISH[rep]'. But it is possible that the result of the function
  is represented differently than the function.
* In Unarise, 'LitRubbish (primRepToType prep)'
  is incorrect: LitRubbish takes a RuntimeRep such as IntRep,
  while primRepToType returns a type such as Any @(TYPE IntRep). Use
  primRepToRuntimeRep instead.
  This code is never run in the testsuite.
* In StgToByteCode, all rubbish literals were assumed to be boxed.
  This code predates representation-polymorphic RubbishLit and I think
  it was not updated.

I don't have a testcase for any of those issues, but the code looks
wrong.

- - - - -
93c16b94 by sheaf at 2022-04-22T08:00:57-04:00
Relax "suppressing errors" assert in reportWanteds

The assertion in reportWanteds that we aren't suppressing all the
Wanted constraints was too strong: it might be the case that we are
inside an implication, and have already reported an unsolved Wanted
from outside the implication. It is possible that all Wanteds inside
the implication have been rewritten by the outer Wanted, so we shouldn't
throw an assertion failure in that case.

Fixes #21405

- - - - -
78ec692d by Andreas Klebinger at 2022-04-22T08:01:33-04:00
Mention new MutableByteArray# wrapper in base changelog.

- - - - -
56d7cb53 by Eric Lindblad at 2022-04-22T14:13:32-04:00
unlist announce

- - - - -
1e4dcf23 by sheaf at 2022-04-22T14:14:12-04:00
decideMonoTyVars: account for CoVars in candidates

The "candidates" passed to decideMonoTyVars can contain coercion holes.
This is because we might well decide to quantify over some unsolved
equality constraints, as long as they are not definitely insoluble.

In that situation, decideMonoTyVars was passing a set of type variables
that was not closed over kinds to closeWrtFunDeps, which was tripping
up an assertion failure.

Fixes #21404

- - - - -
2c541f99 by Simon Peyton Jones at 2022-04-22T14:14:47-04:00
Improve floated dicts in Specialise

Second fix to #21391.  It turned out that we missed calling
bringFloatedDictsIntoScope when specialising imports, which
led to the same bug as before.

I refactored to move that call to a single place, in specCalls,
so we can't forget it.

This meant making `FloatedDictBinds` into its own type, pairing
the dictionary bindings themselves with the set of their binders.
Nicer this way.

- - - - -
0950e2c4 by Ben Gamari at 2022-04-25T10:18:17-04:00
hadrian: Ensure that --extra-lib-dirs are used

Previously we only took `extraLibDirs` and friends from the package
description, ignoring any contribution from the `LocalBuildInfo`. Fix
this.

Fixes #20566.

- - - - -
53cc93ae by Ben Gamari at 2022-04-25T10:18:17-04:00
hadrian: Drop redundant include directories

The package-specific include directories in
Settings.Builders.Common.cIncludeDirs are now redundant since they now
come from Cabal.

Closes #20566.

- - - - -
b2721819 by Ben Gamari at 2022-04-25T10:18:17-04:00
hadrian: Clean up handling of libffi dependencies

- - - - -
18e5103f by Ben Gamari at 2022-04-25T10:18:17-04:00
testsuite: More robust library way detection

Previously `test.mk` would try to determine whether the dynamic,
profiling, and vanilla library ways are available by searching for
`PrimOpWrappers.{,dyn_,p_}hi` in directory reported by `ghc-pkg field
ghc-prim library-dirs`. However, this is extremely fragile as
there is no guarantee that there is only one library directory. To
handle the case of multiple `library-dirs` correct we would
have to carry out the delicate task of tokenising the directory list (in
shell, no less).

Since this isn't a task that I am eager to solve, I have rather moved
the detection logic into the testsuite driver and instead perform a test
compilation in each of the ways. This should be more robust than the
previous approach.

I stumbled upon this while fixing #20579.

- - - - -
6c7a4913 by Ben Gamari at 2022-04-25T10:18:17-04:00
testsuite: Cabalify ghc-config

To ensure that the build benefits from Hadrian's usual logic for building
packages, avoiding #21409.

Closes #21409.

- - - - -
9af091f7 by Ben Gamari at 2022-04-25T10:18:53-04:00
rts: Factor out built-in GC roots

- - - - -
e7c4719d by Ben Gamari at 2022-04-25T10:18:54-04:00
Ensure that wired-in exception closures aren't GC'd

As described in Note [Wired-in exceptions are not CAFfy], a small set of
built-in exception closures get special treatment in the code generator,
being declared as non-CAFfy despite potentially containing CAF
references. The original intent of this treatment for the RTS to then
add StablePtrs for each of the closures, ensuring that they are not
GC'd. However, this logic was not applied consistently and eventually
removed entirely in 951c1fb0. This lead to #21141.

Here we fix this bug by reintroducing the StablePtrs and document the
status quo.

Closes #21141.

- - - - -
9587726f by Ben Gamari at 2022-04-25T10:18:54-04:00
testsuite: Add testcase for #21141

- - - - -
cb71226f by Ben Gamari at 2022-04-25T10:19:29-04:00
Drop dead code in GHC.Linker.Static.linkBinary'

Previously we supported building statically-linked executables using
libtool. However, this was dropped in
91262e75dd1d80f8f28a3922934ec7e59290e28c in favor of using ar/ranlib
directly. Consequently we can drop this logic.

Fixes #18826.

- - - - -
9420d26b by Ben Gamari at 2022-04-25T10:19:29-04:00
Drop libtool path from settings file

GHC no longers uses libtool for linking and therefore this is no longer
necessary.

- - - - -
41cf758b by Ben Gamari at 2022-04-25T10:19:29-04:00
Drop remaining vestiges of libtool

Drop libtool logic from gen-dll, allowing us to drop the remaining logic
from the `configure` script.

Strangely, this appears to reliably reduce compiler allocations of
T16875 on Windows.

Closes #18826.

Metric Decrease:
    T16875

- - - - -
e09afbf2 by Ben Gamari at 2022-04-25T10:20:05-04:00
rts: Refactor handling of dead threads' stacks

This fixes a bug that @JunmingZhao42 and I noticed while working on her
MMTK port. Specifically, in stg_stop_thread we used stg_enter_info as a
sentinel at the tail of a stack after a thread has completed. However,
stg_enter_info expects to have a two-field payload, which we do not
push. Consequently, if the GC ends up somehow the stack it will attempt
to interpret data past the end of the stack as the frame's fields,
resulting in unsound behavior.

To fix this I eliminate this hacky use of `stg_stop_thread` and instead
introduce a new stack frame type, `stg_dead_thread_info`. Not only does
this eliminate the potential for the previously mentioned memory
unsoundness but it also more clearly captures the intended structure of
the dead threads' stacks.

- - - - -
e76705cf by Ben Gamari at 2022-04-25T10:20:05-04:00
rts: Improve documentation of closure types

Also drops the unused TREC_COMMITTED transaction state.

- - - - -
f2c08124 by Andrew Lelechenko at 2022-04-25T10:20:44-04:00
Document behaviour of RULES with KnownNat

- - - - -
360dc2bc by Li-yao Xia at 2022-04-25T19:13:06+00:00
Fix rendering of liftA haddock

- - - - -
16df6058 by Ben Gamari at 2022-04-27T10:02:25-04:00
testsuite: Report minimum and maximum stat changes

As suggested in #20733.

- - - - -
e39cab62 by Fabian Thorand at 2022-04-27T10:03:03-04:00
Defer freeing of mega block groups

Solves the quadratic worst case performance of freeing megablocks that
was described in issue #19897.

During GC runs, we now keep a secondary free list for megablocks that is
neither sorted, nor coalesced. That way, free becomes an O(1) operation
at the expense of not being able to reuse memory for larger allocations.
At the end of a GC run, the secondary free list is sorted and then
merged into the actual free list in a single pass.

That way, our worst case performance is O(n log(n)) rather than O(n^2).

We postulate that temporarily losing coalescense during a single GC run
won't have any adverse effects in practice because:

- We would need to release enough memory during the GC, and then after
  that (but within the same GC run) allocate a megablock group of more
  than one megablock. This seems unlikely, as large objects are not
  copied during GC, and so we shouldn't need such large allocations
  during a GC run.
- Allocations of megablock groups of more than one megablock are rare.
  They only happen when a single heap object is large enough to require
  that amount of space. Any allocation areas that are supposed to hold
  more than one heap object cannot use megablock groups, because only
  the first megablock of a megablock group has valid `bdescr`s. Thus,
  heap object can only start in the first megablock of a group, not in
  later ones.

- - - - -
5de6be0c by Fabian Thorand at 2022-04-27T10:03:03-04:00
Add note about inefficiency in returnMemoryToOS

- - - - -
8bef471a by sheaf at 2022-04-27T10:03:43-04:00
Ensure that Any is Boxed in FFI imports/exports

We should only accept the type `Any` in foreign import/export
declarations when it has type `Type` or `UnliftedType`.
This patch adds a kind check, and a special error message triggered by
occurrences of `Any` in foreign import/export declarations at other
kinds.

Fixes #21305

- - - - -
ba3d4e1c by Ben Gamari at 2022-04-27T10:04:19-04:00
Basic response file support

Here we introduce support into our command-line parsing infrastructure
and driver for handling gnu-style response file arguments,
typically used to work around platform command-line length limitations.

Fixes #16476.

- - - - -
3b6061be by Ben Gamari at 2022-04-27T10:04:19-04:00
testsuite: Add test for #16476

- - - - -
75bf1337 by Matthew Pickering at 2022-04-27T10:04:55-04:00
ci: Fix cabal-reinstall job

It's quite nice we can do this by mostly deleting code

Fixes #21373

- - - - -
2c00d904 by Matthew Pickering at 2022-04-27T10:04:55-04:00
ci: Add test to check that release jobs have profiled libs

- - - - -
50d78d3b by Matthew Pickering at 2022-04-27T10:04:55-04:00
ci: Explicitly handle failures in test_hadrian

We also disable the stage1 testing which is broken.

Related to #21072

- - - - -
2dcdf091 by Matthew Pickering at 2022-04-27T10:04:55-04:00
ci: Fix shell command

- - - - -
55c84123 by Matthew Pickering at 2022-04-27T10:04:55-04:00
bootstrap: Add bootstrapping files for ghc-9_2_2

Fixes #21373

- - - - -
c7ee0be6 by Matthew Pickering at 2022-04-27T10:04:55-04:00
ci: Add linting job which checks authors are not GHC CI

- - - - -
23aad124 by Adam Sandberg Ericsson at 2022-04-27T10:05:31-04:00
rts: state explicitly what evacuate and scavange mean in the copying gc

- - - - -
318e0005 by Ben Gamari at 2022-04-27T10:06:07-04:00
rts/eventlog: Don't attempt to flush if there is no writer

If the user has not configured a writer then there is nothing to flush.

- - - - -
ee11d043 by Ben Gamari at 2022-04-27T10:06:07-04:00
Enable eventlog support in all ways by default

Here we deprecate the eventlogging RTS ways and instead enable eventlog
support in the remaining ways. This simplifies packaging and reduces GHC
compilation times (as we can eliminate two whole compilations of the RTS)
while simplifying the end-user story. The trade-off is a small increase
in binary sizes in the case that the user does not want eventlogging
support, but we think that this is a fine trade-off.

This also revealed a latent RTS bug: some files which included `Cmm.h`
also assumed that it defined various macros which were in fact defined
by `Config.h`, which `Cmm.h` did not include. Fixing this in turn
revealed that `StgMiscClosures.cmm` failed to import various spinlock
statistics counters, as evidenced by the failed unregisterised build.

Closes #18948.

- - - - -
a2e5ab70 by Andreas Klebinger at 2022-04-27T10:06:43-04:00
Change `-dsuppress-ticks` to only suppress non-code ticks.

This means cost centres and coverage ticks will still be present in
output. Makes using -dsuppress-all more convenient when looking at
profiled builds.

- - - - -
ec9d7e04 by Ben Gamari at 2022-04-27T10:07:21-04:00
Bump text submodule.

This should fix #21352

- - - - -
c3105be4 by Andrew Lelechenko at 2022-04-27T10:08:01-04:00
Documentation for setLocaleEncoding

- - - - -
7f618fd3 by sheaf at 2022-04-27T10:08:40-04:00
Update docs for change to type-checking plugins

There was no mention of the changes to type-checking plugins
in the 9.4.1 notes, and the extending_ghc documentation contained
a reference to an outdated type.

- - - - -
4419dd3a by Adam Sandberg Ericsson at 2022-04-27T10:09:18-04:00
rts: add some more documentation to StgWeak closure type

- - - - -
5a7f0dee by Matthew Pickering at 2022-04-27T10:09:54-04:00
Give Cmm files fake ModuleNames which include full filepath

This fixes the initialisation functions when using -prof or
-finfo-table-map.

Fixes #21370

- - - - -
81cf52bb by sheaf at 2022-04-27T10:10:33-04:00
Mark GHC.Prim.PtrEq as Unsafe

This module exports unsafe pointer equality operations,
so we accordingly mark it as Unsafe.

Fixes #21433

- - - - -
f6a8185d by Ben Gamari at 2022-04-28T09:10:31+00:00
testsuite: Add performance test for #14766

This distills the essence of the Sigs.hs program found in the ticket.

- - - - -
c7a3dc29 by Douglas Wilson at 2022-04-28T18:54:44-04:00
hadrian: Add Monoid instance to Way

- - - - -
654bafea by Douglas Wilson at 2022-04-28T18:54:44-04:00
hadrian: Enrich flavours to build profiled/debugged/threaded ghcs per stage

- - - - -
4ad559c8 by Douglas Wilson at 2022-04-28T18:54:44-04:00
hadrian: add debug_ghc and debug_stage1_ghc flavour transformers

- - - - -
f9728fdb by Douglas Wilson at 2022-04-28T18:54:44-04:00
hadrian: Don't pass -rtsopts when building libraries

- - - - -
769279e6 by Matthew Pickering at 2022-04-28T18:54:44-04:00
testsuite: Fix calculation about whether to pass -dynamic to compiler

- - - - -
da8ae7f2 by Ben Gamari at 2022-04-28T18:55:20-04:00
hadrian: Clean up flavour transformer definitions

Previously the `ipe` and `omit_pragmas` transformers were hackily
defined using the textual key-value syntax. Fix this.

- - - - -
61305184 by Ben Gamari at 2022-04-28T18:55:56-04:00
Bump process submodule

- - - - -
a8c99391 by sheaf at 2022-04-28T18:56:37-04:00
Fix unification of ConcreteTvs, removing IsRefl#

This patch fixes the unification of concrete type variables.
The subtlety was that unifying concrete metavariables is more subtle
than other metavariables, as decomposition is possible. See the Note
[Unifying concrete metavariables], which explains how we unify a
concrete type variable with a type 'ty' by concretising 'ty', using
the function 'GHC.Tc.Utils.Concrete.concretise'.

This can be used to perform an eager syntactic check for concreteness,
allowing us to remove the IsRefl# special predicate. Instead of emitting
two constraints `rr ~# concrete_tv` and `IsRefl# rr concrete_tv`, we
instead concretise 'rr'. If this succeeds we can fill 'concrete_tv',
and otherwise we directly emit an error message to the typechecker
environment instead of deferring. We still need the error message
to be passed on (instead of directly thrown), as we might benefit from
further unification in which case we will need to zonk the stored types.
To achieve this, we change the 'wc_holes' field of 'WantedConstraints'
to 'wc_errors', which stores general delayed errors. For the moement,
a delayed error is either a hole, or a syntactic equality error.

hasFixedRuntimeRep_MustBeRefl is now hasFixedRuntimeRep_syntactic, and
hasFixedRuntimeRep has been refactored to directly return the most
useful coercion for PHASE 2 of FixedRuntimeRep.

This patch also adds a field ir_frr to the InferResult datatype,
holding a value of type Maybe FRROrigin. When this value is not
Nothing, this means that we must fill the ir_ref field with a type
which has a fixed RuntimeRep.
When it comes time to fill such an ExpType, we ensure that the type
has a fixed RuntimeRep by performing a representation-polymorphism
check with the given FRROrigin
This is similar to what we already do to ensure we fill an Infer
ExpType with a type of the correct TcLevel.
This allows us to properly perform representation-polymorphism checks
on 'Infer' 'ExpTypes'.

The fillInferResult function had to be moved to GHC.Tc.Utils.Unify
to avoid a cyclic import now that it calls hasFixedRuntimeRep.

This patch also changes the code in matchExpectedFunTys to make use
of the coercions, which is now possible thanks to the previous change.
This implements PHASE 2 of FixedRuntimeRep in some situations.
For example, the test cases T13105 and T17536b are now both accepted.

Fixes #21239 and #21325

-------------------------
Metric Decrease:
    T18223
    T5631
-------------------------

- - - - -
43bd897d by Simon Peyton Jones at 2022-04-28T18:57:13-04:00
Add INLINE pragmas for Enum helper methods

As #21343 showed, we need to be super-certain that the "helper
methods" for Enum instances are actually inlined or specialised.

I also tripped over this when I discovered that numericEnumFromTo
and friends had no pragmas at all, so their performance was very
fragile.  If they weren't inlined, all bets were off.  So I've added
INLINE pragmas for them too.

See new Note [Inline Enum method helpers] in GHC.Enum.

I also expanded Note [Checking for INLINE loop breakers] in
GHC.Core.Lint to explain why an INLINE function might temporarily
be a loop breaker -- this was the initial bug report in #21343.

Strangely we get a 16% runtime allocation decrease in
perf/should_run/T15185, but only on i386.  Since it moves in the right
direction I'm disinclined to investigate, so I'll accept it.

Metric Decrease:
    T15185

- - - - -
ca1434e3 by Ben Gamari at 2022-04-28T18:57:49-04:00
configure: Bump GHC version to 9.5

Bumps haddock submodule.

- - - - -
292e3971 by Teo Camarasu at 2022-04-28T18:58:28-04:00
add since annotation for GHC.Stack.CCS.whereFrom

- - - - -
905206d6 by Tamar Christina at 2022-04-28T22:19:34-04:00
winio: add support to iserv.

- - - - -
d182897e by Tamar Christina at 2022-04-28T22:19:34-04:00
Remove unused line
- - - - -
22cf4698 by Matthew Pickering at 2022-04-28T22:20:10-04:00
Revert "rts: Refactor handling of dead threads' stacks"

This reverts commit e09afbf2a998beea7783e3de5dce5dd3c6ff23db.

- - - - -
8ed57135 by Matthew Pickering at 2022-04-29T04:11:29-04:00
Provide efficient unionMG function for combining two module graphs.

This function is used by API clients (hls).

This supercedes !6922

- - - - -
0235ff02 by Ben Gamari at 2022-04-29T04:12:05-04:00
Bump bytestring submodule

Update to current `master`.

- - - - -
01988418 by Matthew Pickering at 2022-04-29T04:12:05-04:00
testsuite: Normalise package versions in UnusedPackages test

- - - - -
724d0dc0 by Matthew Pickering at 2022-04-29T08:59:42+00:00
testsuite: Deduplicate ways correctly

This was leading to a bug where we would run a profasm test twice which
led to invalid junit.xml which meant the test results database was not
being populated for the fedora33-perf job.

- - - - -
5630dde6 by Ben Gamari at 2022-04-29T13:06:20-04:00
rts: Refactor handling of dead threads' stacks

This fixes a bug that @JunmingZhao42 and I noticed while working on her
MMTK port. Specifically, in stg_stop_thread we used stg_enter_info as a
sentinel at the tail of a stack after a thread has completed. However,
stg_enter_info expects to have a two-field payload, which we do not
push. Consequently, if the GC ends up somehow the stack it will attempt
to interpret data past the end of the stack as the frame's fields,
resulting in unsound behavior.

To fix this I eliminate this hacky use of `stg_stop_thread` and instead
introduce a new stack frame type, `stg_dead_thread_info`. Not only does
this eliminate the potential for the previously mentioned memory
unsoundness but it also more clearly captures the intended structure of
the dead threads' stacks.

- - - - -
0cdef807 by parsonsmatt at 2022-04-30T16:51:12-04:00
Add a note about instance visibility across component boundaries

In principle, the *visible* instances are
* all instances defined in a prior top-level declaration group
  (see docs on `newDeclarationGroup`), or
* all instances defined in any module transitively imported by the
  module being compiled

However, actually searching all modules transitively below the one being
compiled is unreasonably expensive, so `reifyInstances` will report only the
instance for modules that GHC has had some cause to visit during this
compilation.  This is a shortcoming: `reifyInstances` might fail to report
instances for a type that is otherwise unusued, or instances defined in a
different component.  You can work around this shortcoming by explicitly importing the modules
whose instances you want to be visible. GHC issue #20529
has some discussion around this.

Fixes #20529

- - - - -
e2dd884a by Ryan Scott at 2022-04-30T16:51:47-04:00
Make mkFunCo take AnonArgFlags into account

Previously, whenever `mkFunCo` would produce reflexive coercions, it would
use `mkVisFunTy` to produce the kind of the coercion. However, `mkFunCo` is
also used to produce coercions between types of the form `ty1 => ty2` in
certain places. This has the unfortunate side effect of causing the type of
the coercion to appear as `ty1 -> ty2` in certain error messages, as spotted
in #21328.

This patch address this by changing replacing the use of `mkVisFunTy` with
`mkFunctionType` in `mkFunCo`. `mkFunctionType` checks the kind of `ty1` and
makes the function arrow `=>` instead of `->` if `ty1` has kind `Constraint`,
so this should always produce the correct `AnonArgFlag`. As a result, this
patch fixes part (2) of #21328.

This is not the only possible way to fix #21328, as the discussion on that
issue lists some possible alternatives. Ultimately, it was concluded that the
alternatives would be difficult to maintain, and since we already use
`mkFunctionType` in `coercionLKind` and `coercionRKind`, using `mkFunctionType`
in `mkFunCo` is consistent with this choice. Moreover, using `mkFunctionType`
does not regress the performance of any test case we have in GHC's test suite.

- - - - -
170da54f by Ben Gamari at 2022-04-30T16:52:27-04:00
Convert More Diagnostics (#20116)

Replaces uses of `TcRnUnknownMessage` with proper diagnostics
constructors.

- - - - -
39edc7b4 by Marius Ghita at 2022-04-30T16:53:06-04:00
Update user guide example rewrite rules formatting

Change the rewrite rule examples to include a space between the
composition of `f` and `g` in the map rewrite rule examples.

Without this change, if the user has locally enabled the extension
OverloadedRecordDot the copied example will result in a compile time
error that `g` is not a field of `f`.

```
    • Could not deduce (GHC.Records.HasField "g" (a -> b) (a1 -> b))
        arising from selecting the field ‘g’
```

- - - - -
2e951e48 by Adam Sandberg Ericsson at 2022-04-30T16:53:42-04:00
ghc-boot: export typesynonyms from GHC.Utils.Encoding

This makes the Haddocks easier to understand.

- - - - -
d8cbc77e by Adam Sandberg Ericsson at 2022-04-30T16:54:18-04:00
users guide: add categories to some flags

- - - - -
d0f14fad by Chris Martin at 2022-04-30T16:54:57-04:00
hacking guide: mention the core libraries committee

- - - - -
34b28200 by Matthew Pickering at 2022-04-30T16:55:32-04:00
Revert "Make the specialiser handle polymorphic specialisation"

This reverts commit ef0135934fe32da5b5bb730dbce74262e23e72e8.

See ticket #21229

-------------------------
Metric Decrease:
    T15164
Metric Increase:
    T13056
-------------------------

- - - - -
ee891c1e by Matthew Pickering at 2022-04-30T16:55:32-04:00
Add test for T21229

- - - - -
ab677cc8 by Matthew Pickering at 2022-04-30T16:56:08-04:00
Hadrian: Update README about the flavour/testsuite contract

There have been a number of tickets about non-tested flavours not
passing the testsuite.. this is expected and now noted in the
documentation. You use other flavours to run the testsuite at your own
risk.

Fixes #21418

- - - - -
b57b5b92 by Ben Gamari at 2022-04-30T16:56:44-04:00
rts/m32: Fix assertion failure

This fixes an assertion failure in the m32 allocator due to the
imprecisely specified preconditions of `m32_allocator_push_filled_list`.
Specifically, the caller must ensure that the page type is set to filled
prior to calling `m32_allocator_push_filled_list`.

While this issue did result in an assertion failure in the debug RTS,
the issue is in fact benign.

- - - - -
a7053a6c by sheaf at 2022-04-30T16:57:23-04:00
Testsuite driver: don't crash on empty metrics

The testsuite driver crashed when trying to display minimum/maximum
performance changes when there are no metrics (i.e. there is
no baseline available). This patch fixes that.

- - - - -
636f7c62 by Andreas Klebinger at 2022-05-01T22:21:17-04:00
StgLint: Check that functions are applied to compatible runtime reps

We use compatibleRep to compare reps, and avoid checking functions with
levity polymorphic types because of #21399.

- - - - -
60071076 by Hécate Moonlight at 2022-05-01T22:21:55-04:00
Add documentation to the ByteArray# primetype.

close #21417

- - - - -
2b2e3020 by Andreas Klebinger at 2022-05-01T22:22:31-04:00
exprIsDeadEnd: Use isDeadEndAppSig to check if a function appliction is bottoming.

We used to check the divergence and that the number of arguments > arity.
But arity zero represents unknown arity so this was subtly broken for a long time!

We would check if the saturated function diverges, and if we applied >=arity arguments.
But for unknown arity functions any number of arguments is >=idArity.

This fixes #21440.

- - - - -
4eaf0f33 by Eric Lindblad at 2022-05-01T22:23:11-04:00
typos
- - - - -
fc58df90 by Niklas Hambüchen at 2022-05-02T08:59:27+00:00
libraries/base: docs: Explain relationshipt between `finalizeForeignPtr` and `*Conc*` creation

Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/21420

- - - - -
3e400f20 by Krzysztof Gogolewski at 2022-05-02T18:29:23-04:00
Remove obsolete code in CoreToStg

Note [Nullary unboxed tuple] was removed in e9e61f18a548b70693f4.
This codepath is tested by T15696_3.

- - - - -
4a780928 by Krzysztof Gogolewski at 2022-05-02T18:29:24-04:00
Fix several note references

- - - - -
15ffe2b0 by Sebastian Graf at 2022-05-03T20:11:51+02:00
Assume at least one evaluation for nested SubDemands (#21081, #21133)

See the new `Note [SubDemand denotes at least one evaluation]`.

A demand `n :* sd` on a let binder `x=e` now means

> "`x` was evaluated `n` times and in any program trace it is evaluated, `e` is
>  evaluated deeply in sub-demand `sd`."

The "any time it is evaluated" premise is what this patch adds. As a result,
we get better nested strictness. For example (T21081)
```hs
f :: (Bool, Bool) -> (Bool, Bool)
f pr = (case pr of (a,b) -> a /= b, True)
-- before: <MP(L,L)>
-- after:  <MP(SL,SL)>

g :: Int -> (Bool, Bool)
g x = let y = let z = odd x in (z,z) in f y
```
The change in demand signature "before" to "after" allows us to case-bind `z`
here.

Similarly good things happen for the `sd` in call sub-demands `Cn(sd)`, which
allows for more eta-reduction (which is only sound with `-fno-pedantic-bottoms`,
albeit).

We also fix #21085, a surprising inconsistency with `Poly` to `Call` sub-demand
expansion.

In an attempt to fix a regression caused by less inlining due to eta-reduction
in T15426, I eta-expanded the definition of `elemIndex` and `elemIndices`, thus
fixing #21345 on the go.

The main point of this patch is that it fixes #21081 and #21133.

Annoyingly, I discovered that more precise demand signatures for join points can
transform a program into a lazier program if that join point gets floated to the
top-level, see #21392. There is no simple fix at the moment, but !5349 might.
Thus, we accept a ~5% regression in `MultiLayerModulesTH_OneShot`, where #21392
bites us in `addListToUniqDSet`. T21392 reliably reproduces the issue.

Surprisingly, ghc/alloc perf on Windows improves much more than on other jobs, by
0.4% in the geometric mean and by 2% in T16875.

Metric Increase:
    MultiLayerModulesTH_OneShot
Metric Decrease:
    T16875

- - - - -
948c7e40 by Andreas Klebinger at 2022-05-04T09:57:34-04:00
CoreLint - When checking for levity polymorphism look through more ticks.

For expressions like `(scc<cc_name> primOp#) arg1` we should also look
at arg1 to determine if we call primOp# at a fixed runtime rep.

This is what corePrep already does but CoreLint didn't yet. This patch
will bring them in sync in this regard.

It also uses tickishFloatable in CorePrep instead of CorePrep having
it's own slightly differing definition of when a tick is floatable.

- - - - -
85bc73bd by Alexis King at 2022-05-04T09:58:14-04:00
genprimopcode: Support Unicode properly

- - - - -
063d485e by Alexis King at 2022-05-04T09:58:14-04:00
genprimopcode: Replace LaTeX documentation syntax with Haddock

The LaTeX documentation generator does not seem to have been used for
quite some time, so the LaTeX-to-Haddock preprocessing step has become a
pointless complication that makes documenting the contents of GHC.Prim
needlessly difficult. This commit replaces the LaTeX syntax with the
Haddock it would have been converted into, anyway, though with an
additional distinction: it uses single quotes in places to instruct
Haddock to generate hyperlinks to bindings. This improves the quality of
the generated output.

- - - - -
d61f7428 by Ben Gamari at 2022-05-04T09:58:50-04:00
rts/ghc.mk: Only build StgCRunAsm.S when it is needed

Previously the make build system unconditionally included StgCRunAsm.S
in the link, meaning that the RTS would require an execstack
unnecessarily.

Fixes #21478.

- - - - -
934a90dd by Simon Peyton Jones at 2022-05-04T16:15:34-04:00
Improve error reporting in generated code

Our error reporting in generated code (via desugaring before
typechecking) only worked when the generated code was just a simple
call. This commit makes it work in nested cases.

- - - - -
445d3657 by sheaf at 2022-05-04T16:16:12-04:00
Ensure Any is not levity-polymorphic in FFI

The previous patch forgot to account for a type such as

  Any @(TYPE (BoxedRep l))

for a quantified levity variable l.

- - - - -
ddd2591c by Ben Gamari at 2022-05-04T16:16:48-04:00
Update supported LLVM versions

Pull forward minimum version to match 9.2.

(cherry picked from commit c26faa54c5fbe902ccb74e79d87e3fa705e270d1)

- - - - -
f9698d79 by Ben Gamari at 2022-05-04T16:16:48-04:00
testsuite/T7275: Use sed -r

Darwin requires the `-r` flag to be compatible with GNU sed.

(cherry picked from commit 512338c8feec96c38ef0cf799f3a01b77c967c56)

- - - - -
8635323b by Ben Gamari at 2022-05-04T16:16:48-04:00
gitlab-ci: Use ld.lld on ARMv7/Linux

Due to #16177.

Also cleanup some code style issues.

(cherry picked from commit cc1c3861e2372f464bf9e3c9c4d4bd83f275a1a6)

- - - - -
4f6370c7 by Ben Gamari at 2022-05-04T16:16:48-04:00
gitlab-ci: Always preserve artifacts, even in failed jobs

(cherry picked from commit fd08b0c91ea3cab39184f1b1b1aafcd63ce6973f)

- - - - -
6f662754 by Ben Gamari at 2022-05-04T16:16:48-04:00
configure: Make sphinx version check more robust

It appears that the version of sphinx shipped on CentOS 7
reports a version string of `Sphinx v1...`. Accept the `v`.

(cherry picked from commit a9197a292fd4b13308dc6664c01351c7239357ed)

- - - - -
0032dc38 by Ben Gamari at 2022-05-04T16:16:48-04:00
gitlab-ci: Don't run make job in release pipelines

(cherry picked from commit 16d6a8ff011f2194485387dcca1c00f8ddcdbdeb)

- - - - -
27f9aab3 by Ben Gamari at 2022-05-04T16:16:48-04:00
gitlab/ci: Fix name of bootstrap compiler directory

Windows binary distributions built with Hadrian have a target platform
suffix in the name of their root directory. Teach `ci.sh` about this
fact.

(cherry picked from commit df5752f39671f6d04d8cd743003469ae5eb67235)

- - - - -
b528f0f6 by Krzysztof Gogolewski at 2022-05-05T09:05:43-04:00
Fix several note references, part 2

- - - - -
691aacf6 by Adam Sandberg Ericsson at 2022-05-05T09:06:19-04:00
adjustors: align comment about number of integer like arguments with implementation for Amd4+MinGW implementation

- - - - -
f050557e by Simon Jakobi at 2022-05-05T12:47:32-04:00
Remove two uses of IntMap.size

IntMap.size is O(n). The new code should be slightly more efficient.

The transformation of GHC.CmmToAsm.CFG.calcFreqs.nodeCount can be
described formally as the transformation:

    (\sum_{0}^{n-1} \sum_{0}^{k-1} i_nk) + n
    ==>
    (\sum_{0}^{n-1} 1 + \sum_{0}^{k-1} i_nk)

- - - - -
7da90ae3 by Tom Ellis at 2022-05-05T12:48:09-04:00
Explain that 'fail s' should run in the monad itself

- - - - -
610d0283 by Matthew Craven at 2022-05-05T12:48:47-04:00
Add a test for the bracketing in rules for (^)

- - - - -
016f9ca6 by Matthew Craven at 2022-05-05T12:48:47-04:00
Fix broken rules for (^) with known small powers

- - - - -
9372aaab by Matthew Craven at 2022-05-05T12:48:47-04:00
Give the two T19569 tests different names

- - - - -
61901b32 by Andreas Klebinger at 2022-05-05T12:49:23-04:00
SpecConstr: Properly create rules for call patterns representing partial applications

The main fix is that in addVoidWorkerArg we now add the argument to the front.

This fixes #21448.

-------------------------
Metric Decrease:
    T16875
-------------------------

- - - - -
71278dc7 by Teo Camarasu at 2022-05-05T12:50:03-04:00
add since annotations for instances of ByteArray

- - - - -
962ff90b by sheaf at 2022-05-05T12:50:42-04:00
Start 9.6.1-notes

Updates the documentation notes to start tracking changes for
the 9.6.1 release (instead of 9.4).

- - - - -
aacb15a3 by Matthew Pickering at 2022-05-05T20:24:01-04:00
ci: Add job to check that jobs.yaml is up-to-date

There have been quite a few situations where jobs.yaml has been out of
date. It's better to add a CI job which checks that it's right.

We don't want to use a staged pipeline because it obfuscates the
structure of the pipeline.

- - - - -
be7102e5 by Ben Gamari at 2022-05-05T20:24:37-04:00
rts: Ensure that XMM registers are preserved on Win64

Previously we only preserved the bottom 64-bits of the callee-saved
128-bit XMM registers, in violation of the Win64 calling convention.
Fix this.

Fixes #21465.

- - - - -
73b22ff1 by Ben Gamari at 2022-05-05T20:24:37-04:00
testsuite: Add test for #21465

- - - - -
e2ae9518 by Ziyang Liu at 2022-05-06T19:22:22-04:00
Allow `let` just before pure/return in ApplicativeDo

The following is currently rejected:

```haskell
-- F is an Applicative but not a Monad
x :: F (Int, Int)
x = do
  a <- pure 0
  let b = 1
  pure (a, b)
```

This has bitten me multiple times. This MR contains a simple fix:
only allow a "let only" segment to be merged with the next (and not
the previous) segment. As a result, when the last one or more
statements before pure/return are `LetStmt`s, there will be one
more segment containing only those `LetStmt`s.

Note that if the `let` statement mentions a name bound previously, then
the program is still rejected, for example

```haskell
x = do
  a <- pure 0
  let b = a + 1
  pure (a, b)
```

or the example in #18559. To support this would require a more
complex approach, but this is IME much less common than the
previous case.

- - - - -
0415449a by Matthew Pickering at 2022-05-06T19:22:58-04:00
template-haskell: Fix representation of OPAQUE pragmas

There is a mis-match between the TH representation of OPAQUE pragmas and
GHC's internal representation due to how OPAQUE pragmas disallow phase
annotations. It seemed most in keeping to just fix the wired in name
issue by adding a special case to the desugaring of INLINE pragmas
rather than making TH/GHC agree with how the representation should look.

Fixes #21463

- - - - -
4de887e2 by Simon Peyton Jones at 2022-05-06T19:23:34-04:00
Comments only: Note [AppCtxt]

- - - - -
6e69964d by Matthew Pickering at 2022-05-06T19:24:10-04:00
Fix name of windows release bindist in doc-tarball job

- - - - -
ced4689e by Matthew Pickering at 2022-05-06T19:24:46-04:00
ci: Generate source-tarball in release jobs

We need to distribute the source tarball so we should generate it in the
CI pipeline.

- - - - -
3c91de21 by Rob at 2022-05-08T13:40:53+02:00
Change Specialise to use OrdList.

Fixes #21362

Metric Decrease:
    T16875

- - - - -
67072c31 by Simon Jakobi at 2022-05-08T12:23:43-04:00
Tweak GHC.CmmToAsm.CFG.delEdge

mapAdjust is more efficient than mapAlter.

- - - - -
374554bb by Teo Camarasu at 2022-05-09T16:24:37-04:00
Respect -po when heap profiling (#21446)

- - - - -
1ea414b6 by Teo Camarasu at 2022-05-09T16:24:37-04:00
add test case for #21446

- - - - -
c7902078 by Jens Petersen at 2022-05-09T16:25:17-04:00
avoid hadrian/bindist/Makefile install_docs error when --docs=none

When docs are disabled the bindist does not have docs/ and hence docs-utils/ is not generated.
Here we just test that docs-utils exists before attempting to install prologue.txt and gen_contents_index
to avoid the error:

/usr/bin/install: cannot stat 'docs-utils/prologue.txt': No such file or directory
make: *** [Makefile:195: install_docs] Error 1

- - - - -
158bd659 by Hécate Moonlight at 2022-05-09T16:25:56-04:00
Correct base's changelog for 4.16.1.0

This commit reaffects the new Ix instances of the foreign integral
types from base 4.17 to 4.16.1.0

closes #21529

- - - - -
a4fbb589 by Sylvain Henry at 2022-05-09T16:26:36-04:00
STG: only print cost-center if asked to

- - - - -
50347ded by Gergő Érdi at 2022-05-10T11:43:33+00:00
Improve "Glomming" note

Add a paragraph that clarifies that `occurAnalysePgm` finding out-of-order
references, and thus needing to glom, is not a cause for concern when its
root cause is rewrite rules.

- - - - -
df2e3373 by Eric Lindblad at 2022-05-10T20:45:41-04:00
update INSTALL
- - - - -
dcac3833 by Matthew Pickering at 2022-05-10T20:46:16-04:00
driver: Make -no-keep-o-files -no-keep-hi-files work in --make mode

It seems like it was just an oversight to use the incorrect DynFlags
(global rather than local) when implementing these two options. Using
the local flags allows users to request these intermediate files get
cleaned up, which works fine in --make mode because

1. Interface files are stored in memory
2. Object files are only cleaned at the end of session (after link)

Fixes #21349

- - - - -
35da81f8 by Ben Gamari at 2022-05-10T20:46:52-04:00
configure: Check for ffi.h

As noted in #21485, we checked for ffi.h yet then failed to throw an
error if it is missing.

Fixes #21485.

- - - - -
bdc99cc2 by Simon Peyton Jones at 2022-05-10T20:47:28-04:00
Check for uninferrable variables in tcInferPatSynDecl

This fixes #21479

See Note [Unquantified tyvars in a pattern synonym]

While doing this, I found that some error messages pointed at the
pattern synonym /name/, rather than the /declaration/ so I widened the
SrcSpan to encompass the declaration.

- - - - -
142a73d9 by Matthew Pickering at 2022-05-10T20:48:04-04:00
hadrian: Fix split-sections transformer

The splitSections transformer has been broken since -dynamic-too support
was implemented in hadrian. This is because we actually build the
dynamic way when building the dynamic way, so the predicate would always
fail.

The fix is to just always pass `split-sections` even if it doesn't do
anything for a particular way.

Fixes #21138

- - - - -
699f5935 by Matthew Pickering at 2022-05-10T20:48:04-04: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.

Closes #21135

- - - - -
21feece2 by Simon Peyton Jones at 2022-05-10T20:48:39-04:00
Use the wrapper for an unlifted binding

We assumed the wrapper for an unlifted binding is the identity,
but as #21516 showed, that is no always true.

Solution is simple: use it.

- - - - -
68d1ea5f by Matthew Pickering at 2022-05-10T20:49:15-04:00
docs: Fix path to GHC API docs in index.html

In the make bindists we generate documentation in docs/ghc-<VER> but the
hadrian bindists generate docs/ghc/ so the path to the GHC API docs was
wrong in the index.html file.

Rather than make the hadrian and make bindists the same it was easier to
assume that if you're using the mkDocs script that you're using hadrian
bindists.

Fixes #21509

- - - - -
9d8f44a9 by Matthew Pickering at 2022-05-10T20:49:51-04:00
hadrian: Don't pass -j to haddock

This has high potential for oversubcribing as many haddock jobs can be
spawned in parralel which will each request the given number of
capabilities.

Once -jsem is implemented (#19416, !5176) we can expose that haddock via
haddock and use that to pass a semaphore.

Ticket #21136

- - - - -
fec3e7aa by Matthew Pickering at 2022-05-10T20:50:27-04:00
hadrian: Only copy and install libffi headers when using in-tree libffi

When passed `--use-system-libffi` then we shouldn't copy and install the
headers from the system package. Instead the headers are expected to be
available as a runtime dependency on the users system.

Fixes #21485 #21487

- - - - -
5b791ed3 by mikael at 2022-05-11T08:22:13-04:00
FIND_LLVM_PROG: Recognize llvm suffix used by FreeBSD, ie llc10.

- - - - -
8500206e by ARATA Mizuki at 2022-05-11T08:22:57-04:00
Make floating-point abs IEEE 754 compliant

The old code used by via-C backend didn't handle the sign bit of NaN.

See #21043.

- - - - -
4a4c77ed by Alan Zimmerman at 2022-05-11T08:23:33-04:00
EPA: do statement with leading semicolon has wrong anchor

The code

    do; a <- doAsync; b

Generated an incorrect Anchor for the statement list that starts after
the first semicolon.

This commit fixes it.

Closes #20256

- - - - -
e3ca8dac by Simon Peyton Jones at 2022-05-11T08:24:08-04:00
Specialiser: saturate DFuns correctly

Ticket #21489 showed that the saturation mechanism for
DFuns (see Note Specialising DFuns) should use both
UnspecType and UnspecArg.

We weren't doing that; but this MR fixes that problem.

No test case because it's hard to tickle, but it showed up in
Gergo's work with GHC-as-a-library.

- - - - -
fcc7dc4c by Ben Gamari at 2022-05-11T20:05:41-04:00
gitlab-ci: Check for dynamic msys2 dependencies

Both #20878 and #21196 were caused by unwanted dynamic dependencies
being introduced by boot libraries. Ensure that we catch this in CI by
attempting to run GHC in an environment with a minimal PATH.

- - - - -
3c998f0d by Matthew Pickering at 2022-05-11T20:06:16-04:00
Add back Debian9 CI jobs

We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19
not being at EOL until April 2023 and they still need tinfo5.

Fixes #21469

- - - - -
dea9a3d9 by Ben Gamari at 2022-05-11T20:06:51-04:00
rts: Drop setExecutable

Since f6e366c058b136f0789a42222b8189510a3693d1 setExecutable has been
dead code. Drop it.

- - - - -
32cdf62d by Simon Peyton Jones at 2022-05-11T20:07:27-04:00
Add a missing guard in GHC.HsToCore.Utils.is_flat_prod_pat

This missing guard gave rise to #21519.

- - - - -
2c00a8d0 by Matthew Pickering at 2022-05-11T20:08:02-04:00
Add mention of -hi to RTS --help

Fixes #21546

- - - - -
a2dcad4e by Andre Marianiello at 2022-05-12T02:15:48+00:00
Decouple dynflags in Cmm parser (related to #17957)

- - - - -
3a022baa by Andre Marianiello at 2022-05-12T02:15:48+00:00
Remove Module argument from initCmmParserConfig

- - - - -
2fc8d76b by Andre Marianiello at 2022-05-12T02:15:48+00:00
Move CmmParserConfig and PDConfig into GHC.Cmm.Parser.Config

- - - - -
b8c5ffab by Andre Marianiello at 2022-05-12T18:13:55-04:00
Decouple dynflags in GHC.Core.Opt.Arity (related to #17957)

Metric Decrease:
    T16875

- - - - -
3bf938b6 by sheaf at 2022-05-12T18:14:34-04:00
Update extending_ghc for TcPlugin changes

The documentation still mentioned Derived constraints and
an outdated datatype TcPluginResult.

- - - - -
668a9ef4 by jackohughes at 2022-05-13T12:10:34-04:00
Fix printing of brackets in multiplicities (#20315)

Change mulArrow to allow for printing of correct application precedence
where necessary and update callers of mulArrow to reflect this.

As part of this, move mulArrow from GHC/Utils/Outputtable to GHC/Iface/Type.

Fixes #20315

- - - - -
30b8b7f1 by Ben Gamari at 2022-05-13T12:11:09-04:00
rts: Add debug output on ocResolve failure

This makes it easier to see how resolution failures nest.

- - - - -
53b3fa1c by Ben Gamari at 2022-05-13T12:11:09-04:00
rts/PEi386: Fix handling of weak symbols

Previously we would flag the symbol as weak but failed
to set its address, which must be computed from an "auxiliary"
symbol entry the follows the weak symbol.

Fixes #21556.

- - - - -
5678f017 by Ben Gamari at 2022-05-13T12:11:09-04:00
testsuite: Add tests for #21556

- - - - -
49af0e52 by Ben Gamari at 2022-05-13T22:23:26-04:00
Re-export augment and build from GHC.List

Resolves https://gitlab.haskell.org/ghc/ghc/-/issues/19127

- - - - -
aed356e1 by Simon Peyton Jones at 2022-05-13T22:24:02-04:00
Comments only around HsWrapper

- - - - -
27b90409 by Ben Gamari at 2022-05-16T08:30:44-04:00
hadrian: Introduce linting flavour transformer (+lint)

The linting flavour enables -dlint uniformly across anything build by
the stage1 compiler.

-dcmm-lint is not currently enabled because it fails on i386 (see #21563)

- - - - -
3f316776 by Matthew Pickering at 2022-05-16T08:30:44-04:00
hadrian: Uniformly enable -dlint with enableLinting transformer

This fixes some bugs where

* -dcore-lint was being passed when building stage1 libraries with the
  boot compiler
* -dcore-lint was not being passed when building executables.

Fixes #20135

- - - - -
3d74cfca by Andreas Klebinger at 2022-05-16T08:31:20-04:00
Make closure macros EXTERN_INLINE to make debugging easier

Implements #21424.

The RTS macros get_itbl and friends are extremely helpful during debugging.
However only a select few of those were available in the compiled RTS as actual symbols
as the rest were INLINE macros.

This commit marks all of them as EXTERN_INLINE. This will still inline them at use sites
but allow us to use their compiled counterparts during debugging.

This allows us to use things like `p get_fun_itbl(ptr)` in the gdb shell
since `get_fun_itbl` will now be available as symbol!

- - - - -
93153aab by Matthew Pickering at 2022-05-16T08:31:55-04:00
packaging: Introduce CI job for generating hackage documentation

This adds a CI job (hackage-doc-tarball) which generates the necessary
tarballs for uploading libraries and documentation to hackage. The
release script knows to download this folder and the upload script will
also upload the release to hackage as part of the release.

The `ghc_upload_libs` script is moved from ghc-utils into .gitlab/ghc_upload_libs

There are two modes, preparation and upload.

* The `prepare` mode takes a link to a bindist and creates a folder containing the
  source and doc tarballs ready to upload to hackage.
* The `upload` mode takes the folder created by prepare and performs the upload to
  hackage.

Fixes #21493

Related to #21512

- - - - -
65d31d05 by Simon Peyton Jones at 2022-05-16T15:32:50-04:00
Add arity to the INLINE pragmas for pattern synonyms

The lack of INLNE arity was exposed by #21531.  The fix is
simple enough, if a bit clumsy.

- - - - -
43c018aa by Krzysztof Gogolewski at 2022-05-16T15:33:25-04:00
Misc cleanup

- Remove groupWithName (unused)
- Use the RuntimeRepType synonym where possible
- Replace getUniqueM + mkSysLocalOrCoVar with mkSysLocalOrCoVarM

No functional changes.

- - - - -
8dfea078 by Pavol Vargovcik at 2022-05-16T15:34:04-04:00
TcPlugin: access to irreducible givens + fix passed ev_binds_var

- - - - -
fb579e15 by Ben Gamari at 2022-05-17T00:25:02-04:00
driver: Introduce pgmcxx

Here we introduce proper support for compilation of C++ objects. This
includes:

 * logic in `configure` to detect the C++ toolchain and propagating this
   information into the `settings` file
 * logic in the driver to use the C++ toolchain when compiling C++
   sources

- - - - -
43628ed4 by Ben Gamari at 2022-05-17T00:25:02-04:00
testsuite: Build T20918 with HC, not CXX

- - - - -
0ef249aa by Ben Gamari at 2022-05-17T00:25:02-04:00
Introduce package to capture dependency on C++ stdlib

Here we introduce a new "virtual" package into the initial package
database, `system-cxx-std-lib`. This gives users a convenient, platform
agnostic way to link against C++ libraries, addressing #20010.

Fixes #20010.

- - - - -
03efe283 by Ben Gamari at 2022-05-17T00:25:02-04:00
testsuite: Add tests for system-cxx-std-lib package

Test that we can successfully link against C++ code both in GHCi and
batch compilation.

See #20010

- - - - -
5f6527e0 by nineonine at 2022-05-17T00:25:38-04:00
OverloadedRecordFields: mention parent name in 'ambiguous occurrence' error for better disambiguation (#17420)

- - - - -
eccdb208 by Simon Peyton Jones at 2022-05-17T07:16:39-04:00
Adjust flags for pprTrace

We were using defaultSDocContext for pprTrace, which suppresses
lots of useful infomation. This small MR adds

   GHC.Utils.Outputable.traceSDocContext

and uses it for pprTrace and pprTraceUserWarning.

traceSDocContext is a global, and hence not influenced by flags,
but that seems unavoidable.  But I made the sdocPprDebug bit
controlled by unsafeHasPprDebug, since we have the latter for
exactly this purpose.

Fixes #21569

- - - - -
d2284c4c by Simon Peyton Jones at 2022-05-17T07:17:15-04:00
Fix bad interaction between withDict and the Specialiser

This MR fixes a bad bug, where the withDict was inlined too
vigorously, which in turn made the type-class Specialiser generate
a bogus specialisation, because it saw the same overloaded function
applied to two /different/ dictionaries.

Solution: inline `withDict` later.  See (WD8) of Note [withDict]
in GHC.HsToCore.Expr

See #21575, which is fixed by this change.

- - - - -
70f52443 by Matthew Pickering at 2022-05-17T07:17:50-04:00
Bump time submodule to 1.12.2

This bumps the time submodule to the 1.12.2 release.

Fixes #21571

- - - - -
2343457d by Vladislav Zavialov at 2022-05-17T07:18:26-04:00
Remove unused test files (#21582)

Those files were moved to the perf/ subtree in 11c9a469, and then
accidentally reintroduced in 680ef2c8.

- - - - -
cb52b4ae by Ben Gamari at 2022-05-17T16:00:14-04:00
CafAnal: Improve code clarity

Here we implement a few measures to improve the clarity of the CAF
analysis implementation. Specifically:

* Use CafInfo instead of Bool since the former is more descriptive
* Rename CAFLabel to CAFfyLabel, since not all CAFfyLabels are in fact
  CAFs
* Add numerous comments

- - - - -
b048a9f4 by Ben Gamari at 2022-05-17T16:00:14-04:00
codeGen: Ensure that static datacon apps are included in SRTs

When generating an SRT for a recursive group, GHC.Cmm.Info.Build.oneSRT
filters out recursive references, as described in Note [recursive SRTs].
However, doing so for static functions would be unsound, for the reason
described in Note [Invalid optimisation: shortcutting].

However, the same argument applies to static data constructor
applications, as we discovered in #20959. Fix this by ensuring that
static data constructor applications are included in recursive SRTs.

The approach here is not entirely satisfactory, but it is a starting
point.

Fixes #20959.

- - - - -
0e2d16eb by Matthew Pickering at 2022-05-17T16:00:50-04:00
Add test for #21558

This is now fixed on master and 9.2 branch.

Closes #21558

- - - - -
ef3c8d9e by Sylvain Henry at 2022-05-17T20:22:02-04:00
Don't store LlvmConfig into DynFlags

LlvmConfig contains information read from llvm-passes and llvm-targets
files in GHC's top directory. Reading these files is done only when
needed (i.e. when the LLVM backend is used) and cached for the whole
compiler session. This patch changes the way this is done:

- Split LlvmConfig into LlvmConfig and LlvmConfigCache

- Store LlvmConfigCache in HscEnv instead of DynFlags: there is no
  good reason to store it in DynFlags. As it is fixed per session, we
  store it in the session state instead (HscEnv).

- Initializing LlvmConfigCache required some changes to driver functions
  such as newHscEnv. I've used the opportunity to untangle initHscEnv
  from initGhcMonad (in top-level GHC module) and to move it to
  GHC.Driver.Main, close to newHscEnv.

- I've also made `cmmPipeline` independent of HscEnv in order to remove
  the call to newHscEnv in regalloc_unit_tests.

- - - - -
828fbd8a by Andreas Klebinger at 2022-05-17T20:22:38-04:00
Give all EXTERN_INLINE closure macros prototypes

- - - - -
cfc8e2e2 by Ben Gamari at 2022-05-19T04:57:51-04:00
base: Introduce [sg]etFinalizerExceptionHandler

This introduces a global hook which is called when an exception is
thrown during finalization.

- - - - -
372cf730 by Ben Gamari at 2022-05-19T04:57:51-04:00
base: Throw exceptions raised while closing finalized Handles

Fixes #21336.

- - - - -
3dd2f944 by Ben Gamari at 2022-05-19T04:57:51-04:00
testsuite: Add tests for #21336

- - - - -
297156e0 by Matthew Pickering at 2022-05-19T04:58:27-04:00
Add release flavour and use it for the release jobs

The release flavour is essentially the same as the perf flavour
currently but also enables `-haddock`. I have hopefully updated all the
relevant places where the `-perf` flavour was hardcoded.

Fixes #21486

- - - - -
a05b6293 by Matthew Pickering at 2022-05-19T04:58:27-04:00
ci: Don't build sphinx documentation on centos

The centos docker image lacks the sphinx builder so we disable building
sphinx docs for these jobs.

Fixes #21580

- - - - -
209d7c69 by Matthew Pickering at 2022-05-19T04:58:27-04:00
ci: Use correct syntax when args list is empty

This seems to fail on the ancient version of bash present on CentOS

- - - - -
02d16334 by Matthew Pickering at 2022-05-19T04:59:03-04:00
hadrian: Don't attempt to build dynamic profiling libraries

We only support building static profiling libraries, the transformer was
requesting things like a dynamic, threaded, debug, profiling RTS, which
we have never produced nor distributed.

Fixes #21567

- - - - -
35bdab1c by Ben Gamari at 2022-05-19T04:59:39-04:00
configure: Check CC_STAGE0 for --target support

We previously only checked the stage 1/2 compiler
for --target support. We got away with this for quite a while but it
eventually caught up with us in #21579, where `bytestring`'s new NEON
implementation was unbuildable on Darwin due to Rosetta's seemingly
random logic for determining which executable image to execute. This
lead to a confusing failure to build `bytestring`'s cbits, when `clang`
tried to compile NEON builtins while targetting x86-64.

Fix this by checking CC_STAGE0 for --target support.

Fixes #21579.

- - - - -
0ccca94b by Norman Ramsey at 2022-05-20T05:32:32-04:00
add dominator analysis of `CmmGraph`

This commit adds module `GHC.Cmm.Dominators`, which provides a wrapper
around two existing algorithms in GHC: the Lengauer-Tarjan dominator
analysis from the X86 back end and the reverse postorder ordering from
the Cmm Dataflow framework.  Issue #20726 proposes that we evaluate
some alternatives for dominator analysis, but for the time being, the
best path forward is simply to use the existing analysis on
`CmmGraph`s.

This commit addresses a bullet in #21200.

- - - - -
54f0b578 by Norman Ramsey at 2022-05-20T05:32:32-04:00
add dominator-tree function

- - - - -
05ed917b by Norman Ramsey at 2022-05-20T05:32:32-04:00
add HasDebugCallStack; remove unneeded extensions

- - - - -
0b848136 by Andreas Klebinger at 2022-05-20T05:32:32-04:00
document fields of `DominatorSet`
- - - - -
8a26e8d6 by Ben Gamari at 2022-05-20T05:33:08-04:00
nonmoving: Fix documentation of GC statistics fields

These were previously incorrect.

Fixes #21553.

- - - - -
c1e24e61 by Matthew Pickering at 2022-05-20T05:33:44-04:00
Remove pprTrace from pushCoercionIntoLambda (#21555)

This firstly caused spurious output to be emitted (as evidenced by
 #21555) but even worse caused a massive coercion to be attempted to be
 printed (> 200k terms) which would invariably eats up all the memory of
 your computer.

The good news is that removing this trace allows the program to compile
to completion, the bad news is that the program exhibits a core lint
error (on 9.0.2) but not any other releases it seems.

Fixes #21577 and #21555

- - - - -
a36d12ee by Zubin Duggal at 2022-05-20T10:44:35-04:00
docs: Fix LlvmVersion in manpage (#21280)

- - - - -
36b8a57c by Matthew Pickering at 2022-05-20T10:45:10-04:00
validate: Use $make rather than make

In the validate script we are careful to use the $make variable as this
stores whether we are using gmake, make, quiet mode etc. There was just
this one place where we failed to use it.

Fixes #21598

- - - - -
4aa3c5bd by Norman Ramsey at 2022-05-21T03:11:04+00:00
Change `Backend` type and remove direct dependencies

With this change, `Backend` becomes an abstract type
(there are no more exposed value constructors).
Decisions that were formerly made by asking "is the
current back end equal to (or different from) this named value
constructor?" are now made by interrogating the back end about
its properties, which are functions exported by `GHC.Driver.Backend`.

There is a description of how to migrate code using `Backend` in the
user guide.

Clients using the GHC API can find a backdoor to access the Backend
datatype in GHC.Driver.Backend.Internal.

Bumps haddock submodule.

Fixes #20927

- - - - -
ecf5f363 by Julian Ospald at 2022-05-21T12:51:16-04:00
Respect DESTDIR in hadrian bindist Makefile, fixes #19646

- - - - -
7edd991e by Julian Ospald at 2022-05-21T12:51:16-04:00
Test DESTDIR in test_hadrian()

- - - - -
ea895b94 by Matthew Pickering at 2022-05-22T21:57:47-04:00
Consider the stage of typeable evidence when checking stage restriction

We were considering all Typeable evidence to be "BuiltinInstance"s which
meant the stage restriction was going unchecked. In-fact, typeable has
evidence and so we need to apply the stage restriction.

This is
complicated by the fact we don't generate typeable evidence and the
corresponding DFunIds until after typechecking is concluded so we
introcue a new `InstanceWhat` constructor, BuiltinTypeableInstance which
records whether the evidence is going to be local or not.

Fixes #21547

- - - - -
ffbe28e5 by Dominik Peteler at 2022-05-22T21:58:23-04:00
Modularize GHC.Core.Opt.LiberateCase

Progress towards #17957

- - - - -
bc723ac2 by Simon Peyton Jones at 2022-05-23T17:09:34+01:00
Improve FloatOut and SpecConstr

This patch addresses a relatively obscure situation that arose
when chasing perf regressions in !7847, which itself is fixing

It does two things:

* SpecConstr can specialise on ($df d1 d2) dictionary arguments
* FloatOut no longer checks argument strictness

See Note [Specialising on dictionaries] in GHC.Core.Opt.SpecConstr.

A test case is difficult to construct, but it makes a big difference
in nofib/real/eff/VSM, at least when we have the patch for #21286
installed. (The latter stops worker/wrapper for dictionary arguments).

There is a spectacular, but slightly illusory, improvement in
runtime perf on T15426.  I have documented the specifics in
T15426 itself.

Metric Decrease:
    T15426

- - - - -
1a4195b0 by John Ericson at 2022-05-23T17:33:59-04:00
Make debug a `Bool` not an `Int` in `StgToCmmConfig`

We don't need any more resolution than this.

Rename the field to `stgToCmmEmitDebugInfo` to indicate it is no longer
conveying any "level" information.

- - - - -
e9fff12b by Alan Zimmerman at 2022-05-23T21:04:49-04:00
EPA : Remove duplicate comments in DataFamInstD

The code

  data instance Method PGMigration = MigrationQuery Query
                                   -- ^ Run a query against the database
                                   | MigrationCode (Connection -> IO (Either String ()))
                                   -- ^ Run any arbitrary IO code

Resulted in two instances of the "-- ^ Run a query against the database"
comment appearing in the Exact Print Annotations when it was parsed.

Ensure only one is kept.

Closes #20239

- - - - -
e2520df3 by Alan Zimmerman at 2022-05-23T21:05:27-04:00
EPA: Comment Order Reversed

Make sure comments captured in the exact print annotations are in
order of increasing location

Closes #20718

- - - - -
4b45fd72 by Teo Camarasu at 2022-05-24T10:49:13-04:00
Add test for T21455

- - - - -
e2cd1d43 by Teo Camarasu at 2022-05-24T10:49:13-04:00
Allow passing -po outside profiling way

Resolves #21455

- - - - -
3b8c413a by Greg Steuck at 2022-05-24T10:49:52-04:00
Fix haddock_*_perf tests on non-GNU-grep systems

Using regexp pattern requires `egrep` and straight up `+`.  The
haddock_parser_perf and haddock_renamer_perf tests now pass on
OpenBSD. They previously incorrectly parsed the files and awk
complained about invalid syntax.

- - - - -
1db877a3 by Ben Gamari at 2022-05-24T10:50:28-04:00
hadrian/bindist: Drop redundant include of install.mk

`install.mk` is already included by `config.mk`. Moreover, `install.mk`
depends upon `config.mk` to set `RelocatableBuild`, making this first
include incorrect.

- - - - -
f485d267 by Greg Steuck at 2022-05-24T10:51:08-04:00
Remove -z wxneeded for OpenBSD

With all the recent W^X fixes in the loader this workaround is not
necessary any longer. I verified that the only tests failing for me on
OpenBSD 7.1-current are the same (libc++ related) before and after
this commit (with --fast).

- - - - -
7c51177d by Andreas Klebinger at 2022-05-24T22:13:19-04:00
Use UnionListsOrd instead of UnionLists in most places.

This should get rid of most, if not all "Overlong lists" errors and fix #20016

- - - - -
81b3741f by Andreas Klebinger at 2022-05-24T22:13:55-04:00
Fix #21563 by using Word64 for 64bit shift code.

We use the 64bit shifts only on 64bit platforms. But we
compile the code always so compiling it on 32bit caused a
lint error. So use Word64 instead.

- - - - -
2c25fff6 by Zubin Duggal at 2022-05-24T22:14:30-04:00
Fix compilation with -haddock on GHC <= 8.10

-haddock on GHC < 9.0 is quite fragile and can result in obtuse parse errors
when it encounters invalid haddock syntax.

This has started to affect users since 297156e0b8053a28a860e7a18e1816207a59547b
enabled -haddock by default on many flavours.

Furthermore, since we don't test bootstrapping with 8.10 on CI, this problem
managed to slip throught the cracks.

- - - - -
cfb9faff by sheaf at 2022-05-24T22:15:12-04:00
Hadrian: don't add "lib" for relocatable builds

The conditional in hadrian/bindist/Makefile depended on the target OS,
but it makes more sense to use whether we are using a relocatable build.
(Currently this only gets set to true on Windows, but this ensures
that the logic stays correctly coupled.)

- - - - -
9973c016 by Andre Marianiello at 2022-05-25T01:36:09-04:00
Remove HscEnv from GHC.HsToCore.Usage (related to #17957)

Metric Decrease:
    T16875

- - - - -
2ff18e39 by sheaf at 2022-05-25T01:36:48-04:00
SimpleOpt: beta-reduce through casts

The simple optimiser would sometimes fail to
beta-reduce a lambda when there were casts
in between the lambda and its arguments.
This can cause problems because we rely on
representation-polymorphic lambdas getting
beta-reduced away (for example, those
that arise from newtype constructors with
representation-polymorphic arguments, with
UnliftedNewtypes).

- - - - -
e74fc066 by CarrieMY at 2022-05-25T16:43:03+02:00
Desugar RecordUpd in `tcExpr`

This patch typechecks record updates by desugaring them inside
the typechecker using the HsExpansion mechanism, and then typechecking
this desugared result.

Example:

    data T p q = T1 { x :: Int, y :: Bool, z :: Char }
               | T2 { v :: Char }
               | T3 { x :: Int }
               | T4 { p :: Float, y :: Bool, x :: Int }
               | T5

The record update `e { x=e1, y=e2 }` desugars as follows

  e { x=e1, y=e2 }
    ===>
  let { x' = e1; y' = e2 } in
  case e of
     T1 _ _ z -> T1 x' y' z
     T4 p _ _ -> T4 p y' x'

The desugared expression is put into an HsExpansion, and we typecheck
that.

The full details are given in Note [Record Updates] in GHC.Tc.Gen.Expr.

Fixes #2595 #3632 #10808 #10856 #16501 #18311 #18802 #21158 #21289

Updates haddock submodule

- - - - -
2b8bdab8 by Eric Lindblad at 2022-05-26T03:21:58-04:00
update README
- - - - -
3d7e7e84 by BinderDavid at 2022-05-26T03:22:38-04:00
Replace dead link in Haddock documentation of Control.Monad.Fail (fixes #21602)

- - - - -
ee61c7f9 by John Ericson at 2022-05-26T03:23:13-04:00
Add Haddocks for `WwOpts`

- - - - -
da5ccf0e by Dominik Peteler at 2022-05-26T03:23:13-04:00
Avoid global compiler state for `GHC.Core.Opt.WorkWrap`

Progress towards #17957

- - - - -
3bd975b4 by sheaf at 2022-05-26T03:23:52-04:00
Optimiser: avoid introducing bad rep-poly

The functions `pushCoValArg` and `pushCoercionIntoLambda` could
introduce bad representation-polymorphism. Example:

  type RR :: RuntimeRep
  type family RR where { RR = IntRep }
  type F :: TYPE RR
  type family F where  { F  = Int# }

  co = GRefl F (TYPE RR[0])
    :: (F :: TYPE RR)
    ~# (F |> TYPE RR[0] :: TYPE IntRep)

  f :: F -> ()

`pushCoValArg` would transform the unproblematic application

  (f |> (co -> <()>)) (arg :: F |> TYPE RR[0])

into an application in which the argument does not have a fixed
`RuntimeRep`:

  f ((arg |> sym co) :: (F :: TYPE RR))

- - - - -
b22979fb by Fraser Tweedale at 2022-05-26T06:14:51-04:00
executablePath test: fix file extension treatment

The executablePath test strips the file extension (if any) when
comparing the query result with the expected value.  This is to
handle platforms where GHC adds a file extension to the output
program file (e.g. .exe on Windows).

After the initial check, the file gets deleted (if supported).
However, it tries to delete the *stripped* filename, which is
incorrect.  The test currently passes only because Windows does not
allow deleting the program while any process created from it is
alive.

Make the test program correct in general by deleting the
*non-stripped* executable filename.

- - - - -
afde4276 by Fraser Tweedale at 2022-05-26T06:14:51-04:00
fix executablePath test for NetBSD

executablePath support for NetBSD was added in
a172be07e3dce758a2325104a3a37fc8b1d20c9c, but the test was not
updated.

Update the test so that it works for NetBSD.  This requires handling
some quirks:

- The result of getExecutablePath could include "./" segments.
  Therefore use System.FilePath.equalFilePath to compare paths.

- The sysctl(2) call returns the original executable name even after
  it was deleted.  Add `canQueryAfterDelete :: [FilePath]` and
  adjust expectations for the post-delete query accordingly.

Also add a note to the `executablePath` haddock to advise that
NetBSD behaves differently from other OSes when the file has been
deleted.

Also accept a decrease in memory usage for T16875.  On Windows, the
metric is -2.2% of baseline, just outside the allowed ±2%.  I don't
see how this commit could have influenced this metric, so I suppose
it's something in the CI environment.

Metric Decrease:
    T16875

- - - - -
d0e4355a by John Ericson at 2022-05-26T06:15:30-04:00
Factor out `initArityOps` to `GHC.Driver.Config.*` module

We want `DynFlags` only mentioned in `GHC.Driver`.

- - - - -
44bb7111 by romes at 2022-05-26T16:27:57+00:00
TTG: Move MatchGroup Origin field and MatchGroupTc to GHC.Hs

- - - - -
88e58600 by sheaf at 2022-05-26T17:38:43-04:00
Add tests for eta-expansion of data constructors

This patch adds several tests relating to the eta-expansion of
data constructors, including UnliftedNewtypes and DataTypeContexts.

- - - - -
d87530bb by Richard Eisenberg at 2022-05-26T23:20:14-04:00
Generalize breakTyVarCycle to work with TyFamLHS

The function breakTyVarCycle_maybe has been installed
in a dark corner of GHC to catch some gremlins (a.k.a.
occurs-check failures) who lurk
there. But it previously only caught gremlins of the
form (a ~ ... F a ...), where some of our intrepid users
have spawned gremlins of the form (G a ~ ... F (G a) ...).
This commit improves breakTyVarCycle_maybe (and renames
it to breakTyEqCycle_maybe) to catch the new gremlins.

Happily, the change is remarkably small.

The gory details are in Note [Type equality cycles].

Test cases: typecheck/should_compile/{T21515,T21473}.

- - - - -
ed37027f by Hécate Moonlight at 2022-05-26T23:20:52-04:00
[base] Fix the links in the Data.Data module

fix #21658
fix #21657
fix #21657

- - - - -
3bd7d5d6 by Krzysztof Gogolewski at 2022-05-27T16:44:48+02:00
Use a class to check validity of withDict

This moves handling of the magic 'withDict' function from the desugarer
to the typechecker. Details in Note [withDict].

I've extracted a part of T16646Fail to a separate file T16646Fail2,
because the new error in 'reify' hides the errors from 'f' and 'g'.

WithDict now works with casts, this fixes #21328.

Part of #19915

- - - - -
b54f6c4f by sheaf at 2022-05-28T21:00:09-04:00
Fix FreeVars computation for mdo

Commit acb188e0 introduced a regression in the computation of free
variables in mdo statements, as the logic in
GHC.Rename.Expr.segmentRecStmts was slightly different depending on
whether the recursive do block corresponded to an mdo statement or
a rec statment.

This patch restores the previous computation for mdo blocks.

Fixes #21654

- - - - -
0704295c by Matthew Pickering at 2022-05-28T21:00:45-04:00
T16875: Stabilise (temporarily) by increasing acceptance threshold

The theory is that on windows there is some difference in the
environment between pipelines on master and merge requests which affects
all tests equally but because T16875 barely allocates anything it is the
test which is affected the most.

See #21557

- - - - -
6341c8ed by Matthew Pickering at 2022-05-28T21:01:20-04:00
make: Fix make maintainer-clean deleting a file tracked by source control

Fixes #21659

- - - - -
fbf2f254 by Andrew Lelechenko at 2022-05-28T21:01:58-04:00
Expand documentation of hIsTerminalDevice

- - - - -
0092c67c by Teo Camarasu at 2022-05-29T12:25:39+00:00
export IsList from GHC.IsList

it is still re-exported from GHC.Exts

- - - - -
91396327 by Sylvain Henry at 2022-05-30T09:40:55-04:00
MachO linker: fix handling of ARM64_RELOC_SUBTRACTOR

ARM64_RELOC_SUBTRACTOR relocations are paired with an
AMR64_RELOC_UNSIGNED relocation to implement: addend + sym1 - sym2
The linker was doing it in two steps, basically:
  *addend <- *addend - sym2
  *addend <- *addend + sym1
The first operation was likely to overflow. For example when the
relocation target was 32-bit and both sym1/sym2 were 64-bit addresses.
With the small memory model, (sym1-sym2) would fit in 32 bits but
(*addend-sym2) may not.

Now the linker does it in one step:
  *addend <- *addend + sym1 - sym2

- - - - -
acc26806 by Sylvain Henry at 2022-05-30T09:40:55-04:00
Some fixes to SRT documentation

- reordered the 3 SRT implementation cases from the most general to the
  most specific one:
    USE_SRT_POINTER -> USE_SRT_OFFSET -> USE_INLINE_SRT_FIELD
- added requirements for each
- found and documented a confusion about "SRT inlining" not supported
  with MachO. (It is fixed in the following commit)

- - - - -
5878f439 by Sylvain Henry at 2022-05-30T09:40:55-04:00
Enable USE_INLINE_SRT_FIELD on ARM64

It was previously disabled because of:
- a confusion about "SRT inlining" (see removed comment in this commit)
- a linker bug (overflow) in the handling of ARM64_RELOC_SUBTRACTOR
  relocation: fixed by a previous commit.

- - - - -
59bd6159 by Matthew Pickering at 2022-05-30T09:41:39-04:00
ci: Make sure to exit promptly if `make install` fails.

Due to the vageries of bash, you have to explicitly handle the failure
and exit when in a function.

This failed to exit promptly when !8247 was failing.

See #21358 for the general issue

- - - - -
5a5a28da by Sylvain Henry at 2022-05-30T09:42:23-04:00
Split GHC.HsToCore.Foreign.Decl

This is preliminary work for JavaScript support. It's better to put the
code handling the desugaring of Prim, C and JavaScript declarations into
separate modules.

- - - - -
6f5ff4fa by Sylvain Henry at 2022-05-30T09:43:05-04:00
Bump hadrian to LTS-19.8 (GHC 9.0.2)

- - - - -
f2e70707 by Sylvain Henry at 2022-05-30T09:43:05-04:00
Hadrian: remove unused code

- - - - -
2f215b9f by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
Eta reduction with casted function

We want to be able to eta-reduce
   \x y. ((f x) |> co) y
by pushing 'co' inwards.  A very small change accommodates this
See Note [Eta reduction with casted function]

- - - - -
f4f6a87a by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
Do arity trimming at bindings, rather than in exprArity

Sometimes there are very large casts, and coercionRKind
can be slow.

- - - - -
610a2b83 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
Make findRhsArity take RecFlag

This avoids a fixpoint iteration for the common case of
non-recursive bindings.

- - - - -
80ba50c7 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
Comments and white space

- - - - -
0079171b by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
Make PrimOpId record levity

This patch concerns #20155, part (1)

The general idea is that since primops have curried bindings
(currently in PrimOpWrappers.hs) we don't need to eta-expand
them.  But we /do/ need to eta-expand the levity-polymorphic ones,
because they /don't/ have bindings.

This patch makes a start in that direction, by identifying the
levity-polymophic primops in the PrimOpId IdDetails constructor.

For the moment, I'm still eta-expanding all primops (by saying
that hasNoBinding returns True for all primops), because of the
bug reported in #20155.  But I hope that before long we can
tidy that up too, and remove the TEMPORARILY stuff in hasNoBinding.

- - - - -
6656f016 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00
A bunch of changes related to eta reduction

This is a large collection of changes all relating to eta
reduction, originally triggered by #18993, but there followed
a long saga.

Specifics:

* Move state-hack stuff from GHC.Types.Id (where it never belonged)
  to GHC.Core.Opt.Arity (which seems much more appropriate).

* Add a crucial mkCast in the Cast case of
  GHC.Core.Opt.Arity.eta_expand; helps with T18223

* Add clarifying notes about eta-reducing to PAPs.
  See Note [Do not eta reduce PAPs]

* I moved tryEtaReduce from GHC.Core.Utils to GHC.Core.Opt.Arity,
  where it properly belongs.  See Note [Eta reduce PAPs]

* In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, pull out the code for
  when eta-expansion is wanted, to make wantEtaExpansion, and all that
  same function in GHC.Core.Opt.Simplify.simplStableUnfolding.  It was
  previously inconsistent, but it's doing the same thing.

* I did a substantial refactor of ArityType; see Note [ArityType].
  This allowed me to do away with the somewhat mysterious takeOneShots;
  more generally it allows arityType to describe the function, leaving
  its clients to decide how to use that information.

  I made ArityType abstract, so that clients have to use functions
  to access it.

* Make GHC.Core.Opt.Simplify.Utils.rebuildLam (was stupidly called
  mkLam before) aware of the floats that the simplifier builds up, so
  that it can still do eta-reduction even if there are some floats.
  (Previously that would not happen.)  That means passing the floats
  to rebuildLam, and an extra check when eta-reducting (etaFloatOk).

* In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, make use of call-info
  in the idDemandInfo of the binder, as well as the CallArity info. The
  occurrence analyser did this but we were failing to take advantage here.

  In the end I moved the heavy lifting to GHC.Core.Opt.Arity.findRhsArity;
  see Note [Combining arityType with demand info], and functions
  idDemandOneShots and combineWithDemandOneShots.

  (These changes partly drove my refactoring of ArityType.)

* In GHC.Core.Opt.Arity.findRhsArity
  * I'm now taking account of the demand on the binder to give
    extra one-shot info.  E.g. if the fn is always called with two
    args, we can give better one-shot info on the binders
    than if we just look at the RHS.

  * Don't do any fixpointing in the non-recursive
    case -- simple short cut.

  * Trim arity inside the loop. See Note [Trim arity inside the loop]

* Make SimpleOpt respect the eta-reduction flag
  (Some associated refactoring here.)

* I made the CallCtxt which the Simplifier uses distinguish between
  recursive and non-recursive right-hand sides.
     data CallCtxt = ... | RhsCtxt RecFlag | ...
  It affects only one thing:
     - We call an RHS context interesting only if it is non-recursive
       see Note [RHS of lets] in GHC.Core.Unfold

* Remove eta-reduction in GHC.CoreToStg.Prep, a welcome simplification.
  See Note [No eta reduction needed in rhsToBody] in GHC.CoreToStg.Prep.

Other incidental changes

* Fix a fairly long-standing outright bug in the ApplyToVal case of
  GHC.Core.Opt.Simplify.mkDupableContWithDmds. I was failing to take the
  tail of 'dmds' in the recursive call, which meant the demands were All
  Wrong.  I have no idea why this has not caused problems before now.

* Delete dead function GHC.Core.Opt.Simplify.Utils.contIsRhsOrArg

Metrics: compile_time/bytes allocated
                               Test    Metric       Baseline      New value Change
---------------------------------------------------------------------------------------
MultiLayerModulesTH_OneShot(normal) ghc/alloc  2,743,297,692  2,619,762,992  -4.5% GOOD
                     T18223(normal) ghc/alloc  1,103,161,360    972,415,992 -11.9% GOOD
                      T3064(normal) ghc/alloc    201,222,500    184,085,360  -8.5% GOOD
                      T8095(normal) ghc/alloc  3,216,292,528  3,254,416,960  +1.2%
                      T9630(normal) ghc/alloc  1,514,131,032  1,557,719,312  +2.9%  BAD
                 parsing001(normal) ghc/alloc    530,409,812    525,077,696  -1.0%

geo. mean                                 -0.1%

Nofib:
       Program           Size    Allocs   Runtime   Elapsed  TotalMem
--------------------------------------------------------------------------------
         banner          +0.0%     +0.4%     -8.9%     -8.7%      0.0%
    exact-reals          +0.0%     -7.4%    -36.3%    -37.4%      0.0%
 fannkuch-redux          +0.0%     -0.1%     -1.0%     -1.0%      0.0%
           fft2          -0.1%     -0.2%    -17.8%    -19.2%      0.0%
          fluid          +0.0%     -1.3%     -2.1%     -2.1%      0.0%
             gg          -0.0%     +2.2%     -0.2%     -0.1%      0.0%
  spectral-norm          +0.1%     -0.2%      0.0%      0.0%      0.0%
            tak          +0.0%     -0.3%     -9.8%     -9.8%      0.0%
           x2n1          +0.0%     -0.2%     -3.2%     -3.2%      0.0%
--------------------------------------------------------------------------------
            Min          -3.5%     -7.4%    -58.7%    -59.9%      0.0%
            Max          +0.1%     +2.2%    +32.9%    +32.9%      0.0%
 Geometric Mean          -0.0%     -0.1%    -14.2%    -14.8%     -0.0%

Metric Decrease:
    MultiLayerModulesTH_OneShot
    T18223
    T3064
    T15185
    T14766
Metric Increase:
    T9630

- - - - -
cac8c7bb by Matthew Pickering at 2022-05-30T13:44:50-04:00
hadrian: Fix building from source-dist without alex/happy

This fixes two bugs which were adding dependencies on alex/happy when
building from a source dist.

* When we try to pass `--with-alex` and `--with-happy` to cabal when
  configuring but the builders are not set. This is fixed by making them
  optional.
* When we configure, cabal requires alex/happy because of the
  build-tool-depends fields. These are now made optional with a cabal
  flag (build-tool-depends) for compiler/hpc-bin/genprimopcode.

Fixes #21627

- - - - -
a96dccfe by Matthew Pickering at 2022-05-30T13:44:50-04:00
ci: Test the bootstrap without ALEX/HAPPY on path

- - - - -
0e5bb3a8 by Matthew Pickering at 2022-05-30T13:44:50-04:00
ci: Test bootstrapping in release jobs

- - - - -
d8901469 by Matthew Pickering at 2022-05-30T13:44:50-04:00
ci: Allow testing bootstrapping on MRs using the "test-bootstrap" label

- - - - -
18326ad2 by Matthew Pickering at 2022-05-30T13:45:25-04:00
rts: Remove explicit timescale for deprecating -h flag

We originally planned to remove the flag in 9.4 but there's actually no
great rush to do so and it's probably less confusing (forever) to keep
the message around suggesting an explicit profiling option.

Fixes #21545

- - - - -
eaaa1389 by Matthew Pickering at 2022-05-30T13:46:01-04:00
Enable -dlint in hadrian lint transformer

Now #21563 is fixed we can properly enable `-dlint` in CI rather than a
subset of the flags.

- - - - -
0544f114 by Ben Gamari at 2022-05-30T19:16:55-04:00
upload-ghc-libs: Allow candidate-only upload

- - - - -
83467435 by Sylvain Henry at 2022-05-30T19:17:35-04:00
Avoid using DynFlags in GHC.Linker.Unit (#17957)

- - - - -
5c4421b1 by Matthew Pickering at 2022-05-31T08:35:17-04:00
hadrian: Introduce new package database for executables needed to build stage0

These executables (such as hsc2hs) are built using the boot compiler and
crucially, most libraries from the global package database.

We also move other build-time executables to be built in this stage such
as linters which also cleans up which libraries end up in the global
package database. This allows us to remove hacks where linters-common is
removed from the package database when a bindist is created.

This fixes issues caused by infinite recursion due to bytestring adding
a dependency on template-haskell.

Fixes #21634

- - - - -
0dafd3e7 by Matthew Pickering at 2022-05-31T08:35:17-04:00
Build stage1 with -V as well

This helps tracing errors which happen when building stage1

- - - - -
15d42a7a by Matthew Pickering at 2022-05-31T08:35:52-04:00
Revert "packaging: Build perf builds with -split-sections"

This reverts commit 699f593532a3cd5ca1c2fab6e6e4ce9d53be2c1f.

Split sections causes segfaults in profiling way with old toolchains
(deb9) and on windows (#21670)

Fixes #21670

- - - - -
d4c71f09 by John Ericson at 2022-05-31T16:26:28+00:00
Purge `DynFlags` and `HscEnv` from some `GHC.Core` modules where it's not too hard

Progress towards #17957

Because of `CoreM`, I did not move the `DynFlags` and `HscEnv` to other
modules as thoroughly as I usually do. This does mean that risk of
`DynFlags` "creeping back in" is higher than it usually is.

After we do the same process to the other Core passes, and then figure
out what we want to do about `CoreM`, we can finish the job started
here.

That is a good deal more work, however, so it certainly makes sense to
land this now.

- - - - -
a720322f by romes at 2022-06-01T07:44:44-04:00
Restore Note [Quasi-quote overview]

- - - - -
392ce3fc by romes at 2022-06-01T07:44:44-04:00
Move UntypedSpliceFlavour from L.H.S to GHC.Hs

UntypedSpliceFlavour was only used in the client-specific `GHC.Hs.Expr`
but was defined in the client-independent L.H.S.Expr.

- - - - -
7975202b by romes at 2022-06-01T07:44:44-04:00
TTG: Rework and improve splices

This commit redefines the structure of Splices in the AST.

We get rid of `HsSplice` which used to represent typed and untyped
splices, quasi quotes, and the result of splicing either an expression,
a type or a pattern.

Instead we have `HsUntypedSplice` which models an untyped splice or a
quasi quoter, which works in practice just like untyped splices.

The `HsExpr` constructor `HsSpliceE` which used to be constructed with
an `HsSplice` is split into `HsTypedSplice` and `HsUntypedSplice`. The
former is directly constructed with an `HsExpr` and the latter now takes
an `HsUntypedSplice`.

Both `HsType` and `Pat` constructors `HsSpliceTy` and `SplicePat` now
take an `HsUntypedSplice` instead of a `HsSplice` (remember only
/untyped splices/ can be spliced as types or patterns).

The result of splicing an expression, type, or pattern is now
comfortably stored in the extension fields `XSpliceTy`, `XSplicePat`,
`XUntypedSplice` as, respectively, `HsUntypedSpliceResult (HsType
GhcRn)`, `HsUntypedSpliceResult (Pat GhcRn)`, and `HsUntypedSpliceResult
(HsExpr GhcRn)`

Overall the TTG extension points are now better used to
make invalid states unrepresentable and model the progression between
stages better.

See Note [Lifecycle of an untyped splice, and PendingRnSplice]
and Note [Lifecycle of an typed splice, and PendingTcSplice] for more
details.

Updates haddock submodule

Fixes #21263

-------------------------
Metric Decrease:
    hard_hole_fits
-------------------------

- - - - -
320270c2 by Matthew Pickering at 2022-06-01T07:44:44-04:00
Add test for #21619

Fixes #21619

- - - - -
ef7ddd73 by Pierre Le Marre at 2022-06-01T07:44:47-04:00
Pure Haskell implementation of GHC.Unicode

Switch to a pure Haskell implementation of base:GHC.Unicode, based on the implementation of the package unicode-data (https://github.com/composewell/unicode-data/).

Approved by CLC as per https://github.com/haskell/core-libraries-committee/issues/59#issuecomment-1132106691.

- Remove current Unicode cbits.
- Add generator for Unicode property files from Unicode Character Database.
- Generate internal modules.
- Update GHC.Unicode.
- Add unicode003 test for general categories and case mappings.
- Add Python scripts to check 'base' Unicode tests outputs and characters properties.

Fixes #21375

-------------------------
Metric Decrease:
    T16875
Metric Increase:
    T4029
    T18304
    haddock.base
-------------------------

- - - - -
514a6a28 by Eric Lindblad at 2022-06-01T07:44:51-04:00
typos

- - - - -
9004be3c by Matthew Pickering at 2022-06-01T07:44:52-04:00
source-dist: Copy in files created by ./boot

Since we started producing source dists with hadrian we stopped copying
in the files created by ./boot which adds a dependency on python3 and
autoreconf. This adds back in the files which were created by running
configure.

Fixes #21673 #21672 and #21626

- - - - -
a12a3cab by Matthew Pickering at 2022-06-01T07:44:52-04:00
ci: Don't try to run ./boot when testing bootstrap of source dist

- - - - -
e07f9059 by Shlomo Shuck at 2022-06-01T07:44:55-04:00
Language.Haskell.Syntax: Fix docs for PromotedConsT etc.

Fixes ghc/ghc#21675.

- - - - -
87295e6d by Ben Gamari at 2022-06-01T07:44:56-04:00
Bump bytestring, process, and text submodules

Metric Decrease:
    T5631
Metric Increase:
    T18223

(cherry picked from commit 55fcee30cb3281a66f792e8673967d64619643af)

- - - - -
24b5bb61 by Ben Gamari at 2022-06-01T07:44:56-04:00
Bump Cabal submodule

To current `master`.

(cherry picked from commit fbb59c212415188486aafd970eafef170516356a)

- - - - -
5433a35e by Matthew Pickering at 2022-06-01T22:26:30-04:00
hadrian/tool-args: Write output to intermediate file rather than via stdout

This allows us to see the output of hadrian while it is doing the setup.

- - - - -
468f919b by Matthew Pickering at 2022-06-01T22:27:10-04:00
Make -fcompact-unwind the default

This is a follow-up to !7247 (closed) making the inclusion of compact unwinding
sections the default.

Also a slight refactoring/simplification of the flag handling to add
-fno-compact-unwind.

- - - - -
819fdc61 by Zubin Duggal at 2022-06-01T22:27:47-04:00
hadrian bootstrap: add plans for 9.0.2 and 9.2.3

- - - - -
9fa790b4 by Zubin Duggal at 2022-06-01T22:27:47-04:00
ci: Add matrix for bootstrap sources

- - - - -
ce9f986b by John Ericson at 2022-06-02T15:42:59+00:00
HsToCore.Coverage: Improve haddocks

- - - - -
f065804e by John Ericson at 2022-06-02T15:42:59+00:00
Hoist auto `mkModBreaks` and `writeMixEntries` conditions to caller

No need to inline traversing a maybe for `mkModBreaks`. And better to
make each function do one thing and let the caller deside when than
scatter the decision making and make the caller seem more imperative.

- - - - -
d550d907 by John Ericson at 2022-06-02T15:42:59+00:00
Rename `HsToCore.{Coverage -> Ticks}`

The old name made it confusing why disabling HPC didn't disable the
entire pass. The name makes it clear --- there are other reasons to add
ticks in addition.

- - - - -
6520da95 by John Ericson at 2022-06-02T15:42:59+00:00
Split out `GHC.HsToCore.{Breakpoints,Coverage}` and use `SizedSeq`

As proposed in
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7508#note_432877 and
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7508#note_434676,
`GHC.HsToCore.Ticks` is about ticks, breakpoints are separate and
backend-specific (only for the bytecode interpreter), and mix entry
writing is just for HPC.

With this split we separate out those interpreter- and HPC-specific
its, and keep the main `GHC.HsToCore.Ticks` agnostic.

Also, instead of passing the reversed list and count around, we use
`SizedSeq` which abstracts over the algorithm. This is much nicer to
avoid noise and prevents bugs.

(The bugs are not just hypothetical! I missed up the reverses on an
earlier draft of this commit.)

- - - - -
1838c3d8 by Sylvain Henry at 2022-06-02T15:43:14+00:00
GHC.HsToCore.Breakpoints: Slightly improve perf

We have the length already, so we might as well use that rather than
O(n) recomputing it.

- - - - -
5a3fdcfd by John Ericson at 2022-06-02T15:43:59+00:00
HsToCore.Coverage: Purge DynFlags

Finishes what !7467 (closed) started.

Progress towards #17957

- - - - -
9ce9ea50 by HaskellMouse at 2022-06-06T09:50:00-04:00
Deprecate TypeInType extension

This commit fixes #20312
It deprecates "TypeInType" extension
according to the following proposal:
https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0083-no-type-in-type.rst

It has been already implemented.

The migration strategy:
 1. Disable TypeInType
 2. Enable both DataKinds and PolyKinds extensions

Metric Decrease:
    T16875

- - - - -
f2e037fd by Aaron Allen at 2022-06-06T09:50:39-04:00
Diagnostics conversions, part 6 (#20116)

Replaces uses of `TcRnUnknownMessage` with proper diagnostics
constructors in `GHC.Tc.Gen.Match`, `GHC.Tc.Gen.Pat`, and
`GHC.Tc.Gen.Sig`.

- - - - -
04209f2a by Simon Peyton Jones at 2022-06-06T09:51:15-04:00
Ensure floated dictionaries are in scope (again)

In the Specialiser, we missed one more call to
bringFloatedDictsIntoScope (see #21391).

This omission led to #21689. The problem is that the call
to `rewriteClassOps` needs to have in scope any dictionaries
floated out of the arguments we have just specialised.

Easy fix.

- - - - -
a7fece19 by John Ericson at 2022-06-07T05:04:22+00:00
Don't print the number of deps in count-deps tests

It is redundant information and a source of needless version control
conflicts when multiple MRs are changing the deps list.

Just printing the list and not also its length is fine.

- - - - -
a1651a3a by John Ericson at 2022-06-07T05:06:38+00:00
Core.Lint: Reduce `DynFlags` and `HscEnv`

Co-Authored-By: Andre Marianiello <andremarianiello at users.noreply.github.com>

- - - - -
56ebf9a5 by Andreas Klebinger at 2022-06-09T09:11:43-04:00
Fix a CSE shadowing bug.

We used to process the rhs of non-recursive bindings and their body
using the same env. If we had something like
    let x = ... x ...
this caused trouble because the two xs refer to different binders
but we would substitute both for a new binder x2 causing out of scope
errors.

We now simply use two different envs for the rhs and body in cse_bind.
It's all explained in the Note [Separate envs for let rhs and body]

Fixes #21685

- - - - -
28880828 by sheaf at 2022-06-09T09:12:19-04:00
Typecheck remaining ValArgs in rebuildHsApps

This patch refactors hasFixedRuntimeRep_remainingValArgs, renaming it
to tcRemainingValArgs. The logic is moved to rebuildHsApps, which
ensures consistent behaviour across tcApp and quickLookArg1/tcEValArg.

This patch also refactors the treatment of stupid theta for data
constructors, changing the place we drop stupid theta arguments
from dsConLike to mkDataConRep (now the datacon wrapper drops these
arguments).

We decided not to implement PHASE 2 of the FixedRuntimeRep plan for
these remaining ValArgs. Future directions are outlined on the wiki:
  https://gitlab.haskell.org/ghc/ghc/-/wikis/Remaining-ValArgs

Fixes #21544 and #21650

- - - - -
1fbba97b by Matthew Pickering at 2022-06-09T09:12:54-04:00
Add test for T21682

Fixes #21682

- - - - -
8727be73 by Andreas Klebinger at 2022-06-09T09:13:29-04:00
Document dataToTag# primop

- - - - -
7eab75bb by uhbif19 at 2022-06-09T20:22:47+03:00
Remove TcRnUnknownMessage usage from GHC.Rename.Env #20115

- - - - -
46d2fc65 by uhbif19 at 2022-06-09T20:24:40+03:00
Fix TcRnPragmaWarning meaning

- - - - -
69e72ecd by Matthew Pickering at 2022-06-09T19:07:01-04:00
getProcessCPUTime: Fix the getrusage fallback to account for system CPU time

clock_gettime reports the combined total or user AND system time so in
order to replicate it with getrusage we need to add both system and user
time together.

See https://stackoverflow.com/questions/7622371/getrusage-vs-clock-gettime

Some sample measurements when building Cabal with this patch

t1: rusage
t2: clock_gettime

t1: 62347518000; t2: 62347520873
t1: 62395687000; t2: 62395690171
t1: 62432435000; t2: 62432437313
t1: 62478489000; t2: 62478492465
t1: 62514990000; t2: 62514992534
t1: 62515479000; t2: 62515480327
t1: 62515485000; t2: 62515486344

Fixes #21656

- - - - -
722814ba by Yiyun Liu at 2022-06-10T21:23:03-04:00
Use <br> instead of newline character

- - - - -
dc202080 by Matthew Craven at 2022-06-13T14:07:12-04:00
Use (fixed_lev = True) in mkDataTyConRhs

- - - - -
ad70c621 by Matthew Pickering at 2022-06-14T08:40:53-04:00
hadrian: Fix testing stage1 compiler

There were various issues with testing the stage1 compiler..

1. The wrapper was not being built
2. The wrapper was picking up the stage0 package database and trying to
   load prelude from that.
3. The wrappers never worked on windows so just don't support that for
   now.

Fixes #21072

- - - - -
ac83899d by Ben Gamari at 2022-06-14T08:41:30-04:00
validate: Ensure that $make variable is set

Currently the `$make` variable is used without being set in `validate`'s
Hadrian path, which uses make to install the binary distribution. Fix
this.

Fixes #21687.

- - - - -
59bc6008 by John Ericson at 2022-06-15T18:05:35+00:00
CoreToStg.Prep: Get rid of `DynFlags` and `HscEnv`

The call sites in `Driver.Main` are duplicative, but this is good,
because the next step is to remove `InteractiveContext` from `Core.Lint`
into `Core.Lint.Interactive`.

Also further clean up `Core.Lint` to use a better configuration record
than the one we initially added.

- - - - -
aa9d9381 by Ben Gamari at 2022-06-15T20:33:04-04:00
hadrian: Run xattr -rc . on bindist tarball

Fixes #21506.

- - - - -
cdc75a1f by Ben Gamari at 2022-06-15T20:33:04-04:00
configure: Hide spurious warning from ld

Previously the check_for_gold_t22266 configure check could result in
spurious warnings coming from the linker being blurted to stderr.
Suppress these by piping stderr to /dev/null.

- - - - -
e128b7b8 by Ben Gamari at 2022-06-15T20:33:40-04:00
cmm: Add surface syntax for MO_MulMayOflo

- - - - -
bde65ea9 by Ben Gamari at 2022-06-15T20:34:16-04:00
configure: Don't attempt to override linker on Darwin

Configure's --enable-ld-override functionality is intended to ensure
that we don't rely on ld.bfd, which tends to be slow and buggy, on
Linux and Windows. However, on Darwin the lack of sensible package
management makes it extremely easy for users to have awkward mixtures of
toolchain components from, e.g., XCode, the Apple Command-Line Tools
package, and homebrew. This leads to extremely confusing problems
like #21712.

Here we avoid this by simply giving up on linker selection on Darwin
altogether. This isn't so bad since the Apple ld64 linker has decent
performance and AFAICT fairly reliable.

Closes #21712.

- - - - -
25b510c3 by Torsten Schmits at 2022-06-16T12:37:45-04:00
replace quadratic nub to fight byte code gen perf explosion

Despite this code having been present in the core-to-bytecode
implementation, I have observed it in the wild starting with 9.2,
causing enormous slowdown in certain situations.

My test case produces the following profiles:

Before:

```
	total time  =      559.77 secs   (559766 ticks @ 1000 us, 1 processor)
	total alloc = 513,985,665,640 bytes  (excludes profiling overheads)

COST CENTRE MODULE         SRC                                         %time %alloc  ticks     bytes

elem_by     Data.OldList   libraries/base/Data/OldList.hs:429:1-7       67.6   92.9  378282 477447404296
eqInt       GHC.Classes    libraries/ghc-prim/GHC/Classes.hs:275:8-14   12.4    0.0  69333        32
$c>>=       GHC.Data.IOEnv <no location info>                            6.9    0.6  38475 3020371232
```

After:

```
	total time  =       89.83 secs   (89833 ticks @ 1000 us, 1 processor)
	total alloc = 39,365,306,360 bytes  (excludes profiling overheads)

COST CENTRE           MODULE                SRC                                                                  %time %alloc  ticks     bytes

$c>>=                 GHC.Data.IOEnv        <no location info>                                                    43.6    7.7  39156 3020403424
doCase                GHC.StgToByteCode     compiler/GHC/StgToByteCode.hs:(805,1)-(1054,53)                        2.5    7.4   2246 2920777088

```

- - - - -
aa7e1f20 by Matthew Pickering at 2022-06-16T12:38:21-04:00
hadrian: Don't install `include/` directory in bindist.

The install_includes for the RTS package used to be put in the top-level
./include folder but this would lead to confusing things happening if
you installed multiple GHC versions side-by-side.

We don't need this folder anymore because install-includes
is honoured properly by cabal and the relevant header files already
copied in by the cabal installation process.

If you want to depend on the header files for the RTS in a Haskell
project then you just have to depend on the `rts` package and the
correct include directories will be provided for you.

If you want to depend on the header files in a standard C project then
you should query ghc-pkg to get the right paths.

```
ghc-pkg field rts include-dirs  --simple-output
```

Fixes #21609

- - - - -
03172116 by Bryan Richter at 2022-06-16T12:38:57-04:00
Enable eventlogs on nightly perf job

- - - - -
ecbf8685 by Hécate Moonlight at 2022-06-16T16:30:00-04:00
Repair dead link in TH haddocks

Closes #21724

- - - - -
99ff3818 by sheaf at 2022-06-16T16:30:39-04:00
Hadrian: allow configuring Hsc2Hs

This patch adds the ability to pass options to Hsc2Hs as Hadrian
key/value settings, in the same way as cabal configure options,
using the syntax:

  *.*.hsc2hs.run.opts += ...

- - - - -
9c575f24 by sheaf at 2022-06-16T16:30:39-04:00
Hadrian bootstrap: look up hsc2hs

Hadrian bootstrapping looks up where to find ghc_pkg, but the same
logic was not in place for hsc2hs which meant we could fail to
find the appropriate hsc2hs executabe when bootstrapping Hadrian.
This patch adds that missing logic.

- - - - -
229d741f by Ben Gamari at 2022-06-18T10:42:54-04:00
ghc-heap: Add (broken) test for #21622

- - - - -
cadd7753 by Ben Gamari at 2022-06-18T10:42:54-04:00
ghc-heap: Don't Box NULL pointers

Previously we could construct a `Box` of a NULL pointer from the `link`
field of `StgWeak`. Now we take care to avoid ever introducing such
pointers in `collect_pointers` and ensure that the `link` field is
represented as a `Maybe` in the `Closure` type.

Fixes #21622

- - - - -
31c214cc by Tamar Christina at 2022-06-18T10:43:34-04:00
winio: Add support to console handles to handleToHANDLE

- - - - -
711cb417 by Ben Gamari at 2022-06-18T10:44:11-04:00
CmmToAsm/AArch64: Add SMUL[LH] instructions

These will be needed to fix #21624.

- - - - -
d05d90d2 by Ben Gamari at 2022-06-18T10:44:11-04:00
CmmToAsm/AArch64: Fix syntax of OpRegShift operands

Previously this produced invalid assembly containing a redundant comma.

- - - - -
a1e1d8ee by Ben Gamari at 2022-06-18T10:44:11-04:00
ncg/aarch64: Fix implementation of IntMulMayOflo

The code generated for IntMulMayOflo was previously wrong as it
depended upon the overflow flag, which the AArch64 MUL instruction does
not set. Fix this.

Fixes #21624.

- - - - -
26745006 by Ben Gamari at 2022-06-18T10:44:11-04:00
testsuite: Add test for #21624

Ensuring that mulIntMayOflo# behaves as expected.

- - - - -
94f2e92a by Sebastian Graf at 2022-06-20T09:40:58+02:00
CprAnal: Set signatures of DFuns to top

The recursive DFun in the reproducer for #20836 also triggered a bug in CprAnal
that is observable in a debug build. The CPR signature of a recursive DFunId
was never updated and hence the optimistic arity 0 bottom signature triggered a
mismatch with the arity 1 of the binding in WorkWrap. We never miscompiled any
code because WW doesn't exploit bottom CPR signatures.

- - - - -
b570da84 by Sebastian Graf at 2022-06-20T09:43:29+02:00
CorePrep: Don't speculatively evaluate recursive calls (#20836)

In #20836 we have optimised a terminating program into an endless loop,
because we speculated the self-recursive call of a recursive DFun.
Now we track the set of enclosing recursive binders in CorePrep to prevent
speculation of such self-recursive calls.

See the updates to Note [Speculative evaluation] for details.

Fixes #20836.

- - - - -
49fb2f9b by Sebastian Graf at 2022-06-20T09:43:32+02:00
Simplify: Take care with eta reduction in recursive RHSs (#21652)

Similar to the fix to #20836 in CorePrep, we now track the set of enclosing
recursive binders in the SimplEnv and SimpleOptEnv.
See Note [Eta reduction in recursive RHSs] for details.

I also updated Note [Arity robustness] with the insights Simon and I had in a
call discussing the issue.

Fixes #21652.

Unfortunately, we get a 5% ghc/alloc regression in T16577. That is due to
additional eta reduction in GHC.Read.choose1 and the resulting ANF-isation
of a large list literal at the top-level that didn't happen before (presumably
because it was too interesting to float to the top-level). There's not much we
can do about that.

Metric Increase:
    T16577

- - - - -
2563b95c by Sebastian Graf at 2022-06-20T09:45:09+02:00
Ignore .hie-bios

- - - - -
e4e44d8d by Simon Peyton Jones at 2022-06-20T12:31:45-04:00
Instantiate top level foralls in partial type signatures

The main fix for #21667 is the new call to tcInstTypeBnders
in tcHsPartialSigType. It was really a simple omission before.

I also moved the decision about whether we need to apply the
Monomorphism Restriction, from `decideGeneralisationPlan` to
`tcPolyInfer`.  That removes a flag from the InferGen constructor,
which is good.

But more importantly, it allows the new function,
   checkMonomorphismRestriction
called from `tcPolyInfer`, to "see" the `Types` involved rather than
the `HsTypes`.  And that in turn matters because we invoke the MR for
partial signatures if none of the partial signatures in the group have
any overloading context; and we can't answer that question for HsTypes.
See Note [Partial type signatures and the monomorphism restriction]
in GHC.Tc.Gen.Bind.

This latter is really a pre-existing bug.

- - - - -
262a9f93 by Winston Hartnett at 2022-06-20T12:32:23-04:00
Make Outputable instance for InlineSig print the InlineSpec

Fix ghc/ghc#21739

Squash fix ghc/ghc#21739

- - - - -
b5590fff by Matthew Pickering at 2022-06-20T12:32:59-04:00
Add NO_BOOT to hackage_doc_tarball job

We were attempting to boot a src-tarball which doesn't work as ./boot is
not included in the source tarball. This slipped through as the job is
only run on nightly.

- - - - -
d24afd9d by Vladislav Zavialov at 2022-06-20T17:34:44-04:00
HsToken for @-patterns and TypeApplications (#19623)

One more step towards the new design of EPA.

- - - - -
159b7628 by Tamar Christina at 2022-06-20T17:35:23-04:00
linker: only keep rtl exception tables if they have been relocated

- - - - -
da5ff105 by Andreas Klebinger at 2022-06-21T17:04:12+02:00
Ticky:Make json info a separate field.

- - - - -
1a4ce4b2 by Matthew Pickering at 2022-06-22T09:49:22+01:00
Revert "Ticky:Make json info a separate field."

This reverts commit da5ff10503e683e2148c62e36f8fe2f819328862.

This was pushed directly without review.

- - - - -
f89bf85f by Vanessa McHale at 2022-06-22T08:21:32-04:00
Flags to disable local let-floating; -flocal-float-out, -flocal-float-out-top-level CLI flags

These flags affect the behaviour of local let floating.

If `-flocal-float-out` is disabled (the default) then we disable all
local floating.

```
…(let x = let y = e in (a,b) in body)...
===>
…(let y = e; x = (a,b) in body)...

```

Further to this, top-level local floating can be disabled on it's own by
passing -fno-local-float-out-top-level.

```
x = let y = e in (a,b)
===>
y = e; x = (a,b)
```

Note that this is only about local floating, ie, floating two adjacent
lets past each other and doesn't say anything about the global floating
pass which is controlled by `-fno-float`.

Fixes #13663

- - - - -
4ccefc6e by Matthew Craven at 2022-06-22T08:22:12-04:00
Check for Int overflows in Data.Array.Byte

- - - - -
2004e3c8 by Matthew Craven at 2022-06-22T08:22:12-04:00
Add a basic test for ByteArray's Monoid instance

- - - - -
fb36770c by Matthew Craven at 2022-06-22T08:22:12-04:00
Rename `copyByteArray` to `unsafeCopyByteArray`

- - - - -
ecc9aedc by Ben Gamari at 2022-06-22T08:22:48-04:00
testsuite: Add test for #21719

Happily, this has been fixed since 9.2.

- - - - -
19606c42 by Brandon Chinn at 2022-06-22T08:23:28-04:00
Use lookupNameCache instead of lookupOrigIO

- - - - -
4c9dfd69 by Brandon Chinn at 2022-06-22T08:23:28-04:00
Break out thNameToGhcNameIO (ref. #21730)

- - - - -
eb4fb849 by Michael Peyton Jones at 2022-06-22T08:24:07-04:00
Add laws for 'toInteger' and 'toRational'

CLC discussion here:
https://github.com/haskell/core-libraries-committee/issues/58

- - - - -
c1a950c1 by Alexander Esgen at 2022-06-22T12:36:13+00:00
Correct documentation of defaults of the `-V` RTS option

- - - - -
b7b7d90d by Matthew Pickering at 2022-06-22T21:58:12-04:00
Transcribe discussion from #21483 into a Note

In #21483 I had a discussion with Simon Marlow about the memory
retention behaviour of -Fd. I have just transcribed that conversation
here as it elucidates the potentially subtle assumptions which led to
the design of the memory retention behaviours of -Fd.

Fixes #21483

- - - - -
980d1954 by Ben Gamari at 2022-06-22T21:58:48-04:00
eventlog: Don't leave dangling pointers hanging around

Previously we failed to reset pointers to various eventlog buffers to
NULL after freeing them. In principle we shouldn't look at them after
they are freed but nevertheless it is good practice to set them to a
well-defined value.

- - - - -
575ec846 by Eric Lindblad at 2022-06-22T21:59:28-04:00
runhaskell
- - - - -
e6a69337 by Artem Pelenitsyn at 2022-06-22T22:00:07-04:00
re-export GHC.Natural.minusNaturalMaybe from Numeric.Natural

CLC proposal: https://github.com/haskell/core-libraries-committee/issues/45

- - - - -
5d45aa97 by Gergő Érdi at 2022-06-22T22:00:46-04:00
When specialising, look through floatable ticks.

Fixes #21697.

- - - - -
531205ac by Andreas Klebinger at 2022-06-22T22:01:22-04:00
TagCheck.hs: Properly check if arguments are boxed types.

For one by mistake I had been checking against the kind of runtime rep
instead of the boxity.

This uncovered another bug, namely that we tried to generate the
checking code before we had associated the function arguments with
a register, so this could never have worked to begin with.

This fixes #21729 and both of the above issues.

- - - - -
c7f9f6b5 by Gleb Popov at 2022-06-22T22:02:00-04:00
Use correct arch for the FreeBSD triple in gen-data-layout.sh

Downstream bug for reference: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261798
Relevant upstream issue: #15718

- - - - -
75f0091b by Andreas Klebinger at 2022-06-22T22:02:35-04:00
Bump nofib submodule.

Allows the shake runner to build with 9.2.3 among other things.

Fixes #21772

- - - - -
0aa0ce69 by Ben Gamari at 2022-06-27T08:01:03-04:00
Bump ghc-prim and base versions

To 0.9.0 and 4.17.0 respectively.

Bumps array, deepseq, directory, filepath, haskeline, hpc, parsec, stm,
terminfo, text, unix, haddock, and hsc2hs submodules.

(cherry picked from commit ba47b95122b7b336ce1cc00896a47b584ad24095)

- - - - -
4713abc2 by Ben Gamari at 2022-06-27T08:01:03-04:00
testsuite: Use normalise_version more consistently

Previously several tests' output were unnecessarily dependent on version
numbers, particularly of `base`. Fix this.

- - - - -
d7b0642b by Matthew Pickering at 2022-06-27T08:01:03-04:00
linters: Fix lint-submodule-refs when crashing trying to find plausible branches

- - - - -
38378be3 by Andreas Klebinger at 2022-06-27T08:01:39-04:00
hadrian: Improve haddocks for ghcDebugAssertions

- - - - -
ac7a7fc8 by Andreas Klebinger at 2022-06-27T08:01:39-04:00
Don't mark lambda binders as OtherCon

We used to put OtherCon unfoldings on lambda binders of workers
and sometimes also join points/specializations with with the
assumption that since the wrapper would force these arguments
once we execute the RHS they would indeed be in WHNF.

This was wrong for reasons detailed in #21472. So now we purge
evaluated unfoldings from *all* lambda binders.

This fixes #21472, but at the cost of sometimes not using as efficient a
calling convention. It can also change inlining behaviour as some
occurances will no longer look like value arguments when they did
before.

As consequence we also change how we compute CBV information for
arguments slightly. We now *always* determine the CBV convention
for arguments during tidy. Earlier in the pipeline we merely mark
functions as candidates for having their arguments treated as CBV.

As before the process is described in the relevant notes:
Note [CBV Function Ids]
Note [Attaching CBV Marks to ids]
Note [Never put `OtherCon` unfoldigns on lambda binders]

-------------------------
Metric Decrease:
    T12425
    T13035
    T18223
    T18223
    T18923
    MultiLayerModulesTH_OneShot
Metric Increase:
    WWRec
-------------------------

- - - - -
06cf6f4a by Tony Zorman at 2022-06-27T08:02:18-04:00
Add suggestions for unrecognised pragmas (#21589)

In case of a misspelled pragma, offer possible corrections as to what
the user could have meant.

Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/21589

- - - - -
3fbab757 by Greg Steuck at 2022-06-27T08:02:56-04:00
Remove the traces of i386-*-openbsd, long live amd64

OpenBSD will not ship any ghc packages on i386 starting with 7.2
release.  This means there will not be a bootstrap compiler easily
available.  The last available binaries are ghc-8.10.6 which is
already not supported as bootstrap for HEAD.

See here for more information:

https://marc.info/?l=openbsd-ports&m=165060700222580&w=2

- - - - -
58530271 by Andrew Lelechenko at 2022-06-27T08:03:34-04:00
Add Foldable1 and Bifoldable1 type classes

Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/9

Instances roughly follow
https://hackage.haskell.org/package/semigroupoids-5.3.7/docs/Data-Semigroup-Foldable-Class.html#t:Foldable1
but the API of `Foldable1` was expanded in comparison to `semigroupoids`.

Compatibility shim is available from https://github.com/phadej/foldable1 (to be released).

Closes #13573.

- - - - -
a51f4ecc by Naomi Liu at 2022-06-27T08:04:13-04:00
add levity polymorphism to addrToAny#

- - - - -
f4edcdc4 by Naomi Liu at 2022-06-27T08:04:13-04:00
add tests for addrToAny# levity

- - - - -
07016fc9 by Matthew Pickering at 2022-06-27T08:04:49-04:00
hadrian: Update main README page

This README had some quite out-of-date content about the build system so
I did a complete pass deleting old material. I also made the section
about flavours more prominent and mentioned flavour transformers.

- - - - -
79ae2d89 by Ben Gamari at 2022-06-27T08:05:24-04:00
testsuite: Hide output from test compilations with verbosity==2

Previously the output from test compilations used to determine whether,
e.g., profiling libraries are available was shown with verbosity
levels >= 2. However, the default level is 2, meaning that most users
were often spammed with confusing errors. Fix this by bumping the
verbosity threshold for this output to >=3.

Fixes #21760.
- - - - -
995ea44d by Ben Gamari at 2022-06-27T08:06:00-04:00
configure: Only probe for LD in FIND_LD

Since 6be2c5a7e9187fc14d51e1ec32ca235143bb0d8b we would probe for LD
rather early in `configure`. However, it turns out that this breaks
`configure`'s `ld`-override logic, which assumes that `LD` was set by
the user and aborts.

Fixes #21778.

- - - - -
b43d140b by Sergei Trofimovich at 2022-06-27T08:06:39-04:00
`.hs-boot` make rules: add missing order-only dependency on target directory

Noticed missing target directory dependency as a build failure in
`make --shuffle` mode (added in https://savannah.gnu.org/bugs/index.php?62100):

    "cp" libraries/base/./GHC/Stack/CCS.hs-boot libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot
    cp: cannot create regular file 'libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot': No such file or directory
    libraries/haskeline/ghc.mk:4: libraries/haskeline/dist-install/build/.depend-v-p-dyn.haskell: No such file or directory
    make[1]: *** [libraries/base/ghc.mk:4: libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot] Error 1 shuffle=1656129254
    make: *** [Makefile:128: all] Error 2 shuffle=1656129254

Note that `cp` complains about inability to create target file.

The change adds order-only dependency on a target directory (similar to
the rest of rules in that file).

The bug is lurking there since 2009 commit 34cc75e1a (`GHC new build
system megapatch`.) where upfront directory creation was never added to
`.hs-boot` files.

- - - - -
57a5f88c by Ben Gamari at 2022-06-28T03:24:24-04:00
Mark AArch64/Darwin as requiring sign-extension

Apple's AArch64 ABI requires that the caller sign-extend small integer
arguments. Set platformCConvNeedsExtension to reflect this fact.

Fixes #21773.

- - - - -
df762ae9 by Ben Gamari at 2022-06-28T03:24:24-04:00
-ddump-llvm shouldn't imply -fllvm

Previously -ddump-llvm would change the backend used, which contrasts
with all other dump flags. This is quite surprising and cost me quite
a bit of time. Dump flags should not change compiler behavior.

Fixes #21776.

- - - - -
70f0c1f8 by Ben Gamari at 2022-06-28T03:24:24-04:00
CmmToAsm/AArch64: Re-format argument handling logic

Previously there were very long, hard to parse lines. Fix this.

- - - - -
696d64c3 by Ben Gamari at 2022-06-28T03:24:24-04:00
CmmToAsm/AArch64: Sign-extend narrow C arguments

The AArch64/Darwin ABI requires that function arguments narrower
than 32-bits must be sign-extended by the caller. We neglected to
do this, resulting in #20735.

Fixes #20735.

- - - - -
c006ac0d by Ben Gamari at 2022-06-28T03:24:24-04:00
testsuite: Add test for #20735

- - - - -
16b9100c by Ben Gamari at 2022-06-28T03:24:59-04:00
integer-gmp: Fix cabal file

Evidently fields may not come after sections in a cabal file.

- - - - -
03cc5d02 by Sergei Trofimovich at 2022-06-28T15:20:45-04:00
ghc.mk: fix 'make install' (`mk/system-cxx-std-lib-1.0.conf.install` does not exist)

before the change `make install` was failing as:

```
"mv" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc-stage2" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc"
make[1]: *** No rule to make target 'mk/system-cxx-std-lib-1.0.conf.install', needed by 'install_packages'.  Stop.
```

I think it's a recent regression caused by 0ef249aa where `system-cxx-std-lib-1.0.conf`
is created (somewhat manually), but not the .install varianlt of it.

The fix is to consistently use `mk/system-cxx-std-lib-1.0.conf` everywhere.

Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/21784

- - - - -
eecab8f9 by Simon Peyton Jones at 2022-06-28T15:21:21-04:00
Comments only, about join points

This MR just adds some documentation about why casts
destroy join points, following #21716.

- - - - -
251471e7 by Matthew Pickering at 2022-06-28T19:02:41-04:00
Cleanup BuiltInSyntax vs UserSyntax

There was some confusion about whether FUN/TYPE/One/Many should be
BuiltInSyntax or UserSyntax. The answer is certainly UserSyntax as
BuiltInSyntax is for things which are directly constructed by the parser
rather than going through normal renaming channels.

I fixed all the obviously wrong places I could find and added a test for
the original bug which was caused by this (#21752)

Fixes #21752 #20695 #18302

- - - - -
0e22f16c by Ben Gamari at 2022-06-28T19:03:16-04:00
template-haskell: Bump version to 2.19.0.0

Bumps text and exceptions submodules due to bounds.

- - - - -
bbe6f10e by Emily Bourke at 2022-06-29T08:23:13+00:00
Tiny tweak to `IOPort#` documentation

The exclamation mark and bracket don’t seem to make sense here. I’ve
looked through the history, and I don’t think they’re deliberate – possibly
a copy-and-paste error.
- - - - -
70e47489 by Dominik Peteler at 2022-06-29T19:26:31-04:00
Remove `CoreOccurAnal` constructor of the `CoreToDo` type

It was dead code since the last occurence in an expression context got
removed in 71916e1c018dded2e68d6769a2dbb8777da12664.

- - - - -
d0722170 by nineonine at 2022-07-01T08:15:56-04:00
Fix panic with UnliftedFFITypes+CApiFFI (#14624)

When declaring foreign import using CAPI calling convention, using
unlifted unboxed types would result in compiler panic. There was
an attempt to fix the situation in #9274, however it only addressed
some of the ByteArray cases.

This patch fixes other missed cases for all prims that may be used
as basic foreign types.

- - - - -
eb043148 by Douglas Wilson at 2022-07-01T08:16:32-04:00
rts: gc stats: account properly for copied bytes in sequential collections

We were not updating the [copied,any_work,scav_find_work, max_n_todo_overflow]
counters during sequential collections. As well, we were double counting for
parallel collections.

To fix this we add an `else` clause to the `if (is_par_gc())`.

The par_* counters do not need to be updated in the sequential case
because they must be 0.

- - - - -
f95edea9 by Matthew Pickering at 2022-07-01T19:21:55-04:00
desugar: Look through ticks when warning about possible literal overflow

Enabling `-fhpc` or `-finfo-table-map` would case a tick to end up
between the appliation of `neg` to its argument. This defeated the
special logic which looks for `NegApp ... (HsOverLit` to warn about
possible overflow if a user writes a negative literal (without out
NegativeLiterals) in their code.

Fixes #21701

- - - - -
f25c8d03 by Matthew Pickering at 2022-07-01T19:22:31-04:00
ci: Fix definition of slow-validate flavour (so that -dlint) is passed

In this embarassing sequence of events we were running slow-validate
without -dlint.

- - - - -
bf7991b0 by Mike Pilgrem at 2022-07-02T10:12:04-04:00
Identify the extistence of the `runhaskell` command and that it is equivalent to the `runghc` command. Add an entry to the index for `runhaskell`. See https://gitlab.haskell.org/ghc/ghc/-/issues/21411
- - - - -
9e79f6d0 by Simon Jakobi at 2022-07-02T10:12:39-04:00
Data.Foldable1: Remove references to Foldable-specific note

...as discussed in
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8495#note_439455.

- - - - -
3a8970ac by romes at 2022-07-03T14:11:31-04:00
TTG: Move HsModule to L.H.S

Move the definition of HsModule defined in GHC.Hs to
Language.Haskell.Syntax with an added TTG parameter and corresponding
extension fields.

This is progress towards having the haskell-syntax package, as described
in #21592

- - - - -
f9f80995 by romes at 2022-07-03T14:11:31-04:00
TTG: Move ImpExp client-independent bits to L.H.S.ImpExp

Move the GHC-independent definitions from GHC.Hs.ImpExp to
Language.Haskell.Syntax.ImpExp with the required TTG extension fields
such as to keep the AST independent from GHC.

This is progress towards having the haskell-syntax package, as described
in #21592

Bumps haddock submodule

- - - - -
c43dbac0 by romes at 2022-07-03T14:11:31-04:00
Refactor ModuleName to L.H.S.Module.Name

ModuleName used to live in GHC.Unit.Module.Name. In this commit, the
definition of ModuleName and its associated functions are moved to
Language.Haskell.Syntax.Module.Name according to the current plan
towards making the AST GHC-independent.

The instances for ModuleName for Outputable, Uniquable and Binary were
moved to the module in which the class is defined because these instances
depend on GHC.

The instance of Eq for ModuleName is slightly changed to no longer
depend on unique explicitly and instead uses FastString's instance of
Eq.

- - - - -
2635c6f2 by konsumlamm at 2022-07-03T14:12:11-04:00
Expand `Ord` instance for `Down`

Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/23#issuecomment-1172932610

- - - - -
36fba0df by Anselm Schüler at 2022-07-04T05:06:42+00:00
Add applyWhen to Data.Function per CLC prop

Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/71#issuecomment-1165830233

- - - - -
3b13aab1 by Matthew Pickering at 2022-07-04T15:15:00-04:00
hadrian: Don't read package environments in ghc-stage1 wrapper

The stage1 compiler may be on the brink of existence and not have even a
working base library. You may have installed packages globally with a
similar stage2 compiler which will then lead to arguments such as
--show-iface not even working because you are passing too many package
flags. The solution is simple, don't read these implicit files.

Fixes #21803

- - - - -
aba482ea by Andreas Klebinger at 2022-07-04T17:55:55-04:00
Ticky:Make json info a separate field.

Fixes #21233

- - - - -
74f3867d by Matthew Pickering at 2022-07-04T17:56:30-04:00
Add docs:<pkg> command to hadrian to build docs for just one package

- - - - -
418afaf1 by Matthew Pickering at 2022-07-04T17:56:30-04:00
upload-docs: propagate publish correctly in upload_sdist

- - - - -
ed793d7a by Matthew Pickering at 2022-07-04T17:56:30-04:00
docs-upload: Fix upload script when no packages are listed

- - - - -
d002c6e0 by Matthew Pickering at 2022-07-04T17:56:30-04:00
hadrian: Add --haddock-base-url option for specifying base-url when generating docs

The motiviation for this flag is to be able to produce documentation
which is suitable for uploading for hackage, ie, the cross-package links
work correctly.

There are basically three values you want to set this to:

* off - default, base_url = ../%pkg% which works for local browsing
* on - no argument , base_url = https:://hackage.haskell.org/package/%pkg%/docs - for hackage docs upload
* on - argument, for example, base_url = http://localhost:8080/package/%pkg%/docs for testing the documentation.

The `%pkg%` string is a template variable which is replaced with the
package identifier for the relevant package.

This is one step towards fixing #21749

- - - - -
41eb749a by Matthew Pickering at 2022-07-04T17:56:31-04:00
Add nightly job for generating docs suitable for hackage upload

- - - - -
620ee7ed by Matthew Pickering at 2022-07-04T17:57:05-04:00
ghci: Support :set prompt in multi repl

This adds supports for various :set commands apart from `:set <FLAG>` in
multi repl, this includes `:set prompt` and so-on.

Fixes #21796

- - - - -
b151b65e by Matthew Pickering at 2022-07-05T16:32:31-04:00
Vendor filepath inside template-haskell

Adding filepath as a dependency of template-haskell means that it can't
be reinstalled if any build-plan depends on template-haskell.

This is a temporary solution for the 9.4 release.

A longer term solution is to split-up the template-haskell package into
the wired-in part and a non-wired-in part which can be reinstalled. This
was deemed quite risky on the 9.4 release timescale.

Fixes #21738

- - - - -
c9347ecf by John Ericson at 2022-07-05T16:33:07-04:00
Factor fields of `CoreDoSimplify` into separate data type

This avoids some partiality. The work @mmhat is doing cleaning up and
modularizing `Core.Opt` will build on this nicely.

- - - - -
d0e74992 by Eric Lindblad at 2022-07-06T01:35:48-04:00
https urls
- - - - -
803e965c by Eric Lindblad at 2022-07-06T01:35:48-04:00
options and typos
- - - - -
5519baa5 by Eric Lindblad at 2022-07-06T01:35:48-04:00
grammar
- - - - -
4ddc1d3e by Eric Lindblad at 2022-07-06T01:35:48-04:00
sources
- - - - -
c95c2026 by Matthew Pickering at 2022-07-06T01:35:48-04:00
Fix lint warnings in bootstrap.py

- - - - -
86ced2ad by romes at 2022-07-06T01:36:23-04:00
Restore Eq instance of ImportDeclQualifiedStyle

Fixes #21819

- - - - -
3547e264 by romes at 2022-07-06T13:50:27-04:00
Prune L.H.S modules of GHC dependencies

Move around datatypes, functions and instances that are GHC-specific out
of the `Language.Haskell.Syntax.*` modules to reduce the GHC
dependencies in them -- progressing towards #21592

Creates a module `Language.Haskell.Syntax.Basic` to hold basic
definitions required by the other L.H.S modules (and don't belong in any
of them)

- - - - -
e4eea07b by romes at 2022-07-06T13:50:27-04:00
TTG: Move CoreTickish out of LHS.Binds

Remove the `[CoreTickish]` fields from datatype `HsBindLR idL idR` and
move them to the extension point instance, according to the plan
outlined in #21592 to separate the base AST from the GHC specific bits.

- - - - -
acc1816b by romes at 2022-07-06T13:50:27-04:00
TTG for ForeignImport/Export

Add a TTG parameter to both `ForeignImport` and `ForeignExport` and,
according to #21592, move the GHC-specific bits in them and in the other
AST data types related to foreign imports and exports to the TTG
extension point.

- - - - -
371c5ecf by romes at 2022-07-06T13:50:27-04:00
TTG for HsTyLit

Add TTG parameter to `HsTyLit` to move the GHC-specific `SourceText`
fields to the extension point and out of the base AST.

Progress towards #21592

- - - - -
fd379d1b by romes at 2022-07-06T13:50:27-04:00
Remove many GHC dependencies from L.H.S

Continue to prune the `Language.Haskell.Syntax.*` modules out of GHC
imports according to the plan in the linked issue.

Moves more GHC-specific declarations to `GHC.*` and brings more required
GHC-independent declarations to `Language.Haskell.Syntax.*` (extending
e.g. `Language.Haskell.Syntax.Basic`).

Progress towards #21592

Bump haddock submodule for !8308

-------------------------
Metric Decrease:
    hard_hole_fits
-------------------------

- - - - -
c5415bc5 by Alan Zimmerman at 2022-07-06T13:50:27-04:00
Fix exact printing of the HsRule name

Prior to this branch, the HsRule name was

    XRec pass (SourceText,RuleName)

and there is an ExactPrint instance for (SourceText, RuleName).

The SourceText has moved to a different location, so synthesise the
original to trigger the correct instance when printing.

We need both the SourceText and RuleName when exact printing, as it is
possible to have a NoSourceText variant, in which case we fall back to
the FastString.

- - - - -
665fa5a7 by Matthew Pickering at 2022-07-06T13:51:03-04:00
driver: Fix issue with module loops and multiple home units

We were attempting to rehydrate all dependencies of a particular module,
but we actually only needed to rehydrate those of the current package
(as those are the ones participating in the loop).

This fixes loading GHC into a multi-unit session.

Fixes #21814

- - - - -
bbcaba6a by Andreas Klebinger at 2022-07-06T13:51:39-04:00
Remove a bogus #define from ClosureMacros.h

- - - - -
fa59223b by Tamar Christina at 2022-07-07T23:23:57-04:00
winio: make consoleReadNonBlocking not wait for any events at all.

- - - - -
42c917df by Adam Sandberg Ericsson at 2022-07-07T23:24:34-04:00
rts: allow NULL to be used as an invalid StgStablePtr

- - - - -
3739e565 by Andreas Schwab at 2022-07-07T23:25:10-04:00
RTS: Add stack marker to StgCRunAsm.S

Every object file must be properly marked for non-executable stack, even if it
contains no code.

- - - - -
a889bc05 by Ben Gamari at 2022-07-07T23:25:45-04:00
Bump unix submodule

Adds `config.sub` to unix's `.gitignore`, fixing #19574.

- - - - -
3609a478 by Matthew Pickering at 2022-07-09T11:11:58-04:00
ghci: Fix most calls to isLoaded to work in multi-mode

The most egrarious thing this fixes is the report about the total number
of loaded modules after starting a session.

Ticket #20889

- - - - -
fc183c90 by Matthew Pickering at 2022-07-09T11:11:58-04:00
Enable :edit command in ghci multi-mode.

This works after the last change to isLoaded.

Ticket #20888

- - - - -
46050534 by Simon Peyton Jones at 2022-07-09T11:12:34-04:00
Fix a scoping bug in the Specialiser

In the call to `specLookupRule` in `already_covered`, in `specCalls`,
we need an in-scope set that includes the free vars of the arguments.
But we simply were not guaranteeing that: did not include the
`rule_bndrs`.

Easily fixed.  I'm not sure how how this bug has lain for quite
so long without biting us.

Fixes #21828.

- - - - -
6e8d9056 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00
Edit Note [idArity varies independently of dmdTypeDepth]

...and refer to it in GHC.Core.Lint.lintLetBind.

Fixes #21452

- - - - -
89ba4655 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00
Tiny documentation wibbles (comments only)

- - - - -
61a46c6d by Eric Lindblad at 2022-07-13T08:28:29-04:00
fix readme
- - - - -
61babb5e by Eric Lindblad at 2022-07-13T08:28:29-04:00
fix bootstrap
- - - - -
8b417ad5 by Eric Lindblad at 2022-07-13T08:28:29-04:00
tarball
- - - - -
e9d9f078 by Zubin Duggal at 2022-07-13T14:00:18-04:00
hie-files: Fix scopes for deriving clauses and instance signatures (#18425)

- - - - -
c4989131 by Zubin Duggal at 2022-07-13T14:00:18-04:00
hie-files: Record location of filled in default method bindings

This is useful for hie files to reconstruct the evidence that default methods
depend on.

- - - - -
9c52e7fc by Zubin Duggal at 2022-07-13T14:00:18-04:00
testsuite: Factor out common parts from hiefile tests

- - - - -
6a9e4493 by sheaf at 2022-07-13T14:00:56-04:00
Hadrian: update documentation of settings

The documentation for key-value settings was a bit out of date.
This patch updates it to account for `cabal.configure.opts` and
`hsc2hs.run.opts`.

The user-settings document was also re-arranged, to make the key-value
settings more prominent (as it doesn't involve changing the Hadrian
source code, and thus doesn't require any recompilation of Hadrian).

- - - - -
a2f142f8 by Zubin Duggal at 2022-07-13T20:43:32-04:00
Fix potential space leak that arise from ModuleGraphs retaining references
to previous ModuleGraphs, in particular the lazy `mg_non_boot` field.
This manifests in `extendMG`.

Solution: Delete `mg_non_boot` as it is only used for `mgLookupModule`, which
is only called in two places in the compiler, and should only be called at most
once for every home unit:

GHC.Driver.Make:
      mainModuleSrcPath :: Maybe String
      mainModuleSrcPath = do
        ms <- mgLookupModule mod_graph (mainModIs hue)
        ml_hs_file (ms_location ms)

GHCI.UI:
listModuleLine modl line = do
   graph <- GHC.getModuleGraph
   let this = GHC.mgLookupModule graph modl

Instead `mgLookupModule` can be a linear function that looks through the entire
list of `ModuleGraphNodes`

Fixes #21816

- - - - -
dcf8b30a by Ben Gamari at 2022-07-13T20:44:08-04:00
rts: Fix AdjustorPool bitmap manipulation

Previously the implementation of bitmap_first_unset assumed that
`__builtin_clz` would accept `uint8_t` however it apparently rather
extends its argument to `unsigned int`.

To fix this we simply revert to a naive implementation since handling
the various corner cases with `clz` is quite tricky. This should be
fine given that AdjustorPool isn't particularly hot. Ideally we would
have a single, optimised bitmap implementation in the RTS but I'll leave
this for future work.

Fixes #21838.

- - - - -
ad8f3e15 by Luite Stegeman at 2022-07-16T07:20:36-04:00
Change GHCi bytecode return convention for unlifted datatypes.

This changes the bytecode return convention for unlifted
algebraic datatypes to be the same as for lifted
types, i.e. ENTER/PUSH_ALTS instead of
RETURN_UNLIFTED/PUSH_ALTS_UNLIFTED

Fixes #20849

- - - - -
5434d1a3 by Colten Webb at 2022-07-16T07:21:15-04:00
Compute record-dot-syntax types
Ensures type information for record-dot-syntax
is included in HieASTs. See #21797

- - - - -
89d169ec by Colten Webb at 2022-07-16T07:21:15-04:00
Add record-dot-syntax test

- - - - -
4beb9f3c by Ben Gamari at 2022-07-16T07:21:51-04:00
Document RuntimeRep polymorphism limitations of catch#, et al

As noted in #21868, several primops accepting continuations producing
RuntimeRep-polymorphic results aren't nearly as polymorphic as their
types suggest. Document this limitation and adapt the `UnliftedWeakPtr`
test to avoid breaking this limitation in `keepAlive#`.

- - - - -
4ef1c65d by Ben Gamari at 2022-07-16T07:21:51-04:00
Make keepAlive# out-of-line

This is a naive approach to fixing the unsoundness noticed in #21708.
Specifically, we remove the lowering of `keepAlive#` via CorePrep and
instead turn it into an out-of-line primop.
This is simple, inefficient (since the continuation must now be heap
allocated), but good enough for 9.4.1. We will revisit this
(particiularly via #16098) in a future release.

Metric Increase:
    T4978
    T7257
    T9203

- - - - -
1bbff35d by Greg Steuck at 2022-07-16T07:22:29-04:00
Suppress extra output from configure check for c++ libraries

- - - - -
3acbd7ad by Ben Gamari at 2022-07-16T07:23:04-04:00
rel-notes: Drop mention of #21745 fix

Since we have backported the fix to 9.4.1.

- - - - -
b27c2774 by Dominik Peteler at 2022-07-16T07:23:43-04:00
Align the behaviour of `dopt` and `log_dopt`

Before the behaviour of `dopt` and `logHasDumpFlag` (and the underlying
function `log_dopt`) were different as the latter did not take the
verbosity level into account. This led to problems during the
refactoring as we cannot simply replace calls to `dopt` with calls to
`logHasDumpFlag`.

In addition to that a subtle bug in the GHC module was fixed:
`setSessionDynFlags` did not update the logger and as a consequence the
verbosity value of the logger was not set appropriately.

Fixes #21861

- - - - -
28347d71 by Douglas Wilson at 2022-07-16T13:25:06-04:00
rts: forkOn context switches the target capability

Fixes #21824

- - - - -
f1c44991 by Ben Gamari at 2022-07-16T13:25:41-04:00
cmm: Eliminate orphan Outputable instances

Here we reorganize `GHC.Cmm` to eliminate the orphan `Outputable` and
`OutputableP` instances for the Cmm AST. This makes it significantly
easier to use the Cmm pretty-printers in tracing output without
incurring module import cycles.

- - - - -
f2e5e763 by Ben Gamari at 2022-07-16T13:25:41-04:00
cmm: Move toBlockList to GHC.Cmm

- - - - -
fa092745 by Ben Gamari at 2022-07-16T13:25:41-04:00
compiler: Add haddock sections to GHC.Utils.Panic

- - - - -
097759f9 by Ben Gamari at 2022-07-16T13:26:17-04:00
configure: Don't override Windows CXXFLAGS

At some point we used the clang distribution from msys2's `MINGW64`
environment for our Windows toolchain. This defaulted to using libgcc
and libstdc++ for its runtime library. However, we found for a variety
of reasons that compiler-rt, libunwind, and libc++ were more reliable,
consequently we explicitly overrode the CXXFLAGS to use these.

However, since then we have switched to use the `CLANG64` packaging,
which default to these already. Consequently we can drop these
arguments, silencing some redundant argument warnings from clang.

Fixes #21669.

- - - - -
e38a2684 by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/Elf: Check that there are no NULL ctors

- - - - -
616365b0 by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/Elf: Introduce support for invoking finalizers on unload

Addresses #20494.

- - - - -
cdd3be20 by Ben Gamari at 2022-07-16T23:50:36-04:00
testsuite: Add T20494

- - - - -
03c69d8d by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/PEi386: Rename finit field to fini

fini is short for "finalizer", which does not contain a "t".

- - - - -
033580bc by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/PEi386: Refactor handling of oc->info

Previously we would free oc->info after running initializers. However,
we can't do this is we want to also run finalizers.

Moreover, freeing oc->info so early was wrong for another reason:
we will need it in order to unregister the exception tables (see the
call to `RtlDeleteFunctionTable`).

In service of #20494.

- - - - -
f17912e4 by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/PEi386: Add finalization support

This implements #20494 for the PEi386 linker.

Happily, this also appears to fix `T9405`, resolving #21361.

- - - - -
2cd75550 by Ben Gamari at 2022-07-16T23:50:36-04:00
Loader: Implement gnu-style -l:$path syntax

Gnu ld allows `-l` to be passed an absolute file path,
signalled by a `:` prefix. Implement this in the GHC's
loader search logic.

- - - - -
5781a360 by Ben Gamari at 2022-07-16T23:50:36-04:00
Statically-link against libc++ on Windows

Unfortunately on Windows we have no RPATH-like facility, making dynamic
linking extremely fragile. Since we cannot assume that the user will
add their GHC installation to `$PATH` (and therefore their DLL
search path) we cannot assume that the loader will be able to locate our
`libc++.dll`. To avoid this, we instead statically link against `libc++.a` on
Windows.

Fixes #21435.

- - - - -
8e2e883b by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/PEi386: Ensure that all .ctors/.dtors sections are run

It turns out that PE objects may have multiple `.ctors`/`.dtors`
sections but the RTS linker had assumed that there was only one. Fix
this.

Fixes #21618.

- - - - -
fba04387 by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/PEi386: Respect dtor/ctor priority

Previously we would run constructors and destructors in arbitrary order
despite explicit priorities.

Fixes #21847.

- - - - -
1001952f by Ben Gamari at 2022-07-16T23:50:36-04:00
testsuite: Add test for #21618 and #21847

- - - - -
6f3816af by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/PEi386: Fix exception unwind unregistration

RtlDeleteFunctionTable expects a pointer to the .pdata section
yet we passed it the .xdata section.

Happily, this fixes #21354.

- - - - -
d9bff44c by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/MachO: Drop dead code

- - - - -
d161e6bc by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/MachO: Use section flags to identify initializers

- - - - -
fbb17110 by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/MachO: Introduce finalizer support

- - - - -
5b0ed8a8 by Ben Gamari at 2022-07-16T23:50:37-04:00
testsuite: Use system-cxx-std-lib instead of config.stdcxx_impl

- - - - -
6c476e1a by Ben Gamari at 2022-07-16T23:50:37-04:00
rts/linker/Elf: Work around GCC 6 init/fini behavior

It appears that GCC 6t (at least on i386) fails to give
init_array/fini_array sections the correct SHT_INIT_ARRAY/SHT_FINI_ARRAY
section types, instead marking them as SHT_PROGBITS. This caused T20494
to fail on Debian.

- - - - -
5f8203b8 by Ben Gamari at 2022-07-16T23:50:37-04:00
testsuite: Mark T13366Cxx as unbroken on Darwin

- - - - -
1fd2f851 by Ben Gamari at 2022-07-16T23:50:37-04:00
rts/linker: Fix resolution of __dso_handle on Darwin

Darwin expects a leading underscore.

- - - - -
a2dc00f3 by Ben Gamari at 2022-07-16T23:50:37-04:00
rts/linker: Clean up section kinds

- - - - -
aeb1a7c3 by Ben Gamari at 2022-07-16T23:50:37-04:00
rts/linker: Ensure that __cxa_finalize is called on code unload

- - - - -
028f081e by Ben Gamari at 2022-07-16T23:51:12-04:00
testsuite: Fix T11829 on Centos 7

It appears that Centos 7 has a more strict C++ compiler than most
distributions since std::runtime_error is defined in <stdexcept> rather
than <exception>. In T11829 we mistakenly imported the latter.

- - - - -
a10584e8 by Ben Gamari at 2022-07-17T22:30:32-04:00
hadrian: Rename documentation directories for consistency with make

* Rename `docs` to `doc`
* Place pdf documentation in `doc/` instead of `doc/pdfs/`

Fixes #21164.

- - - - -
b27c5947 by Anselm Schüler at 2022-07-17T22:31:11-04:00
Fix incorrect proof of applyWhen’s properties

- - - - -
eb031a5b by Matthew Pickering at 2022-07-18T08:04:47-04:00
hadrian: Add multi:<pkg> and multi targets for starting a multi-repl

This patch adds support to hadrian for starting a multi-repl containing
all the packages which stage0 can build. In particular, there is the new
user-facing command:

```
./hadrian/ghci-multi
```

which when executed will start a multi-repl containing the `ghc` package
and all it's dependencies.

This is implemented by two new hadrian targets:

```
./hadrian/build multi:<pkg>
```

Construct the arguments for a multi-repl session where the top-level
package is <pkg>. For example, `./hadrian/ghci-multi` is implemented
using `multi:ghc` target.

There is also the `multi` command which constructs a repl for everything
in stage0 which we can build.

- - - - -
19e7cac9 by Eric Lindblad at 2022-07-18T08:05:27-04:00
changelog typo
- - - - -
af6731a4 by Eric Lindblad at 2022-07-18T08:05:27-04:00
typos

- - - - -
415468fe by Simon Peyton Jones at 2022-07-18T16:36:54-04:00
Refactor SpecConstr to use treat bindings uniformly

This patch, provoked by #21457, simplifies SpecConstr by treating
top-level and nested bindings uniformly (see the new scBind).

* Eliminates the mysterious scTopBindEnv

* Refactors scBind to handle top-level and nested definitions
  uniformly.

* But, for now at least, continues the status quo of not doing
  SpecConstr for top-level non-recursive bindings.  (In contrast
  we do specialise nested non-recursive bindings, although the
  original paper did not; see Note [Local let bindings].)

  I tried the effect of specialising top-level non-recursive
  bindings (which is now dead easy to switch on, unlike before)
  but found some regressions, so I backed off.  See !8135.

It's a pure refactoring.  I think it'll do a better job in a few
cases, but there is no regression test.

- - - - -
d4d3fe6e by Andreas Klebinger at 2022-07-18T16:37:29-04:00
Rule matching: Don't compute the FVs if we don't look at them.

- - - - -
5f907371 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
White space only in FamInstEnv

- - - - -
ae3b3b62 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
Make transferPolyIdInfo work for CPR

I don't know why this hasn't bitten us before, but it was plain wrong.

- - - - -
9bdfdd98 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
Inline mapAccumLM

This function is called in inner loops in the compiler, and it's
overloaded and higher order.  Best just to inline it.

This popped up when I was looking at something else.  I think
perhaps GHC is delicately balanced on the cusp of inlining this
automatically.

- - - - -
d0b806ff by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
Make SetLevels honour floatConsts

This fix,  in the definition of profitableFloat,
is just for consistency. `floatConsts` should
do what it says!

I don't think it'll affect anything much, though.

- - - - -
d1c25a48 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
Refactor wantToUnboxArg a bit

* Rename GHC.Core.Opt.WorkWrap.Utils.wantToUnboxArg to canUnboxArg
  and similarly wantToUnboxResult to canUnboxResult.

* Add GHC.Core.Opt.DmdAnal.wantToUnboxArg as a wrapper for
  the (new) GHC.Core.Opt.WorkWrap.Utils.canUnboxArg,
  avoiding some yukky duplication.

  I decided it was clearer to give it a new data type for its
  return type, because I nedeed the FD_RecBox case which was not
  otherwise readiliy expressible.

* Add dcpc_args to WorkWrap.Utils.DataConPatContext for the payload

* Get rid of the Unlift constructor of UnboxingDecision, eliminate
  two panics, and two arguments to canUnboxArg (new name).  Much
  nicer now.

- - - - -
6d8a715e by Teo Camarasu at 2022-07-18T16:38:44-04:00
Allow running memInventory when the concurrent nonmoving gc is enabled

If the nonmoving gc is enabled and we are using a threaded RTS,
we now try to grab the collector mutex to avoid memInventory and
the collection racing.

Before memInventory was disabled.

- - - - -
aa75bbde by Ben Gamari at 2022-07-18T16:39:20-04:00
gitignore: don't ignore all aclocal.m4 files

While GHC's own aclocal.m4 is generated by the aclocal tool, other
packages' aclocal.m4 are committed in the repository. Previously
`.gitignore` included an entry which covered *any* file named
`aclocal.m4`, which lead to quite some confusion (e.g. see #21740).
Fix this by modifying GHC's `.gitignore` to only cover GHC's own
`aclocal.m4`.

- - - - -
4b98c5ce by Boris Lykah at 2022-07-19T02:34:12-04:00
Add mapAccumM, forAccumM to Data.Traversable

Approved by Core Libraries Committee in
https://github.com/haskell/core-libraries-committee/issues/65#issuecomment-1186275433

- - - - -
bd92182c by Ben Gamari at 2022-07-19T02:34:47-04:00
configure: Use AC_PATH_TOOL to detect tools

Previously we used AC_PATH_PROG which, as noted by #21601, does not
look for tools with a target prefix,
breaking cross-compilation.

Fixes #21601.

- - - - -
e8c07aa9 by Matthew Pickering at 2022-07-19T10:07:53-04:00
driver: Fix implementation of -S

We were failing to stop before running the assembler so the object file
was also created.

Fixes #21869

- - - - -
e2f0094c by Ben Gamari at 2022-07-19T10:08:28-04:00
rts/ProfHeap: Ensure new Censuses are zeroed

When growing the Census array ProfHeap previously neglected to
zero the new part of the array. Consequently `freeEra` would attempt to
free random words that often looked suspiciously like pointers.

Fixes #21880.

- - - - -
81d65f7f by sheaf at 2022-07-21T15:37:22+02:00
Make withDict opaque to the specialiser

As pointed out in #21575, it is not sufficient to set withDict to inline
after the typeclass specialiser, because we might inline withDict in one
module and then import it in another, and we run into the same problem.
This means we could still end up with incorrect runtime results because
the typeclass specialiser would assume that distinct typeclass evidence
terms at the same type are equal, when this is not necessarily the case
when using withDict.

Instead, this patch introduces a new magicId, 'nospec', which is only
inlined in CorePrep. We make use of it in the definition of withDict
to ensure that the typeclass specialiser does not common up distinct
typeclass evidence terms.

Fixes #21575

- - - - -
9a3e1f31 by Dominik Peteler at 2022-07-22T08:18:40-04:00
Refactored Simplify pass

 * Removed references to driver from GHC.Core.LateCC, GHC.Core.Simplify
   namespace and GHC.Core.Opt.Stats.
   Also removed services from configuration records.

 * Renamed GHC.Core.Opt.Simplify to GHC.Core.Opt.Simplify.Iteration.

 * Inlined `simplifyPgm` and renamed `simplifyPgmIO` to `simplifyPgm`
   and moved the Simplify driver to GHC.Core.Opt.Simplify.

 * Moved `SimplMode` and `FloatEnable` to GHC.Core.Opt.Simplify.Env.

 * Added a configuration record `TopEnvConfig` for the `SimplTopEnv` environment
   in GHC.Core.Opt.Simplify.Monad.

 * Added `SimplifyOpts` and `SimplifyExprOpts`. Provide initialization functions
   for those in a new module GHC.Driver.Config.Core.Opt.Simplify.
   Also added initialization functions for `SimplMode` to that module.

 * Moved `CoreToDo` and friends to a new module GHC.Core.Pipeline.Types
   and the counting types and functions (`SimplCount` and `Tick`) to new
   module GHC.Core.Opt.Stats.

 * Added getter functions for the fields of `SimplMode`. The pedantic bottoms
   option and the platform are retrieved from the ArityOpts and RuleOpts and the
   getter functions allow us to retrieve values from `SpecEnv` without the
   knowledge where the data is stored exactly.

 * Moved the coercion optimization options from the top environment to
   `SimplMode`. This way the values left in the top environment are those
   dealing with monadic functionality, namely logging, IO related stuff and
   counting. Added a note "The environments of the Simplify pass".

 * Removed `CoreToDo` from GHC.Core.Lint and GHC.CoreToStg.Prep and got rid of
   `CoreDoSimplify`. Pass `SimplifyOpts` in the `CoreToDo` type instead.

 * Prep work before removing `InteractiveContext` from `HscEnv`.

- - - - -
2c5991cc by Simon Peyton Jones at 2022-07-22T08:18:41-04:00
Make the specialiser deal better with specialised methods

This patch fixes #21848, by being more careful to update unfoldings
in the type-class specialiser.

See the new Note [Update unfolding after specialisation]

Now that we are being so much more careful about unfoldings,
it turned out that I could dispense with se_interesting, and
all its tricky corners. Hooray.  This fixes #21368.

- - - - -
ae166635 by Ben Gamari at 2022-07-22T08:18:41-04:00
ghc-boot: Clean up UTF-8 codecs

In preparation for moving the UTF-8 codecs into `base`:

* Move them to GHC.Utils.Encoding.UTF8
* Make names more consistent
* Add some Haddocks

- - - - -
e8ac91db by Ben Gamari at 2022-07-22T08:18:41-04:00
base: Introduce GHC.Encoding.UTF8

Here we copy a subset of the UTF-8 implementation living in `ghc-boot`
into `base`, with the intent of dropping the former in the future. For
this reason, the `ghc-boot` copy is now CPP-guarded on
`MIN_VERSION_base(4,18,0)`.

Naturally, we can't copy *all* of the functions defined by `ghc-boot` as
some depend upon `bytestring`; we rather just copy those which only
depend upon `base` and `ghc-prim`.

Further consolidation?
----------------------

Currently GHC ships with at least five UTF-8 implementations:

* the implementation used by GHC in `ghc-boot:GHC.Utils.Encoding`; this
  can be used at a number of types including `Addr#`, `ByteArray#`,
  `ForeignPtr`, `Ptr`, `ShortByteString`, and `ByteString`. Most of this
  can be removed in GHC 9.6+2, when the copies in `base` will become
  available to `ghc-boot`.
* the copy of the `ghc-boot` definition now exported by
  `base:GHC.Encoding.UTF8`. This can be used at `Addr#`, `Ptr`,
  `ByteArray#`, and `ForeignPtr`
* the decoder used by `unpackCStringUtf8#` in `ghc-prim:GHC.CString`;
  this is specialised at `Addr#`.
* the codec used by the IO subsystem in `base:GHC.IO.Encoding.UTF8`;
  this is specialised at `Addr#` but, unlike the above, supports
  recovery in the presence of partial codepoints (since in IO contexts
  codepoints may be broken across buffers)
* the implementation provided by the `text` library

This does seem a tad silly. On the other hand, these implementations
*do* materially differ from one another (e.g. in the types they support,
the detail in errors they can report, and the ability to recover from
partial codepoints). Consequently, it's quite unclear that further
consolidate would be worthwhile.

- - - - -
f9ad8025 by Ben Gamari at 2022-07-22T08:18:41-04:00
Add a Note summarising GHC's UTF-8 implementations

GHC has a somewhat dizzying array of UTF-8 implementations. This note
describes why this is the case.

- - - - -
72dfad3d by Ben Gamari at 2022-07-22T08:18:42-04:00
upload_ghc_libs: Fix path to documentation

The documentation was moved in a10584e8df9b346cecf700b23187044742ce0b35
but this one occurrence was note updated.

Finally closes #21164.

- - - - -
a8b150e7 by sheaf at 2022-07-22T08:18:44-04:00
Add test for #21871

This adds a test for #21871, which was fixed by the No Skolem Info
rework (MR !7105).

Fixes #21871

- - - - -
6379f942 by sheaf at 2022-07-22T08:18:46-04:00
Add test for #21360

The way record updates are typechecked/desugared changed in MR !7981.
Because we desugar in the typechecker to a simple case expression, the
pattern match checker becomes able to spot the long-distance information
and avoid emitting an incorrect pattern match warning.

Fixes #21360

- - - - -
ce0cd12c by sheaf at 2022-07-22T08:18:47-04:00
Hadrian: don't try to build "unix" on Windows
- - - - -
dc27e15a by Simon Peyton Jones at 2022-07-25T09:42:01-04:00
Implement DeepSubsumption

This MR adds the language extension -XDeepSubsumption, implementing
GHC proposal #511.  This change mitigates the impact of GHC proposal

The changes are highly localised, by design.  See Note [Deep subsumption]
in GHC.Tc.Utils.Unify.

The main changes are:

* Add -XDeepSubsumption, which is on by default in Haskell98 and Haskell2010,
  but off in Haskell2021.

  -XDeepSubsumption largely restores the behaviour before the "simple subsumption" change.
  -XDeepSubsumpition has a similar flavour as -XNoMonoLocalBinds:
  it makes type inference more complicated and less predictable, but it
  may be convenient in practice.

* The main changes are in:
  * GHC.Tc.Utils.Unify.tcSubType, which does deep susumption and eta-expanansion
  * GHC.Tc.Utils.Unify.tcSkolemiseET, which does deep skolemisation
  * In GHC.Tc.Gen.App.tcApp we call tcSubTypeNC to match the result
    type. Without deep subsumption, unifyExpectedType would be sufficent.

  See Note [Deep subsumption] in GHC.Tc.Utils.Unify.

* There are no changes to Quick Look at all.

* The type of `withDict` becomes ambiguous; so add -XAllowAmbiguousTypes to
  GHC.Magic.Dict

* I fixed a small but egregious bug in GHC.Core.FVs.varTypeTyCoFVs, where
  we'd forgotten to take the free vars of the multiplicity of an Id.

* I also had to fix tcSplitNestedSigmaTys

  When I did the shallow-subsumption patch
    commit 2b792facab46f7cdd09d12e79499f4e0dcd4293f
    Date:   Sun Feb 2 18:23:11 2020 +0000
    Simple subsumption

  I changed tcSplitNestedSigmaTys to not look through function arrows
  any more.  But that was actually an un-forced change.  This function
  is used only in

  * Improving error messages in GHC.Tc.Gen.Head.addFunResCtxt
  * Validity checking for default methods: GHC.Tc.TyCl.checkValidClass
  * A couple of calls in the GHCi debugger: GHC.Runtime.Heap.Inspect

  All to do with validity checking and error messages. Acutally its
  fine to look under function arrows here, and quite useful a test
  DeepSubsumption05 (a test motivated by a build failure in the
  `lens` package) shows.

  The fix is easy.  I added Note [tcSplitNestedSigmaTys].

- - - - -
e31ead39 by Matthew Pickering at 2022-07-25T09:42:01-04:00
Add tests that -XHaskell98 and -XHaskell2010 enable DeepSubsumption

- - - - -
67189985 by Matthew Pickering at 2022-07-25T09:42:01-04:00
Add DeepSubsumption08

- - - - -
5e93a952 by Simon Peyton Jones at 2022-07-25T09:42:01-04:00
Fix the interaction of operator sections and deep subsumption

Fixes DeepSubsumption08

- - - - -
918620d9 by Zubin Duggal at 2022-07-25T09:42:01-04:00
Add DeepSubsumption09

- - - - -
2a773259 by Gabriella Gonzalez at 2022-07-25T09:42:40-04:00
Default implementation for mempty/(<>)

Approved by: https://github.com/haskell/core-libraries-committee/issues/61

This adds a default implementation for `mempty` and `(<>)` along
with a matching `MINIMAL` pragma so that `Semigroup` and `Monoid`
instances can be defined in terms of `sconcat` / `mconcat`.

The description for each class has also been updated to include the
equivalent set of laws for the `sconcat`-only / `mconcat`-only
instances.

- - - - -
73836fc8 by Bryan Richter at 2022-07-25T09:43:16-04:00
ci: Disable (broken) perf-nofib

See #21859

- - - - -
c24ca5c3 by sheaf at 2022-07-25T09:43:58-04:00
Docs: clarify ConstraintKinds infelicity

GHC doesn't consistently require the ConstraintKinds extension to
be enabled, as it allows programs such as type families returning
a constraint without this extension.

MR !7784 fixes this infelicity, but breaking user programs was deemed
to not be worth it, so we document it instead.

Fixes #21061.

- - - - -
5f2fbd5e by Simon Peyton Jones at 2022-07-25T09:44:34-04:00
More improvements to worker/wrapper

This patch fixes #21888, and simplifies finaliseArgBoxities
by eliminating the (recently introduced) data type FinalDecision.

A delicate interaction meant that this patch
   commit d1c25a48154236861a413e058ea38d1b8320273f
   Date:   Tue Jul 12 16:33:46 2022 +0100
   Refactor wantToUnboxArg a bit

make worker/wrapper go into an infinite loop.  This patch
fixes it by narrowing the handling of case (B) of
Note [Boxity for bottoming functions], to deal only the
arguemnts that are type variables.  Only then do we drop
the trimBoxity call, which is what caused the bug.

I also
* Added documentation of case (B), which was previously
  completely un-mentioned.  And a regression test,
  T21888a, to test it.

* Made unboxDeeplyDmd stop at lazy demands.  It's rare anyway
  for a bottoming function to have a lazy argument (mainly when
  the data type is recursive and then we don't want to unbox
  deeply).  Plus there is Note [No lazy, Unboxed demands in
  demand signature]

* Refactored the Case equation for dmdAnal a bit, to do less
  redundant pattern matching.

- - - - -
b77d95f8 by Simon Peyton Jones at 2022-07-25T09:45:09-04:00
Fix a small buglet in tryEtaReduce

Gergo points out (#21801) that GHC.Core.Opt.Arity.tryEtaReduce was
making an ill-formed cast.  It didn't matter, because the subsequent
guard discarded it; but still worth fixing.  Spurious warnings are
distracting.

- - - - -
3bbde957 by Zubin Duggal at 2022-07-25T09:45:45-04:00
Fix #21889, GHCi misbehaves with Ctrl-C on Windows

On Windows, we create multiple levels of wrappers for GHCi which ultimately
execute ghc --interactive. In order to handle console events properly, each of
these wrappers must call FreeConsole() in order to hand off event processing to
the child process. See #14150.

In addition to this, FreeConsole must only be called from interactive processes (#13411).

This commit makes two changes to fix this situation:

1. The hadrian wrappers generated using `hadrian/bindist/cwrappers/version-wrapper.c` call `FreeConsole`
   if the CPP flag INTERACTIVE_PROCESS is set, which is set when we are generating a wrapper for GHCi.
2. The GHCi wrapper in `driver/ghci/` calls the `ghc-$VER.exe` executable which is not wrapped rather
   than calling `ghc.exe` is is wrapped on windows (and usually non-interactive, so can't call `FreeConsole`:

   Before:
   ghci-$VER.exe calls ghci.exe which calls ghc.exe which calls ghc-$VER.exe

   After:
   ghci-$VER.exe calls ghci.exe which calls ghc-$VER.exe

- - - - -
79f1b021 by Simon Jakobi at 2022-07-25T09:46:21-04:00
docs: Fix documentation of \cases

Fixes #21902.

- - - - -
e4bf9592 by sternenseemann at 2022-07-25T09:47:01-04:00
ghc-cabal: allow Cabal 3.8 to unbreak make build

When bootstrapping GHC 9.4.*, the build will fail when configuring
ghc-cabal as part of the make based build system due to this upper
bound, as Cabal has been updated to a 3.8 release.

Reference #21914, see especially
https://gitlab.haskell.org/ghc/ghc/-/issues/21914#note_444699

- - - - -
726d938e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00
Fix isEvaldUnfolding and isValueUnfolding

This fixes (1) in #21831.  Easy, obviously correct.

- - - - -
5d26c321 by Simon Peyton Jones at 2022-07-25T14:38:14-04:00
Switch off eta-expansion in rules and unfoldings

I think this change will make little difference except to reduce
clutter.  But that's it -- if it causes problems we can switch it
on again.

- - - - -
d4fe2f4e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00
Teach SpecConstr about typeDeterminesValue

This patch addresses #21831, point 2.  See
Note [generaliseDictPats] in SpecConstr

I took the opportunity to refactor the construction of specialisation
rules a bit, so that the rule name says what type we are specialising
at.

Surprisingly, there's a 20% decrease in compile time for test
perf/compiler/T18223. I took a look at it, and the code size seems the
same throughout. I did a quick ticky profile which seemed to show a
bit less substitution going on.  Hmm.  Maybe it's the "don't do
eta-expansion in stable unfoldings" patch, which is part of the
same MR as this patch.

Anyway, since it's a move in the right direction, I didn't think it
was worth looking into further.

Metric Decrease:
    T18223

- - - - -
65f7838a by Simon Peyton Jones at 2022-07-25T14:38:14-04:00
Add a 'notes' file in testsuite/tests/perf/compiler

This file is just a place to accumlate notes about particular
benchmarks, so that I don't keep re-inventing the wheel.

- - - - -
61faff40 by Simon Peyton Jones at 2022-07-25T14:38:50-04:00
Get the in-scope set right in FamInstEnv.injectiveBranches

There was an assert error, as Gergo pointed out in #21896.

I fixed this by adding an InScopeSet argument to tcUnifyTyWithTFs.
And also to GHC.Core.Unify.niFixTCvSubst.

I also took the opportunity to get a couple more InScopeSets right,
and to change some substTyUnchecked into substTy.

This MR touches a lot of other files, but only because I also took the
opportunity to introduce mkInScopeSetList, and use it.

- - - - -
4a7256a7 by Cheng Shao at 2022-07-25T20:41:55+00:00
Add location to cc phase

- - - - -
96811ba4 by Cheng Shao at 2022-07-25T20:41:55+00:00
Avoid as pipeline when compiling c

- - - - -
2869b66d by Cheng Shao at 2022-07-25T20:42:20+00:00
testsuite: Skip test cases involving -S when testing unregisterised GHC

We no longer generate .s files anyway.

Metric Decrease:
    MultiLayerModules
    T10421
    T13035
    T13701
    T14697
    T16875
    T18140
    T18304
    T18923
    T9198

- - - - -
82a0991a by Ben Gamari at 2022-07-25T23:32:05-04:00
testsuite: introduce nonmoving_thread_sanity way

(cherry picked from commit 19f8fce3659de3d72046bea9c61d1a82904bc4ae)

- - - - -
4b087973 by Ben Gamari at 2022-07-25T23:32:06-04:00
rts/nonmoving: Track segment state

It can often be useful during debugging to be able to determine the
state of a nonmoving segment. Introduce some state, enabled by DEBUG, to
track this.

(cherry picked from commit 40e797ef591ae3122ccc98ab0cc3cfcf9d17bd7f)

- - - - -
54a5c32d by Ben Gamari at 2022-07-25T23:32:06-04:00
rts/nonmoving: Don't scavenge objects which weren't evacuated

This fixes a rather subtle bug in the logic responsible for scavenging
objects evacuated to the non-moving generation. In particular, objects
can be allocated into the non-moving generation by two ways:

 a. evacuation out of from-space by the garbage collector
 b. direct allocation by the mutator

Like all evacuation, objects moved by (a) must be scavenged, since they
may contain references to other objects located in from-space. To
accomplish this we have the following scheme:

 * each nonmoving segment's block descriptor has a scan pointer which
   points to the first object which has yet to be scavenged

 * the GC tracks a set of "todo" segments which have pending scavenging
   work

 * to scavenge a segment, we scavenge each of the unmarked blocks
   between the scan pointer and segment's `next_free` pointer.

   We skip marked blocks since we know the allocator wouldn't have
   allocated into marked blocks (since they contain presumably live
   data).

   We can stop at `next_free` since, by
   definition, the GC could not have evacuated any objects to blocks
   above `next_free` (otherwise `next_free wouldn't be the first free
   block).

However, this neglected to consider objects allocated by path (b).
In short, the problem is that objects directly allocated by the mutator
may become unreachable (but not swept, since the containing segment is
not yet full), at which point they may contain references to swept objects.
Specifically, we observed this in #21885 in the following way:

1. the mutator (specifically in #21885, a `lockCAF`) allocates an object
   (specifically a blackhole, which here we will call `blkh`; see Note
   [Static objects under the nonmoving collector] for the reason why) on
   the non-moving heap. The bitmap of the allocated block remains 0
   (since allocation doesn't affect the bitmap) and the containing
   segment's (which we will call `blkh_seg`) `next_free` is advanced.
2. We enter the blackhole, evaluating the blackhole to produce a result
   (specificaly a cons cell) in the nursery
3. The blackhole gets updated into an indirection pointing to the cons
   cell; it is pushed to the generational remembered set
4. we perform a GC, the cons cell is evacuated into the nonmoving heap
   (into segment `cons_seg`)
5. the cons cell is marked
6. the GC concludes
7. the CAF and blackhole become unreachable
8. `cons_seg` is filled
9. we start another GC; the cons cell is swept
10. we start a new GC
11. something is evacuated into `blkh_seg`, adding it to the "todo" list
12. we attempt to scavenge `blkh_seg` (namely, all unmarked blocks
    between `scan` and `next_free`, which includes `blkh`). We attempt to
    evacuate `blkh`'s indirectee, which is the previously-swept cons cell.
    This is unsafe, since the indirectee is no longer a valid heap
    object.

The problem here was that the scavenging logic *assumed* that (a) was
the only source of allocations into the non-moving heap and therefore
*all* unmarked blocks between `scan` and `next_free` were evacuated.
However, due to (b) this is not true.

The solution is to ensure that that the scanned region only encompasses
the region of objects allocated during evacuation. We do this by
updating `scan` as we push the segment to the todo-segment list to
point to the block which was evacuated into.

Doing this required changing the nonmoving scavenging implementation's
update of the `scan` pointer to bump it *once*, instead of after
scavenging each block as was done previously. This is because we may end
up evacuating into the segment being scavenged as we scavenge it. This
was quite tricky to discover but the result is quite simple,
demonstrating yet again that global mutable state should be used
exceedingly sparingly.

Fixes #21885

(cherry picked from commit 0b27ea23efcb08639309293faf13fdfef03f1060)

- - - - -
25c24535 by Ben Gamari at 2022-07-25T23:32:06-04:00
testsuite: Skip a few tests as in the nonmoving collector

Residency monitoring under the non-moving collector is quite
conservative (e.g. the reported value is larger than reality) since
otherwise we would need to block on concurrent collection. Skip a few
tests that are sensitive to residency.

(cherry picked from commit 6880e4fbf728c04e8ce83e725bfc028fcb18cd70)

- - - - -
42147534 by sternenseemann at 2022-07-26T16:26:53-04:00
hadrian: add flag disabling selftest rules which require QuickCheck

The hadrian executable depends on QuickCheck for building, meaning this
library (and its dependencies) will need to be built for bootstrapping
GHC in the future. Building QuickCheck, however, can require
TemplateHaskell. When building a statically linking GHC toolchain,
TemplateHaskell can be tricky to get to work, and cross-compiling
TemplateHaskell doesn't work at all without -fexternal-interpreter,
so QuickCheck introduces an element of fragility to GHC's bootstrap.

Since the selftest rules are the only part of hadrian that need
QuickCheck, we can easily eliminate this bootstrap dependency when
required by introducing a `selftest` flag guarding the rules' inclusion.

Closes #8699.

- - - - -
9ea29d47 by Simon Peyton Jones at 2022-07-26T16:27:28-04:00
Regression test for #21848

- - - - -
ef30e215 by Matthew Pickering at 2022-07-28T13:56:59-04:00
driver: Don't create LinkNodes when -no-link is enabled

Fixes #21866

- - - - -
fc23b5ed by sheaf at 2022-07-28T13:57:38-04:00
Docs: fix mistaken claim about kind signatures

This patch fixes #21806 by rectifying an incorrect claim about
the usage of kind variables in the header of a data declaration with
a standalone kind signature.

It also adds some clarifications about the number of parameters expected
in GADT declarations and in type family declarations.

- - - - -
2df92ee1 by Matthew Pickering at 2022-08-02T05:20:01-04:00
testsuite: Correctly set withNativeCodeGen

Fixes #21918

- - - - -
f2912143 by Matthew Pickering at 2022-08-02T05:20:45-04:00
Fix since annotations in GHC.Stack.CloneStack

Fixes #21894

- - - - -
aeb8497d by Andreas Klebinger at 2022-08-02T19:26:51-04:00
Add -dsuppress-coercion-types to make coercions even smaller.

Instead of `` `cast` <Co:11> :: (Some -> Really -> Large Type)``
simply print `` `cast` <Co:11> :: ... ``

- - - - -
97655ad8 by sheaf at 2022-08-02T19:27:29-04:00
User's guide: fix typo in hasfield.rst

Fixes #21950

- - - - -
35aef18d by Yiyun Liu at 2022-08-04T02:55:07-04:00
Remove TCvSubst and use Subst for both term and type-level subst

This patch removes the TCvSubst data type and instead uses Subst as
the environment for both term and type level substitution. This
change is partially motivated by the existential type proposal,
which will introduce types that contain expressions and therefore
forces us to carry around an "IdSubstEnv" even when substituting for
types. It also reduces the amount of code because "Subst" and
"TCvSubst" share a lot of common operations. There isn't any
noticeable impact on performance (geo. mean for ghc/alloc is around
0.0% but we have -94 loc and one less data type to worry abount).

Currently, the "TCvSubst" data type for substitution on types is
identical to the "Subst" data type except the former doesn't store
"IdSubstEnv". Using "Subst" for type-level substitution means there
will be a redundant field stored in the data type. However, in cases
where the substitution starts from the expression, using "Subst" for
type-level substitution saves us from having to project "Subst" into a
"TCvSubst". This probably explains why the allocation is mostly even
despite the redundant field.

The patch deletes "TCvSubst" and moves "Subst" and its relevant
functions from "GHC.Core.Subst" into "GHC.Core.TyCo.Subst".
Substitution on expressions is still defined in "GHC.Core.Subst" so we
don't have to expose the definition of "Expr" in the hs-boot file that
"GHC.Core.TyCo.Subst" must import to refer to "IdSubstEnv" (whose
codomain is "CoreExpr"). Most functions named fooTCvSubst are renamed
into fooSubst with a few exceptions (e.g. "isEmptyTCvSubst" is a
distinct function from "isEmptySubst"; the former ignores the
emptiness of "IdSubstEnv"). These exceptions mainly exist for
performance reasons and will go away when "Expr" and "Type" are
mutually recursively defined (we won't be able to take those
shortcuts if we can't make the assumption that expressions don't
appear in types).

- - - - -
b99819bd by Krzysztof Gogolewski at 2022-08-04T02:55:43-04:00
Fix TH + defer-type-errors interaction (#21920)

Previously, we had to disable defer-type-errors in splices because of #7276.
But this fix is no longer necessary, the test T7276 no longer segfaults
and is now correctly deferred.

- - - - -
fb529cae by Andreas Klebinger at 2022-08-04T13:57:25-04:00
Add a note about about W/W for unlifting strict arguments

This fixes #21236.

- - - - -
fffc75a9 by Matthew Pickering at 2022-08-04T13:58:01-04:00
Force safeInferred to avoid retaining extra copy of DynFlags

This will only have a (very) modest impact on memory but we don't want
to retain old copies of DynFlags hanging around so best to force this
value.

- - - - -
0f43837f by Matthew Pickering at 2022-08-04T13:58:01-04:00
Force name selectors to ensure no reference to Ids enter the NameCache

I observed some unforced thunks in the NameCache which were retaining a
whole Id, which ends up retaining a Type.. which ends up retaining old
copies of HscEnv containing stale HomeModInfo.

- - - - -
0b1f5fd1 by Matthew Pickering at 2022-08-04T13:58:01-04:00
Fix leaks in --make mode when there are module loops

This patch fixes quite a tricky leak where we would end up retaining
stale ModDetails due to rehydrating modules against non-finalised
interfaces.

== Loops with multiple boot files

It is possible for a module graph to have a loop (SCC, when ignoring boot files)
which requires multiple boot files to break. In this case we must perform the
necessary hydration steps before and after compiling modules which have boot files
which are described above for corectness but also perform an additional hydration step
at the end of the SCC to remove space leaks.

Consider the following example:

┌───────┐   ┌───────┐
│       │   │       │
│   A   │   │   B   │
│       │   │       │
└─────┬─┘   └───┬───┘
      │         │
 ┌────▼─────────▼──┐
 │                 │
 │        C        │
 └────┬─────────┬──┘
      │         │
 ┌────▼──┐  ┌───▼───┐
 │       │  │       │
 │ A-boot│  │ B-boot│
 │       │  │       │
 └───────┘  └───────┘

 A, B and C live together in a SCC. Say we compile the modules in order
 A-boot, B-boot, C, A, B then when we compile A we will perform the hydration steps
 (because A has a boot file). Therefore C will be hydrated relative to A, and the
 ModDetails for A will reference C/A. Then when B is compiled C will be rehydrated again,
 and so B will reference C/A,B, its interface will be hydrated relative to both A and B.
 Now there is a space leak because say C is a very big module, there are now two different copies of
 ModDetails kept alive by modules A and B.

The way to avoid this space leak is to rehydrate an entire SCC together at the
end of compilation so that all the ModDetails point to interfaces for .hs files.
In this example, when we hydrate A, B and C together then both A and B will refer to
C/A,B.

See #21900 for some more discussion.

-------------------------------------------------------

In addition to this simple case, there is also the potential for a leak
during parallel upsweep which is also fixed by this patch. Transcibed is
Note [ModuleNameSet, efficiency and space leaks]

Note [ModuleNameSet, efficiency and space leaks]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

During unsweep the results of compiling modules are placed into a MVar, to find
the environment the module needs to compile itself in the MVar is consulted and
the HomeUnitGraph is set accordingly. The reason we do this is that precisely tracking
module dependencies and recreating the HUG from scratch each time is very expensive.

In serial mode (-j1), this all works out fine because a module can only be compiled after
its dependencies have finished compiling and not interleaved with compiling module loops.
Therefore when we create the finalised or no loop interfaces, the HUG only contains
finalised interfaces.

In parallel mode, we have to be more careful because the HUG variable can contain
non-finalised interfaces which have been started by another thread. In order to avoid
a space leak where a finalised interface is compiled against a HPT which contains a
non-finalised interface we have to restrict the HUG to only the visible modules.

The visible modules is recording in the ModuleNameSet, this is propagated upwards
whilst compiling and explains which transitive modules are visible from a certain point.
This set is then used to restrict the HUG before the module is compiled to only
the visible modules and thus avoiding this tricky space leak.

Efficiency of the ModuleNameSet is of utmost importance because a union occurs for
each edge in the module graph. Therefore the set is represented directly as an IntSet
which provides suitable performance, even using a UniqSet (which is backed by an IntMap) is
too slow. The crucial test of performance here is the time taken to a do a no-op build in --make mode.

See test "jspace" for an example which used to trigger this problem.

Fixes #21900

- - - - -
1d94a59f by Matthew Pickering at 2022-08-04T13:58:01-04:00
Store interfaces in ModIfaceCache more directly

I realised hydration was completely irrelavant for this cache because
the ModDetails are pruned from the result. So now it simplifies things a
lot to just store the ModIface and Linkable, which we can put into the
cache straight away rather than wait for the final version of a
HomeModInfo to appear.

- - - - -
6c7cd50f by Cheng Shao at 2022-08-04T23:01:45-04:00
cmm: Remove unused ReadOnlyData16

We don't actually emit rodata16 sections anywhere.

- - - - -
16333ad7 by Andreas Klebinger at 2022-08-04T23:02:20-04:00
findExternalRules: Don't needlessly traverse the list of rules.

- - - - -
52c15674 by Krzysztof Gogolewski at 2022-08-05T12:47:05-04:00
Remove backported items from 9.6 release notes

They have been backported to 9.4 in commits 5423d84bd9a28f,
13c81cb6be95c5, 67ccbd6b2d4b9b.

- - - - -
78d232f5 by Matthew Pickering at 2022-08-05T12:47:40-04:00
ci: Fix pages job

The job has been failing because we don't bundle haddock docs anymore in
the docs dist created by hadrian.

Fixes #21789

- - - - -
037bc9c9 by Ben Gamari at 2022-08-05T22:00:29-04:00
codeGen/X86: Don't clobber switch variable in switch generation

Previously ce8745952f99174ad9d3bdc7697fd086b47cdfb5 assumed that it was
safe to clobber the switch variable when generating code for a jump
table since we were at the end of a block. However, this assumption is
wrong; the register could be live in the jump target.

Fixes #21968.

- - - - -
50c8e1c5 by Matthew Pickering at 2022-08-05T22:01:04-04:00
Fix equality operator in jspace test

- - - - -
e9c77a22 by Andreas Klebinger at 2022-08-06T06:13:17-04:00
Improve BUILD_PAP comments

- - - - -
41234147 by Andreas Klebinger at 2022-08-06T06:13:17-04:00
Make dropTail comment a haddock comment

- - - - -
ff11d579 by Andreas Klebinger at 2022-08-06T06:13:17-04:00
Add one more sanity check in stg_restore_cccs

- - - - -
1f6c56ae by Andreas Klebinger at 2022-08-06T06:13:17-04:00
StgToCmm: Fix isSimpleScrut when profiling is enabled.

When profiling is enabled we must enter functions that might represent
thunks in order for their sccs to show up in the profile.

We might allocate even if the function is already evaluated in this
case. So we can't consider any potential function thunk to be a simple
scrut when profiling.

Not doing so caused profiled binaries to segfault.

- - - - -
fab0ee93 by Andreas Klebinger at 2022-08-06T06:13:17-04:00
Change `-fprof-late` to insert cost centres after unfolding creation.

The former behaviour of adding cost centres after optimization but
before unfoldings are created is not available via the flag
`prof-late-inline` instead.

I also reduced the overhead of -fprof-late* by pushing the cost centres
into lambdas. This means the cost centres will only account for
execution of functions and not their partial application.

Further I made LATE_CC cost centres it's own CC flavour so they now
won't clash with user defined ones if a user uses the same string for
a custom scc.

LateCC: Don't put cost centres inside constructor workers.

With -fprof-late they are rarely useful as the worker is usually
inlined. Even if the worker is not inlined or we use -fprof-late-linline
they are generally not helpful but bloat compile and run time
significantly. So we just don't add sccs inside constructor workers.

-------------------------
Metric Decrease:
    T13701
-------------------------

- - - - -
f8bec4e3 by Ben Gamari at 2022-08-06T06:13:53-04:00
gitlab-ci: Fix hadrian bootstrapping of release pipelines

Previously we would attempt to test hadrian bootstrapping in the
`validate` build flavour. However, `ci.sh` refuses to run validation
builds during release pipelines, resulting in job failures. Fix this by
testing bootstrapping in the `release` flavour during release pipelines.

We also attempted to record perf notes for these builds, which is
redundant work and undesirable now since we no longer build in a
consistent flavour.

- - - - -
c0348865 by Ben Gamari at 2022-08-06T11:45:17-04:00
compiler: Eliminate two uses of foldr in favor of foldl'

These two uses constructed maps, which is a case where foldl' is
generally more efficient since we avoid constructing an intermediate
O(n)-depth stack.

- - - - -
d2e4e123 by Ben Gamari at 2022-08-06T11:45:17-04:00
rts: Fix code style

- - - - -
57f530d3 by Ben Gamari at 2022-08-06T11:45:17-04:00
genprimopcode: Drop ArrayArray# references

As ArrayArray# no longer exists

- - - - -
7267cd52 by Ben Gamari at 2022-08-06T11:45:17-04:00
base: Organize Haddocks in GHC.Conc.Sync

- - - - -
aa818a9f by Ben Gamari at 2022-08-06T11:48:50-04:00
Add primop to list threads

A user came to #ghc yesterday wondering how best to check whether they
were leaking threads. We ended up using the eventlog but it seems to me
like it would be generally useful if Haskell programs could query their
own threads.

- - - - -
6d1700b6 by Ben Gamari at 2022-08-06T11:51:35-04:00
rts: Move thread labels into TSO

This eliminates the thread label HashTable and instead tracks this
information in the TSO, allowing us to use proper StgArrBytes arrays for
backing the label and greatly simplifying management of object lifetimes
when we expose them to the user with the coming `threadLabel#` primop.

- - - - -
1472044b by Ben Gamari at 2022-08-06T11:54:52-04:00
Add a primop to query the label of a thread

- - - - -
43f2b271 by Ben Gamari at 2022-08-06T11:55:14-04:00
base: Share finalization thread label

For efficiency's sake we float the thread label assigned to the
finalization thread to the top-level, ensuring that we only need to
encode the label once.

- - - - -
1d63b4fb by Ben Gamari at 2022-08-06T11:57:11-04:00
users-guide: Add release notes entry for thread introspection support

- - - - -
09bca1de by Ben Gamari at 2022-08-07T01:19:35-04:00
hadrian: Fix binary distribution install attributes

Previously we would use plain `cp` to install various parts of the
binary distribution. However, `cp`'s behavior w.r.t. file attributes is
quite unclear; for this reason it is much better to rather use
`install`.

Fixes #21965.

- - - - -
2b8ea16d by Ben Gamari at 2022-08-07T01:19:35-04:00
hadrian: Fix installation of system-cxx-std-lib package conf

- - - - -
7b514848 by Ben Gamari at 2022-08-07T01:20:10-04:00
gitlab-ci: Bump Docker images

To give the ARMv7 job access to lld, fixing #21875.

- - - - -
afa584a3 by Ben Gamari at 2022-08-07T05:08:52-04:00
hadrian: Don't use mk/config.mk.in

Ultimately we want to drop mk/config.mk so here I extract the bits
needed by the Hadrian bindist installation logic into a Hadrian-specific
file. While doing this I fixed binary distribution installation, #21901.

- - - - -
b9bb45d7 by Ben Gamari at 2022-08-07T05:08:52-04:00
hadrian: Fix naming of cross-compiler wrappers

- - - - -
78d04cfa by Ben Gamari at 2022-08-07T11:44:58-04:00
hadrian: Extend xattr Darwin hack to cover /lib

As noted in #21506, it is now necessary to remove extended attributes
from `/lib` as well as `/bin` to avoid SIP issues on Darwin.

Fixes #21506.

- - - - -
20457d77 by Andreas Klebinger at 2022-08-08T14:42:26+02:00
NCG(x86): Compile add+shift as lea if possible.

- - - - -
742292e4 by Andreas Klebinger at 2022-08-08T16:46:37-04:00
dataToTag#: Skip runtime tag check if argument is infered tagged

This addresses one part of #21710.

- - - - -
1504a93e by Cheng Shao at 2022-08-08T16:47:14-04:00
rts: remove redundant stg_traceCcszh

This out-of-line primop has no Haskell wrapper and hasn't been used
anywhere in the tree. Furthermore, the code gets in the way of !7632, so
it should be garbage collected.

- - - - -
a52de3cb by Andreas Klebinger at 2022-08-08T16:47:50-04:00
Document a divergence from the report in parsing function lhss.

GHC is happy to parse `(f) x y = x + y` when it should be a parse error
based on the Haskell report. Seems harmless enough so we won't fix it
but it's documented now.

Fixes #19788

- - - - -
5765e133 by Ben Gamari at 2022-08-08T16:48:25-04:00
gitlab-ci: Add release job for aarch64/debian 11

- - - - -
5b26f324 by Ben Gamari at 2022-08-08T19:39:20-04:00
gitlab-ci: Introduce validation job for aarch64 cross-compilation

Begins to address #11958.

- - - - -
e866625c by Ben Gamari at 2022-08-08T19:39:20-04:00
Bump process submodule

- - - - -
ae707762 by Ben Gamari at 2022-08-08T19:39:20-04:00
gitlab-ci: Add basic support for cross-compiler testiing

Here we add a simple qemu-based test for cross-compilers.

- - - - -
50912d68 by Ben Gamari at 2022-08-08T19:39:57-04:00
rts: Ensure that Array# card arrays are initialized

In #19143 I noticed that newArray# failed to initialize the card table
of newly-allocated arrays. However, embarrassingly, I then only fixed
the issue in newArrayArray# and, in so doing, introduced the potential
for an integer underflow on zero-length arrays (#21962).

Here I fix the issue in newArray#, this time ensuring that we do not
underflow in pathological cases.

Fixes #19143.

- - - - -
e5ceff56 by Ben Gamari at 2022-08-08T19:39:57-04:00
testsuite: Add test for #21962

- - - - -
c1c08bd8 by Ben Gamari at 2022-08-09T02:31:14-04:00
gitlab-ci: Don't use coreutils on Darwin

In general we want to ensure that the tested environment is as similar
as possible to the environment the user will use. In the case of Darwin,
this means we want to use the system's BSD command-line utilities, not
coreutils.

This would have caught #21974.

- - - - -
1c582f44 by Ben Gamari at 2022-08-09T02:31:14-04:00
hadrian: Fix bindist installation on Darwin

It turns out that `cp -P` on Darwin does not always copy a symlink as
a symlink. In order to get these semantics one must pass `-RP`. It's not
entirely clear whether this is valid under POSIX, but it is nevertheless
what Apple does.

- - - - -
681aa076 by Ben Gamari at 2022-08-09T02:31:49-04:00
hadrian: Fix access mode of installed package registration files

Previously hadrian's bindist Makefile would modify package
registrations placed by `install` via a shell pipeline and `mv`.
However, the use of `mv` means that if umask is set then the user may
otherwise end up with package registrations which are inaccessible.
Fix this by ensuring that the mode is 0644.

- - - - -
e9dfd26a by Krzysztof Gogolewski at 2022-08-09T02:32:24-04:00
Cleanups around pretty-printing

* Remove hack when printing OccNames. No longer needed since e3dcc0d5
* Remove unused `pprCmms` and `instance Outputable Instr`
* Simplify `pprCLabel` (no need to pass platform)
* Remove evil `Show`/`Eq` instances for `SDoc`. They were needed by
  ImmLit, but that can take just a String instead.
* Remove instance `Outputable CLabel` - proper output of labels
  needs a platform, and is done by the `OutputableP` instance

- - - - -
66d2e927 by Ben Gamari at 2022-08-09T13:46:48-04:00
rts/linker: Resolve iconv_* on FreeBSD

FreeBSD's libiconv includes an implementation of the
iconv_* functions in libc. Unfortunately these can
only be resolved using dlvsym, which is how the RTS linker
usually resolves such functions. To fix this we include an ad-hoc
special case for iconv_*.

Fixes #20354.

- - - - -
5d66a0ce by Ben Gamari at 2022-08-09T13:46:48-04:00
system-cxx-std-lib: Add support for FreeBSD libcxxrt

- - - - -
ea90e61d by Ben Gamari at 2022-08-09T13:46:48-04:00
gitlab-ci: Bump to use freebsd13 runners

- - - - -
d71a2051 by sheaf at 2022-08-09T13:47:28-04:00
Fix size_up_alloc to account for UnliftedDatatypes

The size_up_alloc function mistakenly considered any type that isn't
lifted to not allocate anything, which is wrong. What we want instead
is to check the type isn't boxed. This accounts for (BoxedRep Unlifted).

Fixes #21939

- - - - -
76b52cf0 by Douglas Wilson at 2022-08-10T06:01:53-04:00
testsuite: 21651 add test for closeFdWith + setNumCapabilities

This bug does not affect windows, which does not use the
base module GHC.Event.Thread.

- - - - -
7589ee72 by Douglas Wilson at 2022-08-10T06:01:53-04:00
base: Fix races in IOManager (setNumCapabilities,closeFdWith)

Fix for #21651

Fixes three bugs:

- writes to eventManager should be atomic. It is accessed concurrently by ioManagerCapabilitiesChanged and closeFdWith.
- The race in closeFdWith described in the ticket.
- A race in getSystemEventManager where it accesses the 'IOArray' in
  'eventManager' before 'ioManagerCapabilitiesChanged' has written to
  'eventManager', causing an Array Index exception. The fix here is to
  'yield' and retry.

- - - - -
dc76439d by Trevis Elser at 2022-08-10T06:02:28-04:00
Updates language extension documentation

Adding a 'Status' field with a few values:
- Deprecated
- Experimental
- InternalUseOnly
- Noting if included in 'GHC2021', 'Haskell2010' or 'Haskell98'

Those values are pulled from the existing descriptions or elsewhere in
the documentation.

While at it, include the :implied by: where appropriate, to provide
more detail.

Fixes #21475

- - - - -
823fe5b5 by Jens Petersen at 2022-08-10T06:03:07-04:00
hadrian RunRest: add type signature for stageNumber

avoids warning seen on 9.4.1:

src/Settings/Builders/RunTest.hs:264:53: warning: [-Wtype-defaults]
    • Defaulting the following constraints to type ‘Integer’
        (Show a0)
          arising from a use of ‘show’
          at src/Settings/Builders/RunTest.hs:264:53-84
        (Num a0)
          arising from a use of ‘stageNumber’
          at src/Settings/Builders/RunTest.hs:264:59-83
    • In the second argument of ‘(++)’, namely
        ‘show (stageNumber (C.stage ctx))’
      In the second argument of ‘($)’, namely
        ‘"config.stage=" ++ show (stageNumber (C.stage ctx))’
      In the expression:
        arg $ "config.stage=" ++ show (stageNumber (C.stage ctx))
    |
264 |             , arg "-e", arg $ "config.stage="    ++ show (stageNumber (C.stage ctx))
    |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

compilation tested locally

- - - - -
f95bbdca by Sylvain Henry at 2022-08-10T09:44:46-04:00
Add support for external static plugins (#20964)

This patch adds a new command-line flag:

  -fplugin-library=<file-path>;<unit-id>;<module>;<args>

used like this:

  -fplugin-library=path/to/plugin.so;package-123;Plugin.Module;["Argument","List"]

It allows a plugin to be loaded directly from a shared library. With
this approach, GHC doesn't compile anything for the plugin and doesn't
load any .hi file for the plugin and its dependencies. As such GHC
doesn't need to support two environments (one for plugins, one for
target code), which was the more ambitious approach tracked in #14335.

Fix #20964

Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com>

- - - - -
5bc489ca by Ben Gamari at 2022-08-10T09:45:22-04:00
gitlab-ci: Fix ARMv7 build

It appears that the CI refactoring carried out in
5ff690b8474c74e9c968ef31e568c1ad0fe719a1 failed to carry over some
critical configuration: setting the build/host/target platforms and
forcing use of a non-broken linker.

- - - - -
596db9a5 by Ben Gamari at 2022-08-10T09:45:22-04:00
gitlab-ci: Run ARMv7 jobs when ~ARM label is used

- - - - -
7cabea7c by Ben Gamari at 2022-08-10T15:37:58-04:00
hadrian: Don't attempt to install documentation if doc/ doesn't exist

Previously we would attempt to install documentation even if the `doc`
directory doesn't exist (e.g. due to `--docs=none`). This would result
in the surprising side-effect of the entire contents of the bindist
being installed in the destination documentation directory. Fix this.

Fixes #21976.

- - - - -
67575f20 by normalcoder at 2022-08-10T15:38:34-04:00
ncg/aarch64: Don't use x18 register on AArch64/Darwin

Apple's ABI documentation [1] says: "The platforms reserve register x18.
Don’t use this register." While this wasn't problematic in previous
Darwin releases, macOS 13 appears to start zeroing this register
periodically. See #21964.

[1] https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms

- - - - -
45eb4cbe by Andreas Klebinger at 2022-08-10T22:41:12-04:00
Note [Trimming auto-rules]: State that this improves compiler perf.

- - - - -
5c24b1b3 by Andrew Lelechenko at 2022-08-10T22:41:50-04:00
Document that threadDelay / timeout are susceptible to overflows on 32-bit machines

- - - - -
ff67c79e by Alan Zimmerman at 2022-08-11T16:19:57-04:00
EPA: DotFieldOcc does not have exact print annotations

For the code

    {-# LANGUAGE OverloadedRecordUpdate #-}

    operatorUpdate f = f{(+) = 1}

There are no exact print annotations for the parens around the +
symbol, nor does normal ppr print them.

This MR fixes that.

Closes #21805

Updates haddock submodule

- - - - -
dca43a04 by Matthew Pickering at 2022-08-11T16:20:33-04:00
Revert "gitlab-ci: Add release job for aarch64/debian 11"

This reverts commit 5765e13370634979eb6a0d9f67aa9afa797bee46.

The job was not tested before being merged and fails CI
(https://gitlab.haskell.org/ghc/ghc/-/jobs/1139392)

Ticket #22005

- - - - -
ffc9116e by Eric Lindblad at 2022-08-16T09:01:26-04:00
typo
- - - - -
cd6f5bfd by Ben Gamari at 2022-08-16T09:02:02-04:00
CmmToLlvm: Don't aliasify builtin LLVM variables

Our aliasification logic would previously turn builtin LLVM variables
into aliases, which apparently confuses LLVM. This manifested in
initializers failing to be emitted, resulting in many profiling failures
with the LLVM backend.

Fixes #22019.

- - - - -
dc7da356 by Bryan Richter at 2022-08-16T09:02:38-04:00
run_ci: remove monoidal-containers

Fixes #21492

MonoidalMap is inlined and used to implement Variables, as before.

The top-level value "jobs" is reimplemented as a regular Map, since it
doesn't use the monoidal union anyway.

- - - - -
64110544 by Cheng Shao at 2022-08-16T09:03:15-04:00
CmmToAsm/AArch64: correct a typo

- - - - -
f6a5524a by Andreas Klebinger at 2022-08-16T14:34:11-04:00
Fix #21979 - compact-share failing with -O

I don't have good reason to believe the optimization level should affect
if sharing works or not here. So limit the test to the normal way.

- - - - -
68154a9d by Ben Gamari at 2022-08-16T14:34:47-04:00
users-guide: Fix reference to dead llvm-version substitution

Fixes #22052.

- - - - -
28c60d26 by Ben Gamari at 2022-08-16T14:34:47-04:00
users-guide: Fix incorrect reference to `:extension: role

- - - - -
71102c8f by Ben Gamari at 2022-08-16T14:34:47-04:00
users-guide: Add :ghc-flag: reference

- - - - -
385f420b by Ben Gamari at 2022-08-16T14:34:47-04:00
hadrian: Place manpage in docroot

This relocates it from docs/ to doc/

- - - - -
84598f2e by Ben Gamari at 2022-08-16T14:34:47-04:00
Bump haddock submodule

Includes merge of `main` into `ghc-head` as well as some Haddock users
guide fixes.

- - - - -
59ce787c by Ben Gamari at 2022-08-16T14:34:47-04:00
base: Add changelog entries from ghc-9.2

Closes #21922.

- - - - -
a14e6ae3 by Ben Gamari at 2022-08-16T14:34:47-04:00
relnotes: Add "included libraries" section

As noted in #21988, some users rely on this.

- - - - -
a4212edc by Ben Gamari at 2022-08-16T14:34:47-04:00
users-guide: Rephrase the rewrite rule documentation

Previously the wording was a tad unclear. Fix this.

Closes #21114.

- - - - -
3e493dfd by Peter Becich at 2022-08-17T08:43:21+01:00
Implement Response File support for HPC

This is an improvement to HPC authored by Richard Wallace
(https://github.com/purefn) and myself. I have received permission from
him to attempt to upstream it. This improvement was originally
implemented as a patch to HPC via input-output-hk/haskell.nix:
https://github.com/input-output-hk/haskell.nix/pull/1464

Paraphrasing Richard, HPC currently requires all inputs as command line arguments.
With large projects this can result in an argument list too long error.
I have only seen this error in Nix, but I assume it can occur is a plain Unix environment.

This MR adds the standard response file syntax support to HPC. For
example you can now pass a file to the command line which contains the
arguments.

```
hpc @response_file_1 @response_file_2 ...

The contents of a Response File must have this format:
COMMAND ...

example:
report my_library.tix --include=ModuleA --include=ModuleB
```

Updates hpc submodule

Co-authored-by:  Richard Wallace <rwallace at thewallacepack.net>

Fixes #22050

- - - - -
436867d6 by Matthew Pickering at 2022-08-18T09:24:08-04:00
ghc-heap: Fix decoding of TSO closures

An extra field was added to the TSO structure in 6d1700b6 but the
decoding logic in ghc-heap was not updated for this new field.

Fixes #22046

- - - - -
a740a4c5 by Matthew Pickering at 2022-08-18T09:24:44-04:00
driver: Honour -x option

The -x option is used to manually specify which phase a file should be
started to be compiled from (even if it lacks the correct extension). I
just failed to implement this when refactoring the driver.

In particular Cabal calls GHC with `-E -cpp -x hs Foo.cpphs` to
preprocess source files using GHC.

I added a test to exercise this case.

Fixes #22044

- - - - -
e293029d by Simon Peyton Jones at 2022-08-18T09:25:19-04:00
Be more careful in chooseInferredQuantifiers

This fixes #22065. We were failing to retain a quantifier that
was mentioned in the kind of another retained quantifier.

Easy to fix.

- - - - -
714c936f by Bryan Richter at 2022-08-18T18:37:21-04:00
testsuite: Add test for #21583

- - - - -
989b844d by Ben Gamari at 2022-08-18T18:37:57-04:00
compiler: Drop --build-id=none hack

Since 2011 the object-joining implementation has had a hack to pass
`--build-id=none` to `ld` when supported, seemingly to work around a
linker bug. This hack is now unnecessary and may break downstream users
who expect objects to have valid build-ids. Remove it.

Closes #22060.

- - - - -
519c712e by Matthew Pickering at 2022-08-19T00:09:11-04:00
Make ru_fn field strict to avoid retaining Ids

It's better to perform this projection from Id to Name strictly so we
don't retain an old Id (hence IdInfo, hence Unfolding, hence everything
etc)

- - - - -
7dda04b0 by Matthew Pickering at 2022-08-19T00:09:11-04:00
Force `getOccFS bndr` to avoid retaining reference to Bndr.

This is another symptom of #19619

- - - - -
4303acba by Matthew Pickering at 2022-08-19T00:09:11-04:00
Force unfoldings when they are cleaned-up in Tidy and CorePrep

If these thunks are not forced then the entire unfolding for the binding
is live throughout the whole of CodeGen despite the fact it should have
been discarded.

Fixes #22071

- - - - -
2361b3bc by Matthew Pickering at 2022-08-19T00:09:47-04:00
haddock docs: Fix links from identifiers to dependent packages

When implementing the base_url changes I made the pretty bad mistake of
zipping together two lists which were in different orders. The simpler
thing to do is just modify `haddockDependencies` to also return the
package identifier so that everything stays in sync.

Fixes #22001

- - - - -
9a7e2ea1 by Matthew Pickering at 2022-08-19T00:10:23-04:00
Revert "Refactor SpecConstr to use treat bindings uniformly"

This reverts commit 415468fef8a3e9181b7eca86de0e05c0cce31729.

This refactoring introduced quite a severe residency regression (900MB
live from 650MB live when compiling mmark), see #21993 for a reproducer
and more discussion.

Ticket #21993

- - - - -
9789e845 by Zachary Wood at 2022-08-19T14:17:28-04:00
tc: warn about lazy annotations on unlifted arguments (fixes #21951)

- - - - -
e5567289 by Andreas Klebinger at 2022-08-19T14:18:03-04:00
Fix #22048 where we failed to drop rules for -fomit-interface-pragmas.

Now we also filter the local rules (again) which fixes the issue.

- - - - -
51ffd009 by Swann Moreau at 2022-08-19T18:29:21-04:00
Print constraints in quotes (#21167)

This patch improves the uniformity of error message formatting by
printing constraints in quotes, as we do for types.

Fix #21167

- - - - -
ab3e0f5a by Sasha Bogicevic at 2022-08-19T18:29:57-04:00
19217 Implicitly quantify type variables in :kind command

- - - - -
9939e95f by MorrowM at 2022-08-21T16:51:38-04:00
Recognize file-header pragmas in GHCi (#21507)

- - - - -
fb7c2d99 by Matthew Pickering at 2022-08-21T16:52:13-04:00
hadrian: Fix bootstrapping with ghc-9.4

The error was that we were trying to link together

    containers from boot package library (which depends template-haskell in boot package library)
    template-haskell from in-tree package database

So the fix is to build containers in stage0 (and link against template-haskell built in stage0).

Fixes #21981

- - - - -
b946232c by Mario Blažević at 2022-08-22T22:06:21-04:00
Added pprType with precedence argument, as a prerequisite to fix issues #21723 and #21942.

* refines the precedence levels, adding `qualPrec` and `funPrec` to better control parenthesization
* `pprParendType`, `pprFunArgType`, and `instance Ppr Type` all just call `pprType` with proper precedence
* `ParensT` constructor is now always printed parenthesized
* adds the precedence argument to `pprTyApp` as well, as it needs to keep track and pass it down
* using `>=` instead of former `>` to match the Core type printing logic
* some test outputs have changed, losing extraneous parentheses

- - - - -
fe4ff0f7 by Mario Blažević at 2022-08-22T22:06:21-04:00
Fix and test for issue #21723

- - - - -
33968354 by Mario Blažević at 2022-08-22T22:06:21-04:00
Test for issue #21942

- - - - -
c9655251 by Mario Blažević at 2022-08-22T22:06:21-04:00
Updated the changelog

- - - - -
80102356 by Ben Gamari at 2022-08-22T22:06:57-04:00
hadrian: Don't duplicate binaries on installation

Previously we used `install` on symbolic links, which ended up
copying the target file rather than installing a symbolic link.

Fixes #22062.

- - - - -
b929063e by Matthew Farkas-Dyck at 2022-08-24T02:37:01-04:00
Unbreak Haddock comments in `GHC.Core.Opt.WorkWrap.Utils`.

Closes #22092.

- - - - -
112e4f9c by Cheng Shao at 2022-08-24T02:37:38-04:00
driver: don't actually merge objects when ar -L works

- - - - -
a9f0e68e by Ben Gamari at 2022-08-24T02:38:13-04:00
rts: Consistently use MiB in stats output

Previously we would say `MB` even where we
meant `MiB`.
- - - - -
a90298cc by Simon Peyton Jones at 2022-08-25T08:38:16+01:00
Fix arityType: -fpedantic-bottoms, join points, etc

This MR fixes #21694, #21755.  It also makes sure that #21948 and
fix to #21694.

* For #21694 the underlying problem was that we were calling arityType
  on an expression that had free join points.  This is a Bad Bad Idea.
  See Note [No free join points in arityType].

* To make "no free join points in arityType" work out I had to avoid
  trying to use eta-expansion for runRW#. This entailed a few changes
  in the Simplifier's treatment of runRW#.  See
  GHC.Core.Opt.Simplify.Iteration Note [No eta-expansion in runRW#]

* I also made andArityType work correctly with -fpedantic-bottoms;
  see Note [Combining case branches: andWithTail].

* Rewrote Note [Combining case branches: optimistic one-shot-ness]

* arityType previously treated join points differently to other
  let-bindings. This patch makes them unform; arityType analyses
  the RHS of all bindings to get its ArityType, and extends am_sigs.

  I realised that, now we have am_sigs giving the ArityType for
  let-bound Ids, we don't need the (pre-dating) special code in
  arityType for join points. But instead we need to extend the env for
  Rec bindings, which weren't doing before.  More uniform now.  See
  Note [arityType for let-bindings].

  This meant we could get rid of ae_joins, and in fact get rid of
  EtaExpandArity altogether.  Simpler.

* And finally, it was the strange treatment of join-point Ids in
  arityType (involving a fake ABot type) that led to a serious bug:
  #21755.  Fixed by this refactoring, which treats them uniformly;
  but without breaking #18328.

  In fact, the arity for recursive join bindings is pretty tricky;
  see the long Note [Arity for recursive join bindings]
  in GHC.Core.Opt.Simplify.Utils.  That led to more refactoring,
  including deciding that an Id could have an Arity that is bigger
  than its JoinArity; see Note [Invariants on join points], item
  2(b) in GHC.Core

* Make sure that the "demand threshold" for join points in DmdAnal
  is no bigger than the join-arity.  In GHC.Core.Opt.DmdAnal see
  Note [Demand signatures are computed for a threshold arity based on idArity]

* I moved GHC.Core.Utils.exprIsDeadEnd into GHC.Core.Opt.Arity,
  where it more properly belongs.

* Remove an old, redundant hack in FloatOut.  The old Note was
  Note [Bottoming floats: eta expansion] in GHC.Core.Opt.SetLevels.

Compile time improves very slightly on average:

Metrics: compile_time/bytes allocated
---------------------------------------------------------------------------------------
  T18223(normal) ghc/alloc    725,808,720    747,839,216  +3.0%  BAD
  T6048(optasm)  ghc/alloc    105,006,104    101,599,472  -3.2% GOOD
  geo. mean                                          -0.2%
  minimum                                            -3.2%
  maximum                                            +3.0%

For some reason Windows was better

   T10421(normal) ghc/alloc    125,888,360    124,129,168  -1.4% GOOD
   T18140(normal) ghc/alloc     85,974,520     83,884,224  -2.4% GOOD
  T18698b(normal) ghc/alloc    236,764,568    234,077,288  -1.1% GOOD
   T18923(normal) ghc/alloc     75,660,528     73,994,512  -2.2% GOOD
    T6048(optasm) ghc/alloc    112,232,512    108,182,520  -3.6% GOOD
  geo. mean                                          -0.6%

I had a quick look at T18223 but it is knee deep in coercions and
the size of everything looks similar before and after.  I decided
to accept that 3% increase in exchange for goodness elsewhere.

Metric Decrease:
    T10421
    T18140
    T18698b
    T18923
    T6048

Metric Increase:
    T18223

- - - - -
909edcfc by Ben Gamari at 2022-08-25T10:03:34-04:00
upload_ghc_libs: Add means of passing Hackage credentials

- - - - -
28402eed by M Farkas-Dyck at 2022-08-25T10:04:17-04:00
Scrub some partiality in `CommonBlockElim`.

- - - - -
54affbfa by Ben Gamari at 2022-08-25T20:05:31-04:00
hadrian: Fix whitespace

Previously this region of Settings.Packages was incorrectly indented.

- - - - -
c4bba0f0 by Ben Gamari at 2022-08-25T20:05:31-04:00
validate: Drop --legacy flag

In preparation for removal of the legacy `make`-based build system.

- - - - -
822b0302 by Ben Gamari at 2022-08-25T20:05:31-04:00
gitlab-ci: Drop make build validation jobs

In preparation for removal of the `make`-based build system

- - - - -
6fd9b0a1 by Ben Gamari at 2022-08-25T20:05:31-04:00
Drop make build system

Here we at long last remove the `make`-based build system, it having
been replaced with the Shake-based Hadrian build system. Users are
encouraged to refer to the documentation in `hadrian/doc` and this [1]
blog post for details on using Hadrian.

Closes #17527.

[1] https://www.haskell.org/ghc/blog/20220805-make-to-hadrian.html

- - - - -
dbb004b0 by Ben Gamari at 2022-08-25T20:05:31-04:00
Remove testsuite/tests/perf/haddock/.gitignore

As noted in #16802, this is no longer needed.

Closes #16802.

- - - - -
fe9d824d by Ben Gamari at 2022-08-25T20:05:31-04:00
Drop hc-build script

This has not worked for many, many years and relied on the now-removed
`make`-based build system.

- - - - -
659502bc by Ben Gamari at 2022-08-25T20:05:31-04:00
Drop mkdirhier

This is only used by nofib's dead `dist` target

- - - - -
4a426924 by Ben Gamari at 2022-08-25T20:05:31-04:00
Drop mk/{build,install,config}.mk.in

- - - - -
46924b75 by Ben Gamari at 2022-08-25T20:05:31-04:00
compiler: Drop comment references to make

- - - - -
d387f687 by Harry Garrood at 2022-08-25T20:06:10-04:00
Add inits1 and tails1 to Data.List.NonEmpty

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

- - - - -
8603c921 by Harry Garrood at 2022-08-25T20:06:10-04:00
Add since annotations and changelog entries

- - - - -
6b47aa1c by Krzysztof Gogolewski at 2022-08-25T20:06:46-04:00
Fix redundant import

This fixes a build error on x86_64-linux-alpine3_12-validate.
See the function 'loadExternalPlugins' defined in this file.

- - - - -
4786acf7 by sheaf at 2022-08-26T15:05:23-04:00
Pmc: consider any 2 dicts of the same type equal

This patch massages the keys used in the `TmOracle` `CoreMap` to ensure
that dictionaries of coherent classes give the same key.
That is, whenever we have an expression we want to insert or lookup in
the `TmOracle` `CoreMap`, we first replace any dictionary
`$dict_abcd :: ct` with a value of the form `error @ct`.

This allows us to common-up view pattern functions with required
constraints whose arguments differed only in the uniques of the
dictionaries they were provided, thus fixing #21662.

This is a rather ad-hoc change to the keys used in the
`TmOracle` `CoreMap`. In the long run, we would probably want to use
a different representation for the keys instead of simply using
`CoreExpr` as-is. This more ambitious plan is outlined in #19272.

Fixes #21662
Updates unix submodule

- - - - -
f5e0f086 by Krzysztof Gogolewski at 2022-08-26T15:06:01-04:00
Remove label style from printing context

Previously, the SDocContext used for code generation contained
information whether the labels should use Asm or C style.
However, at every individual call site, this is known statically.
This removes the parameter to 'PprCode' and replaces every 'pdoc'
used to print a label in code style with 'pprCLabel' or 'pprAsmLabel'.
The OutputableP instance is now used only for dumps.

The output of T15155 changes, it now uses the Asm style
(which is faithful to what actually happens).

- - - - -
1007829b by Cheng Shao at 2022-08-26T15:06:40-04:00
boot: cleanup legacy args

Cleanup legacy boot script args, following removal of the legacy make
build system.

- - - - -
95fe09da by Simon Peyton Jones at 2022-08-27T00:29:02-04:00
Improve SpecConstr for evals

As #21763 showed, we were over-specialising in some cases, when
the function involved was doing a simple 'eval', but not taking
the value apart, or branching on it.

This MR fixes the problem.  See Note [Do not specialise evals].

Nofib barely budges, except that spectral/cichelli allocates about
3% less.

Compiler bytes-allocated improves a bit
   geo. mean                                          -0.1%
   minimum                                            -0.5%
   maximum                                            +0.0%

The -0.5% is on T11303b, for what it's worth.

- - - - -
565a8ec8 by Matthew Pickering at 2022-08-27T00:29:39-04:00
Revert "Revert "Refactor SpecConstr to use treat bindings uniformly""

This reverts commit 851d8dd89a7955864b66a3da8b25f1dd88a503f8.

This commit was originally reverted due to an increase in space usage.
This was diagnosed as because the SCE increased in size and that was
being retained by another leak. See #22102

- - - - -
82ce1654 by Matthew Pickering at 2022-08-27T00:29:39-04:00
Avoid retaining bindings via ModGuts held on the stack

It's better to overwrite the bindings fields of the ModGuts before
starting an iteration as then all the old bindings can be collected as
soon as the simplifier has processed them. Otherwise we end up with the
old bindings being alive until right at the end of the simplifier pass
as the mg_binds field is only modified right at the end.

- - - - -
64779dcd by Matthew Pickering at 2022-08-27T00:29:39-04:00
Force imposs_deflt_cons in filterAlts

This fixes a pretty serious space leak as the forced thunk would retain
`Alt b` values which would then contain reference to a lot of old
bindings and other simplifier gunk.

The OtherCon unfolding was not forced on subsequent simplifier runs so
more and more old stuff would be retained until the end of
simplification.

Fixing this has a drastic effect on maximum residency for the mmark
package which goes from

```
  45,005,401,056 bytes allocated in the heap
  17,227,721,856 bytes copied during GC
     818,281,720 bytes maximum residency (33 sample(s))
       9,659,144 bytes maximum slop
            2245 MiB total memory in use (0 MB lost due to fragmentation)
```

to

```
  45,039,453,304 bytes allocated in the heap
  13,128,181,400 bytes copied during GC
     331,546,608 bytes maximum residency (40 sample(s))
       7,471,120 bytes maximum slop
             916 MiB total memory in use (0 MB lost due to fragmentation)
```

See #21993 for some more discussion.

- - - - -
a3b23a33 by Matthew Pickering at 2022-08-27T00:29:39-04:00
Use Solo to avoid retaining the SCE but to avoid performing the substitution

The use of Solo here allows us to force the selection into the SCE to obtain
the Subst but without forcing the substitution to be applied. The resulting thunk
is placed into a lazy field which is rarely forced, so forcing it regresses
peformance.

- - - - -
161a6f1f by Simon Peyton Jones at 2022-08-27T00:30:14-04:00
Fix a nasty loop in Tidy

As the remarkably-simple #22112 showed, we were making a black hole
in the unfolding of a self-recursive binding.  Boo!

It's a bit tricky.  Documented in GHC.Iface.Tidy,
   Note [tidyTopUnfolding: avoiding black holes]

- - - - -
68e6786f by Giles Anderson at 2022-08-29T00:01:35+02:00
Use TcRnDiagnostic in GHC.Tc.TyCl.Class (#20117)

The following `TcRnDiagnostic` messages have been introduced:

TcRnIllegalHsigDefaultMethods
TcRnBadGenericMethod
TcRnWarningMinimalDefIncomplete
TcRnDefaultMethodForPragmaLacksBinding
TcRnIgnoreSpecialisePragmaOnDefMethod
TcRnBadMethodErr
TcRnNoExplicitAssocTypeOrDefaultDeclaration

- - - - -
cbe51ac5 by Simon Peyton Jones at 2022-08-29T04:18:57-04:00
Fix a bug in anyInRnEnvR

This bug was a subtle error in anyInRnEnvR, introduced by

    commit d4d3fe6e02c0eb2117dbbc9df72ae394edf50f06
    Author: Andreas Klebinger <klebinger.andreas at gmx.at>
    Date:   Sat Jul 9 01:19:52 2022 +0200

    Rule matching: Don't compute the FVs if we don't look at them.

The net result was #22028, where a rewrite rule would wrongly
match on a lambda.

The fix to that function is easy.

- - - - -
0154bc80 by sheaf at 2022-08-30T06:05:41-04:00
Various Hadrian bootstrapping fixes

  - Don't always produce a distribution archive (#21629)
  - Use correct executable names for ghc-pkg and hsc2hs on windows
    (we were missing the .exe file extension)
  - Fix a bug where we weren't using the right archive format on Windows
    when unpacking the bootstrap sources.

Fixes #21629

- - - - -
451b1d90 by Matthew Pickering at 2022-08-30T06:06:16-04:00
ci: Attempt using normal submodule cloning strategy

We do not use any recursively cloned submodules, and this protects us
from flaky upstream remotes.

Fixes #22121

- - - - -
9d5ad7c4 by Pi Delport at 2022-08-30T22:40:46+00:00
Fix typo in Any docs: stray "--"

- - - - -
3a002632 by Pi Delport at 2022-08-30T22:40:46+00:00
Fix typo in Any docs: syntatic -> syntactic

- - - - -
7f490b13 by Simon Peyton Jones at 2022-08-31T03:53:54-04:00
Add a missing trimArityType

This buglet was exposed by #22114, a consequence of my earlier
refactoring of arity for join points.

- - - - -
e6fc820f by Ben Gamari at 2022-08-31T13:16:01+01:00
Bump binary submodule to 0.8.9.1

- - - - -
4c1e7b22 by Ben Gamari at 2022-08-31T13:16:01+01:00
Bump stm submodule to 2.5.1.0

- - - - -
837472b4 by Ben Gamari at 2022-08-31T13:16:01+01:00
users-guide: Document system-cxx-std-lib

- - - - -
f7a9947a by Douglas Wilson at 2022-08-31T13:16:01+01:00
Update submodule containers to 0.6.6

- - - - -
4ab1c2ca by Douglas Wilson at 2022-08-31T13:16:02+01:00
Update submodule process to 1.6.15.0

- - - - -
1309ea1e by Ben Gamari at 2022-08-31T13:16:02+01:00
Bump directory submodule to 1.3.7.1

- - - - -
7962a33a by Douglas Wilson at 2022-08-31T13:16:02+01:00
Bump text submodule to 2.0.1

- - - - -
fd8d80c3 by Ben Gamari at 2022-08-31T13:26:52+01:00
Bump deepseq submodule to 1.4.8.0

- - - - -
a9baafac by Ben Gamari at 2022-08-31T13:26:52+01:00
Add dates to base, ghc-prim changelogs

- - - - -
2cee323c by Ben Gamari at 2022-08-31T13:26:52+01:00
Update autoconf scripts

Scripts taken from autoconf 02ba26b218d3d3db6c56e014655faf463cefa983

- - - - -
e62705ff by Ben Gamari at 2022-08-31T13:26:53+01:00
Bump bytestring submodule to 0.11.3.1

- - - - -
f7b4dcbd by Douglas Wilson at 2022-08-31T13:26:53+01:00
Update submodule Cabal to tag Cabal-v3.8.1.0

closes #21931

- - - - -
e8eaf807 by Matthew Pickering at 2022-08-31T18:27:57-04:00
Refine in-tree compiler args for --test-compiler=stage1

Some of the logic to calculate in-tree arguments was not correct for the
stage1 compiler. Namely we were not correctly reporting whether we were
building static or dynamic executables and whether debug assertions were
enabled.

Fixes #22096

- - - - -
6b2f7ffe by Matthew Pickering at 2022-08-31T18:27:57-04:00
Make ghcDebugAssertions into a Stage predicate (Stage -> Bool)

We also care whether we have debug assertions enabled for a stage one
compiler, but the way which we turned on the assertions was quite
different from the stage2 compiler. This makes the logic for turning on
consistent across both and has the advantage of being able to correct
determine in in-tree args whether a flavour enables assertions or not.

Ticket #22096

- - - - -
15111af6 by Zubin Duggal at 2022-09-01T01:18:50-04:00
Add regression test for #21550

This was fixed by ca90ffa321a31842a32be1b5b6e26743cd677ec5
"Use local instances with least superclass depth"

- - - - -
7d3a055d by Krzysztof Gogolewski at 2022-09-01T01:19:26-04:00
Minor cleanup

- Remove mkHeteroCoercionType, sdocImpredicativeTypes, isStateType (unused),
  isCoVar_maybe (duplicated by getCoVar_maybe)
- Replace a few occurrences of voidPrimId with (# #).
  void# is a deprecated synonym for the unboxed tuple.
- Use showSDoc in :show linker.
  This makes it consistent with the other :show commands

- - - - -
31a8989a by Tommy Bidne at 2022-09-01T12:01:20-04:00
Change Ord defaults per CLC proposal

Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/24#issuecomment-1233331267

- - - - -
7f527f01 by Matthew Pickering at 2022-09-01T12:01:56-04:00
Fix bootstrap with ghc-9.0

It turns out Solo is a very recent addition to base, so for older GHC
versions we just defined it inline here the one place we use it in the
compiler.

- - - - -
d2be80fd by Sebastian Graf at 2022-09-05T23:12:14-04:00
DmdAnal: Don't panic in addCaseBndrDmd (#22039)

Rather conservatively return Top.
See Note [Untyped demand on case-alternative binders].

I also factored `addCaseBndrDmd` into two separate functions `scrutSubDmd` and
`fieldBndrDmds`.

Fixes #22039.

- - - - -
25f68ace by Ben Gamari at 2022-09-05T23:12:50-04:00
gitlab-ci: Ensure that ghc derivation is in scope

Previously the lint-ci job attempted to use cabal-install (specifically
`cabal update`) without a GHC in PATH. However, cabal-install-3.8
appears to want GHC, even for `cabal update`.

- - - - -
f37b621f by sheaf at 2022-09-06T11:51:53+00:00
Update instances.rst, clarifying InstanceSigs

Fixes #22103

- - - - -
d4f908f7 by Jan Hrček at 2022-09-06T15:36:58-04:00
Fix :add docs in user guide

- - - - -
808bb793 by Cheng Shao at 2022-09-06T15:37:35-04:00
ci: remove unused build_make/test_make in ci script

- - - - -
d0a2efb2 by Eric Lindblad at 2022-09-07T16:42:45-04:00
typo
- - - - -
fac0098b by Eric Lindblad at 2022-09-07T16:42:45-04:00
typos

- - - - -
a581186f by Eric Lindblad at 2022-09-07T16:42:45-04:00
whitespace

- - - - -
04a738cb by Cheng Shao at 2022-09-07T16:43:22-04:00
CmmToAsm: remove unused ModLocation from NatM_State

- - - - -
ee1cfaa9 by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00
Minor SDoc cleanup

Change calls to renderWithContext with showSDocOneLine; it's more
efficient and explanatory.

Remove polyPatSig (unused)

- - - - -
7918265d by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00
Remove Outputable Char instance

Use 'text' instead of 'ppr'.
Using 'ppr' on the list "hello" rendered as "h,e,l,l,o".

- - - - -
77209ab3 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00
Export liftA2 from Prelude

Changes:
In order to be warning free and compatible, we hide Applicative(..)
from Prelude in a few places and instead import it directly from
Control.Applicative.
Please see the migration guide at
https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md
for more details.

This means that Applicative is now exported in its entirety from
Prelude.

Motivation:

This change is motivated by a few things:
* liftA2 is an often used function, even more so than (<*>) for some
  people.
* When implementing Applicative, the compiler will prompt you for either
  an implementation of (<*>) or of liftA2, but trying to use the latter
  ends with an error, without further imports. This could be confusing
  for newbies.
* For teaching, it is often times easier to introduce liftA2 first,
  as it is a natural generalisation of fmap.
* This change seems to have been unanimously and enthusiastically
  accepted by the CLC members, possibly indicating a lot of love for it.
* This change causes very limited breakage, see the linked issue below
  for an investigation on this.

See https://github.com/haskell/core-libraries-committee/issues/50
for the surrounding discussion and more details.

- - - - -
442a94e8 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00
Add changelog entry for liftA2 export from Prelude

- - - - -
fb968680 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00
Bump submodule containers to one with liftA2 warnings fixed

- - - - -
f54ff818 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00
Bump submodule Cabal to one with liftA2 warnings fixed

- - - - -
a4b34808 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00
Isolate some Applicative hidings to GHC.Prelude

By reexporting the entirety of Applicative from GHC.Prelude, we can save
ourselves some `hiding` and importing of `Applicative` in consumers of GHC.Prelude.
This also has the benefit of isolating this type of change to
GHC.Prelude, so that people in the future don't have to think about it.

- - - - -
9c4ea90c by Cheng Shao at 2022-09-08T17:49:47-04:00
CmmToC: enable 64-bit CallishMachOp on 32-bit targets

Normally, the unregisterised builds avoid generating 64-bit
CallishMachOp in StgToCmm, so CmmToC doesn't support these. However,
there do exist cases where we'd like to invoke cmmToC for other cmm
inputs which may contain such CallishMachOps, and it's a rather low
effort to add support for these since they only require calling into
existing ghc-prim cbits.

- - - - -
04062510 by Alexis King at 2022-09-11T11:30:32+02:00
Add native delimited continuations to the RTS

This patch implements GHC proposal 313, "Delimited continuation
primops", by adding native support for delimited continuations to the
GHC RTS.

All things considered, the patch is relatively small. It almost
exclusively consists of changes to the RTS; the compiler itself is
essentially unaffected. The primops come with fairly extensive Haddock
documentation, and an overview of the implementation strategy is given
in the Notes in rts/Continuation.c.

This first stab at the implementation prioritizes simplicity over
performance. Most notably, every continuation is always stored as a
single, contiguous chunk of stack. If one of these chunks is
particularly large, it can result in poor performance, as the current
implementation does not attempt to cleverly squeeze a subset of the
stack frames into the existing stack: it must fit all at once. If this
proves to be a performance issue in practice, a cleverer strategy would
be a worthwhile target for future improvements.

- - - - -
ee471dfb by Cheng Shao at 2022-09-12T07:07:33-04:00
rts: fix missing dirty_MVAR argument in stg_writeIOPortzh

- - - - -
a5f9c35f by Cheng Shao at 2022-09-12T13:29:05-04:00
ci: enable parallel compression for xz

- - - - -
3a815f30 by Ryan Scott at 2022-09-12T13:29:41-04:00
Windows: Always define _UCRT when compiling C code

As seen in #22159, this is required to ensure correct behavior when MinGW-w64
headers are in the `C_INCLUDE_PATH`.

Fixes #22159.

- - - - -
65a0bd69 by sheaf at 2022-09-13T10:27:52-04:00
Add diagnostic codes

This MR adds diagnostic codes, assigning unique numeric codes to
error and warnings, e.g.

  error: [GHC-53633]
  Pattern match is redundant

This is achieved as follows:

  - a type family GhcDiagnosticCode that gives the diagnostic code
    for each diagnostic constructor,
  - a type family ConRecursInto that specifies whether to recur into
    an argument of the constructor to obtain a more fine-grained code
    (e.g. different error codes for different 'deriving' errors),
  - generics machinery to generate the value-level function assigning
    each diagnostic its error code; see Note [Diagnostic codes using generics]
    in GHC.Types.Error.Codes.

The upshot is that, to add a new diagnostic code, contributors only need
to modify the two type families mentioned above. All logic relating to
diagnostic codes is thus contained to the GHC.Types.Error.Codes module,
with no code duplication.

This MR also refactors error message datatypes a bit, ensuring we can
derive Generic for them, and cleans up the logic around constraint
solver reports by splitting up 'TcSolverReportInfo' into separate
datatypes (see #20772).

Fixes #21684

- - - - -
362cca13 by sheaf at 2022-09-13T10:27:53-04:00
Diagnostic codes: acccept test changes

The testsuite output now contains diagnostic codes, so many tests need
to be updated at once.
We decided it was best to keep the diagnostic codes in the testsuite
output, so that contributors don't inadvertently make changes to the
diagnostic codes.

- - - - -
08f6730c by Adam Gundry at 2022-09-13T10:28:29-04:00
Allow imports to reference multiple fields with the same name (#21625)

If a module `M` exports two fields `f` (using DuplicateRecordFields), we can
still accept

    import M (f)
    import M hiding (f)

and treat `f` as referencing both of them.  This was accepted in GHC 9.0, but gave
rise to an ambiguity error in GHC 9.2.  See #21625.

This patch also documents this behaviour in the user's guide, and updates the
test for #16745 which is now treated differently.

- - - - -
c14370d7 by Cheng Shao at 2022-09-13T10:29:07-04:00
ci: remove unused appveyor config

- - - - -
dc6af9ed by Cheng Shao at 2022-09-13T10:29:45-04:00
compiler: remove unused lazy state monad

- - - - -
646d15ad by Eric Lindblad at 2022-09-14T03:13:56-04:00
Fix typos

This fixes various typos and spelling mistakes
in the compiler.

Fixes #21891

- - - - -
7d7e71b0 by Matthew Pickering at 2022-09-14T03:14:32-04:00
hadrian: Bump index state

This bumps the index state so a build plan can also be found when
booting with 9.4.

Fixes #22165

- - - - -
98b62871 by Matthew Pickering at 2022-09-14T17:17:04-04:00
hadrian: Use a stamp file to record when a package is built in a certain way

Before this patch which library ways we had built wasn't recorded
directly. So you would run into issues if you build the .conf file with
some library ways before switching the library ways which you wanted to
build.

Now there is one stamp file for each way, so in order to build a
specific way you can need that specific stamp file rather than going
indirectly via the .conf file.

- - - - -
b42cedbe by Matthew Pickering at 2022-09-14T17:17:04-04:00
hadrian: Inplace/Final package databases

There are now two different package databases per stage. An inplace
package database contains .conf files which point directly into the
build directories. The final package database contains .conf files which
point into the installed locations. The inplace .conf files are created
before any building happens and have fake ABI hash values. The final
.conf files are created after a package finished building and contains
the proper ABI has.

The motivation for this is to make the dependency structure more
fine-grained when building modules. Now a module depends just depends
directly on M.o from package p rather than the .conf file depend on the
.conf file for package p. So when all of a modules direct dependencies
have finished building we can start building it rather than waiting for
the whole package to finish.

The secondary motivation is that the multi-repl doesn't need to build
everything before starting the multi-repl session. We can just configure
the inplace package-db and use that in order to start the repl.

- - - - -
6515c32b by Matthew Pickering at 2022-09-14T17:17:04-04:00
hadrian: Add some more packages to multi-cradle

The main improvement here is to pass `-this-unit-id` for executables so
that they can be added to the multi-cradle if desired as well as normal
library packages.

- - - - -
e470e91f by Matthew Pickering at 2022-09-14T17:17:04-04:00
hadrian: Need builders needed by Cabal Configure in parallel

Because of the use of withStaged (which needs the necessary builder)
when configuring a package, the builds of stage1:exe:ghc-bin and
stage1:exe:ghc-pkg where being linearised when building a specific
target like `binary-dist-dir`.

Thankfully the fix is quite local, to supply all the `withStaged`
arguments together so the needs can be batched together and hence
performed in parallel.

Fixes #22093

- - - - -
c4438347 by Matthew Pickering at 2022-09-14T17:17:04-04:00
Remove stage1:exe:ghc-bin pre-build from CI script

CI builds stage1:exe:ghc-bin before the binary-dist target which
introduces some quite bad linearisation (see #22093) because we don't
build stage1 compiler in parallel with anything. Then when the
binary-dist target is started we have to build stage1:exe:ghc-pkg before
doing anything.

Fixes #22094

- - - - -
71d8db86 by Matthew Pickering at 2022-09-14T17:17:04-04:00
hadrian: Add extra implicit dependencies from DeriveLift

ghc -M should know that modules which use DeriveLift (or
TemplateHaskellQuotes) need TH.Lib.Internal but until it does, we have
to add these extra edges manually or the modules will be compiled before
TH.Lib.Internal is compiled which leads to a desugarer error.

- - - - -
43e574f0 by Greg Steuck at 2022-09-14T17:17:43-04:00
Repair c++ probing on OpenBSD

Failure without this change:
```
checking C++ standard library flavour... libc++
checking for linkage against 'c++ c++abi'... failed
checking for linkage against 'c++ cxxrt'... failed
configure: error: Failed to find C++ standard library
```

- - - - -
534b39ee by Douglas Wilson at 2022-09-14T17:18:21-04:00
libraries: template-haskell: vendor filepath differently

Vendoring with ../ in hs-source-dirs prevents upload to hackage.

(cherry picked from commit 1446be7586ba70f9136496f9b67f792955447842)

- - - - -
bdd61cd6 by M Farkas-Dyck at 2022-09-14T22:39:34-04:00
Unbreak Hadrian with Cabal 3.8.

- - - - -
df04d6ec by Krzysztof Gogolewski at 2022-09-14T22:40:09-04:00
Fix typos

- - - - -
d6ea8356 by Andreas Klebinger at 2022-09-15T10:12:41+02:00
Tag inference: Fix #21954 by retaining tagsigs of vars in function position.

For an expression like:

    case x of y
      Con z -> z

If we also retain the tag sig for z we can generate code to immediately return
it rather than calling out to stg_ap_0_fast.

- - - - -
7cce7007 by Andreas Klebinger at 2022-09-15T10:12:42+02:00
Stg.InferTags.Rewrite - Avoid some thunks.

- - - - -
88c4cbdb by Cheng Shao at 2022-09-16T13:57:56-04:00
hadrian: enable -fprof-late only for profiling ways

- - - - -
d7235831 by Cheng Shao at 2022-09-16T13:57:56-04:00
hadrian: add late_ccs flavour transformer

- - - - -
ce203753 by Cheng Shao at 2022-09-16T13:58:34-04:00
configure: remove unused program checks

- - - - -
9b4c1056 by Pierre Le Marre at 2022-09-16T13:59:16-04:00
Update to Unicode 15.0

- - - - -
c6e9b89a by Andrew Lelechenko at 2022-09-16T13:59:55-04:00
Avoid partial head and tail in ghc-heap; replace with total pattern-matching

- - - - -
616afde3 by Cheng Shao at 2022-09-16T14:00:33-04:00
hadrian: relax Cabal upper bound to allow building with Cabal-3.8

A follow up of !8910.

- - - - -
df35d994 by Alexis King at 2022-09-16T14:01:11-04:00
Add links to the continuations haddocks in the docs for each primop

fixes #22176

- - - - -
383f7549 by Matthew Pickering at 2022-09-16T21:42:10-04:00
-Wunused-pattern-binds: Recurse into patterns to check whether there's a splice

See the examples in #22057 which show we have to traverse deeply into a
pattern to determine whether it contains a splice or not. The original
implementation pointed this out but deemed this very shallow traversal
"too expensive".

Fixes #22057

I also fixed an oversight in !7821 which meant we lost a warning which
was present in 9.2.2.

Fixes #22067

- - - - -
5031bf49 by sheaf at 2022-09-16T21:42:49-04:00
Hadrian: Don't try to build terminfo on Windows

Commit b42cedbe introduced a dependency on terminfo on Windows,
but that package isn't available on Windows.

- - - - -
c9afe221 by M Farkas-Dyck at 2022-09-17T06:44:47-04:00
Clean up some. In particular:
• Delete some dead code, largely under `GHC.Utils`.
• Clean up a few definitions in `GHC.Utils.(Misc, Monad)`.
• Clean up `GHC.Types.SrcLoc`.
• Derive stock `Functor, Foldable, Traversable` for more types.
• Derive more instances for newtypes.

Bump haddock submodule.

- - - - -
85431ac3 by Cheng Shao at 2022-09-17T06:45:25-04:00
driver: pass original Cmm filename in ModLocation

When compiling Cmm, the ml_hs_file field is used to indicate Cmm
filename when later generating DWARF information. We should pass the
original filename here, otherwise for preprocessed Cmm files, the
filename will be a temporary filename which is confusing.

- - - - -
63aa0069 by Cheng Shao at 2022-09-17T06:46:04-04:00
rts: remove legacy logging cabal flag

- - - - -
bd0f4184 by Cheng Shao at 2022-09-17T06:46:04-04:00
rts: make threaded ways optional

For certain targets (e.g. wasm32-wasi), the threaded rts is known not to
work. This patch adds a "threaded" cabal flag to rts to make threaded
rts ways optional. Hadrian enables this flag iff the flavour rtsWays
contains threaded ways.

- - - - -
8a666ad2 by Ryan Scott at 2022-09-18T08:00:44-04:00
DeriveFunctor: Check for last type variables using dataConUnivTyVars

Previously, derived instances of `Functor` (as well as the related classes
`Foldable`, `Traversable`, and `Generic1`) would determine which constraints to
infer by checking for fields that contain the last type variable. The problem
was that this last type variable was taken from `tyConTyVars`. For GADTs, the
type variables in each data constructor are _not_ the same type variables as
in `tyConTyVars`, leading to #22167.

This fixes the issue by instead checking for the last type variable using
`dataConUnivTyVars`. (This is very similar in spirit to the fix for #21185,
which also replaced an errant use of `tyConTyVars` with type variables from
each data constructor.)

Fixes #22167.

- - - - -
78037167 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00
Lexer: pass updated buffer to actions (#22201)

In the lexer, predicates have the following type:
	{ ... } :: user       -- predicate state
		-> AlexInput  -- input stream before the token
		-> Int        -- length of the token
		-> AlexInput  -- input stream after the token
		-> Bool       -- True <=> accept the token
This is documented in the Alex manual.

There is access to the input stream both before and after the token.
But when the time comes to construct the token, GHC passes only the
initial string buffer to the lexer action. This patch fixes it:

	- type Action = PsSpan -> StringBuffer -> Int ->                 P (PsLocated Token)
	+ type Action = PsSpan -> StringBuffer -> Int -> StringBuffer -> P (PsLocated Token)

Now lexer actions have access to the string buffer both before and after
the token, just like the predicates. It's just a matter of passing an
additional function parameter throughout the lexer.

- - - - -
75746594 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00
Lexer: define varsym without predicates (#22201)

Before this patch, the varsym lexing rules were defined as follows:

	<0> {
	  @varsym / { precededByClosingToken `alexAndPred` followedByOpeningToken } { varsym_tight_infix }
	  @varsym / { followedByOpeningToken }  { varsym_prefix }
	  @varsym / { precededByClosingToken }  { varsym_suffix }
	  @varsym                               { varsym_loose_infix }
	}

Unfortunately, this meant that the predicates 'precededByClosingToken' and
'followedByOpeningToken' were recomputed several times before we could figure
out the whitespace context.

With this patch, we check for whitespace context directly in the lexer
action:

	<0> {
	  @varsym { with_op_ws varsym }
	}

The checking for opening/closing tokens happens in 'with_op_ws' now,
which is part of the lexer action rather than the lexer predicate.

- - - - -
c1f81b38 by Matthew Farkas-Dyck at 2022-09-19T09:07:05-04:00
Scrub partiality about `NewOrData`.

Rather than a list of constructors and a `NewOrData` flag, we define `data DataDefnCons a = NewTypeCon a | DataTypeCons [a]`, which enforces a newtype to have exactly one constructor.

Closes #22070.

Bump haddock submodule.

- - - - -
1e1ed8c5 by Cheng Shao at 2022-09-19T09:07:43-04:00
CmmToC: emit __builtin_unreachable() after noreturn ccalls

Emit a __builtin_unreachable() call after a foreign call marked as
CmmNeverReturns. This is crucial to generate correctly typed code for
wasm; as for other archs, this is also beneficial for the C compiler
optimizations.

- - - - -
19f45a25 by Jan Hrček at 2022-09-20T03:49:29-04:00
Document :unadd GHCi command in user guide

- - - - -
545ff490 by sheaf at 2022-09-20T03:50:06-04:00
Hadrian: merge archives even in stage 0

We now always merge .a archives when ar supports -L.
This change is necessary in order to bootstrap GHC using GHC 9.4
on Windows, as nested archives aren't supported.
Not doing so triggered bug #21990 when trying to use the Win32
package, with errors such as:

  Not a x86_64 PE+ file.
  Unknown COFF 4 type in getHeaderInfo.

  ld.lld: error: undefined symbol: Win32zm2zi12zi0zi0_SystemziWin32ziConsoleziCtrlHandler_withConsoleCtrlHandler1_info

We have to be careful about which ar is meant: in stage 0, the check
should be done on the system ar (system-ar in system.config).

- - - - -
59fe128c by Vladislav Zavialov at 2022-09-20T03:50:42-04:00
Fix -Woperator-whitespace for consym (part of #19372)

Due to an oversight, the initial specification and implementation of
-Woperator-whitespace focused on varsym exclusively and completely
ignored consym.

This meant that expressions such as "x+ y" would produce a warning,
while "x:+ y" would not.

The specification was corrected in ghc-proposals pull request #404,
and this patch updates the implementation accordingly.

Regression test included.

- - - - -
c4c2cca0 by John Ericson at 2022-09-20T13:11:49-04:00
Add `Eq` and `Ord` instances for `Generically1`

These are needed so the subsequent commit overhauling the `*1` classes
type-checks.

- - - - -
7beb356e by John Ericson at 2022-09-20T13:11:50-04:00
Relax instances for Functor combinators; put superclass on Class1 and Class2 to make non-breaking

This change is approved by the Core Libraries commitee in
https://github.com/haskell/core-libraries-committee/issues/10

The first change makes the `Eq`, `Ord`, `Show`, and `Read` instances for
`Sum`, `Product`, and `Compose` match those for `:+:`, `:*:`, and `:.:`.
These have the proper flexible contexts that are exactly what the
instance needs:

For example, instead of
```haskell
instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where
  (==) = eq1
```
we do
```haskell
deriving instance Eq (f (g a)) => Eq (Compose f g a)
```

But, that change alone is rather breaking, because until now `Eq (f a)`
and `Eq1 f` (and respectively the other classes and their `*1`
equivalents too) are *incomparable* constraints. This has always been an
annoyance of working with the `*1` classes, and now it would rear it's
head one last time as an pesky migration.

Instead, we give the `*1` classes superclasses, like so:
```haskell
(forall a. Eq a => Eq (f a)) => Eq1 f
```
along with some laws that canonicity is preserved, like:
```haskell
liftEq (==) = (==)
```

and likewise for `*2` classes:
```haskell
(forall a. Eq a => Eq1 (f a)) => Eq2 f
```
and laws:
```haskell
liftEq2 (==) = liftEq1
```

The `*1` classes also have default methods using the `*2` classes where
possible.

What this means, as explained in the docs, is that `*1` classes really
are generations of the regular classes, indicating that the methods can
be split into a canonical lifting combined with a canonical inner, with
the super class "witnessing" the laws[1] in a fashion.

Circling back to the pragmatics of migrating, note that the superclass
means evidence for the old `Sum`, `Product`, and `Compose` instances is
(more than) sufficient, so breakage is less likely --- as long no
instances are "missing", existing polymorphic code will continue to
work.

Breakage can occur when a datatype implements the `*1` class but not the
corresponding regular class, but this is almost certainly an oversight.
For example, containers made that mistake for `Tree` and `Ord`, which I
fixed in https://github.com/haskell/containers/pull/761, but fixing the
issue by adding `Ord1` was extremely *un*controversial.

`Generically1` was also missing `Eq`, `Ord`, `Read,` and `Show`
instances. It is unlikely this would have been caught without
implementing this change.

-----

[1]: In fact, someday, when the laws are part of the language and not
only documentation, we might be able to drop the superclass field of the
dictionary by using the laws to recover the superclass in an
instance-agnostic manner, e.g. with a *non*-overloaded function with
type:

```haskell
DictEq1 f -> DictEq a -> DictEq (f a)
```

But I don't wish to get into optomizations now, just demonstrate the
close relationship between the law and the superclass.

Bump haddock submodule because of test output changing.

- - - - -
6a8c6b5e by Tom Ellis at 2022-09-20T13:12:27-04:00
Add notes to ghc-prim Haddocks that users should not import it

- - - - -
ee9d0f5c by matoro at 2022-09-20T13:13:06-04:00
docs: clarify that LLVM codegen is not available in unregisterised mode

The current docs are misleading and suggest that it is possible to use
LLVM codegen from an unregisterised build.  This is not the case;
attempting to pass `-fllvm` to an unregisterised build warns:

```
when making flags consistent: warning:
    Target platform uses unregisterised ABI, so compiling via C
```

and uses the C codegen anyway.

- - - - -
854224ed by Nicolas Trangez at 2022-09-20T20:14:29-04:00
rts: remove copy-paste error from `cabal.rts.in`

This was, likely accidentally, introduced in 4bf542bf1c.

See: 4bf542bf1cdf2fa468457fc0af21333478293476

- - - - -
c8ae3add by Matthew Pickering at 2022-09-20T20:15:04-04:00
hadrian: Add extra_dependencies edges for all different ways

The hack to add extra dependencies needed by DeriveLift extension missed
the cases for profiles and dynamic ways. For the profiled way this leads
to errors like:

```
GHC error in desugarer lookup in Data.IntSet.Internal:
  Failed to load interface for ‘Language.Haskell.TH.Lib.Internal’
  Perhaps you haven't installed the profiling libraries for package ‘template-haskell’?
  Use -v (or `:set -v` in ghci) to see a list of the files searched for.
ghc: panic! (the 'impossible' happened)
  GHC version 9.5.20220916:
        initDs
```

Therefore the fix is to add these extra edges in.

Fixes #22197

- - - - -
a971657d by Mon Aaraj at 2022-09-21T06:41:24+03:00
users-guide: fix incorrect ghcappdata folder for unix and windows

- - - - -
06ccad0d by sheaf at 2022-09-21T08:28:49-04:00
Don't use isUnliftedType in isTagged

The function GHC.Stg.InferTags.Rewrite.isTagged can be given
the Id of a join point, which might be representation polymorphic.
This would cause the call to isUnliftedType to crash. It's better
to use typeLevity_maybe instead.

Fixes #22212

- - - - -
c0ba775d by Teo Camarasu at 2022-09-21T14:30:37-04:00
Add fragmentation statistic to GHC.Stats

Implements #21537

- - - - -
2463df2f by Torsten Schmits at 2022-09-21T14:31:24-04:00
Rename Solo[constructor] to MkSolo

Part of proposal 475 (https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst)

Moves all tuples to GHC.Tuple.Prim
Updates ghc-prim version (and bumps bounds in dependents)

updates haddock submodule
updates deepseq submodule
updates text submodule

- - - - -
9034fada by Matthew Pickering at 2022-09-22T09:25:29-04:00
Update filepath to filepath-1.4.100.0

Updates submodule

* Always rely on vendored filepath
* filepath must be built as stage0 dependency because it uses
  template-haskell.

Towards #22098

- - - - -
615e2278 by Krzysztof Gogolewski at 2022-09-22T09:26:05-04:00
Minor refactor around Outputable

* Replace 'text . show' and 'ppr' with 'int'.
* Remove Outputable.hs-boot, no longer needed
* Use pprWithCommas
* Factor out instructions in AArch64 codegen

- - - - -
aeafdba5 by Sebastian Graf at 2022-09-27T15:14:54+02:00
Demand: Clear distinction between Call SubDmd and eval Dmd (#21717)

In #21717 we saw a reportedly unsound strictness signature due to an unsound
definition of plusSubDmd on Calls. This patch contains a description and the fix
to the unsoundness as outlined in `Note [Call SubDemand vs. evaluation Demand]`.

This fix means we also get rid of the special handling of `-fpedantic-bottoms`
in eta-reduction. Thanks to less strict and actually sound strictness results,
we will no longer eta-reduce the problematic cases in the first place, even
without `-fpedantic-bottoms`.

So fixing the unsoundness also makes our eta-reduction code simpler with less
hacks to explain. But there is another, more unfortunate side-effect:
We *unfix* #21085, but fortunately we have a new fix ready:
See `Note [mkCall and plusSubDmd]`.

There's another change:
I decided to make `Note [SubDemand denotes at least one evaluation]` a lot
simpler by using `plusSubDmd` (instead of `lubPlusSubDmd`) even if both argument
demands are lazy. That leads to less precise results, but in turn rids ourselves
from the need for 4 different `OpMode`s and the complication of
`Note [Manual specialisation of lub*Dmd/plus*Dmd]`. The result is simpler code
that is in line with the paper draft on Demand Analysis.

I left the abandoned idea in `Note [Unrealised opportunity in plusDmd]` for
posterity. The fallout in terms of regressions is negligible, as the testsuite
and NoFib shows.

```
        Program         Allocs    Instrs
--------------------------------------------------------------------------------
         hidden          +0.2%     -0.2%
         linear          -0.0%     -0.7%
--------------------------------------------------------------------------------
            Min          -0.0%     -0.7%
            Max          +0.2%     +0.0%
 Geometric Mean          +0.0%     -0.0%
```

Fixes #21717.

- - - - -
9b1595c8 by Ross Paterson at 2022-09-27T14:12:01-04:00
implement proposal 106 (Define Kinds Without Promotion) (fixes #6024)

includes corresponding changes to haddock submodule

- - - - -
c2d73cb4 by Andreas Klebinger at 2022-09-28T15:07:30-04:00
Apply some tricks to speed up core lint.

Below are the noteworthy changes and if given their impact on compiler
allocations for a type heavy module:

* Use the oneShot trick on LintM
* Use a unboxed tuple for the result of LintM: ~6% reduction
* Avoid a thunk for the result of typeKind in lintType: ~5% reduction
* lint_app: Don't allocate the error msg in the hot code path: ~4%
  reduction
* lint_app: Eagerly force the in scope set: ~4%
* nonDetCmpType: Try to short cut using reallyUnsafePtrEquality#: ~2%
* lintM: Use a unboxed maybe for the `a` result: ~12%
* lint_app: make go_app tail recursive to avoid allocating the go function
            as heap closure: ~7%
* expandSynTyCon_maybe: Use a specialized data type

For a less type heavy module like nofib/spectral/simple compiled with
-O -dcore-lint allocations went down by ~24% and compile time by ~9%.

-------------------------
Metric Decrease:
    T1969
-------------------------

- - - - -
b74b6191 by sheaf at 2022-09-28T15:08:10-04:00
matchLocalInst: do domination analysis

When multiple Given quantified constraints match a Wanted, and there is
a quantified constraint that dominates all others, we now pick it
to solve the Wanted.

See Note [Use only the best matching quantified constraint].

For example:

  [G] d1: forall a b. ( Eq a, Num b, C a b  ) => D a b
  [G] d2: forall a  .                C a Int  => D a Int
  [W] {w}: D a Int

When solving the Wanted, we find that both Givens match, but we pick
the second, because it has a weaker precondition, C a Int, compared
to (Eq a, Num Int, C a Int). We thus say that d2 dominates d1;
see Note [When does a quantified instance dominate another?].

This domination test is done purely in terms of superclass expansion,
in the function GHC.Tc.Solver.Interact.impliedBySCs. We don't attempt
to do a full round of constraint solving; this simple check suffices
for now.

Fixes #22216 and #22223

- - - - -
2a53ac18 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00
Improve aggressive specialisation

This patch fixes #21286, by not unboxing dictionaries in
worker/wrapper (ever). The main payload is tiny:

* In `GHC.Core.Opt.DmdAnal.finaliseArgBoxities`, do not unbox
  dictionaries in `get_dmd`.  See Note [Do not unbox class dictionaries]
  in that module

* I also found that imported wrappers were being fruitlessly
  specialised, so I fixed that too, in canSpecImport.
  See Note [Specialising imported functions] point (2).

In doing due diligence in the testsuite I fixed a number of
other things:

* Improve Note [Specialising unfoldings] in GHC.Core.Unfold.Make,
  and Note [Inline specialisations] in GHC.Core.Opt.Specialise,
  and remove duplication between the two. The new Note describes
  how we specialise functions with an INLINABLE pragma.

  And simplify the defn of `spec_unf` in `GHC.Core.Opt.Specialise.specCalls`.

* Improve Note [Worker/wrapper for INLINABLE functions] in
  GHC.Core.Opt.WorkWrap.

  And (critially) make an actual change which is to propagate the
  user-written pragma from the original function to the wrapper; see
  `mkStrWrapperInlinePrag`.

* Write new Note [Specialising imported functions] in
  GHC.Core.Opt.Specialise

All this has a big effect on some compile times. This is
compiler/perf, showing only changes over 1%:

Metrics: compile_time/bytes allocated
-------------------------------------
                LargeRecord(normal)  -50.2% GOOD
           ManyConstructors(normal)   +1.0%
MultiLayerModulesTH_OneShot(normal)   +2.6%
                  PmSeriesG(normal)   -1.1%
                     T10547(normal)   -1.2%
                     T11195(normal)   -1.2%
                     T11276(normal)   -1.0%
                    T11303b(normal)   -1.6%
                     T11545(normal)   -1.4%
                     T11822(normal)   -1.3%
                     T12150(optasm)   -1.0%
                     T12234(optasm)   -1.2%
                     T13056(optasm)   -9.3% GOOD
                     T13253(normal)   -3.8% GOOD
                     T15164(normal)   -3.6% GOOD
                     T16190(normal)   -2.1%
                     T16577(normal)   -2.8% GOOD
                     T16875(normal)   -1.6%
                     T17836(normal)   +2.2%
                    T17977b(normal)   -1.0%
                     T18223(normal)  -33.3% GOOD
                     T18282(normal)   -3.4% GOOD
                     T18304(normal)   -1.4%
                    T18698a(normal)   -1.4% GOOD
                    T18698b(normal)   -1.3% GOOD
                     T19695(normal)   -2.5% GOOD
                      T5837(normal)   -2.3%
                      T9630(normal)  -33.0% GOOD
                      WWRec(normal)   -9.7% GOOD
             hard_hole_fits(normal)   -2.1% GOOD
                     hie002(normal)   +1.6%

                          geo. mean   -2.2%
                          minimum    -50.2%
                          maximum     +2.6%

I diligently investigated some of the big drops.

* Caused by not doing w/w for dictionaries:
    T13056, T15164, WWRec, T18223

* Caused by not fruitlessly specialising wrappers
    LargeRecord, T9630

For runtimes, here is perf/should+_run:

Metrics: runtime/bytes allocated
--------------------------------
               T12990(normal)   -3.8%
                T5205(normal)   -1.3%
                T9203(normal)  -10.7% GOOD
        haddock.Cabal(normal)   +0.1%
         haddock.base(normal)   -1.1%
     haddock.compiler(normal)   -0.3%
        lazy-bs-alloc(normal)   -0.2%
------------------------------------------
                    geo. mean   -0.3%
                    minimum    -10.7%
                    maximum     +0.1%

I did not investigate exactly what happens in T9203.

Nofib is a wash:

+-------------------------------++--+-----------+-----------+
|                               ||  | tsv (rel) | std. err. |
+===============================++==+===========+===========+
|                     real/anna ||  |    -0.13% |      0.0% |
|                      real/fem ||  |    +0.13% |      0.0% |
|                   real/fulsom ||  |    -0.16% |      0.0% |
|                     real/lift ||  |    -1.55% |      0.0% |
|                  real/reptile ||  |    -0.11% |      0.0% |
|                  real/smallpt ||  |    +0.51% |      0.0% |
|          spectral/constraints ||  |    +0.20% |      0.0% |
|               spectral/dom-lt ||  |    +1.80% |      0.0% |
|               spectral/expert ||  |    +0.33% |      0.0% |
+===============================++==+===========+===========+
|                     geom mean ||  |           |           |
+-------------------------------++--+-----------+-----------+

I spent quite some time investigating dom-lt, but it's pretty
complicated.  See my note on !7847.  Conclusion: it's just a delicate
inlining interaction, and we have plenty of those.

Metric Decrease:
    LargeRecord
    T13056
    T13253
    T15164
    T16577
    T18223
    T18282
    T18698a
    T18698b
    T19695
    T9630
    WWRec
    hard_hole_fits
    T9203

- - - - -
addeefc0 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00
Refactor UnfoldingSource and IfaceUnfolding

I finally got tired of the way that IfaceUnfolding reflected
a previous structure of unfoldings, not the current one. This
MR refactors UnfoldingSource and IfaceUnfolding to be simpler
and more consistent.

It's largely just a refactor, but in UnfoldingSource (which moves
to GHC.Types.Basic, since it is now used in IfaceSyn too), I
distinguish between /user-specified/ and /system-generated/ stable
unfoldings.

    data UnfoldingSource
      = VanillaSrc
      | StableUserSrc   -- From a user-specified pragma
      | StableSystemSrc -- From a system-generated unfolding
      | CompulsorySrc

This has a minor effect in CSE (see the use of isisStableUserUnfolding
in GHC.Core.Opt.CSE), which I tripped over when working on
specialisation, but it seems like a Good Thing to know anyway.

- - - - -
7be6f9a4 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00
INLINE/INLINEABLE pragmas in Foreign.Marshal.Array

Foreign.Marshal.Array contains many small functions, all of which are
overloaded, and which are critical for performance. Yet none of them
had pragmas, so it was a fluke whether or not they got inlined.

This patch makes them all either INLINE (small ones) or
INLINEABLE and hence specialisable (larger ones).

See Note [Specialising array operations] in that module.

- - - - -
b0c89dfa by Jade Lovelace at 2022-09-28T17:49:49-04:00
Export OnOff from GHC.Driver.Session

I was working on fixing an issue where HLS was trying to pass its
DynFlags to HLint, but didn't pass any of the disabled language
extensions, which HLint would then assume are on because of their
default values.

Currently it's not possible to get any of the "No" flags because the
`DynFlags.extensions` field can't really be used since it is [OnOff
Extension] and OnOff is not exported.

So let's export it.

- - - - -
2f050687 by Andrew Lelechenko at 2022-09-28T17:50:28-04:00
Avoid Data.List.group; prefer Data.List.NonEmpty.group

This allows to avoid further partiality, e. g., map head . group is
replaced by map NE.head . NE.group, and there are less panic calls.

- - - - -
bc0020fa by M Farkas-Dyck at 2022-09-28T22:51:59-04:00
Clean up `findWiredInUnit`. In particular, avoid `head`.

- - - - -
6a2eec98 by Andrew Lelechenko at 2022-09-28T22:52:38-04:00
Eliminate headFS, use unconsFS instead

A small step towards #22185 to avoid partial functions + safe implementation
of `startsWithUnderscore`.

- - - - -
5a535172 by Sebastian Graf at 2022-09-29T17:04:20+02:00
Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231)

Justification in #22231. Short form: In a demand like `1C1(C1(L))`
it was too easy to confuse which `1` belongs to which `C`. Now
that should be more obvious.

Fixes #22231

- - - - -
ea0083bf by Bryan Richter at 2022-09-29T15:48:38-04:00
Revert "ci: enable parallel compression for xz"

Combined wxth XZ_OPT=9, this blew the memory capacity of CI runners.

This reverts commit a5f9c35f5831ef5108e87813a96eac62803852ab.

- - - - -
f5e8f493 by Sebastian Graf at 2022-09-30T18:42:13+02:00
Boxity: Don't update Boxity unless worker/wrapper follows (#21754)

A small refactoring in our Core Opt pipeline and some new functions for
transfering argument boxities from one signature to another to facilitate
`Note [Don't change boxity without worker/wrapper]`.

Fixes #21754.

- - - - -
4baf7b1c by M Farkas-Dyck at 2022-09-30T17:45:47-04:00
Scrub various partiality involving empty lists.

Avoids some uses of `head` and `tail`, and some panics when an argument is null.

- - - - -
95ead839 by Alexis King at 2022-10-01T00:37:43-04:00
Fix a bug in continuation capture across multiple stack chunks

- - - - -
22096652 by Andrew Lelechenko at 2022-10-01T00:38:22-04:00
Enforce internal invariant of OrdList and fix bugs in viewCons / viewSnoc

`viewCons` used to ignore `Many` constructor completely, returning `VNothing`.
`viewSnoc` violated internal invariant of `Many` being a non-empty list.

- - - - -
48ab9ca5 by Nicolas Trangez at 2022-10-04T20:34:10-04:00
chore: extend `.editorconfig` for C files

- - - - -
b8df5c72 by Brandon Chinn at 2022-10-04T20:34:46-04:00
Fix docs for pattern synonyms
- - - - -
463ffe02 by Oleg Grenrus at 2022-10-04T20:35:24-04:00
Use sameByteArray# in sameByteArray

- - - - -
fbe1e86e by Pierre Le Marre at 2022-10-05T15:58:43+02:00
Minor fixes following Unicode 15.0.0 update

- Fix changelog for Unicode 15.0.0
- Fix the checksums of the downloaded Unicode files, in base's tool: "ucd2haskell".

- - - - -
8a31d02e by Cheng Shao at 2022-10-05T20:40:41-04:00
rts: don't enforce aligned((8)) on 32-bit targets

We simply need to align to the word size for pointer tagging to work. On
32-bit targets, aligned((8)) is wasteful.

- - - - -
532de368 by Ryan Scott at 2022-10-06T07:45:46-04:00
Export symbolSing, SSymbol, and friends (CLC#85)

This implements this Core Libraries Proposal:
https://github.com/haskell/core-libraries-committee/issues/85

In particular, it:

1. Exposes the `symbolSing` method of `KnownSymbol`,
2. Exports the abstract `SSymbol` type used in `symbolSing`, and
3. Defines an API for interacting with `SSymbol`.

This also makes corresponding changes for `natSing`/`KnownNat`/`SNat` and
`charSing`/`KnownChar`/`SChar`. This fixes #15183 and addresses part (2)
of #21568.

- - - - -
d83a92e6 by sheaf at 2022-10-07T07:36:30-04:00
Remove mention of make from README.md

- - - - -
945e8e49 by Andrew Lelechenko at 2022-10-10T17:13:31-04:00
Add a newline before since pragma in Data.Array.Byte

- - - - -
44fcdb04 by Vladislav Zavialov at 2022-10-10T17:14:06-04:00
Parser/PostProcess: rename failOp* functions

There are three functions named failOp* in the parser:
	failOpNotEnabledImportQualifiedPost
	failOpImportQualifiedTwice
	failOpFewArgs
Only the last one has anything to do with operators. The other two
were named this way either by mistake or due to a misunderstanding of
what "op" stands for. This small patch corrects this.

- - - - -
96d32ff2 by Simon Peyton Jones at 2022-10-10T22:30:21+01:00
Make rewrite rules "win" over inlining

If a rewrite rule and a rewrite rule compete in the simplifier, this
patch makes sure that the rewrite rule "win".  That is, in general
a bit fragile, but it's a huge help when making specialisation work
reliably, as #21851 and #22097 showed.

The change is fairly straightforwad, and documented in
   Note [Rewrite rules and inlining]
in GHC.Core.Opt.Simplify.Iteration.

Compile-times change, up and down a bit -- in some cases because
we get better specialisation.  But the payoff (more reliable
specialisation) is large.

Metrics: compile_time/bytes allocated
-----------------------------------------------
    T10421(normal)   +3.7% BAD
   T10421a(normal)   +5.5%
    T13253(normal)   +1.3%
      T14052(ghci)   +1.8%
    T15304(normal)   -1.4%
    T16577(normal)   +3.1% BAD
    T17516(normal)   +2.3%
    T17836(normal)   -1.9%
    T18223(normal)   -1.8%
     T8095(normal)   -1.3%
     T9961(normal)   +2.5% BAD

         geo. mean   +0.0%
         minimum     -1.9%
         maximum     +5.5%

Nofib results are (bytes allocated)

+-------------------------------++----------+
|                               ||tsv (rel) |
+===============================++==========+
|           imaginary/paraffins ||   +0.27% |
|                imaginary/rfib ||   -0.04% |
|                     real/anna ||   +0.02% |
|                      real/fem ||   -0.04% |
|                    real/fluid ||   +1.68% |
|                   real/gamteb ||   -0.34% |
|                       real/gg ||   +1.54% |
|                   real/hidden ||   -0.01% |
|                      real/hpg ||   -0.03% |
|                    real/infer ||   -0.03% |
|                   real/prolog ||   +0.02% |
|                  real/veritas ||   -0.47% |
|       shootout/fannkuch-redux ||   -0.03% |
|         shootout/k-nucleotide ||   -0.02% |
|               shootout/n-body ||   -0.06% |
|        shootout/spectral-norm ||   -0.01% |
|         spectral/cryptarithm2 ||   +1.25% |
|             spectral/fibheaps ||  +18.33% |
|           spectral/last-piece ||   -0.34% |
+===============================++==========+
|                     geom mean ||   +0.17% |

There are extensive notes in !8897 about the regressions.
Briefly

* fibheaps: there was a very delicately balanced inlining that
  tipped over the wrong way after this change.

* cryptarithm2 and paraffins are caused by #22274, which is
  a separate issue really.  (I.e. the right fix is *not* to
  make inlining "win" over rules.)

So I'm accepting these changes

Metric Increase:
    T10421
    T16577
    T9961

- - - - -
ed4b5885 by Joachim Breitner at 2022-10-10T23:16:11-04:00
Utils.JSON: do not escapeJsonString in ToJson String instance

as `escapeJsonString` is used in `renderJSON`, so the `JSString`
constructor is meant to carry the unescaped string.

- - - - -
fbb88740 by Matthew Pickering at 2022-10-11T12:48:45-04:00
Tidy implicit binds

We want to put implicit binds into fat interface files, so the easiest
thing to do seems to be to treat them uniformly with other binders.

- - - - -
e058b138 by Matthew Pickering at 2022-10-11T12:48:45-04:00
Interface Files with Core Definitions

This commit adds three new flags

* -fwrite-if-simplified-core: Writes the whole core program into an interface
  file
* -fbyte-code-and-object-code: Generate both byte code and object code
  when compiling a file
* -fprefer-byte-code: Prefer to use byte-code if it's available when
  running TH splices.

The goal for including the core bindings in an interface file is to be able to restart the compiler pipeline
at the point just after simplification and before code generation. Once compilation is
restarted then code can be created for the byte code backend.
This can significantly speed up
start-times for projects in GHCi. HLS already implements its own version of these extended interface
files for this reason.

Preferring to use byte-code means that we can avoid some potentially
expensive code generation steps (see #21700)

* Producing object code is much slower than producing bytecode, and normally you
  need to compile with `-dynamic-too` to produce code in the static and dynamic way, the
  dynamic way just for Template Haskell execution when using a dynamically linked compiler.

* Linking many large object files, which happens once per splice, can be quite
  expensive compared to linking bytecode.

And you can get GHC to compile the necessary byte code so
`-fprefer-byte-code` has access to it by using
`-fbyte-code-and-object-code`.

Fixes #21067

- - - - -
9789ea8e by Matthew Pickering at 2022-10-11T12:48:45-04:00
Teach -fno-code about -fprefer-byte-code

This patch teachs the code generation logic of -fno-code about
-fprefer-byte-code, so that if we need to generate code for a module
which prefers byte code, then we generate byte code rather than object
code.

We keep track separately which modules need object code and which byte
code and then enable the relevant code generation for each. Typically
the option will be enabled globally so one of these sets should be empty
and we will just turn on byte code or object code generation.

We also fix the bug where we would generate code for a module which
enables Template Haskell despite the fact it was unecessary.

Fixes #22016

- - - - -
caced757 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00
Don't keep exit join points so much

We were religiously keeping exit join points throughout, which
had some bad effects (#21148, #22084).

This MR does two things:

* Arranges that exit join points are inhibited from inlining
  only in /one/ Simplifier pass (right after Exitification).

  See Note [Be selective about not-inlining exit join points]
  in GHC.Core.Opt.Exitify

  It's not a big deal, but it shaves 0.1% off compile times.

* Inline used-once non-recursive join points very aggressively
  Given join j x = rhs in
        joinrec k y = ....j x....

  where this is the only occurrence of `j`, we want to inline `j`.
  (Unless sm_keep_exits is on.)

  See Note [Inline used-once non-recursive join points] in
  GHC.Core.Opt.Simplify.Utils

  This is just a tidy-up really.  It doesn't change allocation, but
  getting rid of a binding is always good.

Very effect on nofib -- some up and down.

- - - - -
284cf387 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00
Make SpecConstr bale out less often

When doing performance debugging on #22084 / !8901, I found that the
algorithm in SpecConstr.decreaseSpecCount was so aggressive that if
there were /more/ specialisations available for an outer function,
that could more or less kill off specialisation for an /inner/
function.  (An example was in nofib/spectral/fibheaps.)

This patch makes it a bit more aggressive, by dividing by 2, rather
than by the number of outer specialisations.

This makes the program bigger, temporarily:

   T19695(normal) ghc/alloc   +11.3% BAD

because we get more specialisation.  But lots of other programs
compile a bit faster and the geometric mean in perf/compiler
is 0.0%.

Metric Increase:
    T19695

- - - - -
66af1399 by Cheng Shao at 2022-10-11T12:49:59-04:00
CmmToC: emit explicit tail calls when the C compiler supports it

Clang 13+ supports annotating a return statement using the musttail
attribute, which guarantees that it lowers to a tail call if compilation
succeeds.

This patch takes advantage of that feature for the unregisterised code
generator. The configure script tests availability of the musttail
attribute, if it's available, the Cmm tail calls will become C tail
calls that avoids the mini interpreter trampoline overhead. Nothing is
affected if the musttail attribute is not supported.

Clang documentation:
https://clang.llvm.org/docs/AttributeReference.html#musttail

- - - - -
7f0decd5 by Matthew Pickering at 2022-10-11T12:50:40-04:00
Don't include BufPos in interface files

Ticket #22162 pointed out that the build directory was leaking into the
ABI hash of a module because the BufPos depended on the location of the
build tree.

BufPos is only used in GHC.Parser.PostProcess.Haddock, and the
information doesn't need to be propagated outside the context of a
module.

Fixes #22162

- - - - -
dce9f320 by Cheng Shao at 2022-10-11T12:51:19-04:00
CLabel: fix isInfoTableLabel

isInfoTableLabel does not take Cmm info table into account. This patch is required for data section layout of wasm32 NCG to work.

- - - - -
da679f2e by Andrew Lelechenko at 2022-10-11T18:02:59-04:00
Extend documentation for Data.List, mostly wrt infinite lists

- - - - -
9c099387 by jwaldmann at 2022-10-11T18:02:59-04:00
Expand comment for Data.List.permutations
- - - - -
d3863cb7 by Andrew Lelechenko at 2022-10-11T18:03:37-04:00
ByteArray# is unlifted, not unboxed

- - - - -
f6260e8b by Ben Gamari at 2022-10-11T23:45:10-04:00
rts: Add missing declaration of stg_noDuplicate

- - - - -
69ccec2c by Ben Gamari at 2022-10-11T23:45:10-04:00
base: Move CString, CStringLen to GHC.Foreign

- - - - -
f6e8feb4 by Ben Gamari at 2022-10-11T23:45:10-04:00
base: Move IPE helpers to GHC.InfoProv

- - - - -
866c736e by Ben Gamari at 2022-10-11T23:45:10-04:00
rts: Refactor IPE tracing support

- - - - -
6b0d2022 by Ben Gamari at 2022-10-11T23:45:10-04:00
Refactor IPE initialization

Here we refactor the representation of info table provenance information
in object code to significantly reduce its size and link-time impact.
Specifically, we deduplicate strings and represent them as 32-bit
offsets into a common string table.

In addition, we rework the registration logic to eliminate allocation
from the registration path, which is run from a static initializer where
things like allocation are technically undefined behavior (although it
did previously seem to work). For similar reasons we eliminate lock
usage from registration path, instead relying on atomic CAS.

Closes #22077.

- - - - -
9b572d54 by Ben Gamari at 2022-10-11T23:45:10-04:00
Separate IPE source file from span

The source file name can very often be shared across many IPE entries
whereas the source coordinates are generally unique. Separate the two to
exploit sharing of the former.

- - - - -
27978ceb by Krzysztof Gogolewski at 2022-10-11T23:45:46-04:00
Make Cmm Lint messages use dump style

Lint errors indicate an internal error in GHC, so it makes sense to use
it instead of the user style. This is consistent with Core Lint and STG Lint:

https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Core/Lint.hs#L429

https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Stg/Lint.hs#L144

Fixes #22218.

- - - - -
64a390d9 by Bryan Richter at 2022-10-12T09:52:51+03:00
Mark T7919 as fragile

On x86_64-linux, T7919 timed out ~30 times during July 2022.

And again ~30 times in September 2022.

- - - - -
481467a5 by Ben Gamari at 2022-10-12T08:08:37-04:00
rts: Don't hint inlining of appendToRunQueue

These hints have resulted in compile-time warnings due to failed
inlinings for quite some time. Moreover, it's quite unlikely that
inlining them is all that beneficial given that they are rather sizeable
functions.

Resolves #22280.

- - - - -
81915089 by Curran McConnell at 2022-10-12T16:32:26-04:00
remove name shadowing

- - - - -
626652f7 by Tamar Christina at 2022-10-12T16:33:13-04:00
winio: do not re-translate input when handle is uncooked

- - - - -
5172789a by Charles Taylor at 2022-10-12T16:33:57-04:00
Unrestricted OverloadedLabels (#11671)

Implements GHC proposal:
https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst

- - - - -
ce293908 by Andreas Klebinger at 2022-10-13T05:58:19-04:00
Add a perf test for the generics code pattern from #21839.

This code showed a strong shift between compile time (got worse) and
run time (got a lot better) recently which is perfectly acceptable.

However it wasn't clear why the compile time regression was happening
initially so I'm adding this test to make it easier to track such changes
in the future.

- - - - -
78ab7afe by Ben Gamari at 2022-10-13T05:58:56-04:00
rts/linker: Consolidate initializer/finalizer handling

Here we extend our treatment of initializer/finalizer priorities to
include ELF and in so doing refactor things to share the implementation
with PEi386. As well, I fix a subtle misconception of the ordering
behavior for `.ctors`.

Fixes #21847.

- - - - -
44692713 by Ben Gamari at 2022-10-13T05:58:56-04:00
rts/linker: Add support for .fini sections

- - - - -
beebf546 by Simon Hengel at 2022-10-13T05:59:37-04:00
Update phases.rst

(the name of the original source file is $1, not $2)
- - - - -
eda6c05e by Finley McIlwaine at 2022-10-13T06:00:17-04:00
Clearer error msg for newtype GADTs with defaulted kind

When a newtype introduces GADT eq_specs due to a defaulted
RuntimeRep, we detect this and print the error message with
explicit kinds.

This also refactors newtype type checking to use the new
diagnostic infra.

Fixes #21447

- - - - -
43ab435a by Pierre Le Marre at 2022-10-14T07:45:43-04:00
Add standard Unicode case predicates isUpperCase and isLowerCase.

These predicates use the standard Unicode case properties and are more intuitive than isUpper and isLower.

Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/90#issuecomment-1276649403.

Fixes #14589

- - - - -
aec5a443 by Andrew Lelechenko at 2022-10-14T07:46:21-04:00
Add type signatures in where-clause of Data.List.permutations

The type of interleave' is very much revealing, otherwise it's extremely tough to decipher.

- - - - -
ee0deb80 by Ben Gamari at 2022-10-14T18:29:20-04:00
rts: Use pthread_setname_np correctly on Darwin

As noted in #22206, pthread_setname_np on Darwin only supports
setting the name of the calling thread. Consequently we must introduce
a trampoline which first sets the thread name before entering the thread
entrypoint.
- - - - -
8eff62a4 by Ben Gamari at 2022-10-14T18:29:57-04:00
testsuite: Add test for #22282

This will complement mpickering's more general port of foundation's
numerical testsuite, providing a test for the specific case found
in #22282.

- - - - -
62a55001 by Ben Gamari at 2022-10-14T18:29:57-04:00
ncg/aarch64: Fix sub-word sign extension yet again

In adc7f108141a973b6dcb02a7836eed65d61230e8 we fixed a number of issues
to do with sign extension in the AArch64 NCG found by ghc/test-primops>.
However, this patch made a critical error, assuming that getSomeReg
would allocate a fresh register for the result of its evaluation.
However, this is not the case as `getSomeReg (CmmReg r) == r`.
Consequently, any mutation of the register returned by `getSomeReg` may
have unwanted side-effects on other expressions also mentioning `r`. In
the fix listed above, this manifested as the registers containing the
operands of binary arithmetic operations being incorrectly
sign-extended. This resulted in #22282.

Sadly, the rather simple structure of the tests generated
by `test-primops` meant that this particular case was not exercised.
Even more surprisingly, none of our testsuite caught this case.

Here we fix this by ensuring that intermediate sign extension is
performed in a fresh register.

Fixes #22282.

- - - - -
54e41b16 by Teo Camarasu at 2022-10-15T18:09:24+01:00
rts: ensure we are below maxHeapSize after returning megablocks

When the heap is heavily block fragmented the live byte size might be
low while the memory usage is high. We want to ensure that heap overflow
triggers in these cases.

We do so by checking that we can return enough megablocks to
under maxHeapSize at the end of GC.

- - - - -
29bb90db by Teo Camarasu at 2022-10-15T18:09:24+01:00
rts: trigger a major collection if megablock usage exceeds maxHeapSize

When the heap is suffering from block fragmentation, live bytes might be
low while megablock usage is high.

If megablock usage exceeds maxHeapSize, we want to trigger a major GC to
try to recover some memory otherwise we will die from a heapOverflow at
the end of the GC.

Fixes #21927

- - - - -
4a4641ca by Teo Camarasu at 2022-10-15T18:11:29+01:00
Add realease note for #21927

- - - - -
c1e5719a by Sebastian Graf at 2022-10-17T11:58:46-04:00
DmdAnal: Look through unfoldings of DataCon wrappers (#22241)

Previously, the demand signature we computed upfront for a DataCon wrapper

lacked boxity information and was much less precise than the demand transformer

for the DataCon worker.

In this patch we adopt the solution to look through unfoldings of DataCon

wrappers during Demand Analysis, but still attach a demand signature for other

passes such as the Simplifier.

See `Note [DmdAnal for DataCon wrappers]` for more details.

Fixes #22241.

- - - - -
8c72411d by Gergő Érdi at 2022-10-17T19:20:04-04:00
Add `Enum (Down a)` instance that swaps `succ` and `pred`

See https://github.com/haskell/core-libraries-committee/issues/51 for
discussion. The key points driving the implementation are the following
two ideas:

* For the `Int` type, `comparing (complement @Int)` behaves exactly as
  an order-swapping `compare @Int`.
* `enumFrom @(Down a)` can be implemented in terms of `enumFromThen @a`,
  if only the corner case of starting at the very end is handled specially

- - - - -
d80ad2f4 by Alan Zimmerman at 2022-10-17T19:20:40-04:00
Update the check-exact infrastructure to match ghc-exactprint

GHC tests the exact print annotations using the contents of
utils/check-exact.

The same functionality is provided via
https://github.com/alanz/ghc-exactprint

The latter was updated to ensure it works with all of the files on
hackage when 9.2 was released, as well as updated to ensure users of
the library could work properly (apply-refact, retrie, etc).

This commit brings the changes from ghc-exactprint into
GHC/utils/check-exact, adapting for the changes to master.

Once it lands, it will form the basis for the 9.4 version of
ghc-exactprint.

See also discussion around this process at #21355

- - - - -
08ab5419 by Andreas Klebinger at 2022-10-17T19:21:15-04:00
Avoid allocating intermediate lists for non recursive bindings.

We do so by having an explicit folding function that doesn't need to
allocate intermediate lists first.

Fixes #22196

- - - - -
ff6275ef by Andreas Klebinger at 2022-10-17T19:21:52-04:00
Testsuite: Add a new tables_next_to_code predicate.

And use it to avoid T21710a failing on non-tntc archs.

Fixes #22169

- - - - -
abb82f38 by Eric Lindblad at 2022-10-17T19:22:33-04:00
example rewrite
- - - - -
39beb801 by Eric Lindblad at 2022-10-17T19:22:33-04:00
remove redirect
- - - - -
0d9fb651 by Eric Lindblad at 2022-10-17T19:22:33-04:00
use heredoc
- - - - -
0fa2d185 by Matthew Pickering at 2022-10-17T19:23:10-04:00
testsuite: Fix typo when setting llvm_ways

Since 2014 llvm_ways has been set to [] so none of the tests which use
only_ways(llvm_ways) have worked as expected.

Hopefully the tests still pass with this typo fix!

- - - - -
ced664a2 by Krzysztof Gogolewski at 2022-10-17T19:23:10-04:00
Fix T15155l not getting -fllvm

- - - - -
0ac60423 by Andreas Klebinger at 2022-10-18T03:34:47-04:00
Fix GHCis interaction with tag inference.

I had assumed that wrappers were not inlined in interactive mode.
Meaning we would always execute the compiled wrapper which properly
takes care of upholding the strict field invariant.
This turned out to be wrong. So instead we now run tag inference even
when we generate bytecode. In that case only for correctness not
performance reasons although it will be still beneficial for runtime
in some cases.

I further fixed a bug where GHCi didn't tag nullary constructors
properly when used as arguments. Which caused segfaults when calling
into compiled functions which expect the strict field invariant to
be upheld.

Fixes #22042 and #21083

-------------------------
Metric Increase:
    T4801

Metric Decrease:
    T13035
-------------------------

- - - - -
9ecd1ac0 by M Farkas-Dyck at 2022-10-18T03:35:38-04:00
Make `Functor` a superclass of `TrieMap`, which lets us derive the `map` functions.

- - - - -
f60244d7 by Ben Gamari at 2022-10-18T03:36:15-04:00
configure: Bump minimum bootstrap GHC version

Fixes #22245

- - - - -
ba4bd4a4 by Matthew Pickering at 2022-10-18T03:36:55-04:00
Build System: Remove out-of-date comment about make build system

Both make and hadrian interleave compilation of modules of different
modules and don't respect the package boundaries. Therefore I just
remove this comment which points out this "difference".

Fixes #22253

- - - - -
e1bbd368 by Matthew Pickering at 2022-10-18T16:15:49+02:00
Allow configuration of error message printing

This MR implements the idea of #21731 that the printing of a diagnostic
method should be configurable at the printing time.

The interface of the `Diagnostic` class is modified from:

```
class Diagnostic a where
  diagnosticMessage :: a -> DecoratedSDoc
  diagnosticReason  :: a -> DiagnosticReason
  diagnosticHints   :: a -> [GhcHint]
```

to

```
class Diagnostic a where
  type DiagnosticOpts a
  defaultDiagnosticOpts :: DiagnosticOpts a
  diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc
  diagnosticReason  :: a -> DiagnosticReason
  diagnosticHints   :: a -> [GhcHint]
```

and so each `Diagnostic` can implement their own configuration record
which can then be supplied by a client in order to dictate how to print
out the error message.

At the moment this only allows us to implement #21722 nicely but in
future it is more natural to separate the configuration of how much
information we put into an error message and how much we decide to print
out of it.

Updates Haddock submodule

- - - - -
99dc3e3d by Matthew Pickering at 2022-10-18T16:15:53+02:00
Add -fsuppress-error-contexts to disable printing error contexts in errors

In many development environments, the source span is the primary means
of seeing what an error message relates to, and the In the expression:
and In an equation for: clauses are not particularly relevant. However,
they can grow to be quite long, which can make the message itself both
feel overwhelming and interact badly with limited-space areas.

It's simple to implement this flag so we might as well do it and give
the user control about how they see their messages.

Fixes #21722

- - - - -
5b3a992f by Dai at 2022-10-19T10:45:45-04:00
Add VecSlot for unboxed sums of SIMD vectors

This patch adds the missing `VecRep` case to `primRepSlot` function and
all the necessary machinery to carry this new `VecSlot` through code
generation. This allows programs involving unboxed sums of SIMD vectors
to be written and compiled.

Fixes #22187

- - - - -
6d7d9181 by sheaf at 2022-10-19T10:45:45-04:00
Remove SIMD conversions

This patch makes it so that packing/unpacking SIMD
vectors always uses the right sized types, e.g.
unpacking a Word16X4# will give a tuple of Word16#s.

As a result, we can get rid of the conversion instructions
that were previously required.

Fixes #22296

- - - - -
3be48877 by sheaf at 2022-10-19T10:45:45-04:00
Cmm Lint: relax SIMD register assignment check

As noted in #22297, SIMD vector registers can be used
to store different kinds of values, e.g. xmm1 can be used
both to store integer and floating point values.
The Cmm type system doesn't properly account for this, so
we weaken the Cmm register assignment lint check to only
compare widths when comparing a vector type with its
allocated vector register.

- - - - -
f7b7a312 by sheaf at 2022-10-19T10:45:45-04:00
Disable some SIMD tests on non-X86 architectures

- - - - -
83638dce by M Farkas-Dyck at 2022-10-19T10:46:29-04:00
Scrub various partiality involving lists (again).

Lets us avoid some use of `head` and `tail`, and some panics.

- - - - -
c3732c62 by M Farkas-Dyck at 2022-10-19T10:47:13-04:00
Enforce invariant of `ListBag` constructor.

- - - - -
488d3631 by Andrew Lelechenko at 2022-10-19T10:47:52-04:00
More precise types for fields of OverlappingInstances and UnsafeOverlap in TcSolverReportMsg

It's clear from asserts in `GHC.Tc.Errors` that `overlappingInstances_matches`
and `unsafeOverlapped` are supposed to be non-empty, and `unsafeOverlap_matches`
contains a single instance, but these invariants are immediately lost afterwards
and not encoded in types. This patch enforces the invariants by pattern matching
and makes types more precise, avoiding asserts and partial functions such as `head`.

- - - - -
607ce263 by sheaf at 2022-10-19T10:47:52-04:00
Rename unsafeOverlap_matches -> unsafeOverlap_match in UnsafeOverlap
- - - - -
1fab9598 by Matthew Pickering at 2022-10-19T10:48:29-04:00
Add SpliceTypes test for hie files

This test checks that typed splices and quotes get the right type
information when used in hiefiles.

See #21619

- - - - -
a8b52786 by Jan Hrček at 2022-10-19T10:49:09-04:00
Small language fixes in 'Using GHC'

- - - - -
1dab1167 by Gergő Érdi at 2022-10-19T10:49:51-04:00
Fix typo in `Opt_WriteIfSimplifiedCore`'s name

- - - - -
b17cfc9c by sheaf at 2022-10-19T10:50:37-04:00
TyEq:N assertion: only for saturated applications

The assertion that checked TyEq:N in canEqCanLHSFinish incorrectly
triggered in the case of an unsaturated newtype TyCon heading the RHS,
even though we can't unwrap such an application. Now, we only trigger
an assertion failure in case of a saturated application of a newtype
TyCon.

Fixes #22310

- - - - -
ff6f2228 by M Farkas-Dyck at 2022-10-20T16:15:51-04:00
CoreToStg: purge `DynFlags`.

- - - - -
1ebd521f by Matthew Pickering at 2022-10-20T16:16:27-04:00
ci: Make fat014 test robust

For some reason I implemented this as a makefile test rather than a
ghci_script test. Hopefully making it a ghci_script test makes it more
robust.

Fixes #22313

- - - - -
8cd6f435 by Curran McConnell at 2022-10-21T02:58:01-04:00
remove a no-warn directive from GHC.Cmm.ContFlowOpt

This patch is motivated by the desire to remove the {-# OPTIONS_GHC
-fno-warn-incomplete-patterns #-} directive at the top of
GHC.Cmm.ContFlowOpt. (Based on the text in this coding standards doc, I
understand it's a goal of the project to remove such directives.) I
chose this task because I'm a new contributor to GHC, and it seemed like
a good way to get acquainted with the patching process.

In order to address the warning that arose when I removed the no-warn
directive, I added a case to removeUnreachableBlocksProc to handle the
CmmData constructor. Clearly, since this partial function has not been
erroring out in the wild, its inputs are always in practice wrapped by
the CmmProc constructor. Therefore the CmmData case is handled by a
precise panic (which is an improvement over the partial pattern match
from before).

- - - - -
a2af7c4c by Nicolas Trangez at 2022-10-21T02:58:39-04:00
build: get rid of `HAVE_TIME_H`

As advertized by `autoreconf`:

> All current systems provide time.h; it need not be checked for.

Hence, remove the check for it in `configure.ac` and remove conditional
inclusion of the header in `HAVE_TIME_H` blocks where applicable.

The `time.h` header was being included in various source files without a
`HAVE_TIME_H` guard already anyway.

- - - - -
25cdc630 by Nicolas Trangez at 2022-10-21T02:58:39-04:00
rts: remove use of `TIME_WITH_SYS_TIME`

`autoreconf` will insert an `m4_warning` when the obsolescent
`AC_HEADER_TIME` macro is used:

> Update your code to rely only on HAVE_SYS_TIME_H,
> then remove this warning and the obsolete code below it.
> All current systems provide time.h; it need not be checked for.
> Not all systems provide sys/time.h, but those that do, all allow
> you to include it and time.h simultaneously.

Presence of `sys/time.h` was already checked in an earlier
`AC_CHECK_HEADERS` invocation, so `AC_HEADER_TIME` can be dropped and
guards relying on `TIME_WITH_SYS_TIME` can be reworked to
(unconditionally) include `time.h` and include `sys/time.h` based on
`HAVE_SYS_TIME_H`.

Note the documentation of `AC_HEADER_TIME` in (at least) Autoconf 2.67
says

> This macro is obsolescent, as current systems can include both files
> when they exist. New programs need not use this macro.

- - - - -
1fe7921c by Eric Lindblad at 2022-10-21T02:59:21-04:00
runhaskell
- - - - -
e3b3986e by David Feuer at 2022-10-21T03:00:00-04:00
Document how to quote certain names with spaces

Quoting a name for Template Haskell is a bit tricky if the second
character of that name is a single quote. The User's Guide falsely
claimed that it was impossible. Document how to do it.

Fixes #22236
- - - - -
0eba81e8 by Krzysztof Gogolewski at 2022-10-21T03:00:00-04:00
Fix syntax
- - - - -
a4dbd102 by Ben Gamari at 2022-10-21T09:11:12-04:00
Fix manifest filename when writing Windows .rc files

As noted in #12971, we previously used `show` which resulted in
inappropriate escaping of non-ASCII characters.

- - - - -
30f0d9a9 by Ben Gamari at 2022-10-21T09:11:12-04:00
Write response files in UTF-8 on Windows

This reverts the workaround introduced in
f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file
logic to write response files with the `latin1` encoding to workaround
`gcc`'s lacking Unicode support. This is now no longer necessary (and in
fact actively unhelpful) since we rather use Clang.

- - - - -
b8304648 by Matthew Farkas-Dyck at 2022-10-21T09:11:56-04:00
Scrub some partiality in `GHC.Core.Opt.Simplify.Utils`.

- - - - -
09ec7de2 by Teo Camarasu at 2022-10-21T13:23:07-04:00
template-haskell: Improve documentation of strictness annotation types

Before it was undocumentated that DecidedLazy can be returned by
reifyConStrictness for strict fields. This can happen when a field has
an unlifted type or its the single field of a newtype constructor.

Fixes #21380

- - - - -
88172069 by M Farkas-Dyck at 2022-10-21T13:23:51-04:00
Delete `eqExpr`, since GHC 9.4 has been released.

- - - - -
86e6549e by Ömer Sinan Ağacan at 2022-10-22T07:41:30-04:00
Introduce a standard thunk for allocating strings

Currently for a top-level closure in the form

    hey = unpackCString# x

we generate code like this:

    Main.hey_entry() //  [R1]
             { info_tbls: [(c2T4,
                            label: Main.hey_info
                            rep: HeapRep static { Thunk }
                            srt: Nothing)]
               stack_info: arg_space: 8 updfr_space: Just 8
             }
         {offset
           c2T4: // global
               _rqm::P64 = R1;
               if ((Sp + 8) - 24 < SpLim) (likely: False) goto c2T5; else goto c2T6;
           c2T5: // global
               R1 = _rqm::P64;
               call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8;
           c2T6: // global
               (_c2T1::I64) = call "ccall" arg hints:  [PtrHint,
                                                        PtrHint]  result hints:  [PtrHint] newCAF(BaseReg, _rqm::P64);
               if (_c2T1::I64 == 0) goto c2T3; else goto c2T2;
           c2T3: // global
               call (I64[_rqm::P64])() args: 8, res: 0, upd: 8;
           c2T2: // global
               I64[Sp - 16] = stg_bh_upd_frame_info;
               I64[Sp - 8] = _c2T1::I64;
               R2 = hey1_r2Gg_bytes;
               Sp = Sp - 16;
               call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24;
         }
     }

This code is generated for every string literal. Only difference between
top-level closures like this is the argument for the bytes of the string
(hey1_r2Gg_bytes in the code above).

With this patch we introduce a standard thunk in the RTS, called
stg_MK_STRING_info, that does what `unpackCString# x` does, except it
gets the bytes address from the payload. Using this, for the closure
above, we generate this:

    Main.hey_closure" {
        Main.hey_closure:
            const stg_MK_STRING_info;
            const 0; // padding for indirectee
            const 0; // static link
            const 0; // saved info
            const hey1_r1Gg_bytes; // the payload
    }

This is much smaller in code.

Metric Decrease:
    T10421
    T11195
    T12150
    T12425
    T16577
    T18282
    T18698a
    T18698b

Co-Authored By: Ben Gamari <ben at well-typed.com>

- - - - -
1937016b by Andreas Klebinger at 2022-10-22T07:42:06-04:00
hadrian: Improve error for wrong key/value errors.

- - - - -
11fe42d8 by Vladislav Zavialov at 2022-10-23T00:11:50+03:00
Class layout info (#19623)

Updates the haddock submodule.

- - - - -
f0a90c11 by Sven Tennie at 2022-10-24T00:12:51-04:00
Pin used way for test cloneMyStack (#21977)

cloneMyStack checks the order of closures on the cloned stack. This may
change for different ways. Thus we limit this test to one way (normal).

- - - - -
0614e74d by Aaron Allen at 2022-10-24T17:11:21+02:00
Convert Diagnostics in GHC.Tc.Gen.Splice (#20116)

Replaces uses of `TcRnUnknownMessage` in `GHC.Tc.Gen.Splice` with
structured diagnostics.

closes #20116

- - - - -
8d2dbe2d by Andreas Klebinger at 2022-10-24T15:59:41-04:00
Improve stg lint for unboxed sums.

It now properly lints cases where sums end up distributed
over multiple args after unarise.

Fixes #22026.

- - - - -
41406da5 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00
Fix binder-swap bug

This patch fixes #21229 properly, by avoiding doing a
binder-swap on dictionary Ids.  This is pretty subtle, and explained
in Note [Care with binder-swap on dictionaries].

Test is already in simplCore/should_run/T21229

This allows us to restore a feature to the specialiser that we had
to revert: see Note [Specialising polymorphic dictionaries].
(This is done in a separate patch.)

I also modularised things, using a new function scrutBinderSwap_maybe
in all the places where we are (effectively) doing a binder-swap,
notably

* Simplify.Iteration.addAltUnfoldings
* SpecConstr.extendCaseBndrs

In Simplify.Iteration.addAltUnfoldings I also eliminated a guard
    Many <- idMult case_bndr
because we concluded, in #22123, that it was doing no good.

- - - - -
5a997e16 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00
Make the specialiser handle polymorphic specialisation

Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a
program run (a lot) slower, because less specialisation took place
overall. It turned out that the specialiser was missing opportunities
because of quantified type variables.

It was quite easy to fix. The story is given in
    Note [Specialising polymorphic dictionaries]

Two other minor fixes in the specialiser

* There is no benefit in specialising data constructor /wrappers/.
  (They can appear overloaded because they are given a dictionary
  to store in the constructor.)  Small guard in canSpecImport.

* There was a buglet in the UnspecArg case of specHeader, in the
  case where there is a dead binder. We need a LitRubbish filler
  for the specUnfolding stuff.  I expanded
  Note [Drop dead args from specialisations] to explain.

There is a 4% increase in compile time for T15164, because we generate
more specialised code.  This seems OK.

Metric Increase:
    T15164

- - - - -
7f203d00 by Sylvain Henry at 2022-10-25T18:07:43-04:00
Numeric exceptions: replace FFI calls with primops

ghc-bignum needs a way to raise numerical exceptions defined in base
package. At the time we used FFI calls into primops defined in the RTS.
These FFI calls had to be wrapped into hacky bottoming functions because
"foreign import prim" syntax doesn't support giving a bottoming demand
to the foreign call (cf #16929).

These hacky wrapper functions trip up the JavaScript backend (#21078)
because they are polymorphic in their return type. This commit
replaces them with primops very similar to raise# but raising predefined
exceptions.

- - - - -
0988a23d by Sylvain Henry at 2022-10-25T18:08:24-04:00
Enable popcount rewrite rule when cross-compiling

The comment applies only when host's word size < target's word size.
So we can relax the guard.

- - - - -
a2f53ac8 by Sylvain Henry at 2022-10-25T18:09:05-04:00
Add GHC.SysTools.Cpp module

Move doCpp out of the driver to be able to use it in the upcoming JS backend.

- - - - -
1fd7f201 by Ben Gamari at 2022-10-25T18:09:42-04:00
llvm-targets: Add datalayouts for big-endian AArch64 targets

Fixes #22311.

Thanks to @zeldin for the patch.

- - - - -
f5a486eb by Krzysztof Gogolewski at 2022-10-25T18:10:19-04:00
Cleanup String/FastString conversions

Remove unused mkPtrString and isUnderscoreFS.
We no longer use mkPtrString since 1d03d8bef96.

Remove unnecessary conversions between FastString and String and back.

- - - - -
f7bfb40c by Ryan Scott at 2022-10-26T00:01:24-04:00
Broaden the in-scope sets for liftEnvSubst and composeTCvSubst

This patch fixes two distinct (but closely related) buglets that were uncovered
in #22235:

* `liftEnvSubst` used an empty in-scope set, which was not wide enough to cover
  the variables in the range of the substitution. This patch fixes this by
  populating the in-scope set from the free variables in the range of the
  substitution.
* `composeTCvSubst` applied the first substitution argument to the range of the
  second substitution argument, but the first substitution's in-scope set was
  not wide enough to cover the range of the second substutition. We similarly
  fix this issue in this patch by widening the first substitution's in-scope set
  before applying it.

Fixes #22235.

- - - - -
0270cc54 by Vladislav Zavialov at 2022-10-26T00:02:01-04:00
Introduce TcRnWithHsDocContext (#22346)

Before this patch, GHC used withHsDocContext to attach an HsDocContext
to an error message:

	addErr $ mkTcRnUnknownMessage $ mkPlainError noHints (withHsDocContext ctxt msg)

The problem with this approach is that it only works with
TcRnUnknownMessage. But could we attach an HsDocContext to a
structured error message in a generic way? This patch solves
the problem by introducing a new constructor to TcRnMessage:

	data TcRnMessage where
	  ...
	  TcRnWithHsDocContext :: !HsDocContext -> !TcRnMessage -> TcRnMessage
	  ...

- - - - -
9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00
Testsuite: more precise test options

Necessary for newer cross-compiling backends (JS, Wasm) that don't
support TH yet.

- - - - -
f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00
Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115)

When faced with VDQ in the type of a term, GHC generates the following
error message:

	Illegal visible, dependent quantification in the type of a term
	(GHC does not yet support this)

Prior to this patch, there were two ways this message could have been
generated and represented:

	1. with the dedicated constructor TcRnVDQInTermType
	    (see check_type in GHC.Tc.Validity)
	2. with the transitional constructor TcRnUnknownMessage
	    (see noNestedForallsContextsErr in GHC.Rename.Utils)

Not only this led to duplication of code generating the final SDoc,
it also made it tricky to track the origin of the error message.

This patch fixes the problem by using TcRnVDQInTermType exclusively.

- - - - -
223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00
Remove source location information from interface files

This change aims to minimize source location information leaking
into interface files, which makes ABI hashes dependent on the
build location.

The `Binary (Located a)` instance has been removed completely.

It seems that the HIE interface still needs the ability to
serialize SrcSpans, but by wrapping the instances, it should
be a lot more difficult to inadvertently add source location
information.

- - - - -
22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00
Add missing dict binds to specialiser

I had forgotten to add the auxiliary dict bindings to the
/unfolding/ of a specialised function.  This caused #22358,
which reports failures when compiling Hackage packages
     fixed-vector
     indexed-traversable

Regression test T22357 is snarfed from indexed-traversable

- - - - -
a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00
Fix broken link to `async` package

- - - - -
750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00
Pass correct package db when testing stage1.

It used to pick the db for stage-2 which obviously didn't work.

- - - - -
ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00
Minor SDoc-related cleanup

* Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel
  for a function using CStyle (analogous to pprAsmLabel)
* Move LabelStyle to the CLabel module, it no longer needs to be in Outputable.
* Move calls to 'text' right next to literals, to make sure the text/str
  rule is triggered.
* Remove FastString/String roundtrip in Tc.Deriv.Generate
* Introduce showSDocForUser', which abstracts over a pattern in
  GHCi.UI

- - - - -
c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00
CI: Don't run lint-submods on nightly

Fixes #22325

- - - - -
270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00
Start the deprecation process for GHC.Pack

- - - - -
d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00
Drop a kludge for binutils<2.17, which is now over 10 years old.

- - - - -
8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00
rts: `name` argument of `createOSThread` can be `const`

Since we don't intend to ever change the incoming string, declare this
to be true.

Also, in the POSIX implementation, the argument is no longer `STG_UNUSED`
(since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path.

See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080

- - - - -
13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00
rts: fix lifetime of `start_thread`s `name` value

Since, unlike the code in ee0deb8054da2^, usage of the `name` value
passed to `createOSThread` now outlives said function's lifetime, and
could hence be released by the caller by the time the new thread runs
`start_thread`, it needs to be copied.

See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080
See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066

- - - - -
edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00
rts: fix OS thread naming in ticker

Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed
when invoking `createOSThread`. However, the 'ticker' has some
thread-creation code which doesn't rely on `createOSThread`, yet also
uses `pthread_setname_np`.

This patch enforces all thread creation to go through a single
function, which uses the (correct) thread-naming code introduced in
ee0deb805.

See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2
See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206
See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066

- - - - -
b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00
Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core

- - - - -
30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00
ThToHs: fix overzealous parenthesization

Before this patch, when converting from TH.Exp to LHsExpr GhcPs,
the compiler inserted more parentheses than required:

	((f a) (b + c)) d

This was happening because the LHS of the function application was
parenthesized as if it was the RHS.

Now we use funPrec and appPrec appropriately and produce sensibly
parenthesized expressions:

	f a (b + c) d

I also took the opportunity to remove the special case for LamE,
which was not special at all and simply duplicated code.

- - - - -
0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00
Add accurate skolem info when quantifying

Ticket #22379 revealed that skolemiseQuantifiedTyVar was
dropping the passed-in skol_info on the floor when it encountered
a SkolemTv.  Bad!  Several TyCons thereby share a single SkolemInfo
on their binders, which lead to bogus error reports.

- - - - -
38d19668 by Fendor at 2022-11-01T12:50:25-04:00
Expose UnitEnvGraphKey for user-code

- - - - -
77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00
Shrink test case for #22357

Ryan Scott offered a cut-down repro case
(60 lines instead of more than 700 lines)

- - - - -
4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00
Add two tests for #17366

- - - - -
6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
rts: introduce (and use) `STG_NORETURN`

Instead of sprinkling the codebase with
`GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for,
basically, the same thing) similar to `STG_UNUSED` and others, and
update the code to use this macro where applicable.

- - - - -
f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
rts: consistently use `STG_UNUSED`

- - - - -
81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
rts: introduce (and use) `STG_USED`

Similar to `STG_UNUSED`, have a specific macro for
`__attribute__(used)`.

- - - - -
41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
rts: introduce (and use) `STG_MALLOC`

Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC`
macro definition and use it instead.

- - - - -
3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00
rts: use `STG_UNUSED`

- - - - -
9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00
rts: specify deallocator of allocating functions

This patch adds a new `STG_MALLOC1` macro (and its counterpart
`STG_MALLOC2` for completeness) which allows to specify the deallocation
function to be used with allocations of allocating functions, and
applies it to `stg*allocBytes`.

It also fixes a case where `free` was used to free up an
`stgMallocBytes` allocation, found by the above change.

See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute
See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381

- - - - -
81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
rts: use `alloc_size` attribute

This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which
allow to set the `alloc_size` attribute on functions, when available.

See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute
See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381

- - - - -
99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
rts: add and use `STG_RETURNS_NONNULL`

See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute
See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381

- - - - -
c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00
rts: tag `stgStrndup` as `STG_MALLOC`

See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381

- - - - -
ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00
Move Symbol implementation note out of public haddock

- - - - -
284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00
gen-dll: Drop it

Currently it is only used by the make build system, which is soon to be
retired, and it has not built since 41cf758b. We may need to reintroduce
it when dynamic-linking support is introduced on Windows, but we will
cross that bridge once we get there.

Fixes #21753.

- - - - -
24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00
Port foundation numeric tests to GHC testsuite

This commit ports the numeric tests which found a regression in GHC-9.4.

https://github.com/haskell-foundation/foundation/issues/571

Included in the commit is a simple random number generator and
simplified QuickCheck implementation. In future these could be factored
out of this standalone file and reused as a general purpose library
which could be used for other QuickCheck style tests in the testsuite.

See #22282

- - - - -
d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00
git: ignore HIE files.

Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci.

- - - - -
a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00
Clarify status of bindings in WholeCoreBindings

Gergo points out that these bindings are tidied, rather than prepd as
the variable claims. Therefore we update the name of the variable to
reflect reality and add a comment to the data type to try to erase any
future confusion.

Fixes #22307

- - - - -
634da448 by Andrew Lelechenko at 2022-11-03T21:25:02+00:00
Fix haddocks for GHC.IORef

- - - - -
31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00
Export pprTrace and friends from GHC.Prelude.

Introduces GHC.Prelude.Basic which can be used in modules which are a
dependency of the ppr code.

- - - - -
bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00
CI: Allow hadrian-ghc-in-ghci to run in nightlies

Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs
to mark it as "optional" so it can run if the job doesn't exist.

Fixes #22396.

- - - - -
3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00
Minor refactor around FastStrings

Pass FastStrings to functions directly, to make sure the rule
for fsLit "literal" fires.

Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph.

- - - - -
e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00
Bump unix submodule to 2.8.0.0

Also bumps process and ghc-boot bounds on unix.

For hadrian, when cross-compiling, we add -Wwarn=unused-imports
-Wwarn=unused-top-binds to validation flavour. Further fixes in unix
and/or hsc2hs is needed to make it completely free of warnings; for
the time being, this change is needed to unblock other
cross-compilation related work.

- - - - -
42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00
Bump Win32 submodule to 2.13.4.0

Fixes #22098

- - - - -
e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00
Bump ci-images revision

ci-images has recently been updated, including changes needed for wasm32-wasi CI.

- - - - -
88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00
Bump gmp-tarballs submodule

Includes a fix for wasm support, doesn't impact other targets.

- - - - -
69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00
Bump haskeline submodule

Includes a fix for wasm support, doesn't impact other targets.

- - - - -
5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00
bump llvm upper bound
- - - - -
68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00
Define `Infinite` list and use where appropriate.

Also add perf test for infinite list fusion.

In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names.

Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists].

- - - - -
ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00
Fix TypeData issues (fixes #22315 and #22332)

There were two bugs here:

1. Treating type-level constructors as PromotedDataCon doesn't always
   work, in particular because constructors promoted via DataKinds are
   called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b)
   Fix: guard these cases with isDataKindsPromotedDataCon.

2. Type-level constructors were sent to the code generator, producing
   things like constructor wrappers. (Tests T22332a, T22332b)
   Fix: test for them in isDataTyCon.

Other changes:

* changed the marking of "type data" DataCon's as suggested by SPJ.

* added a test TDGADT for a type-level GADT.

* comment tweaks

* change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo
  is used only for pretty printing, not for typechecking. (SPJ)

- - - - -
132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00
Clarify msum/asum documentation

- - - - -
bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00
Add example for (<$)

- - - - -
080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00
Document what Alternative/MonadPlus instances actually do

- - - - -
92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00
Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117)

The following `TcRnDiagnostic` messages have been introduced:

TcRnWarnUnsatisfiedMinimalDefinition
TcRnMisplacedInstSig
TcRnBadBootFamInstDeclErr
TcRnIllegalFamilyInstance
TcRnAssocInClassErr
TcRnBadFamInstDecl
TcRnNotOpenFamily

- - - - -
90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00
GHCi tags generation phase 2

see #19884

- - - - -
f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00
Fire RULES in the Specialiser

The Specialiser has, for some time, fires class-op RULES in the
specialiser itself: see
   Note [Specialisation modulo dictionary selectors]

This MR beefs it up a bit, so that it fires /all/ RULES in the
specialiser, not just class-op rules.  See
   Note [Fire rules in the specialiser]
The result is a bit more specialisation; see test
   simplCore/should_compile/T21851_2

This pushed me into a bit of refactoring.  I made a new data types
GHC.Core.Rules.RuleEnv, which combines
  - the several source of rules (local, home-package, external)
  - the orphan-module dependencies

in a single record for `getRules` to consult.  That drove a bunch of
follow-on refactoring, including allowing me to remove
cr_visible_orphan_mods from the CoreReader data type.

I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule.

The reorganisation in the Simplifier improve compile times a bit
(geom mean -0.1%), but T9961 is an outlier

Metric Decrease:
    T9961

- - - - -
2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00
Make indexError work better

The problem here is described at some length in
Note [Boxity for bottoming functions] and
Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal.

This patch adds a SPECIALISE pragma for indexError, which
makes it much less vulnerable to the problem described in
these Notes.

(This came up in another line of work, where a small change made
indexError do reboxing (in nofib/spectral/simple/table_sort)
that didn't happen before my change.  I've opened #22404
to document the fagility.

- - - - -
399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00
Fix DsUselessSpecialiseForClassMethodSelector msg

The error message for DsUselessSpecialiseForClassMethodSelector
was just wrong (a typo in some earlier work); trivial fix

- - - - -
dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00
WorkWrap: Unboxing unboxed tuples is not always useful (#22388)

See Note [Unboxing through unboxed tuples].

Fixes #22388.

- - - - -
1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00
Boxity: Handle argument budget of unboxed tuples correctly (#21737)

Now Budget roughly tracks the combined width of all arguments after unarisation.
See the changes to `Note [Worker argument budgets]`.

Fixes #21737.

- - - - -
2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00
autoconf: check getpid getuid raise

This patch adds checks for getpid, getuid and raise in autoconf. These
functions are absent in wasm32-wasi and thus needs to be checked.

- - - - -
f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00
hadrian: add -Wwarn only for cross-compiling unix

- - - - -
2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00
hadrian: add targetSupportsThreadedRts flag

This patch adds a targetSupportsThreadedRts flag to indicate whether
the target supports the threaded rts at all, different from existing
targetSupportsSMP that checks whether -N is supported by the RTS. All
existing flavours have also been updated accordingly to respect this
flags.

Some targets (e.g. wasm32-wasi) does not support the threaded rts,
therefore this flag is needed for the default flavours to work. It
makes more sense to have proper autoconf logic to check for threading
support, but for the time being, we just set the flag to False iff the
target is wasm32.

- - - - -
8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00
Fix Cmm symbol kind

- - - - -
b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00
add the two key graph modules from Martin Erwig's FGL

Martin Erwig's FGL (Functional Graph Library) provides an "inductive"
representation of graphs.  A general graph has labeled nodes and
labeled edges.  The key operation on a graph is to decompose it by
removing one node, together with the edges that connect the node to
the rest of the graph.  There is also an inverse composition
operation.

The decomposition and composition operations make this representation
of graphs exceptionally well suited to implement graph algorithms in
which the graph is continually changing, as alluded to in #21259.

This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the
interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides
an implementation.  Both modules are taken from `fgl-5.7.0.3` on
Hackage, with these changes:

  - Copyright and license text have been copied into the files
    themselves, not stored separately.

  - Some calls to `error` have been replaced with calls to `panic`.

  - Conditional-compilation support for older versions of GHC,
    `containers`, and `base` has been removed.

- - - - -
3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00
add new modules for reducibility and WebAssembly translation

- - - - -
df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00
Add support for the wasm32-wasi target tuple

This patch adds the wasm32-wasi tuple support to various places in the
tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen
logic will come in subsequent commits.

- - - - -
32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00
deriveConstants: parse .ll output for wasm32 due to broken nm

This patch makes deriveConstants emit and parse an .ll file when
targeting wasm. It's a necessary workaround for broken llvm-nm on
wasm, which isn't capable of reporting correct constant values when
parsing an object.

- - - - -
07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00
rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking

Unlike other targets, wasm requires the function signature of the call
site and callee to strictly match. So in Cmm, when we call a C
function that actually returns a value, we need to add an _unused
local variable to receive it, otherwise type error awaits.

An even bigger problem is calling variadic functions like barf() and
such. Cmm doesn't support CAPI calling convention yet, so calls to
variadic functions just happen to work in some cases with some
target's ABI. But again, it doesn't work with wasm. Fortunately, the
wasm C ABI lowers varargs to a stack pointer argument, and it can be
passed NULL when no other arguments are expected to be passed. So we
also add the additional unused NULL arguments to those functions, so
to fix wasm, while not affecting behavior on other targets.

- - - - -
00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00
testsuite: correct sleep() signature in T5611

In libc, sleep() returns an integer. The ccall type signature should
match the libc definition, otherwise it causes linker error on wasm.

- - - - -
d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00
rts: prefer ffi_type_void over FFI_TYPE_VOID

This patch uses ffi_type_void instead of FFI_TYPE_VOID in the
interpreter code, since the FFI_TYPE_* macros are not available in
libffi-wasm32 yet. The libffi public documentation also only mentions
the lower-case ffi_type_* symbols, so we should prefer the lower-case
API here.

- - - - -
4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00
rts: don't define RTS_USER_SIGNALS when signal.h is not present

In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related
logic is guarded with RTS_USER_SIGNALS. This patch extends the range
of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff
signal.h is actually detected by autoconf. This is required for
wasm32-wasi to work, which lacks signals.

- - - - -
3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00
rts: use HAVE_GETPID to guard subprocess related logic

We've previously added detection of getpid() in autoconf. This patch
uses HAVE_GETPID to guard some subprocess related logic in the RTS.
This is required for certain targets like wasm32-wasi, where there
isn't a process model at all.

- - - - -
50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00
rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined

This patch adds the missing THREADED_RTS CPP guard to mutex logic in
IPE.c.

- - - - -
ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00
rts: genericRaise: use exit() instead when not HAVE_RAISE

We check existence of raise() in autoconf, and here, if not
HAVE_RAISE, we should use exit() instead in genericRaise.

- - - - -
c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00
rts: checkSuid: don't do it when not HAVE_GETUID

When getuid() is not present, don't do checkSuid since it doesn't make
sense anyway on that target.

- - - - -
d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00
rts: wasm32 placeholder linker

This patch adds minimal placeholder linker logic for wasm32, just
enough to unblock compiling rts on wasm32. RTS linker functionality is
not properly implemented yet for wasm32.

- - - - -
65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00
rts: RtsStartup: chdir to PWD on wasm32

This patch adds a wasm32-specific behavior to RtsStartup logic. When
the PWD environment variable is present, we chdir() to it first.

The point is to workaround an issue in wasi-libc: it's currently not
possible to specify the initial working directory, it always defaults
to / (in the virtual filesystem mapped from some host directory). For
some use cases this is sufficient, but there are some other cases
(e.g. in the testsuite) where the program needs to access files
outside.

- - - - -
65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00
rts: no timer for wasm32

Due to the lack of threads, on wasm32 there can't be a background
timer that periodically resets the context switch flag. This patch
disables timer for wasm32, and also makes the scheduler default to -C0
on wasm32 to avoid starving threads.

- - - - -
e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00
rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32

The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32.

- - - - -
0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00
rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32

On wasm32 there isn't a process model at all, so no
FORKPROCESS_PRIMOP_SUPPORTED.

- - - - -
88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00
rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32

libffi-wasm32 only supports non-standard libffi closure api via
ffi_alloc_prep_closure(). This patch implements
ffi_alloc_prep_closure() via standard libffi closure api on other
targets, and uses it to implement adjustor functionality.

- - - - -
15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00
rts: don't return memory to OS on wasm32

This patch makes the storage manager not return any memory on wasm32.
The detailed reason is described in Note [Megablock allocator on
wasm].

- - - - -
631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00
rts: make flushExec a no-op on wasm32

This patch makes flushExec a no-op on wasm32, since there's no such
thing as executable memory on wasm32 in the first place.

- - - - -
654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00
rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32

This patch prevents resetTerminalSettings and freeThreadingResources
to be called on wasm32, since there is no TTY or threading on wasm32
at all.

- - - - -
f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00
rts: OSThreads.h: stub types for wasm32

This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey
types for wasm32, just enough to unblock compiling RTS. Any
threading-related functionality has been patched to be disabled on
wasm32.

- - - - -
a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00
Add register mapping for wasm32

This patch adds register mapping logic for wasm32. See Note [Register
mapping on WebAssembly] in wasm32 NCG for more description.

- - - - -
d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00
rts: wasm32 specific logic

This patch adds the rest of wasm32 specific logic in rts.

- - - - -
7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00
base: fall back to using monotonic clock to emulate cputime on wasm32

On wasm32, we have to fall back to using monotonic clock to emulate
cputime, since there's no native support for cputime as a clock id.

- - - - -
5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00
base: more autoconf checks for wasm32

This patch adds more autoconf checks to base, since those functions
and headers may exist on other POSIX systems but don't exist on
wasm32.

- - - - -
00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00
base: avoid using unsupported posix functionality on wasm32

This base patch avoids using unsupported posix functionality on
wasm32.

- - - - -
34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00
autoconf: set CrossCompiling=YES in cross bindist configure

This patch fixes the bindist autoconf logic to properly set
CrossCompiling=YES when it's a cross GHC bindist.

- - - - -
5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00
compiler: add util functions for UniqFM and UniqMap

This patch adds addToUFM_L (backed by insertLookupWithKey),
addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util
functions are used by the wasm32 NCG.

- - - - -
177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00
driver: avoid -Wl,--no-as-needed for wasm32

The driver used to pass -Wl,--no-as-needed for LLD linking. This is
actually only supported for ELF targets, and must be avoided when
linking for wasm32.

- - - - -
06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00
compiler: allow big arith for wasm32

This patch enables Cmm big arithmetic on wasm32, since 64-bit
arithmetic can be efficiently lowered to wasm32 opcodes.

- - - - -
df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00
driver: pass -Wa,--no-type-check for wasm32 when runAsPhase

This patch passes -Wa,--no-type-check for wasm32 when compiling
assembly. See the added note for more detailed explanation.

- - - - -
c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00
compiler: enforce cmm switch planning for wasm32

This patch forcibly enable Cmm switch planning for wasm32, since
otherwise the switch tables we generate may exceed the br_table
maximum allowed size.

- - - - -
a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00
compiler: annotate CmmFileEmbed with blob length

This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG
needs to know the precise size of each data segment.

- - - - -
36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00
compiler: wasm32 NCG

This patch adds the wasm32 NCG.

- - - - -
435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00
ci: add wasm32-wasi release bindist job

- - - - -
d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00
ci: add a stronger test for cross bindists

This commit adds a simple GHC API program that parses and reprints the
original hello world program used for basic testing of cross bindists.
Before there's full cross-compilation support in the test suite
driver, this provides better coverage than the original test.

- - - - -
8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00
CODEOWNERS: add wasm-specific maintainers

- - - - -
707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00
Clarify that LLVM upper bound is non-inclusive during configure (#22411)

- - - - -
430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00
rts: Check for program_invocation_short_name via autoconf

Instead of assuming support on all Linuxes.

- - - - -
6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00
driver: Fix -fdefer-diagnostics flag

The `withDeferredDiagnostics` wrapper wasn't doing anything because the
session it was modifying wasn't used in hsc_env. Therefore the fix is
simple, just push the `getSession` call into the scope of
`withDeferredDiagnostics`.

Fixes #22391

- - - - -
d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00
Add a fast path for data constructor workers

See Note [Fast path for data constructors] in
GHC.Core.Opt.Simplify.Iteration

This bypasses lots of expensive logic, in the special case of
applications of data constructors.  It is a surprisingly worthwhile
improvement, as you can see in the figures below.

Metrics: compile_time/bytes allocated
------------------------------------------------
          CoOpt_Read(normal)   -2.0%
    CoOpt_Singletons(normal)   -2.0%
    ManyConstructors(normal)   -1.3%
              T10421(normal)   -1.9% GOOD
             T10421a(normal)   -1.5%
              T10858(normal)   -1.6%
              T11545(normal)   -1.7%
              T12234(optasm)   -1.3%
              T12425(optasm)   -1.9% GOOD
              T13035(normal)   -1.0% GOOD
              T13056(optasm)   -1.8%
              T13253(normal)   -3.3% GOOD
              T15164(normal)   -1.7%
              T15304(normal)   -3.4%
              T15630(normal)   -2.8%
              T16577(normal)   -4.3% GOOD
              T17096(normal)   -1.1%
              T17516(normal)   -3.1%
              T18282(normal)   -1.9%
              T18304(normal)   -1.2%
             T18698a(normal)   -1.2% GOOD
             T18698b(normal)   -1.5% GOOD
              T18923(normal)   -1.3%
               T1969(normal)   -1.3% GOOD
              T19695(normal)   -4.4% GOOD
             T21839c(normal)   -2.7% GOOD
             T21839r(normal)   -2.7% GOOD
               T4801(normal)   -3.8% GOOD
               T5642(normal)   -3.1% GOOD
               T6048(optasm)   -2.5% GOOD
               T9020(optasm)   -2.7% GOOD
               T9630(normal)   -2.1% GOOD
               T9961(normal)  -11.7% GOOD
               WWRec(normal)   -1.0%

                   geo. mean   -1.1%
                   minimum    -11.7%
                   maximum     +0.1%

Metric Decrease:
    T10421
    T12425
    T13035
    T13253
    T16577
    T18698a
    T18698b
    T1969
    T19695
    T21839c
    T21839r
    T4801
    T5642
    T6048
    T9020
    T9630
    T9961

- - - - -
3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00
Use a more efficient printer for code generation (#21853)

The changes in `GHC.Utils.Outputable` are the bulk of the patch
and drive the rest.
The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc`
and support printing directly to a handle with `bPutHDoc`.
See Note [SDoc versus HDoc] and Note [HLine versus HDoc].

The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic
over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF
and dependencies (printing module names, labels etc.).

Co-authored-by: Alexis King <lexi.lambda at gmail.com>

Metric Decrease:
    CoOpt_Read
    ManyAlternatives
    ManyConstructors
    T10421
    T12425
    T12707
    T13035
    T13056
    T13253
    T13379
    T18140
    T18282
    T18698a
    T18698b
    T1969
    T20049
    T21839c
    T21839r
    T3064
    T3294
    T4801
    T5321FD
    T5321Fun
    T5631
    T6048
    T783
    T9198
    T9233

- - - - -
6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00
Weaken wrinkle 1 of Note [Scrutinee Constant Folding]

Fixes #22375.

Co-authored-by:  Simon Peyton Jones <simon.peytonjones at gmail.com>

- - - - -
154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00
Fix fragile RULE setup in GHC.Float

In testing my type-vs-constraint patch I found that the handling
of Natural literals was very fragile -- and I somehow tripped that
fragility in my work.

So this patch fixes the fragility.
See Note [realToFrac natural-to-float]

This made a big (9%) difference in one existing test in
perf/should_run/T1-359

Metric Decrease:
    T10359

- - - - -
778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00
Type vs Constraint: finally nailed

This big patch addresses the rats-nest of issues that have plagued
us for years, about the relationship between Type and Constraint.
See #11715/#21623.

The main payload of the patch is:
* To introduce CONSTRAINT :: RuntimeRep -> Type
* To make TYPE and CONSTRAINT distinct throughout the compiler

Two overview Notes in GHC.Builtin.Types.Prim

* Note [TYPE and CONSTRAINT]

* Note [Type and Constraint are not apart]
  This is the main complication.

The specifics

* New primitive types (GHC.Builtin.Types.Prim)
  - CONSTRAINT
  - ctArrowTyCon (=>)
  - tcArrowTyCon (-=>)
  - ccArrowTyCon (==>)
  - funTyCon     FUN     -- Not new
  See Note [Function type constructors and FunTy]
  and Note [TYPE and CONSTRAINT]

* GHC.Builtin.Types:
  - New type Constraint = CONSTRAINT LiftedRep
  - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in

* Exploit the fact that Type and Constraint are distinct throughout GHC
  - Get rid of tcView in favour of coreView.
  - Many tcXX functions become XX functions.
    e.g. tcGetCastedTyVar --> getCastedTyVar

* Kill off Note [ForAllTy and typechecker equality], in (old)
  GHC.Tc.Solver.Canonical.  It said that typechecker-equality should ignore
  the specified/inferred distinction when comparein two ForAllTys.  But
  that wsa only weakly supported and (worse) implies that we need a separate
  typechecker equality, different from core equality. No no no.

* GHC.Core.TyCon: kill off FunTyCon in data TyCon.  There was no need for it,
  and anyway now we have four of them!

* GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo
  See Note [FunCo] in that module.

* GHC.Core.Type.  Lots and lots of changes driven by adding CONSTRAINT.
  The key new function is sORTKind_maybe; most other changes are built
  on top of that.

  See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`.

* Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in
  kinding ForAllTys.  See new tules (FORALL1) and (FORALL2) in GHC.Core.Type.
  (The bug was that before (forall (cv::t1 ~# t2). blah), where
  blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be
  (TYPE LiftedRep).  See Note [Kinding rules for types] in GHC.Core.Type.

* GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType.
  Of course, no tcEqType any more.

* GHC.Core.TyCo.FVs. I moved some free-var-like function into this module:
  tyConsOfType, visVarsOfType, and occCheckExpand.  Refactoring only.

* GHC.Builtin.Types.  Compiletely re-engineer boxingDataCon_maybe to
  have one for each /RuntimeRep/, rather than one for each /Type/.
  This dramatically widens the range of types we can auto-box.
  See Note [Boxing constructors] in GHC.Builtin.Types
  The boxing types themselves are declared in library ghc-prim:GHC.Types.

  GHC.Core.Make.  Re-engineer the treatment of "big" tuples (mkBigCoreVarTup
  etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially)
  types of kind Constraint. That allows the desugaring for arrows to work;
  it gathers up free variables (including dictionaries) into tuples.
  See  Note [Big tuples] in GHC.Core.Make.

  There is still work to do here: #22336. But things are better than
  before.

* GHC.Core.Make.  We need two absent-error Ids, aBSENT_ERROR_ID for types of
  kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint.
  Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make;
  see Note [inlineId magic].

* GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion.  It is now called
  SelCo, and its fields are much more descriptive than the single Int we used to
  have.  A great improvement.  See Note [SelCo] in GHC.Core.TyCo.Rep.

* GHC.Core.RoughMap.roughMatchTyConName.  Collapse TYPE and CONSTRAINT to
  a single TyCon, so that the rough-map does not distinguish them.

* GHC.Core.DataCon
  - Mainly just improve documentation

* Some significant renamings:
  GHC.Core.Multiplicity: Many -->  ManyTy (easier to grep for)
                         One  -->  OneTy
  GHC.Core.TyCo.Rep TyCoBinder      -->   GHC.Core.Var.PiTyBinder
  GHC.Core.Var      TyCoVarBinder   -->   ForAllTyBinder
                    AnonArgFlag     -->   FunTyFlag
                    ArgFlag         -->   ForAllTyFlag
  GHC.Core.TyCon    TyConTyCoBinder --> TyConPiTyBinder
  Many functions are renamed in consequence
  e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc

* I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type
    data FunTyFlag
      = FTF_T_T           -- (->)  Type -> Type
      | FTF_T_C           -- (-=>) Type -> Constraint
      | FTF_C_T           -- (=>)  Constraint -> Type
      | FTF_C_C           -- (==>) Constraint -> Constraint

* GHC.Tc.Errors.Ppr.  Some significant refactoring in the TypeEqMisMatch case
  of pprMismatchMsg.

* I made the tyConUnique field of TyCon strict, because I
  saw code with lots of silly eval's.  That revealed that
  GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because
  we pack the sum tag into a 6-bit field.  (Lurking bug squashed.)

Fixes
* #21530

Updates haddock submodule slightly.

Performance changes
~~~~~~~~~~~~~~~~~~~
I was worried that compile times would get worse, but after
some careful profiling we are down to a geometric mean 0.1%
increase in allocation (in perf/compiler).  That seems fine.

There is a big runtime improvement in T10359

Metric Decrease:
    LargeRecord
    MultiLayerModulesTH_OneShot
    T13386
    T13719
Metric Increase:
    T8095

- - - - -
360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00
Indent closing "#-}" to silence HLint

- - - - -
e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00
Fix merge conflict in T18355.stderr

Fixes #22446

- - - - -
294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00
Fix a trivial typo in dataConNonlinearType

Fixes #22416

- - - - -
268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00
eventlog: Ensure that IPE output contains actual info table pointers

The refactoring in 866c736e introduced a rather subtle change in the
semantics of the IPE eventlog output, changing the eventlog field from
encoding info table pointers to "TNTC pointers" (which point to entry
code when tables-next-to-code is enabled). Fix this.

Fixes #22452.

- - - - -
d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00
testsuite: Add tests for T22347

These are fixed in recent versions but might as well add regression
tests.

See #22347

- - - - -
8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00
testsuite: Improve output from tests which have failing pre_cmd

There are two changes:

* If a pre_cmd fails, then don't attempt to run the test.
* If a pre_cmd fails, then print the stdout and stderr from running that
  command (which hopefully has a nice error message).

For example:

```
=====> 1 of 1 [0, 0, 0]
*** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2
** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}".
stdout:
stderr:
DefaultLifted.hs:19:13: error: [GHC-76037]
    Not in scope: type constructor or class ‘Typ’
    Suggested fix:
      Perhaps use one of these:
        ‘Type’ (imported from GHC.Tc.Utils.TcType),
        data constructor ‘Type’ (imported from GHC.Plugins)
   |
19 | instance Eq Typ where
   |             ^^^
make: *** [Makefile:17: package.test-defaulting-plugin] Error 1

Performance Metrics (test environment: local):
```

Fixes #22329

- - - - -
2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00
Implement UNPACK support for sum types.

This is based on osa's unpack_sums PR from ages past.

The meat of the patch is implemented in dataConArgUnpackSum
and described in Note [UNPACK for sum types].

- - - - -
78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00
Expand on the need to clone local binders.

Fixes #22402.

- - - - -
65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00
Fix :i Constraint printing "type Constraint = Constraint"

Since Constraint became a synonym for CONSTRAINT 'LiftedRep,
we need the same code for handling printing as for the synonym
Type = TYPE 'LiftedRep.
This addresses the same bug as #18594, so I'm reusing the test.

- - - - -
94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00
configure: Don't check for an unsupported version of LLVM

The upper bound is not inclusive.

Fixes #22449

- - - - -
02d3511b by Andrew Lelechenko at 2022-11-15T21:36:41-05:00
Fix capitalization in haddock for TestEquality

- - - - -
08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00
base: make Foreign.Marshal.Pool use RTS internal arena for allocation

`Foreign.Marshal.Pool` used to call `malloc` once for each allocation
request. Each `Pool` maintained a list of allocated pointers, and
traverses the list to `free` each one of those pointers. The extra O(n)
overhead is apparently bad for a `Pool` that serves a lot of small
allocation requests.

This patch uses the RTS internal arena to implement `Pool`, with these
benefits:

- Gets rid of the extra O(n) overhead.
- The RTS arena is simply a bump allocator backed by the block
  allocator, each allocation request is likely faster than a libc
  `malloc` call.

Closes #14762 #18338.

- - - - -
37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00
Misc cleanup

* Replace catMaybes . map f with mapMaybe f
* Use concatFS to concatenate multiple FastStrings
* Fix documentation of -exclude-module
* Cleanup getIgnoreCount in GHCi.UI

- - - - -
b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00
Give better errors for code corrupted by Unicode smart quotes (#21843)

Previously, we emitted a generic and potentially confusing error during lexical
analysis on programs containing smart quotes (“/”/‘/’). This commit adds
smart quote-aware lexer errors.

- - - - -
cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00
Make OpaqueNo* tests less noisy to unrelated changes

- - - - -
b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00
Simplifier: Consider `seq` as a `BoringCtxt` (#22317)

See `Note [Seq is boring]` for the rationale.

Fixes #22317.

- - - - -
9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00
Make T21839c's ghc/max threshold more forgiving

- - - - -
4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00
Be more careful when reporting unbound RULE binders

See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds.

Fixes #22471.

- - - - -
e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00
PPC NCG: Fix generating assembler code

Fixes #22479

- - - - -
f2f9ef07 by Andrew Lelechenko at 2022-11-20T18:39:30-05:00
Extend documentation for Data.IORef

- - - - -
ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00
Buglet in GHC.Tc.Module.checkBootTyCon

This lurking bug used the wrong function to compare two
types in GHC.Tc.Module.checkBootTyCon

It's hard to trigger the bug, which only came up during
!9343, so there's no regression test in this MR.

- - - - -
451aeac3 by Andrew Lelechenko at 2022-11-20T18:40:44-05:00
Add since pragmas for c_interruptible_open and hostIsThreaded

- - - - -
8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00
Introduce CapIOManager as the per-cap I/O mangager state

Rather than each I/O manager adding things into the Capability structure
ad-hoc, we should have a common CapIOManager iomgr member of the
Capability structure, with a common interface to initialise etc.

The content of the CapIOManager struct will be defined differently for
each I/O manager implementation. Eventually we should be able to have
the CapIOManager be opaque to the rest of the RTS, and known just to the
I/O manager implementation. We plan for that by making the Capability
contain a pointer to the CapIOManager rather than containing the
structure directly.

Initially just move the Unix threaded I/O manager's control FD.

- - - - -
8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00
Add hook markCapabilityIOManager

To allow I/O managers to have GC roots in the Capability, within the
CapIOManager structure.

Not yet used in this patch.

- - - - -
5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00
Move APPEND_TO_BLOCKED_QUEUE from cmm to C

The I/O and delay blocking primitives for the non-threaded way
currently access the blocked_queue and sleeping_queue directly.

We want to move where those queues are to make their ownership clearer:
to have them clearly belong to the I/O manager impls rather than to the
scheduler. Ultimately we will want to change their representation too.

It's inconvenient to do that if these queues are accessed directly from
cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a
C version appendToIOBlockedQueue(), and replace the open-coded
sleeping_queue insertion with insertIntoSleepingQueue().

- - - - -
ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00
Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager

The blocked_queue_{hd,tl} and the sleeping_queue are currently
cooperatively managed between the scheduler and (some but not all of)
the non-threaded I/O manager implementations.

They lived as global vars with the scheduler, but are poked by I/O
primops and the I/O manager backends.

This patch is a step on the path towards making the management of I/O or
timer blocking belong to the I/O managers and not the scheduler.

Specifically, this patch moves the {blocked,sleeping}_queue from being
global vars in the scheduler to being members of the CapIOManager struct
within each Capability. They are not yet exclusively used by the I/O
managers: they are still poked from a couple other places, notably in
the scheduler before calling awaitEvent.

- - - - -
0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00
Remove the now-unused markScheduler

The global vars {blocked,sleeping}_queue are now in the Capability and
so get marked there via markCapabilityIOManager.

- - - - -
39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00
Move macros for checking for pending IO or timers

from Schedule.h to Schedule.c and IOManager.h

This is just moving, the next step will be to rejig them slightly.

For the non-threaded RTS the scheduler needs to be able to test for
there being pending I/O operation or pending timers. The implementation
of these tests should really be considered to be part of the I/O
managers and not part of the scheduler.

- - - - -
664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00
Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function

These are the macros originaly from Scheduler.h, previously moved to
IOManager.h, and now replaced with a single inline function
anyPendingTimeoutsOrIO(). We can use a single function since the two
macros were always checked together.

Note that since anyPendingTimeoutsOrIO is defined for all IO manager
cases, including threaded, we do not need to guard its use by cpp
 #if !defined(THREADED_RTS)

- - - - -
32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00
Expand emptyThreadQueues inline for clarity

It was not really adding anything. The name no longer meant anything
since those I/O and timeout queues do not belong to the scheuler.

In one of the two places it was used, the comments already had to
explain what it did, whereas now the code matches the comment nicely.

- - - - -
9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00
Move the awaitEvent declaration into IOManager.h

And add or adjust comments at the use sites of awaitEvent.

- - - - -
054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00
Pass the Capability *cap explicitly to awaitEvent

It is currently only used in the non-threaded RTS so it works to use
MainCapability, but it's a bit nicer to pass the cap anyway. It's
certainly shorter.

- - - - -
667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00
Pass the Capability *cap explicitly to appendToIOBlockedQueue

And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler
though not strictly necessary given that these primops are currently
only used in the non-threaded RTS.

- - - - -
7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00
Reveiew feedback: improve one of the TODO comments

The one about the nonsense (const False) test on WinIO for there being any IO
or timers pending, leading to unnecessary complication later in the
scheduler.

- - - - -
e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00
Optimize getLevity.

Avoid the intermediate data structures allocated by splitTyConApp.
This avoids ~0.5% of allocations for a build using -O2.

Fixes #22254

- - - - -
de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00
hadrian:Set TNTC when running testsuite.

- - - - -
9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00
Add unsafePtrEquality# restricted to UnliftedTypes

- - - - -
e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00
utils/unlit: adjust parser to match Report spec

The Haskell 2010 Report says that, for Latex-style Literate format,
"Program code begins on the first line following a line that begins
\begin{code}". (This is unchanged from the 98 Report)

However the unlit.c implementation only matches a line that contains
"\begin{code}" and nothing else. One consequence of this is that one
cannot suffix Latex options to the code environment. I.e., this does
not work:

\begin{code}[label=foo,caption=Foo Code]

Adjust the matcher to conform to the specification from the Report.

The Haskell Wiki currently recommends suffixing a '%' to \begin{code}
in order to deliberately hide a code block from Haskell. This is bad
advice, as it's relying on an implementation quirk rather than specified
behaviour. None-the-less, some people have tried to use it, c.f.
<https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html>

An alternative solution is to define a separate, equivalent Latex
environment to "code", that is functionally identical in Latex but
ignored by unlit. This should not be a burden: users are required to
manually define the code environment anyway, as it is not provided
by the Latex verbatim or lstlistings packages usually used for
presenting code in documents.

Fixes #3549.

- - - - -
0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00
Fix eventlog all option

Previously it didn't enable/disable nonmoving_gc and ticky event types

Fixes #21813

- - - - -
04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00
Expand Note [Linear types] with the stance on linting linearity

Per the discussion on #22123

- - - - -
e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00
Add documentation on custom Prelude modules (#22228)

Specifically, custom Prelude modules that are named `Prelude`.

- - - - -
b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00
Don't let configure perform trivial substitutions (#21846)

Hadrian now performs substitutions, especially to generate .cabal files
from .cabal.in files. Two benefits:

1. We won't have to re-configure when we modify thing.cabal.in. Hadrian
   will take care of this for us.

2. It paves the way to allow the same package to be configured
   differently by Hadrian in the same session. This will be useful to
   fix #19174: we want to build a stage2 cross-compiler for the host
   platform and a stage1 compiler for the cross target platform in the
   same Hadrian session.

- - - - -
99aca26b by nineonine at 2022-11-23T12:47:11-05:00
CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043)

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

- - - - -
040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00
Scrub some no-warning pragmas.

- - - - -
178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00
Check if the SDoc starts with a single quote (#22488)

This patch fixes pretty-printing of character literals
inside promoted lists and tuples.

When we pretty-print a promoted list or tuple whose first element
starts with a single quote, we want to add a space between the opening
bracket and the element:

	'[True]    -- ok
	'[ 'True]  -- ok
	'['True]   -- not ok

If we don't add the space, we accidentally produce a character
literal '['.

Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST
and tried to guess if it would be rendered with a single quote. However,
it missed the case when the inner type was itself a character literal:

	'[ 'x']  -- ok
	'['x']   -- not ok

Instead of adding this particular case, I opted for a more future-proof
solution: check the SDoc directly. This way we can detect if the single
quote is actually there instead of trying to predict it from the AST.
The new function is called spaceIfSingleQuote.

- - - - -
11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00
notes: Fix references to HPT space leak note

Updating this note was missed when updating the HPT to the HUG.

Fixes #22477

- - - - -
86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00
Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115)

Problem: avoid usage of TcRnMessageUnknown

Solution:
The following `TcRnMessage` messages has been introduced:
  TcRnNoRebindableSyntaxRecordDot
  TcRnNoFieldPunsRecordDot
  TcRnIllegalStaticExpression
  TcRnIllegalStaticFormInSplice
  TcRnListComprehensionDuplicateBinding
  TcRnEmptyStmtsGroup
  TcRnLastStmtNotExpr
  TcRnUnexpectedStatementInContext
  TcRnIllegalTupleSection
  TcRnIllegalImplicitParameterBindings
  TcRnSectionWithoutParentheses

Co-authored-by: sheaf <sam.derbyshire at gmail.com>

- - - - -
d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00
rts: fix missing Arena.h symbols in RtsSymbols.c

It was an unfortunate oversight in !8961 and broke devel2 builds.

- - - - -
5943e739 by Andrew Lelechenko at 2022-11-25T04:38:28-05:00
Assorted fixes to avoid Data.List.{head,tail}

- - - - -
1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00
Review suggestions for assorted fixes to avoid Data.List.{head,tail}

- - - - -
13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00
Print unticked promoted data constructors (#20531)

Before this patch, GHC unconditionally printed ticks before promoted
data constructors:

	ghci> type T = True  -- unticked (user-written)
	ghci> :kind! T
	T :: Bool
	= 'True              -- ticked (compiler output)

After this patch, GHC prints ticks only when necessary:

	ghci> type F = False    -- unticked (user-written)
	ghci> :kind! F
	F :: Bool
	= False                 -- unticked (compiler output)

	ghci> data False        -- introduce ambiguity
	ghci> :kind! F
	F :: Bool
	= 'False                -- ticked by necessity (compiler output)

The old behavior can be enabled by -fprint-redundant-promotion-ticks.

Summary of changes:
* Rename PrintUnqualified to NamePprCtx
* Add QueryPromotionTick to it
* Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick)
* Introduce -fprint-redundant-promotion-ticks

Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht>

- - - - -
d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00
Fix decomposition of TyConApps

Ticket #22331 showed that we were being too eager to decompose
a Wanted TyConApp, leading to incompleteness in the solver.

To understand all this I ended up doing a substantial rewrite
of the old Note [Decomposing equalities], now reborn as
Note [Decomposing TyConApp equalities]. Plus rewrites of other
related Notes.

The actual fix is very minor and actually simplifies the code: in
`can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call
`noMatchableIrreds`.  A closely related refactor: we stop trying to
use the same "no matchable givens" function here as in
`matchClassInst`.  Instead split into two much simpler functions.

- - - - -
2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00
Redirect output of musttail attribute test

Compilation output from test for support of musttail attribute leaked to
the console.

- - - - -
0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00
Move hs_mulIntMayOflo cbits to ghc-prim

It's only used by wasm NCG at the moment, but ghc-prim is a more
reasonable place for hosting out-of-line primops. Also, we only need a
single version of hs_mulIntMayOflo.

- - - - -
36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00
compiler: generate ccalls for clz/ctz/popcnt in wasm NCG

We used to generate a single wasm clz/ctz/popcnt opcode, but it's
wrong when it comes to subwords, so might as well generate ccalls for
them. See #22470 for details.

- - - - -
d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00
compiler: remove unused MO_U_MulMayOflo

We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere.

- - - - -
8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00
Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order

Fixes: #217093
Associated to #19415

This change
* Flips the orientation of the the generated kind equality coercion in canEqLHSHetero;
* Removes `cc_fundeps` in CDictCan as the check was incomplete;
* Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities
* Adds 2 new tests for validating the change
   - testsuites/typecheck/should_compile/T21703.hs and
   - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs)
* Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors
* Changes in Notes:
  - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances]
  - Added Note [Kind Equality Orientation] to visualize the kind flipping
  - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties]

- - - - -
646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00
Change printing of sized literals to match the proposal

Literals in Core were printed as e.g. 0xFF#16 :: Int16#.
The proposal 451 now specifies syntax 0xFF#Int16.
This change affects the Core printer only - more to be done later.

Part of #21422.

- - - - -
02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00
Be a bit more selective about floating bottoming expressions

This MR arranges to float a bottoming expression to the top
only if it escapes a value lambda.

See #22494 and Note [Floating to the top] in SetLevels.

This has a generally beneficial effect in nofib

+-------------------------------++----------+
|                               ||tsv (rel) |
+===============================++==========+
|           imaginary/paraffins ||   -0.93% |
|                imaginary/rfib ||   -0.05% |
|                      real/fem ||   -0.03% |
|                    real/fluid ||   -0.01% |
|                   real/fulsom ||   +0.05% |
|                   real/gamteb ||   -0.27% |
|                       real/gg ||   -0.10% |
|                   real/hidden ||   -0.01% |
|                      real/hpg ||   -0.03% |
|                      real/scs ||  -11.13% |
|         shootout/k-nucleotide ||   -0.01% |
|               shootout/n-body ||   -0.08% |
|   shootout/reverse-complement ||   -0.00% |
|        shootout/spectral-norm ||   -0.02% |
|             spectral/fibheaps ||   -0.20% |
|           spectral/hartel/fft ||   -1.04% |
|         spectral/hartel/solid ||   +0.33% |
|     spectral/hartel/wave4main ||   -0.35% |
|                 spectral/mate ||   +0.76% |
+===============================++==========+
|                     geom mean ||   -0.12% |

The effect on compile time is generally slightly beneficial

Metrics: compile_time/bytes allocated
----------------------------------------------
MultiLayerModulesTH_OneShot(normal)  +0.3%
                  PmSeriesG(normal)  -0.2%
                  PmSeriesT(normal)  -0.1%
                     T10421(normal)  -0.1%
                    T10421a(normal)  -0.1%
                     T10858(normal)  -0.1%
                     T11276(normal)  -0.1%
                    T11303b(normal)  -0.2%
                     T11545(normal)  -0.1%
                     T11822(normal)  -0.1%
                     T12150(optasm)  -0.1%
                     T12234(optasm)  -0.3%
                     T13035(normal)  -0.2%
                     T16190(normal)  -0.1%
                     T16875(normal)  -0.4%
                    T17836b(normal)  -0.2%
                     T17977(normal)  -0.2%
                    T17977b(normal)  -0.2%
                     T18140(normal)  -0.1%
                     T18282(normal)  -0.1%
                     T18304(normal)  -0.2%
                    T18698a(normal)  -0.1%
                     T18923(normal)  -0.1%
                     T20049(normal)  -0.1%
                    T21839r(normal)  -0.1%
                      T5837(normal)  -0.4%
                      T6048(optasm)  +3.2% BAD
                      T9198(normal)  -0.2%
                      T9630(normal)  -0.1%
       TcPlugin_RewritePerf(normal)  -0.4%
             hard_hole_fits(normal)  -0.1%

                          geo. mean  -0.0%
                          minimum    -0.4%
                          maximum    +3.2%

The T6048 outlier is hard to pin down, but it may be the effect of
reading in more interface files definitions. It's a small program for
which compile time is very short, so I'm not bothered about it.

Metric Increase:
    T6048

- - - - -
ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00
testsuite: Mark unpack_sums_6 as fragile due to #22504

This test is explicitly dependent upon runtime, which is generally not
appropriate given that the testsuite is run in parallel and generally
saturates the CPU.

- - - - -
def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00
testsuite: Don't use grep -q in unpack_sums_7

`grep -q` closes stdin as soon as it finds the pattern it is looking
for, resulting in #22484.

- - - - -
cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00
Add Javascript backend

Add JS backend adapted from the GHCJS project by Luite Stegeman.

Some features haven't been ported or implemented yet. Tests for these
features have been disabled with an associated gitlab ticket.

Bump array submodule

Work funded by IOG.

Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io>
Co-authored-by: Luite Stegeman <stegeman at gmail.com>
Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com>

- - - - -
68c966cd by sheaf at 2022-11-30T09:31:25-05:00
Fix @since annotations on WithDict and Coercible

Fixes #22453

- - - - -
a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00
Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther

We were failing to account for the cc_pend_sc flag in this
important function, with the result that we expanded superclasses
forever.

Fixes #22516.

- - - - -
a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00
Use mkNakedFunTy in tcPatSynSig

As #22521 showed, in tcPatSynSig we make a "fake type" to
kind-generalise; and that type has unzonked type variables in it. So
we must not use `mkFunTy` (which checks FunTy's invariants) via
`mkPhiTy` when building this type.  Instead we need to use
`mkNakedFunTy`.

Easy fix.

- - - - -
31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00
Properly cast values when writing/reading unboxed sums.

Unboxed sums might store a Int8# value as Int64#. This patch
makes sure we keep track of the actual value type.

See Note [Casting slot arguments] for the details.

- - - - -
10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00
Move Void to GHC.Base...

This change would allow `Void` to be used deeper in module graph.
For example exported from `Prelude` (though that might be already
possible).

Also this change includes a change `stimes @Void _ x = x`,
https://github.com/haskell/core-libraries-committee/issues/95

While the above is not required, maintaining old stimes behavior
would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`,
which would require more hs-boot files.

- - - - -
b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00
DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475)

See the updated `Note [Data-con worker strictness]`
and the new `Note [Demand transformer for data constructors]`.

Fixes #22475.

- - - - -
d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00
Make Functor a quantified superclass of Bifunctor.

See https://github.com/haskell/core-libraries-committee/issues/91 for
discussion.

This change relates Bifunctor with Functor by requiring second = fmap.
Moreover this change is a step towards unblocking the major version bump
of bifunctors and profunctors to major version 6. This paves the way to
move the Profunctor class into base. For that Functor first similarly
becomes a superclass of Profunctor in the new major version 6.

- - - - -
72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00
FastString: SAT bucket_match

Metric Decrease:
    MultiLayerModulesTH_OneShot

- - - - -
afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00
Add a missing varToCoreExpr in etaBodyForJoinPoint

This subtle bug showed up when compiling a library with 9.4.
See #22491.  The bug is present in master, but it is hard to
trigger; the new regression test T22491 fails in 9.4.

The fix was easy: just add a missing varToCoreExpr in
etaBodyForJoinPoint.

The fix is definitely right though!

I also did some other minor refatoring:
* Moved the preInlineUnconditionally test in simplExprF1 to
  before the call to joinPointBinding_maybe, to avoid fruitless
  eta-expansion.
* Added a boolean from_lam flag to simplNonRecE, to avoid two
  fruitless tests, and commented it a bit better.

These refactorings seem to save 0.1% on compile-time allocation in
perf/compiler; with a max saving of 1.4% in T9961

Metric Decrease:
    T9961

- - - - -
81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00
CI: Forbid the fully static build on Alpine to fail.

To do so, we mark some tests broken in this configuration.

- - - - -
c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00
CI: Remove ARMv7 jobs

These jobs fail (and are allowed to fail) nearly every time.

Soon they won't even be able to run at all, as we won't currently have
runners that can run them.

Fixing the latter problem is tracked in #22409.

I went ahead and removed all settings and configurations.

- - - - -
d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00
CI: Fix CI lint

Failure was introduced by conflicting changes to gen_ci.hs that did
*not* trigger git conflicts.

- - - - -
ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00
Refactor TyCon to have a top-level product

This patch changes the representation of TyCon so that it has
a top-level product type, with a field that gives the details
(newtype, type family etc), #22458.

Not much change in allocation, but execution seems to be a bit
faster.

Includes a change to the haddock submodule to adjust for API changes.

- - - - -
74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00
ApplicativeDo: Set pattern location before running exhaustiveness checker

This improves the error messages of the exhaustiveness checker when
checking statements which have been moved around with ApplicativeDo.

Before:

Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns]
    Pattern match(es) are non-exhaustive
    In a pattern binding:
        Patterns of type ‘Maybe ()’ not matched: Nothing
  |
2 |   let x = ()
  |   ^^^^^^^^^^

After:

Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns]
    Pattern match(es) are non-exhaustive
    In a pattern binding:
        Patterns of type ‘Maybe ()’ not matched: Nothing
  |
4 |   ~(Just res1) <- seq x (pure $ Nothing @())
  |

Fixes #22483

- - - - -
85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00
Add special case for :Main module in `GHC.IfaceToCore.mk_top_id`

See Note [Root-main Id]

The `:Main` special binding is actually defined in the current module
(hence don't go looking for it externally) but the module name is rOOT_MAIN
rather than the current module so we need this special case.

There was already some similar logic in `GHC.Rename.Env` for
External Core, but now the "External Core" is in interface files it
needs to be moved here instead.

Fixes #22405

- - - - -
108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00
Fix linearity checking in Lint

Lint was not able to see that x*y <= x*y, because this inequality
was decomposed to x <= x*y && y <= x*y, but there was no rule
to see that x <= x*y.

Fixes #22546.

- - - - -
bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00
Mark T16916 fragile

See https://gitlab.haskell.org/ghc/ghc/-/issues/16966

- - - - -
5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00
Refactor: FreshOrReuse instead of addTyClTyVarBinds

This is a refactoring that should have no effect on observable behavior.

Prior to this change, GHC.HsToCore.Quote contained a few closely related
functions to process type variable bindings: addSimpleTyVarBinds,
addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds.

We can classify them by their input type and name generation strategy:

                              Fresh names only    Reuse bound names
                          +---------------------+-------------------+
                   [Name] | addSimpleTyVarBinds |                   |
[LHsTyVarBndr flag GhcRn] |     addHsTyVarBinds |                   |
        LHsQTyVars GhcRn  |      addQTyVarBinds | addTyClTyVarBinds |
                          +---------------------+-------------------+

Note how two functions are missing. Because of this omission, there were
two places where a LHsQTyVars value was constructed just to be able to pass it
to addTyClTyVarBinds:

1. mk_qtvs in addHsOuterFamEqnTyVarBinds    -- bad
2. mkHsQTvs in repFamilyDecl                -- bad

This prevented me from making other changes to LHsQTyVars, so the main
goal of this refactoring is to get rid of those workarounds.

The most direct solution would be to define the missing functions.
But that would lead to a certain amount of code duplication. To avoid
code duplication, I factored out the name generation strategy into a
function parameter:

	data FreshOrReuse
	  = FreshNamesOnly
	  | ReuseBoundNames

	addSimpleTyVarBinds :: FreshOrReuse -> ...
	addHsTyVarBinds     :: FreshOrReuse -> ...
	addQTyVarBinds      :: FreshOrReuse -> ...

- - - - -
c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00
addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders

Consider this example:

	[d| instance forall a. C [a] where
	      type forall b. G [a] b = Proxy b |]

When we process "forall b." in the associated type instance, it is
unambiguously the binding site for "b" and we want a fresh name for it.
Therefore, FreshNamesOnly is more fitting than ReuseBoundNames.
This should not have any observable effect but it avoids pointless
lookups in the MetaEnv.

- - - - -
42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00
Handle type data declarations in Template Haskell quotations and splices (fixes #22500)

This adds a TypeDataD constructor to the Template Haskell Dec type,
and ensures that the constructors it contains go in the TyCls namespace.

- - - - -
1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00
Add BufSpan to EpaLocation (#22319, #22558)

The key part of this patch is the change to mkTokenLocation:

	- mkTokenLocation (RealSrcSpan r _)  = TokenLoc (EpaSpan r)
	+ mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb)

mkTokenLocation used to discard the BufSpan, but now it is saved and can
be retrieved from LHsToken or LHsUniToken.

This is made possible by the following change to EpaLocation:

	- data EpaLocation = EpaSpan !RealSrcSpan
	+ data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan)
	                   | ...

The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock.

- - - - -
cd31acad by sheaf at 2022-12-06T15:45:58-05:00
Hadrian: fix ghcDebugAssertions off-by-one error

Commit 6b2f7ffe changed the logic that decided whether to enable debug
assertions. However, it had an off-by-one error, as the stage parameter
to the function inconsistently referred to the stage of the compiler
being used to build or the stage of the compiler we are building.

This patch makes it consistent. Now the parameter always refers to the
the compiler which is being built.

In particular, this patch re-enables
assertions in the stage 2 compiler when building with devel2 flavour,
and disables assertions in the stage 2 compiler when building with
validate flavour.

Some extra performance tests are now run in the "validate" jobs because
the stage2 compiler no longer contains assertions.

-------------------------
Metric Decrease:
    CoOpt_Singletons
    MultiComponentModules
    MultiComponentModulesRecomp
    MultiLayerModulesTH_OneShot
    T11374
    T12227
    T12234
    T13253-spj
    T13701
    T14683
    T14697
    T15703
    T17096
    T17516
    T18304
    T18478
    T18923
    T5030
    T9872b
    TcPlugin_RewritePerf
Metric Increase:
    MultiComponentModules
    MultiComponentModulesRecomp
    MultiLayerModules
    MultiLayerModulesRecomp
    MultiLayerModulesTH_Make
    T13386
    T13719
    T3294
    T9233
    T9675
    parsing001
-------------------------

- - - - -
21d66db1 by mrkun at 2022-12-06T15:46:38-05:00
Push DynFlags out of runInstallNameTool

- - - - -
aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00
Push DynFlags out of askOtool

- - - - -
4e28f49e by mrkun at 2022-12-06T15:46:38-05:00
Push DynFlags out of runInjectRPaths

- - - - -
a7422580 by mrkun at 2022-12-06T15:46:38-05:00
Push DynFlags out of Linker.MacOS

- - - - -
e902d771 by Matthew Craven at 2022-12-08T08:30:23-05:00
Fix bounds-checking buglet in Data.Array.Byte

...another manifestation of #20851 which
I unfortunately missed in my first pass.

- - - - -
8d36c0c6 by Gergő Érdi at 2022-12-08T08:31:03-05:00
Remove copy-pasted definitions of `graphFromEdgedVertices*`

- - - - -
c5d8ed3a by Gergő Érdi at 2022-12-08T08:31:03-05:00
Add version of `reachableGraph` that avoids loop for cyclic inputs
by building its result connected component by component

Fixes #22512

- - - - -
90cd5396 by Krzysztof Gogolewski at 2022-12-08T08:31:39-05:00
Mark Type.Reflection.Unsafe as Unsafe

This module can be used to construct ill-formed TypeReps, so it should
be Unsafe.

- - - - -
2057c77d by Ian-Woo Kim at 2022-12-08T08:32:19-05:00
Truncate eventlog event for large payload (#20221)

RTS eventlog events for postCapsetVecEvent are truncated if payload
is larger than EVENT_PAYLOAD_SIZE_MAX
Previously, postCapsetVecEvent records eventlog event with payload
of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without
any validation, resulting in corrupted data.
For example, this happens when a Haskell binary is invoked with very
long command line arguments exceeding 2^16 bytes (see #20221).
Now we check the size of accumulated payload messages incrementally,
and truncate the message just before the payload size exceeds
EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing
how many arguments are truncated.

- - - - -
9ec76f61 by Cheng Shao at 2022-12-08T08:32:59-05:00
hadrian: don't add debug info to non-debug ways of rts

Hadrian used to pass -g when building all ways of rts. It makes output
binaries larger (especially so for wasm backend), and isn't needed by
most users out there, so this patch removes that flag. In case the
debug info is desired, we still pass -g3 when building the debug way,
and there's also the debug_info flavour transformer which ensures -g3
is passed for all rts ways.

- - - - -
7658cdd4 by Krzysztof Gogolewski at 2022-12-08T08:33:36-05:00
Restore show (typeRep @[]) == "[]"

The Show instance for TypeRep [] has changed in 9.5 to output "List"
because the name of the type constructor changed.
This seems to be accidental and is inconsistent with TypeReps of saturated
lists, which are printed as e.g. "[Int]".
For now, I'm restoring the old behavior; in the future,
maybe we should show TypeReps without puns (List, Tuple, Type).

- - - - -
216deefd by Matthew Pickering at 2022-12-08T22:45:27-05:00
Add test for #22162

- - - - -
5d0a311f by Matthew Pickering at 2022-12-08T22:45:27-05:00
ci: Add job to test interface file determinism guarantees

In this job we can run on every commit we add a test which builds the
Cabal library twice and checks that the ABI hash and interface hash is
stable across the two builds.

* We run the test 20 times to try to weed out any race conditions due to
  `-j`
* We run the builds in different temporary directories to try to weed
  out anything related to build directory affecting ABI or interface
  file hash.

Fixes #22180

- - - - -
0a76d7d4 by Matthew Pickering at 2022-12-08T22:45:27-05:00
ci: Add job for testing interface stability across builds

The idea is that both the bindists should product libraries with the
same ABI and interface hash.
So the job checks with ghc-pkg to make sure the computed ABI
is the same.

In future this job can be extended to check for the other facets of
interface determinism.

Fixes #22180

- - - - -
74c9bf91 by Matthew Pickering at 2022-12-08T22:45:27-05:00
backpack: Be more careful when adding together ImportAvails

There was some code in the signature merging logic which added together
the ImportAvails of the signature and the signature which was merged
into it. This had the side-effect of making the merged signature depend
on the signature (via a normal module dependency). The intention was to
propagate orphan instances through the merge but this also messed up
recompilation logic because we shouldn't be attempting to load B.hi when
mergeing it.

The fix is to just combine the part of ImportAvails that we intended to
(transitive info, orphan instances and type family instances) rather
than the whole thing.

- - - - -
d122e022 by Matthew Pickering at 2022-12-08T22:45:27-05:00
Fix mk_mod_usage_info if the interface file is not already loaded

In #22217 it was observed that the order modules are compiled in affects
the contents of an interface file. This was because a module dependended
on another module indirectly, via a re-export but the interface file for
this module was never loaded because the symbol was never used in the
file.

If we decide that we depend on a module then we jolly well ought to
record this fact in the interface file! Otherwise it could lead to very
subtle recompilation bugs if the dependency is not tracked and the
module is updated.

Therefore the best thing to do is just to make sure the file is loaded
by calling the `loadSysInterface` function.  This first checks the
caches (like we did before) but then actually goes to find the interface
on disk if it wasn't loaded.

Fixes #22217

- - - - -
ea25088d by lrzlin at 2022-12-08T22:46:06-05:00
Add initial support for LoongArch Architecture.

- - - - -
9eb9d2f4 by Andrew Lelechenko at 2022-12-08T22:46:47-05:00
Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD

- - - - -
08d8fe2a by Andrew Lelechenko at 2022-12-08T22:46:47-05:00
Allow mtl-2.3 in hadrian

- - - - -
3807a46c by Andrew Lelechenko at 2022-12-08T22:46:47-05:00
Support mtl-2.3 in check-exact

- - - - -
ef702a18 by Andrew Lelechenko at 2022-12-08T22:46:47-05:00
Fix tests

- - - - -
3144e8ff by Sebastian Graf at 2022-12-08T22:47:22-05:00
Make (^) INLINE (#22324)

So that we get to cancel away the allocation for the lazily used base.

We can move `powImpl` (which *is* strict in the base) to the top-level
so that we don't duplicate too much code and move the SPECIALISATION
pragmas onto `powImpl`.

The net effect of this change is that `(^)` plays along much better with
inlining thresholds and loopification (#22227), for example in `x2n1`.

Fixes #22324.

- - - - -
1d3a8b8e by Matthew Pickering at 2022-12-08T22:47:59-05:00
Typeable: Fix module locations of some definitions in GHC.Types

There was some confusion in Data.Typeable about which module certain
wired-in things were defined in. Just because something is wired-in
doesn't mean it comes from GHC.Prim, in particular things like LiftedRep
and RuntimeRep are defined in GHC.Types and that's the end of the story.

Things like Int#, Float# etc are defined in GHC.Prim as they have no
Haskell definition site at all so we need to generate type
representations for them (which live in GHC.Types).

Fixes #22510

- - - - -
0f7588b5 by Sebastian Graf at 2022-12-08T22:48:34-05:00
Make `drop` and `dropWhile` fuse (#18964)

I copied the fusion framework we have in place for `take`.
T18964 asserts that we regress neither when fusion fires nor when it doesn't.

Fixes #18964.

- - - - -
26e71562 by Sebastian Graf at 2022-12-08T22:49:10-05:00
Do not strictify a DFun's parameter dictionaries (#22549)

... thus fixing #22549.

The details are in the refurbished and no longer dead
`Note [Do not strictify a DFun's parameter dictionaries]`.

There's a regression test in T22549.

- - - - -
36093407 by John Ericson at 2022-12-08T22:49:45-05:00
Delete `rts/package.conf.in`

It is a relic of the Make build system. The RTS now uses a
`package.conf` file generated the usual way by Cabal.

- - - - -
b0cc2fcf by Krzysztof Gogolewski at 2022-12-08T22:50:21-05:00
Fixes around primitive literals

* The SourceText of primitive characters 'a'# did not include
  the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#.
  We can now remove the function pp_st_suffix, which was a hack
  to add the # back.
* Negative primitive literals shouldn't use parentheses, as described in
  Note [Printing of literals in Core]. Added a testcase to T14681.

- - - - -
aacf616d by Bryan Richter at 2022-12-08T22:50:56-05:00
testsuite: Mark conc024 fragile on Windows

- - - - -
ed239a24 by Ryan Scott at 2022-12-09T09:42:16-05:00
Document TH splices' interaction with INCOHERENT instances

Top-level declaration splices can having surprising interactions with
`INCOHERENT` instances, as observed in #22492. This patch
resolves #22492 by documenting this strange interaction in the GHC User's
Guide.

[ci skip]

- - - - -
1023b432 by Mike Pilgrem at 2022-12-09T09:42:56-05:00
Fix #22300 Document GHC's extensions to valid whitespace

- - - - -
79b0cec0 by Luite Stegeman at 2022-12-09T09:43:38-05:00
Add support for environments that don't have setImmediate

- - - - -
5b007ec5 by Luite Stegeman at 2022-12-09T09:43:38-05:00
Fix bound thread status

- - - - -
65335d10 by Matthew Pickering at 2022-12-09T20:15:45-05:00
Update containers submodule

This contains a fix necessary for the multi-repl to work on GHC's code
base where we try to load containers and template-haskell into the same
session.

- - - - -
4937c0bb by Matthew Pickering at 2022-12-09T20:15:45-05:00
hadrian-multi: Put interface files in separate directories

Before we were putting all the interface files in the same directory
which was leading to collisions if the files were called the same thing.

- - - - -
8acb5b7b by Matthew Pickering at 2022-12-09T20:15:45-05:00
hadrian-toolargs: Add filepath to allowed repl targets

- - - - -
5949d927 by Matthew Pickering at 2022-12-09T20:15:45-05:00
driver: Set correct UnitId when rehydrating modules

We were not setting the UnitId before rehydrating modules which just led
to us attempting to find things in the wrong HPT. The test for this is
the hadrian-multi command (which is now added as a CI job).

Fixes #22222

- - - - -
ab06c0f0 by Matthew Pickering at 2022-12-09T20:15:45-05:00
ci: Add job to test hadrian-multi command

I am not sure this job is good because it requires booting HEAD with
HEAD, but it should be fine.

- - - - -
fac3e568 by Matthew Pickering at 2022-12-09T20:16:20-05:00
hadrian: Update bootstrap plans to 9.2.* series and 9.4.* series.

This updates the build plans for the most recent compiler versions, as
well as fixing the hadrian-bootstrap-gen script to a specific GHC
version.

- - - - -
195b08b4 by Matthew Pickering at 2022-12-09T20:16:20-05:00
ci: Bump boot images to use ghc-9.4.3

Also updates the bootstrap jobs to test booting 9.2 and 9.4.

- - - - -
c658c580 by Matthew Pickering at 2022-12-09T20:16:20-05:00
hlint: Removed redundant UnboxedSums pragmas

UnboxedSums is quite confusingly implied by UnboxedTuples, alas, just
the way it is.

See #22485

- - - - -
b3e98a92 by Oleg Grenrus at 2022-12-11T12:26:17-05:00
Add heqT, a kind-heterogeneous variant of heq

CLC proposal https://github.com/haskell/core-libraries-committee/issues/99

- - - - -
bfd7c1e6 by Andrew Lelechenko at 2022-12-11T12:26:55-05:00
Document that Bifunctor instances for tuples are lawful only up to laziness

- - - - -
5d1a1881 by Bryan Richter at 2022-12-12T16:22:36-05:00
Mark T21336a fragile

- - - - -
c30accc2 by Matthew Pickering at 2022-12-12T16:23:11-05:00
Add test for #21476

This issues seems to have been fixed since the ticket was made, so let's
add a test and move on.

Fixes #21476

- - - - -
e9d74a3e by Sebastian Graf at 2022-12-13T22:18:39-05:00
Respect -XStrict in the pattern-match checker (#21761)

We were missing a call to `decideBangHood` in the pattern-match checker.
There is another call in `matchWrapper.mk_eqn_info` which seems redundant
but really is not; see `Note [Desugaring -XStrict matches in Pmc]`.

Fixes #21761.

- - - - -
884790e2 by Gergő Érdi at 2022-12-13T22:19:14-05:00
Fix loop in the interface representation of some `Unfolding` fields

As discovered in #22272, dehydration of the unfolding info of a
recursive definition used to involve a traversal of the definition
itself, which in turn involves traversing the unfolding info. Hence,
a loop.

Instead, we now store enough data in the interface that we can produce
the unfolding info without this traversal. See Note [Tying the 'CoreUnfolding' knot]
for details.

Fixes #22272

Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com>

- - - - -
9f301189 by Alan Zimmerman at 2022-12-13T22:19:50-05:00
EPA: When splitting out header comments, keep ones for first decl

Any comments immediately preceding the first declaration are no longer
kept as header comments, but attach to the first declaration instead.

- - - - -
8b1f1b45 by Sylvain Henry at 2022-12-13T22:20:28-05:00
JS: fix object file name comparison (#22578)

- - - - -
e9e161bb by Bryan Richter at 2022-12-13T22:21:03-05:00
configure: Bump min bootstrap GHC version to 9.2

- - - - -
75855643 by Ben Gamari at 2022-12-15T03:54:02-05:00
hadrian: Don't enable TSAN in stage0 build

- - - - -
da7b51d8 by Ben Gamari at 2022-12-15T03:54:02-05:00
cmm: Introduce blockConcat

- - - - -
34f6b09c by Ben Gamari at 2022-12-15T03:54:02-05:00
cmm: Introduce MemoryOrderings

- - - - -
43beaa7b by Ben Gamari at 2022-12-15T03:54:02-05:00
llvm: Respect memory specified orderings

- - - - -
8faf74fc by Ben Gamari at 2022-12-15T03:54:02-05:00
Codegen/x86: Eliminate barrier for relaxed accesses

- - - - -
6cc3944a by Ben Gamari at 2022-12-15T03:54:02-05:00
cmm/Parser: Reduce some repetition

- - - - -
6c9862c4 by Ben Gamari at 2022-12-15T03:54:02-05:00
cmm/Parser: Add syntax for ordered loads and stores

- - - - -
748490d2 by Ben Gamari at 2022-12-15T03:54:02-05:00
cmm/Parser: Atomic load syntax

Originally I had thought I would just use the `prim` call syntax instead
of introducing new syntax for atomic loads. However, it turns out that
`prim` call syntax tends to make things quite unreadable. This new
syntax seems quite natural.

- - - - -
28c6781a by Ben Gamari at 2022-12-15T03:54:02-05:00
codeGen: Introduce ThreadSanitizer instrumentation

This introduces a new Cmm pass which instruments the program with
ThreadSanitizer annotations, allowing full tracking of mutator memory
accesses via TSAN.

- - - - -
d97aa311 by Ben Gamari at 2022-12-15T03:54:02-05:00
Hadrian: Drop TSAN_ENABLED define from flavour

This is redundant since the TSANUtils.h already defines it.

- - - - -
86974ef1 by Ben Gamari at 2022-12-15T03:54:02-05:00
hadrian: Enable Cmm instrumentation in TSAN flavour

- - - - -
93723290 by Ben Gamari at 2022-12-15T03:54:02-05:00
rts: Ensure that global regs are never passed as fun call args

This is in general unsafe as they may be clobbered if they are mapped to
caller-saved machine registers. See Note [Register parameter passing].

- - - - -
2eb0fb87 by Matthew Pickering at 2022-12-15T03:54:39-05:00
Package Imports: Get candidate packages also from re-exported modules

Previously we were just looking at the direct imports to try and work
out what a package qualifier could apply to but #22333 pointed out we
also needed to look for reexported modules.

Fixes #22333

- - - - -
552b7908 by Ben Gamari at 2022-12-15T03:55:15-05:00
compiler: Ensure that MutVar operations have necessary barriers

Here we add acquire and release barriers in readMutVar# and
writeMutVar#, which are necessary for soundness.

Fixes #22468.

- - - - -
933d61a4 by Simon Peyton Jones at 2022-12-15T03:55:51-05:00
Fix bogus test in Lint

The Lint check for branch compatiblity within an axiom, in
GHC.Core.Lint.compatible_branches was subtly different to the
check made when contructing an axiom, in
GHC.Core.FamInstEnv.compatibleBranches.

The latter is correct, so I killed the former and am now using the
latter.

On the way I did some improvements to pretty-printing and documentation.

- - - - -
03ed0b95 by Ryan Scott at 2022-12-15T03:56:26-05:00
checkValidInst: Don't expand synonyms when splitting sigma types

Previously, the `checkValidInst` function (used when checking that an instance
declaration is headed by an actual type class, not a type synonym) was using
`tcSplitSigmaTy` to split apart the `forall`s and instance context. This is
incorrect, however, as `tcSplitSigmaTy` expands type synonyms, which can cause
instances headed by quantified constraint type synonyms to be accepted
erroneously.

This patch introduces `splitInstTyForValidity`, a variant of `tcSplitSigmaTy`
specialized for validity checking that does _not_ expand type synonyms, and
uses it in `checkValidInst`.

Fixes #22570.

- - - - -
ed056bc3 by Ben Gamari at 2022-12-16T16:12:44-05:00
rts/Messages: Refactor

This doesn't change behavior but makes the code a bit easier to follow.

- - - - -
7356f8e0 by Ben Gamari at 2022-12-16T16:12:44-05:00
rts/ThreadPaused: Ordering fixes

- - - - -
914f0025 by Ben Gamari at 2022-12-16T16:12:44-05:00
eventlog: Silence spurious data race

- - - - -
fbc84244 by Ben Gamari at 2022-12-16T16:12:44-05:00
Introduce SET_INFO_RELEASE for Cmm

- - - - -
821b5472 by Ben Gamari at 2022-12-16T16:12:44-05:00
rts: Use fences instead of explicit barriers

- - - - -
2228c999 by Ben Gamari at 2022-12-16T16:12:44-05:00
rts/stm: Fix memory ordering in readTVarIO#

See #22421.

- - - - -
99269b9f by Ben Gamari at 2022-12-16T16:12:44-05:00
Improve heap memory barrier Note

Also introduce MUT_FIELD marker in Closures.h to document mutable
fields.

- - - - -
70999283 by Ben Gamari at 2022-12-16T16:12:44-05:00
rts: Introduce getNumCapabilities

And ensure accesses to n_capabilities are atomic (although with relaxed
ordering). This is necessary as RTS API callers may concurrently call
into the RTS without holding a capability.

- - - - -
98689f77 by Ben Gamari at 2022-12-16T16:12:44-05:00
ghc: Fix data race in dump file handling

Previously the dump filename cache would use a non-atomic update which
could potentially result in lost dump contents. Note that this is still
a bit racy since the first writer may lag behind a later appending
writer.

- - - - -
605d9547 by Ben Gamari at 2022-12-16T16:12:45-05:00
rts: Always use atomics for context_switch and interrupt

Since these are modified by the timer handler.

- - - - -
86f20258 by Ben Gamari at 2022-12-16T16:12:45-05:00
rts/Timer: Always use atomic operations

As noted in #22447, the existence of the pthread-based ITimer
implementation means that we cannot assume that the program is
single-threaded.

- - - - -
f8e901dc by Ben Gamari at 2022-12-16T16:12:45-05:00
rts: Encapsulate recent_activity access

This makes it easier to ensure that it is accessed using the necessary
atomic operations.

- - - - -
e0affaa9 by Ben Gamari at 2022-12-16T16:12:45-05:00
rts: Encapsulate access to capabilities array

- - - - -
7ca683e4 by Ben Gamari at 2022-12-16T16:12:45-05:00
rts: Encapsulate sched_state

- - - - -
1cf13bd0 by Ben Gamari at 2022-12-16T16:12:45-05:00
PrimOps: Fix benign MutVar race

Relaxed ordering is fine here since the later CAS implies a release.

- - - - -
3d2a7e08 by Ben Gamari at 2022-12-16T16:12:45-05:00
rts: Style fix

- - - - -
82c62074 by Ben Gamari at 2022-12-16T16:12:45-05:00
compiler: Use release store in eager blackholing

- - - - -
eb1a0136 by Ben Gamari at 2022-12-16T16:12:45-05:00
rts: Fix ordering of makeStableName

- - - - -
ad0e260a by Ben Gamari at 2022-12-16T16:12:45-05:00
rts: Use ordered accesses instead of explicit barriers

- - - - -
a3eccf06 by Ben Gamari at 2022-12-16T16:12:45-05:00
rts: Statically allocate capabilities

This is a rather simplistic way of solving #17289.

- - - - -
287fa3fb by Ben Gamari at 2022-12-16T16:12:45-05:00
rts: Ensure that all accesses to pending_sync are atomic

- - - - -
351eae58 by Ben Gamari at 2022-12-16T16:12:45-05:00
rts: Note race with wakeBlockingQueue

- - - - -
5acf33dd by Andrew Lelechenko at 2022-12-16T16:13:22-05:00
Bump submodule directory to 1.3.8.0 and hpc to HEAD

- - - - -
0dd95421 by Andrew Lelechenko at 2022-12-16T16:13:22-05:00
Accept allocations increase on Windows

This is because of `filepath-1.4.100.0` and AFPP, causing increasing round-trips
between lists and ByteArray. See #22625 for discussion.

Metric Increase:
    MultiComponentModules
    MultiComponentModulesRecomp
    MultiLayerModules
    MultiLayerModulesRecomp
    T10421
    T10547
    T12150
    T12227
    T12234
    T12425
    T13035
    T13253
    T13253-spj
    T13701
    T13719
    T15703
    T16875
    T18140
    T18282
    T18304
    T18698a
    T18698b
    T18923
    T20049
    T21839c
    T21839r
    T5837
    T6048
    T9198
    T9961
    TcPlugin_RewritePerf
    hard_hole_fits

- - - - -
ef9ac9d2 by Cheng Shao at 2022-12-16T16:13:59-05:00
testsuite: Mark T9405 as fragile instead of broken on Windows

It's starting to pass again, and the unexpected pass blocks CI.

- - - - -
1f3abd85 by Cheng Shao at 2022-12-16T21:16:28+00:00
compiler: remove obsolete commented code in wasm NCG

It was just a temporary hack to workaround a bug in the relooper, that
bug has been fixed long before the wasm backend is merged.

- - - - -
e3104eab by Cheng Shao at 2022-12-16T21:16:28+00:00
compiler: add missing export list of GHC.CmmToAsm.Wasm.FromCmm

Also removes some unreachable code here.

- - - - -
1c6930bf by Cheng Shao at 2022-12-16T21:16:28+00:00
compiler: change fallback function signature to Cmm function signature in wasm NCG

In the wasm NCG, when handling a `CLabel` of undefined function
without knowing its function signature, we used to fallback to `() ->
()` which is accepted by `wasm-ld`. This patch changes it to the
signature of Cmm functions, which equally works, but would be required
when we emit tail call instructions.

- - - - -
8a81d9d9 by Cheng Shao at 2022-12-16T21:16:28+00:00
compiler: add optional tail-call support in wasm NCG

When the `-mtail-call` clang flag is passed at configure time, wasm
tail-call extension is enabled, and the wasm NCG will emit
`return_call`/`return_call_indirect` instructions to take advantage of
it and avoid the `StgRun` trampoline overhead.

Closes #22461.

- - - - -
d1431cc0 by Cheng Shao at 2022-12-17T08:07:15-05:00
base: add missing autoconf checks for waitpid/umask

These are not present in wasi-libc. Required for fixing #22589

- - - - -
da3f1e91 by Cheng Shao at 2022-12-17T08:07:51-05:00
compiler: make .wasm the default executable extension on wasm32

Following convention as in other wasm toolchains. Fixes #22594.

- - - - -
ad21f4ef by Cheng Shao at 2022-12-17T08:07:51-05:00
ci: support hello.wasm in ci.sh cross testing logic

- - - - -
6fe2d778 by amesgen at 2022-12-18T19:33:49-05:00
Correct `exitWith` Haddocks

The `IOError`-specific `catch` in the Prelude is long gone.

- - - - -
b3eacd64 by Ben Gamari at 2022-12-18T19:34:24-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.

- - - - -
761c1f49 by Ben Gamari at 2022-12-18T19:35:00-05:00
rts/libdw: Silence uninitialized usage warnings

As noted in #22538, previously some GCC versions warned that various
locals in Libdw.c may be used uninitialized. Although this wasn't
strictly true (since they were initialized in an inline assembler block)
we fix this by providing explicit empty initializers.

Fixes #22538
- - - - -
5e047eff by Matthew Pickering at 2022-12-20T15:12:04+00:00
testsuite: Mark T16392 as fragile on windows

See #22649

- - - - -
703a4665 by M Farkas-Dyck at 2022-12-20T21:14:46-05:00
Scrub some partiality in `GHC.Cmm.Info.Build`: `doSRTs` takes a `[(CAFSet, CmmDecl)]` but truly wants a `[(CAFSet, CmmStatics)]`.

- - - - -
9736ab74 by Matthew Pickering at 2022-12-20T21:15:22-05:00
packaging: Fix upload_ghc_libs.py script

This change reflects the changes where .cabal files are now generated by
hadrian rather than ./configure.

Fixes #22518

- - - - -
7c6de18d by Ben Gamari at 2022-12-20T21:15:57-05:00
configure: Drop uses of AC_PROG_CC_C99

As noted in #22566, this macro is deprecated as of autoconf-2.70
`AC_PROG_CC` now sets `ac_cv_prog_cc_c99` itself.

Closes #22566.

- - - - -
36c5d98e by Ben Gamari at 2022-12-20T21:15:57-05:00
configure: Use AS_HELP_STRING instead of AC_HELP_STRING

The latter has been deprecated.

See #22566.

- - - - -
befe6ff8 by Andrew Lelechenko at 2022-12-20T21:16:37-05:00
GHCi.UI: fix various usages of head and tail

- - - - -
666d0ba7 by Andrew Lelechenko at 2022-12-20T21:16:37-05:00
GHCi.UI: avoid head and tail in parseCallEscape and around

- - - - -
5d96fd50 by Andrew Lelechenko at 2022-12-20T21:16:37-05:00
Make GHC.Driver.Main.hscTcRnLookupRdrName to return NonEmpty

- - - - -
3ce2ab94 by Andrew Lelechenko at 2022-12-21T06:17:56-05:00
Allow transformers-0.6 in ghc, ghci, ghc-bin and hadrian

- - - - -
954de93a by Andrew Lelechenko at 2022-12-21T06:17:56-05:00
Update submodule haskeline to HEAD (to allow transformers-0.6)

- - - - -
cefbeec3 by Andrew Lelechenko at 2022-12-21T06:17:56-05:00
Update submodule transformers to 0.6.0.4

- - - - -
b4730b62 by Andrew Lelechenko at 2022-12-21T06:17:56-05:00
Fix tests

T13253 imports MonadTrans, which acquired a quantified constraint in transformers-0.6, thus increase in allocations

Metric Increase:
    T13253

- - - - -
0be75261 by Simon Peyton Jones at 2022-12-21T06:18:32-05:00
Abstract over the right free vars

Fix #22459, in two ways:

(1) Make the Specialiser not create a bogus specialisation if
    it is presented by strangely polymorphic dictionary.
    See Note [Weird special case in SpecDict] in
    GHC.Core.Opt.Specialise

(2) Be more careful in abstractFloats
    See Note [Which type variables to abstract over]
    in GHC.Core.Opt.Simplify.Utils.

So (2) stops creating the excessively polymorphic dictionary in
abstractFloats, while (1) stops crashing if some other pass should
nevertheless create a weirdly polymorphic dictionary.

- - - - -
df7bc6b3 by Ying-Ruei Liang (TheKK) at 2022-12-21T14:31:54-05:00
rts: explicitly store return value of ccall checkClosure to prevent type error (#22617)

- - - - -
e193e537 by Simon Peyton Jones at 2022-12-21T14:32:30-05:00
Fix shadowing lacuna in OccurAnal

Issue #22623 demonstrated another lacuna in the implementation
of wrinkle (BS3) in Note [The binder-swap substitution] in
the occurrence analyser.

I was failing to add TyVar lambda binders using
addInScope/addOneInScope and that led to a totally bogus binder-swap
transformation.

Very easy to fix.

- - - - -
3d55d8ab by Simon Peyton Jones at 2022-12-21T14:32:30-05:00
Fix an assertion check in addToEqualCtList

The old assertion saw that a constraint ct could rewrite itself
(of course it can) and complained (stupid).

Fixes #22645

- - - - -
ceb2e9b9 by Ben Gamari at 2022-12-21T15:26:08-05:00
configure: Bump version to 9.6

- - - - -
fb4d36c4 by Ben Gamari at 2022-12-21T15:27:49-05:00
base: Bump version to 4.18

Requires various submodule bumps.

- - - - -
93ee7e90 by Ben Gamari at 2022-12-21T15:27:49-05:00
ghc-boot: Fix bootstrapping

- - - - -
fc3a2232 by Ben Gamari at 2022-12-22T13:45:06-05:00
Bump GHC version to 9.7

- - - - -
914f7fe3 by Andreas Klebinger at 2022-12-22T23:36:10-05: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.

- - - - -
32b32d7f by Matthew Pickering at 2022-12-22T23:36:46-05: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

- - - - -
b3ddf803 by Ben Gamari at 2022-12-22T23:37:23-05:00
rts: Drop paths from configure from cabal file

A long time ago we would rely on substitutions from the configure script
to inject paths of the include and library directories of libffi and
libdw. However, now these are instead handled inside Hadrian when
calling Cabal's `configure` (see the uses of `cabalExtraDirs` in
Hadrian's `Settings.Packages.packageArgs`).

While the occurrences in the cabal file were redundant, they did no
harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have
no longer been interpolated. @mpickering noticed the suspicious
uninterpolated occurrence of `@FFIIncludeDir@` in #22595,
prompting this commit to finally remove them.

- - - - -
b2c7523d by Ben Gamari at 2022-12-22T23:37:59-05:00
Bump libffi-tarballs submodule

We will now use libffi-3.4.4.

- - - - -
3699a554 by Alan Zimmerman at 2022-12-22T23:38:35-05:00
EPA: Make EOF position part of AnnsModule

Closes #20951
Closes #19697

- - - - -
99757ce8 by Sylvain Henry at 2022-12-22T23:39:13-05: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.

- - - - -
02ed7d78 by Simon Peyton Jones at 2022-12-22T23:39:49-05: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.

- - - - -
35267f07 by Ben Gamari at 2022-12-22T23:40:32-05:00
base: Fix event manager shutdown race on non-Linux platforms

During shutdown it's possible that we will attempt to use a closed fd
to wakeup another capability's event manager. On the Linux eventfd path
we were careful to handle this. However on the non-Linux path we failed
to do so. Fix this.

- - - - -
317f45c1 by Simon Peyton Jones at 2022-12-22T23:41:07-05:00
Fix unifier bug: failing to decompose over-saturated type family

This simple patch fixes #22647

- - - - -
14b2e3d3 by Ben Gamari at 2022-12-22T23:41:42-05:00
rts/m32: Fix sanity checking

Previously we would attempt to clear pages which were marked as
read-only. Fix this.

- - - - -
16a1bcd1 by Matthew Pickering at 2022-12-23T09:15:24+00:00
ci: Move wasm pipelines into nightly rather than master

See #22664 for the changes which need to be made to bring one of these
back to the validate pipeline.

- - - - -
18d2acd2 by Ben Gamari at 2022-12-23T19:09:30-05:00
nonmoving: Fix race in marking of blackholes

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

- - - - -
11241efa by Ben Gamari at 2022-12-23T19:09:30-05:00
nonmoving: Fix segment list races

- - - - -
602455c9 by Ben Gamari at 2022-12-23T19:09:30-05:00
nonmoving: Use atomic when looking at bd->gen

Since it may have been mutated by a moving GC.

- - - - -
9d63b160 by Ben Gamari at 2022-12-23T19:09:30-05: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.

- - - - -
26837523 by Ben Gamari at 2022-12-23T19:09:30-05:00
nonmoving: Ensure that mutable fields have acquire barrier

- - - - -
8093264a by Ben Gamari at 2022-12-23T19:09:30-05: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.

- - - - -
387d4fcc by Ben Gamari at 2022-12-23T19:09:30-05:00
nonmoving: Make segment state updates atomic

- - - - -
543cae00 by Ben Gamari at 2022-12-23T19:09:30-05: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.

- - - - -
c9936718 by Ben Gamari at 2022-12-23T19:09:30-05:00
nonmoving: Ensure that we aren't holding locks when closing them

TSAN complains about this sort of thing.

- - - - -
0cd31f7d by Ben Gamari at 2022-12-23T19:09:30-05: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.

- - - - -
d3fe110a by Ben Gamari at 2022-12-23T19:09:30-05: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.

- - - - -
ab6cf893 by Ben Gamari at 2022-12-23T19:09:30-05: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.

- - - - -
36c9f23c by Ben Gamari at 2022-12-23T19:09:30-05:00
nonmoving: Make free list counter accesses atomic

Since these may race with the allocator(s).

- - - - -
aebef31c by doyougnu at 2022-12-23T19:10:09-05:00
add GHC.Utils.Binary.foldGet' and use for Iface

A minor optimization to remove lazy IO and a lazy accumulator

strictify foldGet'

IFace.Binary: use strict foldGet'

remove superfluous bang

- - - - -
5eb357d9 by Ben Gamari at 2022-12-24T00:41:05-05: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).

- - - - -
cbaebfb9 by Matthew Pickering at 2022-12-24T00:41:40-05: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.

- - - - -
f4850f36 by Matthew Pickering at 2022-12-24T00:41:40-05: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)

- - - - -
c264b06b by Matthew Pickering at 2022-12-24T00:41:40-05: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.

- - - - -
63b97430 by Ben Gamari at 2022-12-24T00:42:16-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
- - - - -
f42ba88f by Ben Gamari at 2022-12-24T00:42:16-05:00
gitlab-ci: Introduce aarch64-linux-llvm job

This nightly job will ensure that we don't break the LLVM backend on
AArch64/Linux by bootstrapping GHC.

This would have caught #22640.

- - - - -
6d62f6bf by Matthew Pickering at 2022-12-24T00:42:51-05: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

- - - - -
3c3060e4 by Richard Eisenberg at 2022-12-24T17:34:19+00:00
Drop support for kind constraints.

This implements proposal 547 and closes ticket #22298.
See the proposal and ticket for motivation.

Compiler perf improves a bit

Metrics: compile_time/bytes allocated
-------------------------------------
  CoOpt_Singletons(normal)   -2.4% GOOD
            T12545(normal)   +1.0%
            T13035(normal)  -13.5% GOOD
            T18478(normal)   +0.9%
            T9872d(normal)   -2.2% GOOD

                 geo. mean   -0.2%
                 minimum    -13.5%
                 maximum     +1.0%

Metric Decrease:
    CoOpt_Singletons
    T13035
    T9872d

- - - - -
6d7d4393 by Ben Gamari at 2022-12-24T21:09:56-05: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.

- - - - -
a5bd0eb8 by Andrew Lelechenko at 2022-12-24T21:10:34-05:00
Document infelicities of instance Ord Double and workarounds

- - - - -
62b9a7b2 by Zubin Duggal at 2023-01-03T12:22:11+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.

- - - - -
21bedd84 by Facundo Domínguez at 2023-01-03T23:27:30-05:00
Explain the auxiliary functions of permutations

- - - - -
32255d05 by Matthew Pickering at 2023-01-04T11:58:42+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.

- - - - -
e640940c by Matthew Pickering at 2023-01-04T11:58:42+00:00
hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler

This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b

- - - - -
15bee123 by Matthew Pickering at 2023-01-04T11:58:42+00:00
hadrian: Add test:all_deps to build just testsuite dependencies

Fixes #22534

- - - - -
fec6638e by Matthew Pickering at 2023-01-04T11:58:42+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.

- - - - -
3dc05726 by Matthew Pickering at 2023-01-04T11:58:42+00:00
check-exact: Fix build with -Werror

- - - - -
53a6ae7a by Matthew Pickering at 2023-01-04T11:58:42+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

- - - - -
32e264c1 by Matthew Pickering at 2023-01-04T11:58:42+00:00
hadrian: Document using GHC environment variable to select boot compiler

Fixes #22340

- - - - -
be9dd9b0 by Matthew Pickering at 2023-01-04T11:58:42+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

- - - - -
00dc5106 by Matthew Pickering at 2023-01-04T14:32:45-05: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

- - - - -
541aedcd by Krzysztof Gogolewski at 2023-01-05T10:48:34-05:00
Misc cleanup

- Remove unused uniques and hs-boot declarations
- Fix types of seq and unsafeCoerce#
- Remove FastString/String roundtrip in JS
- Use TTG to enforce totality
- Remove enumeration in Heap/Inspect; the 'otherwise' clause
  serves the primitive types well.

- - - - -
22bb8998 by Alan Zimmerman at 2023-01-05T10:49:09-05:00
EPA: Do not collect comments from end of file

In Parser.y semis1 production triggers for the virtual semi at the end
of the file. This is detected by it being zero length.

In this case, do not extend the span being used to gather comments, so
any final comments are allocated at the module level instead.

- - - - -
9e077999 by Vladislav Zavialov at 2023-01-05T23:01:55-05:00
HsToken in TypeArg (#19623)

Updates the haddock submodule.

- - - - -
b2a2db04 by Matthew Pickering at 2023-01-05T23:02:30-05: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

- - - - -
28f8c0eb by Luite Stegeman at 2023-01-06T18:16:24+09: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

- - - - -
ac39e8e9 by Matthew Pickering at 2023-01-06T13:47:00-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

- - - - -
c306d939 by Matthew Pickering at 2023-01-06T22:08:53-05:00
ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3

Fixes #22599

- - - - -
0db496ff by Matthew Pickering at 2023-01-06T22:08:53-05: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.

- - - - -
2459c358 by Ben Gamari at 2023-01-06T22:09:29-05:00
rts: MUT_VAR is not a StgMutArrPtrs

There was previously a comment claiming that the MUT_VAR closure type
had the layout of StgMutArrPtrs.
- - - - -
6206cb92 by Simon Peyton Jones at 2023-01-07T12:14:40-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

- - - - -
a960ca81 by Matthew Pickering at 2023-01-07T12:15:15-05: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

- - - - -
73484710 by Matthew Pickering at 2023-01-07T12:15:15-05: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.

- - - - -
8c0ea25f by Matthew Pickering at 2023-01-07T12:15:15-05: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

- - - - -
365b3045 by Matthew Pickering at 2023-01-09T02:36:20-05: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.

- - - - -
965a2735 by Alan Zimmerman at 2023-01-09T02:36:20-05:00
EPA: exact print HsDocTy

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

- - - - -
5d65773e by John Ericson at 2023-01-09T20:39:27-05:00
Remove RTS hack for configuring

See the brand new Note [Undefined symbols in the RTS] for additional
details.

- - - - -
e3fff751 by Sebastian Graf at 2023-01-09T20:40:02-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

- - - - -
d53f6f4d by Oleg Grenrus at 2023-01-09T21:11:02-05:00
Add safe list indexing operator: !?

With Joachim's amendments.

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

- - - - -
cfaf1ad7 by Nicolas Trangez at 2023-01-09T21:11:03-05:00
rts, tests: limit thread name length to 15 bytes

On Linux, `pthread_setname_np` (or rather, the kernel) only allows for
thread names up to 16 bytes, including the terminating null byte.

This commit adds a note pointing this out in `createOSThread`, and fixes
up two instances where a thread name of more than 15 characters long was
used (in the RTS, and in a test-case).

Fixes: #22366
Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/22366
See: https://gitlab.haskell.org/ghc/ghc/-/issues/22366#note_460796

- - - - -
64286132 by Matthew Pickering at 2023-01-09T21:11:03-05: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

- - - - -
4724e8d1 by Matthew Pickering at 2023-01-09T21:11:04-05: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

- - - - -
2e926b88 by Georgi Lyubenov at 2023-01-09T21:11:07-05:00
Fix outdated link to Happy section on sequences

- - - - -
146a1458 by Matthew Pickering at 2023-01-09T21:11:07-05:00
Revert "NCG(x86): Compile add+shift as lea if possible."

This reverts commit 20457d775885d6c3df020d204da9a7acfb3c2e5a.

See #22666 and #21777

- - - - -
6e6adbe3 by Jade Lovelace at 2023-01-11T00:55:30-05:00
Fix tcPluginRewrite example

- - - - -
faa57138 by Jade Lovelace at 2023-01-11T00:55:31-05:00
fix missing haddock pipe

- - - - -
0470ea7c by Florian Weimer at 2023-01-11T00:56:10-05:00
m4/fp_leading_underscore.m4: Avoid implicit exit function declaration

And switch to a new-style function definition.

Fixes build issues with compilers that do not accept implicit function
declarations.

- - - - -
b2857df4 by HaskellMouse at 2023-01-11T00:56:52-05:00
Added a new warning about compatibility with RequiredTypeArguments

This commit introduces a new warning
that indicates code incompatible with
future extension: RequiredTypeArguments.

Enabling this extension may break some code and the warning
will help to make it compatible in advance.

- - - - -
5f17e21a by Ben Gamari at 2023-01-11T00:57:27-05:00
testsuite: Drop testheapalloced.c

As noted in #22414, this file (which appears to be a benchmark for
characterising the one-step allocator's MBlock cache) is currently 
unreferenced. Remove it.

Closes #22414. 
- - - - -
bc125775 by Vladislav Zavialov at 2023-01-11T00:58:03-05:00
Introduce the TypeAbstractions language flag

GHC Proposals #448 "Modern scoped type variables"
and #425 "Invisible binders in type declarations"
introduce a new language extension flag: TypeAbstractions.

Part of the functionality guarded by this flag has already been
implemented, namely type abstractions in constructor patterns, but it
was guarded by a combination of TypeApplications and ScopedTypeVariables
instead of a dedicated language extension flag.

This patch does the following:

* introduces a new language extension flag TypeAbstractions
* requires TypeAbstractions for @a-syntax in constructor patterns
  instead of TypeApplications and ScopedTypeVariables
* creates a User's Guide page for TypeAbstractions and
  moves the "Type Applications in Patterns" section there

To avoid a breaking change, the new flag is implied by
ScopedTypeVariables and is retroactively added to GHC2021.

Metric Decrease:
    MultiLayerModulesTH_OneShot

- - - - -
083f7015 by Krzysztof Gogolewski at 2023-01-11T00:58:38-05:00
Misc cleanup

- Remove unused mkWildEvBinder
- Use typeTypeOrConstraint - more symmetric and asserts that
  that the type is Type or Constraint
- Fix escape sequences in Python; they raise a deprecation warning
  with -Wdefault

- - - - -
aed1974e by Richard Eisenberg at 2023-01-11T08:30:42+00: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.

- - - - -
300bcc15 by HaskellMouse at 2023-01-11T13:43:36-05:00
Parse qualified terms in type signatures

This commit allows qualified terms in type
signatures to pass the parser and to be cathced by renamer
with more informative error message. Adds a few tests.

Fixes #21605

- - - - -
964284fc by Simon Peyton Jones at 2023-01-11T13:44:12-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.

- - - - -
f7ceafc9 by Krzysztof Gogolewski at 2023-01-11T22:36:59-05:00
Add 'docWithStyle' to improve codegen

This new combinator

docWithStyle :: IsOutput doc => doc -> (PprStyle -> SDoc) -> doc

let us remove the need for code to be polymorphic in HDoc
when not used in code style.

Metric Decrease:
    ManyConstructors
    T13035
    T1969

- - - - -
b3be0d18 by Simon Peyton Jones at 2023-01-11T22:37:35-05:00
Fix finaliseArgBoxities for OPAQUE function

We never do worker wrapper for OPAQUE functions, so we must
zap the unboxing info during strictness analysis.

This patch fixes #22502

- - - - -
db11f358 by Ben Gamari at 2023-01-12T07:49:04-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.

- - - - -
3242139f by Ben Gamari at 2023-01-12T07:49:04-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.

- - - - -
9ffd5d57 by Ben Gamari at 2023-01-12T07:49:41-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.

- - - - -
905d0b6e by Sebastian Graf at 2023-01-12T15:51:47-05:00
Fix contification with stable unfoldings (#22428)

Many functions now return a `TailUsageDetails` that adorns a `UsageDetails` with
a `JoinArity` that reflects the number of join point binders around the body
for which the `UsageDetails` was computed. `TailUsageDetails` is now returned by
`occAnalLamTail` as well as `occAnalUnfolding` and `occAnalRules`.

I adjusted `Note [Join points and unfoldings/rules]` and
`Note [Adjusting right-hand sides]` to account for the new machinery.
I also wrote a new `Note [Join arity prediction based on joinRhsArity]`
and refer to it when we combine `TailUsageDetails` for a recursive RHS.

I also renamed

  * `occAnalLam` to `occAnalLamTail`
  * `adjustRhsUsage` to `adjustTailUsage`
  * a few other less important functions

and properly documented the that each call of `occAnalLamTail` must pair up with
`adjustTailUsage`.

I removed `Note [Unfoldings and join points]` because it was redundant with
`Note [Occurrences in stable unfoldings]`.

While in town, I refactored `mkLoopBreakerNodes` so that it returns a condensed
`NodeDetails` called `SimpleNodeDetails`.

Fixes #22428.

The refactoring seems to have quite beneficial effect on ghc/alloc performance:

```
     CoOpt_Read(normal) ghc/alloc    784,778,420    768,091,176  -2.1% GOOD
         T12150(optasm) ghc/alloc     77,762,270     75,986,720  -2.3% GOOD
         T12425(optasm) ghc/alloc     85,740,186     84,641,712  -1.3% GOOD
         T13056(optasm) ghc/alloc    306,104,656    299,811,632  -2.1% GOOD
         T13253(normal) ghc/alloc    350,233,952    346,004,008  -1.2%
         T14683(normal) ghc/alloc  2,800,514,792  2,754,651,360  -1.6%
         T15304(normal) ghc/alloc  1,230,883,318  1,215,978,336  -1.2%
         T15630(normal) ghc/alloc    153,379,590    151,796,488  -1.0%
         T16577(normal) ghc/alloc  7,356,797,056  7,244,194,416  -1.5%
         T17516(normal) ghc/alloc  1,718,941,448  1,692,157,288  -1.6%
         T19695(normal) ghc/alloc  1,485,794,632  1,458,022,112  -1.9%
        T21839c(normal) ghc/alloc    437,562,314    431,295,896  -1.4% GOOD
        T21839r(normal) ghc/alloc    446,927,580    440,615,776  -1.4% GOOD

              geo. mean                                          -0.6%
              minimum                                            -2.4%
              maximum                                            -0.0%
```

Metric Decrease:
    CoOpt_Read
    T10421
    T12150
    T12425
    T13056
    T18698a
    T18698b
    T21839c
    T21839r
    T9961

- - - - -
a1491c87 by Andreas Klebinger at 2023-01-12T15:52:23-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.

- - - - -
8acfe930 by Cheng Shao at 2023-01-12T15:53:00-05:00
Change MSYSTEM to CLANG64 uniformly

- - - - -
73bc162b by M Farkas-Dyck at 2023-01-12T15:53:42-05:00
Make `GHC.Tc.Errors.Reporter` take `NonEmpty ErrorItem` rather than `[ErrorItem]`, which lets us drop some panics.

Also use the `BasicMismatch` constructor rather than `mkBasicMismatchMsg`, which lets us drop the "-Wno-incomplete-record-updates" flag.

- - - - -
1b812b69 by Oleg Grenrus at 2023-01-12T15:54:21-05:00
Fix #22728: Not all diagnostics in safe check are fatal

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

- - - - -
c79b2b65 by Matthew Pickering at 2023-01-12T15:54:58-05:00
Don't run hadrian-multi on fast-ci label

Fixes #22667

- - - - -
9a3d6add by Andrew Lelechenko at 2023-01-13T00:46:36-05:00
Bump submodule bytestring to 0.11.4.0

Metric Decrease:
    T21839c
    T21839r

- - - - -
df33c13c by Ben Gamari at 2023-01-13T00:47:12-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.

- - - - -
756a66ec by Ben Gamari at 2023-01-13T00:47:12-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`.
- - - - -
1142f858 by Cheng Shao at 2023-01-13T11:04:00+00:00
Bump hsc2hs submodule

- - - - -
d4686729 by Cheng Shao at 2023-01-13T11:04:00+00:00
Bump process submodule

- - - - -
84ae6573 by Cheng Shao at 2023-01-13T11:06:58+00:00
ci: Bump DOCKER_REV

- - - - -
d53598c5 by Cheng Shao at 2023-01-13T11:06:58+00:00
ci: enable xz parallel compression for x64 jobs

- - - - -
d31fcbca by Cheng Shao at 2023-01-13T11:06:58+00:00
ci: use in-image emsdk for js jobs

- - - - -
93b9bbc1 by Cheng Shao at 2023-01-13T11:47:17+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.

- - - - -
8acc56c7 by Cheng Shao at 2023-01-13T11:47:17+00:00
ci: source the toolchain env file in wasm jobs

- - - - -
87194df0 by Cheng Shao at 2023-01-13T11:47:17+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.

- - - - -
b6eb9bcc by Matthew Pickering at 2023-01-13T11:52:16+00:00
wasm ci: Remove wasm release jobs

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

- - - - -
496607fd by Simon Peyton Jones at 2023-01-13T16:52:07-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.

- - - - -
7a9a1042 by Andreas Klebinger at 2023-01-16T20:48:19-05:00
Separate core inlining logic from `Unfolding` type.

This seems like a good idea either way, but is mostly motivated by a
patch where this avoids a module loop.

- - - - -
33b58f77 by sheaf at 2023-01-16T20:48:57-05:00
Hadrian: generalise &%> to avoid warnings

This patch introduces a more general version of &%> that works
with general traversable shapes, instead of lists. This allows us
to pass along the information that the length of the list of filepaths
passed to the function exactly matches the length of the input list
of filepath patterns, avoiding pattern match warnings.

Fixes #22430

- - - - -
8c7a991c by Andreas Klebinger at 2023-01-16T20:49:34-05:00
Add regression test for #22611.

A case were a function used to fail to specialize, but now does.

- - - - -
6abea760 by Andreas Klebinger at 2023-01-16T20:50:10-05:00
Mark maximumBy/minimumBy as INLINE.

The RHS was too large to inline which often prevented the overhead of the Maybe
from being optimized away. By marking it as INLINE we can eliminate the
overhead of both the maybe and are able to unpack the accumulator when
possible.

Fixes #22609

- - - - -
99d151bb by Matthew Pickering at 2023-01-16T20:50:50-05:00
ci: Bump CACHE_REV so that ghc-9.6 branch and HEAD have different caches

Having the same CACHE_REV on both branches leads to issues where the
darwin toolchain is different on ghc-9.6 and HEAD which leads to long
darwin build times.

In general we should ensure that each branch has a different CACHE_REV.

- - - - -
6a5845fb by Matthew Pickering at 2023-01-16T20:51:25-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
```

- - - - -
4afb952c by Matthew Pickering at 2023-01-16T20:51:25-05:00
ci: Don't build aarch64-deb10-llvm job on release pipelines

Closes #22721

- - - - -
8039feb9 by Matthew Pickering at 2023-01-16T20:51:25-05:00
ci: Change owner of files in test-bootstrap job

- - - - -
0b358d0c by Matthew Pickering at 2023-01-16T20:51:25-05: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.

- - - - -
28cb2ed0 by Matthew Pickering at 2023-01-16T20:51:25-05: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.

- - - - -
eeea59bb by Matthew Pickering at 2023-01-16T20:51:26-05: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.

- - - - -
97bd4d8c by Andrew Lelechenko at 2023-01-16T20:52:04-05:00
Bump submodule parsec to 3.1.16.1

- - - - -
97ac8230 by Alan Zimmerman at 2023-01-16T20:52:39-05:00
EPA: Add annotation for 'type' in DataDecl

Closes #22765

- - - - -
dbbab95d by Ben Gamari at 2023-01-17T06:36:06-05:00
compiler: Small optimisation of assertM

In #22739 @AndreasK noticed that assertM performed the action to compute
the asserted predicate regardless of whether DEBUG is enabled. This is
inconsistent with the other assertion operations and general convention.
Fix this.

Closes #22739.

- - - - -
fc02f3bb by Viktor Dukhovni at 2023-01-17T06:36:47-05:00
Avoid unnecessary printf warnings in EventLog.c

Fixes #22778

- - - - -
003b6d44 by Simon Peyton Jones at 2023-01-17T16:33:05-05:00
Document the semantics of pattern bindings a bit better

This MR is in response to the discussion on #22719

- - - - -
f4d50baf by Vladislav Zavialov at 2023-01-17T16:33:41-05:00
Hadrian: fix warnings (#22783)

This change fixes the following warnings when building Hadrian:

	src/Hadrian/Expression.hs:38:10: warning: [-Wredundant-constraints]
	src/Hadrian/Expression.hs:84:13: warning: [-Wtype-equality-requires-operators]
	src/Hadrian/Expression.hs:84:21: warning: [-Wtype-equality-requires-operators]
	src/Hadrian/Haskell/Cabal/Parse.hs:67:1: warning: [-Wunused-imports]

- - - - -
06036d93 by Sylvain Henry at 2023-01-18T01:55:10-05:00
testsuite: req_smp --> req_target_smp, req_ghc_smp

See #22630 and !9552

This commit:
 - splits req_smp into req_target_smp and req_ghc_smp
 - changes the testsuite driver to calculate req_ghc_smp
 - changes a handful of tests to use req_target_smp instead of req_smp
 - changes a handful of tests to use req_host_smp when needed

The problem:
 - the problem this solves is the ambiguity surrounding req_smp
 - on master req_smp was used to express the constraint that the program
 being compiled supports smp _and_ that the host RTS (i.e., the RTS used
 to compile the program) supported smp. Normally that is fine, but in
 cross compilation this is not always the case as was discovered in #22630.

The solution:
 - Differentiate the two constraints:
   - use req_target_smp to say the RTS the compiled program is linked
   with (and the platform) supports smp
   - use req_host_smp to say the RTS the host is linked with supports smp

WIP: fix req_smp (target vs ghc)

add flag to separate bootstrapper

split req_smp -> req_target_smp and req_ghc_smp

update tests smp flags

cleanup and add some docstrings

only set ghc_with_smp to bootstrapper on S1 or CC

Only set ghc_with_smp to bootstrapperWithSMP of when testing stage 1
and cross compiling

test the RTS in config/ghc not hadrian

re-add ghc_with_smp

fix and align req names

fix T11760 to use req_host_smp

test the rts directly, avoid python 3.5 limitation

test the compiler in a try block

align out of tree and in tree withSMP flags

mark failing tests as host req smp

testsuite: req_host_smp --> req_ghc_smp

Fix ghc vs host, fix ghc_with_smp leftover

- - - - -
ee9b78aa by Krzysztof Gogolewski at 2023-01-18T01:55:45-05:00
Use -Wdefault when running Python testdriver (#22727)

- - - - -
e9c0537c by Vladislav Zavialov at 2023-01-18T01:56:22-05: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.

- - - - -
4efee43d by Ryan Scott at 2023-01-18T01:56:59-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.

- - - - -
f891a442 by Ben Gamari at 2023-01-18T07:28:00-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.

- - - - -
b13c6ea5 by Ben Gamari at 2023-01-18T07:28:00-05:00
Bump gmp-tarballs submodule

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

- - - - -
c45a5fff by Cheng Shao at 2023-01-18T07:28:37-05: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.

- - - - -
b4c14c4b by Luite Stegeman at 2023-01-18T14:21:42-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

- - - - -
d0a63ef8 by Adam Gundry at 2023-01-18T14:22:26-05:00
Refactor warning flag parsing to add missing flags

This adds `-Werror=<group>` and `-fwarn-<group>` flags for warning
groups as well as individual warnings. Previously these were defined
on an ad hoc basis so for example we had `-Werror=compat` but not
`-Werror=unused-binds`, whereas we had `-fwarn-unused-binds` but not
`-fwarn-compat`. Fixes #22182.

- - - - -
7ed1b8ef by Adam Gundry at 2023-01-18T14:22:26-05:00
Minor corrections to comments

- - - - -
5389681e by Adam Gundry at 2023-01-18T14:22:26-05:00
Revise warnings documentation in user's guide

- - - - -
ab0d5cda by Adam Gundry at 2023-01-18T14:22:26-05:00
Move documentation of deferred type error flags out of warnings section

- - - - -
eb5a6b91 by John Ericson at 2023-01-18T22:24:10-05:00
Give the RTS it's own configure script

Currently it doesn't do much anything, we are just trying to introduce
it without breaking the build. Later, we will move functionality from
the top-level configure script over to it.

We need to bump Cabal for https://github.com/haskell/cabal/pull/8649; to
facilitate and existing hack of skipping some configure checks for the
RTS we now need to skip just *part* not *all* of the "post configure"
hook, as running the configure script (which we definitely want to do)
is also implemented as part of the "post configure" hook. But doing this
requires exposing functionality that wasn't exposed before.

- - - - -
32ab07bf by Andrew Lelechenko at 2023-01-18T22:24:51-05:00
ghc package does not have to depend on terminfo

- - - - -
981ff7c4 by Andrew Lelechenko at 2023-01-18T22:24:51-05:00
ghc-pkg does not have to depend on terminfo

- - - - -
f058e367 by Ben Gamari at 2023-01-18T22:25:27-05: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.

- - - - -
154889db by Ryan Scott at 2023-01-18T22:26:03-05:00
Add regression test for #22151

Issue #22151 was coincidentally fixed in commit
aed1974e92366ab8e117734f308505684f70cddf (`Refactor the treatment of loopy
superclass dicts`). This adds a regression test to ensure that the issue
remains fixed.

Fixes #22151.

- - - - -
14b5982a by Andrei Borzenkov at 2023-01-18T22:26:43-05: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.

- - - - -
1fe806d3 by Cheng Shao at 2023-01-23T04:48:47-05: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.

- - - - -
317cad26 by Cheng Shao at 2023-01-23T04:48:47-05:00
hadrian: add missing docs for recently added flavour transformers

- - - - -
658f4446 by Ben Gamari at 2023-01-23T04:49:23-05:00
gitlab-ci: Add Rocky8 jobs

Addresses #22268.

- - - - -
a83ec778 by Vladislav Zavialov at 2023-01-23T04:49:58-05:00
Set "since: 9.8" for TypeAbstractions and -Wterm-variable-capture

These flags did not make it into the 9.6 release series,
so the "since" annotations must be corrected.

- - - - -
fec7c2ea by Alan Zimmerman at 2023-01-23T04:50:33-05:00
EPA: Add SourceText to HsOverLabel

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

Close #22771

- - - - -
3efd1e99 by Ben Gamari at 2023-01-23T04:51:08-05:00
template-haskell: Bump version to 2.20.0.0

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

Addresses #22767.

- - - - -
0900b584 by Cheng Shao at 2023-01-23T04:51:45-05: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).

- - - - -
db0f1bfd by Cheng Shao at 2023-01-23T04:52:21-05: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.

- - - - -
9222b167 by Matthew Pickering at 2023-01-23T04:52:57-05:00
ghcup metadata: Fix subdir for windows bindist

- - - - -
9a9bec57 by Matthew Pickering at 2023-01-23T04:52:57-05:00
ghcup metadata: Remove viPostRemove field from generated metadata

This has been removed from the downstream metadata.

- - - - -
82884ce0 by Simon Peyton Jones at 2023-01-23T04:53:32-05:00
Fix #22742

runtimeRepLevity_maybe was panicing unnecessarily; and
the error printing code made use of the case when it should
return Nothing rather than panicing.

For some bizarre reason perf/compiler/T21839r shows a 10% bump in runtime
peak-megagbytes-used, on a single architecture (alpine). See !9753 for
commentary, but I'm going to accept it.

Metric Increase:
    T21839r

- - - - -
2c6deb18 by Bryan Richter at 2023-01-23T14:12:22+02:00
codeowners: Add Ben, Matt, and Bryan to CI

- - - - -
eee3bf05 by Matthew Craven at 2023-01-23T21:46:41-05:00
Do not collect compile-time metrics for T21839r

...the testsuite doesn't handle this properly since it
also collects run-time metrics.  Compile-time metrics
for this test are already tracked via T21839c.

Metric Decrease:
    T21839r

- - - - -
1d1dd3fb by Matthew Pickering at 2023-01-24T05:37:52-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

- - - - -
7bfb30f9 by Matthew Pickering at 2023-01-24T05:37:52-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

- - - - -
69500dd4 by Matthew Pickering at 2023-01-24T05:37:52-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

- - - - -
336b2b1c by Matthew Pickering at 2023-01-24T05:37:52-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

- - - - -
6469fea7 by Matthew Pickering at 2023-01-24T05:37:52-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

- - - - -
06cc0a95 by Matthew Pickering at 2023-01-24T05:37:52-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

- - - - -
4fe9eaff by Matthew Pickering at 2023-01-24T05:37:52-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

- - - - -
ada29f5c by Matthew Pickering at 2023-01-24T05:37:52-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

- - - - -
be701cc6 by Matthew Pickering at 2023-01-24T05:37:52-05:00
Debug: Print full NodeKey when pretty printing ModuleGraphNode

This is helpful when debugging multiple component issues.

- - - - -
34d2d463 by Krzysztof Gogolewski at 2023-01-24T05:38:32-05:00
Fix Lint check for duplicate external names

Lint was checking for duplicate external names by calling removeDups,
which needs a comparison function that is passed to Data.List.sortBy.
But the comparison was not a valid ordering - it returned LT
if one of the names was not external.
For example, the previous implementation won't find a duplicate in
[M.x, y, M.x].
Instead, we filter out non-external names before looking for duplicates.

- - - - -
1c050ed2 by Matthew Pickering at 2023-01-24T05:39:08-05:00
Add test for T22671

This was fixed by b13c6ea5

Closes #22671

- - - - -
05e6a2d9 by Tom Ellis at 2023-01-24T12:10:52-05:00
Clarify where `f` is defined

- - - - -
d151546e by Cheng Shao at 2023-01-24T12:11:29-05: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

- - - - -
e5383a29 by Wander Hillen at 2023-01-24T20:02:26-05:00
Allow waiting for timerfd to be interrupted during rts shutdown

- - - - -
1957eda1 by Ryan Scott at 2023-01-24T20:03:01-05:00
Restore Compose's Read/Show behavior to match Read1/Show1 instances

Fixes #22816.

- - - - -
30972827 by Matthew Pickering at 2023-01-25T03:54:14-05:00
docs: Update INSTALL.md

Removes references to make.

Fixes #22480

- - - - -
bc038c3b by Cheng Shao at 2023-01-25T03:54:50-05: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.

- - - - -
e987e345 by Sylvain Henry at 2023-01-25T14:47:41-05: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.

- - - - -
48131ee2 by Sylvain Henry at 2023-01-25T14:47:41-05:00
Hadrian: fix Windows cross-compilation

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

- - - - -
288fa017 by Sylvain Henry at 2023-01-25T14:47:41-05:00
Fix RTS build on Windows

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

- - - - -
2fdf22ae by Sylvain Henry at 2023-01-25T14:47:41-05:00
configure: support "windows" as an OS

- - - - -
13a0566b by Simon Peyton Jones at 2023-01-25T14:48:16-05: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.

- - - - -
b7efdb24 by Matthew Pickering at 2023-01-25T14:48:51-05:00
ci: Disable HLint job due to excessive runtime

The HLint jobs takes much longer to run (20 minutes) after "Give the RTS it's own configure script" eb5a6b91

Now the CI job will build the stage0 compiler before it generates the necessary RTS headers.

We either need to:

* Fix the linting rules so they take much less time
* Revert the commit
* Remove the linting of base from the hlint job
* Remove the hlint job

This is highest priority as it is affecting all CI pipelines.

For now I am just disabling the job because there are many more pressing
matters at hand.

Ticket #22830

- - - - -
1bd32a35 by Sylvain Henry at 2023-01-26T12:34:21-05:00
Factorize hptModulesBelow

Create and use moduleGraphModulesBelow in GHC.Unit.Module.Graph that
doesn't need anything from the driver to be used.

- - - - -
1262d3f8 by Matthew Pickering at 2023-01-26T12:34:56-05: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

- - - - -
e27eb80c by Matthew Pickering at 2023-01-26T12:34:56-05: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

- - - - -
3d004d5a by Matthew Pickering at 2023-01-26T12:34:56-05: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

- - - - -
f2a0fea0 by Matthew Pickering at 2023-01-26T12:34:56-05:00
Strict fields in ModNodeKey (otherwise retains HomeModInfo)

Towards #22530

- - - - -
5640cb1d by Sylvain Henry at 2023-01-26T12:35:36-05:00
Hadrian: fix doc generation

Was missing dependencies on files generated by templates (e.g.
ghc.cabal)

- - - - -
3e827c3f by Richard Eisenberg at 2023-01-26T20:06:53-05:00
Do newtype unwrapping in the canonicaliser and rewriter

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

Close #22519.

- - - - -
b3ef5c89 by doyougnu at 2023-01-26T20:07:48-05:00
tryFillBuffer: strictify

more speculative bangs

- - - - -
d0d7ba0f by Vladislav Zavialov at 2023-01-26T20:08:25-05:00
base: NoImplicitPrelude in Data.Void and Data.Kind

This change removes an unnecessary dependency on Prelude
from two modules in the base package.

- - - - -
fa1db923 by Matthew Pickering at 2023-01-26T20:09:00-05: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

- - - - -
807310a1 by Matthew Pickering at 2023-01-26T20:09:00-05:00
rel-eng: Add missing rocky8 bindist

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

- - - - -
c7116b10 by Ben Gamari at 2023-01-26T20:09:35-05:00
base: Make changelog proposal references more consistent

Addresses #22773.

- - - - -
6932cfc7 by Sylvain Henry at 2023-01-26T20:10:27-05:00
Fix spurious change from !9568

- - - - -
e480fbc2 by Ben Gamari at 2023-01-27T05:01:24-05: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

- - - - -
2648c09c by Andrei Borzenkov at 2023-01-27T05:02:07-05:00
Replace errors from badOrigBinding with new one (#22839)

Problem: in 02279a9c the type-level [] syntax was changed from a built-in name
to an alias for the GHC.Types.List constructor. badOrigBinding assumes that if
a name is not built-in then it must have come from TH quotation, but this is
not necessarily the case with [].

The outdated assumption in badOrigBinding leads to incorrect error messages.
This code:
  data []
Fails with "Cannot redefine a Name retrieved by a Template Haskell quote: []"

Unfortunately, there is not enough information in RdrName to directly determine
if the name was constructed via TH or by the parser, so this patch changes the
error message instead.

It unifies TcRnIllegalBindingOfBuiltIn and TcRnNameByTemplateHaskellQuote
into a new error TcRnBindingOfExistingName and changes its wording to avoid
guessing the origin of the name.

- - - - -
545bf8cf by Matthew Pickering at 2023-01-27T14:58:53+00:00
Revert "base: NoImplicitPrelude in Data.Void and Data.Kind"

Fixes CI errors of the form.

```
===> Command failed with error code: 1
ghc: panic! (the 'impossible' happened)
  GHC version 9.7.20230127:
	lookupGlobal
  Failed to load interface for ‘GHC.Num.BigNat’
  There are files missing in the ‘ghc-bignum’ package,
  try running 'ghc-pkg check'.
  Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/GHC/Utils/Panic.hs:189:37 in ghc:GHC.Utils.Panic
        pprPanic, called at compiler/GHC/Tc/Utils/Env.hs:154:32 in ghc:GHC.Tc.Utils.Env
  CallStack (from HasCallStack):
    panic, called at compiler/GHC/Utils/Error.hs:454:29 in ghc:GHC.Utils.Error
Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug
```

This reverts commit d0d7ba0fb053ebe7f919a5932066fbc776301ccd.

The module now lacks a dependency on GHC.Num.BigNat which it implicitly
depends on. It is causing all CI jobs to fail so we revert without haste
whilst the patch can be fixed.

Fixes #22848

- - - - -
638277ba by Simon Peyton Jones at 2023-01-27T23:54:55-05: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

- - - - -
46a53bb2 by Simon Peyton Jones at 2023-01-27T23:54:55-05:00
Report family instance orphans correctly

This fixes the fact that we were not reporting orphan family instances
at all. The fix here is easy, but touches a bit of code. I refactored
the code to be much more similar to the way that class instances are done:

   - Add a fi_orphan field to FamInst, like the is_orphan field in ClsInst
   - Make newFamInst initialise this field, just like newClsInst
   - And make newFamInst report a warning for an orphan, just like newClsInst
   - I moved newFamInst from GHC.Tc.Instance.Family to GHC.Tc.Utils.Instantiate,
     just like newClsInst.
   - I added mkLocalFamInst to FamInstEnv, just like mkLocalClsInst in InstEnv
   - TcRnOrphanInstance and SuggestFixOrphanInstance are now parametrised
     over class instances vs type/data family instances.

Fixes #19773

- - - - -
faa300fb by Simon Peyton Jones at 2023-01-27T23:54:55-05:00
Avoid orphans in STG

This patch removes some orphan instances in the STG namespace
by introducing the GHC.Stg.Lift.Types module, which allows various
type family instances to be moved to GHC.Stg.Syntax, avoiding orphan
instances.

- - - - -
0f25a13b by Simon Peyton Jones at 2023-01-27T23:54:55-05:00
Avoid orphans in the parser

This moves Anno instances for PatBuilder from GHC.Parser.PostProcess
to GHC.Parser.Types to avoid orphans.

- - - - -
15750d33 by Simon Peyton Jones at 2023-01-27T23:54:55-05:00
Accept an orphan declaration (sadly)

This accepts the orphan type family instance

  type instance DsForeignHook = ...

in GHC.HsToCore.Types.

See Note [The Decoupling Abstract Data Hack] in GHC.Driver.Hooks

- - - - -
c9967d13 by Zubin Duggal at 2023-01-27T23:55:31-05:00
bindist configure: Fail if find not found (#22691)

- - - - -
ad8cfed4 by John Ericson at 2023-01-27T23:56:06-05:00
Put hadrian bootstrap plans through `jq`

This makes it possible to review changes with conventional diffing
tools.

- - - - -
d0ddc01b by Ben Gamari at 2023-01-27T23:56:42-05:00
testsuite: Introduce threaded2_sanity way

Incredibly, we previously did not have a single way which would test the
threaded RTS with multiple capabilities and the sanity-checker enabled.

- - - - -
38ad8351 by Ben Gamari at 2023-01-27T23:56:42-05:00
rts: Relax Messages assertion

`doneWithMsgThrowTo` was previously too strict in asserting that the
`Message` is locked. Specifically, it failed to consider that the
`Message` may not be locked if we are deleting all threads during RTS
shutdown.

- - - - -
a9fe81af by Ben Gamari at 2023-01-27T23:56:42-05:00
testsuite: Fix race in UnliftedTVar2

Previously UnliftedTVar2 would fail when run with multiple capabilities
(and possibly even with one capability) as it would assume that
`killThread#` would immediately kill the "increment" thread.

Also, refactor the the executable to now succeed with no output and
fails with an exit code.

- - - - -
8519af60 by Ben Gamari at 2023-01-27T23:56:42-05:00
testsuite: Make listThreads more robust

Previously it was sensitive to the labels of threads which it did not
create (e.g. the IO manager event loop threads). Fix this.

- - - - -
55a81995 by Ben Gamari at 2023-01-27T23:56:43-05:00
rts: Fix non-atomic mutation of enabled_capabilities

- - - - -
b5c75f1d by Ben Gamari at 2023-01-27T23:56:43-05:00
rts: Fix C++ compilation issues

Make the RTS compilable with a C++ compiler by inserting necessary
casts.

- - - - -
c261b62f by Ben Gamari at 2023-01-27T23:56:43-05:00
rts: Fix typo

"tracingAddCapabilities" was mis-named

- - - - -
77fdbd3f by Ben Gamari at 2023-01-27T23:56:43-05:00
rts: Drop long-dead fallback definitions for INFINITY & NAN

These are no longer necessary since we now compile as C99.

- - - - -
56c1bd98 by Ben Gamari at 2023-01-28T02:57:59-05:00
Revert "CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043)"

This reverts commit 99aca26b652603bc62953157a48e419f737d352d.

- - - - -
b3a3534b by nineonine at 2023-01-28T02:57:59-05: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.

- - - - -
082b7d43 by Oleg Grenrus at 2023-01-28T02:58:38-05:00
Add Foldable1 Solo instance

- - - - -
50b1e2e8 by Andrei Borzenkov at 2023-01-28T02:59:18-05:00
Convert diagnostics in GHC.Rename.Bind to proper TcRnMessage (#20115)

I removed all occurrences of TcRnUnknownMessage in GHC.Rename.Bind
module. Instead, these TcRnMessage messages were introduced:
  TcRnMultipleFixityDecls
  TcRnIllegalPatternSynonymDecl
  TcRnIllegalClassBiding
  TcRnOrphanCompletePragma
  TcRnEmptyCase
  TcRnNonStdGuards
  TcRnDuplicateSigDecl
  TcRnMisplacedSigDecl
  TcRnUnexpectedDefaultSig
  TcRnBindInBootFile
  TcRnDuplicateMinimalSig

- - - - -
3330b819 by Matthew Pickering at 2023-01-28T02:59:54-05:00
hadrian: Fix library-dirs, dynamic-library-dirs and static-library-dirs in inplace .conf files

Previously we were just throwing away the contents of the library-dirs
fields but really we have to do the same thing as for include-dirs,
relativise the paths into the current working directory and maintain any
extra libraries the user has specified.

Now the relevant section of the rts.conf file looks like:

```
library-dirs:
    ${pkgroot}/../rts/build
    ${pkgroot}/../../..//_build/stage1/rts/build
    /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib
    /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib

library-dirs-static:
    ${pkgroot}/../rts/build
    ${pkgroot}/../../..//_build/stage1/rts/build
    /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib
    /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib

dynamic-library-dirs:
    ${pkgroot}/../rts/build
    ${pkgroot}/../../..//_build/stage1/rts/build
    /nix/store/av4c0fib4rkmb6sa1074z0rb1ciria5b-gperftools-2.10/lib
    /nix/store/2infxahfp9lj084xn3q9ib5ajks8447i-libffi-3.4.4/lib
```

Fixes #22209

- - - - -
c9ad8852 by Andrew Lelechenko at 2023-01-28T03:00:33-05:00
Document differences between Data.{Monoid,Semigroup}.{First,Last}

- - - - -
7e11c6dc by Cheng Shao at 2023-01-28T03:01:09-05: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.

- - - - -
6ea2aa02 by Cheng Shao at 2023-01-28T03:01:46-05: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.

- - - - -
2b62739d by Andrew Lelechenko at 2023-01-28T17:16:11-05:00
Assorted changes to avoid Data.List.{head,tail}

- - - - -
78c07219 by Cheng Shao at 2023-01-28T17:16:48-05: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.

- - - - -
8bed166b by Ben Gamari at 2023-01-30T05:06:26-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.

- - - - -
da468391 by Cheng Shao at 2023-01-30T05:07:03-05: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.

- - - - -
08ba8720 by Andreas Klebinger at 2023-01-30T21:18:45-05: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
-------------------------

- - - - -
20598ef6 by Ryan Scott at 2023-01-30T21:19:20-05: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.

- - - - -
2f145052 by Ryan Scott at 2023-01-30T21:19:56-05: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.

- - - - -
d0f34f25 by Simon Peyton Jones at 2023-01-30T21:20:35-05: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.)

- - - - -
de963cb6 by Matthew Pickering at 2023-01-30T21:21:11-05:00
ci: Remove FreeBSD job from release pipelines

We no longer attempt to build or distribute this release

- - - - -
f26d27ec by Matthew Pickering at 2023-01-30T21:21:11-05: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.

- - - - -
7619c0b4 by Matthew Pickering at 2023-01-30T21:21:11-05:00
rel_eng: Fix the name of the ubuntu-* jobs

These were not uploaded for alpha1

Fixes #22844

- - - - -
68eb8877 by Matthew Pickering at 2023-01-30T21:21:11-05: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.

- - - - -
b69461a0 by Jason Shipman at 2023-01-30T21:21:50-05:00
User's guide: Clarify overlapping instance candidate elimination

This commit updates the user's guide section on overlapping instance candidate
elimination to use "or" verbiage instead of "either/or" in regards to the
current pair of candidates' being overlappable or overlapping. "Either IX is
overlappable, or IY is overlapping" can cause confusion as it suggests "Either
IX is overlappable, or IY is overlapping, but not both".

This was initially discussed on this Discourse topic:

https://discourse.haskell.org/t/clarification-on-overlapping-instance-candidate-elimination/5677

- - - - -
7cbdaad0 by Matthew Pickering at 2023-01-31T07:53:53-05: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

- - - - -
fd8f32bf by Cheng Shao at 2023-01-31T07:54:29-05: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.

- - - - -
085a6db6 by Joachim Breitner at 2023-01-31T07:55:05-05:00
Update note at beginning of GHC.Builtin.NAmes

some things have been renamed since it was written, it seems.

- - - - -
7716cbe6 by Cheng Shao at 2023-01-31T07:55:41-05: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.

- - - - -
19c1fbcd by doyougnu at 2023-01-31T13:08:03-05:00
InfoTableProv: ShortText --> ShortByteString

- - - - -
765fab98 by doyougnu at 2023-01-31T13:08:03-05:00
FastString: add fastStringToShorText

- - - - -
a83c810d by Simon Peyton Jones at 2023-01-31T13:08:38-05:00
Improve exprOkForSpeculation for classops

This patch fixes #22745 and #15205, which are about GHC's
failure to discard unnecessary superclass selections that
yield coercions.  See
  GHC.Core.Utils Note [exprOkForSpeculation and type classes]

The main changes are:

* Write new Note [NON-BOTTOM_DICTS invariant] in GHC.Core, and
  refer to it

* Define new function isTerminatingType, to identify those
  guaranteed-terminating dictionary types.

* exprOkForSpeculation has a new (very simple) case for ClassOpId

* ClassOpId has a new field that says if the return type is
  an unlifted type, or a terminating type.

This was surprisingly tricky to get right.  In particular note
that unlifted types are not terminating types; you can write an
expression of unlifted type, that diverges.  Not so for dictionaries
(or, more precisely, for the dictionaries that GHC constructs).

Metric Decrease:
    LargeRecord

- - - - -
f83374f8 by Krzysztof Gogolewski at 2023-01-31T13:09:14-05:00
Support "unusable UNPACK pragma" warning with -O0

Fixes #11270

- - - - -
a2d814dc by Ben Gamari at 2023-01-31T13:09:50-05: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.

- - - - -
5618fc21 by sheaf at 2023-01-31T15:51:06-05:00
Cmm: track the type of global registers

This patch tracks the type of Cmm global registers. This is needed
in order to lint uses of polymorphic registers, such as SIMD vector
registers that can be used both for floating-point and integer values.

This changes allows us to refactor VanillaReg to not store VGcPtr,
as that information is instead stored in the type of the usage of the
register.

Fixes #22297

- - - - -
78b99430 by sheaf at 2023-01-31T15:51:06-05:00
Revert "Cmm Lint: relax SIMD register assignment check"

This reverts commit 3be48877, which weakened a Cmm Lint check involving
SIMD vectors. Now that we keep track of the type a global register is
used at, we can restore the original stronger check.

- - - - -
be417a47 by Ben Gamari at 2023-01-31T15:51:45-05: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.

- - - - -
30989d13 by Ben Gamari at 2023-01-31T15:51:45-05: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.

- - - - -
7566fd9d by Ben Gamari at 2023-01-31T15:51:45-05: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.

- - - - -
2cb500a5 by Ben Gamari at 2023-01-31T15:51:45-05:00
testsuite: Add regression test for #22798

- - - - -
03d693b2 by Ben Gamari at 2023-01-31T15:52:32-05:00
Revert "Hadrian: fix doc generation"

This is too large of a hammer.

This reverts commit 5640cb1d84d3cce4ce0a9e90d29b2b20d2b38c2f.

- - - - -
f838815c by Ben Gamari at 2023-01-31T15:52:32-05: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.

- - - - -
2e48c19a by Ben Gamari at 2023-01-31T15:52:32-05: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.

- - - - -
93f0e3c4 by Ben Gamari at 2023-01-31T15:52:33-05:00
hadrian: Substitute LIBRARY_*_VERSION variables

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

Fixes #22714.

- - - - -
22089f69 by Ben Gamari at 2023-01-31T20:46:27-05:00
Bump transformers submodule to 0.6.0.6

Fixes #22862.

- - - - -
f0eefa3c by Cheng Shao at 2023-01-31T20:47:03-05: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.

- - - - -
9f95db54 by Simon Peyton Jones at 2023-02-01T08:55:08+00: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

- - - - -
955a99ea by Simon Peyton Jones at 2023-02-01T12:31:23-05: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.

- - - - -
0cc16aaf by Matthew Pickering at 2023-02-01T12:31:58-05: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

- - - - -
f94f1450 by Matthew Pickering at 2023-02-01T12:31:58-05: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.

- - - - -
083e26ed by Matthew Pickering at 2023-02-01T17:43:21-05:00
Remove tracing OPTIONS_GHC

These were accidentally left over from !9542

- - - - -
354aa47d by Teo Camarasu at 2023-02-01T17:44:00-05:00
doc: fix gcdetails_block_fragmentation_bytes since annotation

- - - - -
61ce5bf6 by Jaro Reinders at 2023-02-02T00:15:30-05:00
compiler: Implement higher order patterns in the rule matcher

This implements proposal 555 and closes ticket #22465.
See the proposal and ticket for motivation.

The core changes of this patch are in the GHC.Core.Rules.match function
and they are explained in the Note [Matching higher order patterns].

- - - - -
394b91ce by doyougnu at 2023-02-02T00:16:10-05:00
CI: JavaScript backend runs testsuite

This MR runs the testsuite for the JS backend. Note that this is a
temporary solution until !9515 is merged.

Key point: The CI runs hadrian on the built cross compiler _but not_ on
the bindist.

Other Highlights:

 - stm submodule gets a bump to mark tests as broken
 - several tests are marked as broken or are fixed by adding more
 - conditions to their test runner instance.

List of working commit messages:

CI: test cross target _and_ emulator

CI: JS: Try run testsuite with hadrian

JS.CI: cleanup and simplify hadrian invocation

use single bracket, print info

JS CI: remove call to test_compiler from hadrian

don't build haddock

JS: mark more tests as broken

Tracked in https://gitlab.haskell.org/ghc/ghc/-/issues/22576

JS testsuite: don't skip sum_mod test

Its expected to fail, yet we skipped it which automatically makes it
succeed leading to an unexpected success,

JS testsuite: don't mark T12035j as skip

leads to an unexpected pass

JS testsuite: remove broken on T14075

leads to unexpected pass

JS testsuite: mark more tests as broken

JS testsuite: mark T11760 in base as broken

JS testsuite: mark ManyUnbSums broken

submodules: bump process and hpc for JS tests

Both submodules has needed tests skipped or marked broken for th JS
backend. This commit now adds these changes to GHC.

See:

HPC: https://gitlab.haskell.org/hpc/hpc/-/merge_requests/21

Process: https://github.com/haskell/process/pull/268

remove js_broken on now passing tests

separate wasm and js backend ci

test: T11760: add threaded, non-moving only_ways

test: T10296a add req_c

T13894: skip for JS backend

tests: jspace, T22333: mark as js_broken(22573)

test: T22513i mark as req_th

stm submodule: mark stm055, T16707 broken for JS

tests: js_broken(22374) on unpack_sums_6, T12010

dont run diff on JS CI, cleanup

fixup: More CI cleanup

fix: align text to master

fix: align exceptions submodule to master

CI: Bump DOCKER_REV

Bump to ci-images commit that has a deb11 build with node. Required for
!9552

testsuite: mark T22669 as js_skip

See #22669

This test tests that .o-boot files aren't created when run in using the
interpreter backend. Thus this is not relevant for the JS backend.

testsuite: mark T22671 as broken on JS

See #22835

base.testsuite: mark Chan002 fragile for JS

see #22836

revert: submodule process bump

bump stm submodule

New hash includes skips for the JS backend.

testsuite: mark RnPatternSynonymFail broken on JS

Requires TH:
 - see !9779
 - and #22261

compiler: GHC.hs ifdef import Utils.Panic.Plain

- - - - -
1ffe770c by Cheng Shao at 2023-02-02T09:40:38+00:00
docs: 9.6 release notes for wasm backend

- - - - -
0ada4547 by Matthew Pickering at 2023-02-02T11:39:44-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

- - - - -
7e2d3eb5 by lrzlin at 2023-02-03T05:23:27-05:00
Enable tables next to code for LoongArch64

- - - - -
2931712a by Wander Hillen at 2023-02-03T05:24:06-05:00
Move pthread and timerfd ticker implementations to separate files

- - - - -
41c4baf8 by Ben Gamari at 2023-02-03T05:24:44-05:00
base: Fix Note references in GHC.IO.Handle.Types

- - - - -
31358198 by Andrew Lelechenko at 2023-02-03T05:25:22-05:00
Bump submodule containers to 0.6.7

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

- - - - -
8feb9301 by Ben Gamari at 2023-02-03T05:25:59-05:00
gitlab-ci: Eliminate redundant ghc --info output

Previously ci.sh would emit the output of `ghc --info` every time it ran
when using the nix toolchain. This produced a significant amount of
noise.

See #22861.
- - - - -
de1d1512 by Ryan Scott at 2023-02-03T14:07:30-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
```

- - - - -
48e39195 by Tamar Christina at 2023-02-03T14:07:30-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.

- - - - -
b2bb3e62 by Ben Gamari at 2023-02-03T14:07:30-05:00
Bump Windows toolchain

Updates to LLVM 14, hopefully fixing #21964.

- - - - -
bf3f88a1 by Andreas Klebinger at 2023-02-03T14:08:07-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.

- - - - -
faea4bcd by j at 2023-02-03T14:08:47-05:00
Disable several ignore-warning flags in genapply.
- - - - -
25537dfd by Ben Gamari at 2023-02-04T04:12:57-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)

- - - - -
7612dc71 by Krzysztof Gogolewski at 2023-02-04T04:13:34-05:00
Minor refactor

* Introduce refactorDupsOn f = refactorDups (comparing f)
* Make mkBigTupleCase and coreCaseTuple monadic.
  Every call to those functions was preceded by calling newUniqueSupply.
* Use mkUserLocalOrCoVar, which is equivalent to combining
  mkLocalIdOrCoVar with mkInternalName.

- - - - -
5a54ac0b by Andrew Lelechenko at 2023-02-04T18:48:32-05:00
Fix colors in emacs terminal

- - - - -
3c0f0c6d by Andrew Lelechenko at 2023-02-04T18:49:11-05:00
base changelog: move entries which were not backported to ghc-9.6 to base-4.19 section

- - - - -
b18fbf52 by Josh Meredith at 2023-02-06T07:47:57+00:00
Update JavaScript fileStat to match Emscripten layout

- - - - -
6636b670 by Sylvain Henry at 2023-02-06T09:43:21-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>

- - - - -
77a8234c by Luite Stegeman at 2023-02-06T09:43:59-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

- - - - -
3e09cf82 by Jan Hrček at 2023-02-06T09:44:38-05:00
Remove extraneous word in Roles user guide

- - - - -
b17fb3d9 by sheaf at 2023-02-07T10:51:33-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

- - - - -
5dce04ee by romes at 2023-02-07T10:52:10-05:00
Update kinds in comments in GHC.Core.TyCon

Use `Type` instead of star kind (*)
Fix comment with incorrect kind * to have kind `Constraint`

- - - - -
92916194 by Ben Gamari at 2023-02-07T10:52:48-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)

- - - - -
c1670c6b by Sylvain Henry at 2023-02-07T21:25:18-05:00
JS: avoid head/tail and unpackFS

- - - - -
a9912de7 by Krzysztof Gogolewski at 2023-02-07T21:25:53-05:00
testsuite: Fix Python warnings (#22856)

- - - - -
9ee761bf by sheaf at 2023-02-08T14:40:40-05: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

- - - - -
7eac2468 by Matthew Pickering at 2023-02-08T14:41:17-05: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
-------------------------

- - - - -
633f2799 by Cheng Shao at 2023-02-08T18:42:16-05: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.

- - - - -
ca6673e3 by Cheng Shao at 2023-02-08T18:42:16-05: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.

- - - - -
f22cce70 by Alan Zimmerman at 2023-02-08T18:42:51-05: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

- - - - -
d69ecac2 by Josh Meredith at 2023-02-09T03:24:05-05:00
JS generated refs: update testsuite conditions

- - - - -
2ea1a6bc by sheaf at 2023-02-09T03:24:44-05:00
Bump transformers to 0.6.1.0

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

Updates transformers submodule.

- - - - -
d9d0c28d by konsumlamm at 2023-02-09T14:07:48-05:00
Update `Data.List.singleton` doc comment
- - - - -
fe9cd6ef by Ben Gamari at 2023-02-09T14:08:23-05:00
gitlab-template: Emphasize `user facing` label

My sense is that the current mention of the ~"user facing" label is
overlooked by many MR authors.

Let's move this point up in the list to make it more likely that it is
seen. Also rephrase some of the points.

- - - - -
e45eb828 by Simon Peyton Jones at 2023-02-10T06:51:28-05: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.

- - - - -
11e0cacb by Rebecca Turner at 2023-02-10T06:52:09-05:00
Detect the `mold` linker

Enables support for the `mold` linker by rui314.

- - - - -
59556235 by parsonsmatt at 2023-02-10T09:53:11-05:00
Add Lift instance for Fixed

- - - - -
c44e5f30 by Sylvain Henry at 2023-02-10T09:53:51-05:00
Testsuite: decrease length001 timeout for JS (#22921)

- - - - -
133516af by Zubin Duggal at 2023-02-10T09:54:27-05:00
compiler: Use NamedFieldPuns for `ModIface_` and `ModIfaceBackend` `NFData`
instances

This is a minor refactor that makes it easy to add and remove fields from
`ModIface_` and `ModIfaceBackend`.

Also change the formatting to make it clear exactly which fields are
fully forced with `rnf`

- - - - -
1e9eac1c by Matthew Pickering at 2023-02-13T11:36:41+01:00
Refresh profiling docs

I went through the whole of the profiling docs and tried to amend them
to reflect current best practices and tooling. In particular I removed
some old references to tools such as hp2any and replaced them with
references to eventlog2html.

- - - - -
da208b9a by Matthew Pickering at 2023-02-13T11:36:41+01:00
docs: Add section about profiling and foreign calls

Previously there was no documentation for how foreign calls interacted
with the profiler. This can be quite confusing for users so getting it
into the user guide is the first step to a potentially better solution.
See the ticket for more insightful discussion.

Fixes #21764

- - - - -
081640f1 by Andrew Lelechenko at 2023-02-13T12:51:52-05:00
Document that -fproc-alignment was introduced only in GHC 8.6

- - - - -
16adc349 by Sven Tennie at 2023-02-14T11:26:31-05:00
Add clangd flag to include generated header files

This enables clangd to correctly check C files that import Rts.h.
(The added include directory contains ghcautoconf.h et. al.)

- - - - -
c399ccd9 by amesgen at 2023-02-14T11:27:14-05:00
Mention new `Foreign.Marshal.Pool` implementation in User's Guide

- - - - -
b9282cf7 by Ben Gamari at 2023-02-14T11:27:50-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).

- - - - -
aa3a262d by PHO at 2023-02-14T11:28:29-05:00
Assume platforms support rpaths if they use either ELF or Mach-O

Not only Linux, Darwin, and FreeBSD support rpaths. Determine the usability
of rpaths based on the object format, not on OS.

- - - - -
47716024 by PHO at 2023-02-14T11:29:09-05:00
RTS linker: Improve compatibility with NetBSD

1. Hint address to NetBSD mmap(2) has a different semantics from that of
   Linux. When a hint address is provided, mmap(2) searches for a free
   region at or below the hint but *never* above it. This means we can't
   reliably search for free regions incrementally on the userland,
   especially when ASLR is enabled. Let the kernel do it for us if we don't
   care where the mapped address is going to be.

2. NetBSD not only hates to map pages as rwx, but also disallows to switch
   pages from rw- to r-x unless the intention is declared when pages are
   initially requested. This means we need a new MemoryAccess mode for
   pages that are going to be changed to r-x.

- - - - -
11de324a by Li-yao Xia at 2023-02-14T11:29:49-05:00
base: Move changelog entry to its place

- - - - -
75930424 by Ben Gamari at 2023-02-14T11:30:27-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.

- - - - -
d6411d6c by Andreas Klebinger at 2023-02-14T11:31:04-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

- - - - -
9fb4ca89 by sheaf at 2023-02-14T11:31:49-05: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

- - - - -
1928c7f3 by Cheng Shao at 2023-02-14T11:32:26-05:00
rts: make it possible to change mblock size on 32-bit targets

The MBLOCK_SHIFT macro must be the single source of truth for defining
the mblock size, and changing it should only affect performance, not
correctness. This patch makes it truly possible to reconfigure mblock
size, at least on 32-bit targets, by fixing places which implicitly
relied on the previous MBLOCK_SHIFT constant. Fixes #22901.

- - - - -
78aa3b39 by Simon Hengel at 2023-02-14T11:33:06-05:00
Update outdated references to notes

- - - - -
e8baecd2 by meooow25 at 2023-02-14T11:33:49-05:00
Documentation: Improve Foldable1 documentation

* Explain foldrMap1, foldlMap1, foldlMap1', and foldrMap1' in greater
  detail, the text is mostly adapted from documentation of Foldable.
* Describe foldr1, foldl1, foldl1' and foldr1' in terms of the above
  functions instead of redoing the full explanation.
* Small updates to documentation of fold1, foldMap1 and toNonEmpty,
  again adapting from Foldable.
* Update the foldMap1 example to lists instead of Sum since this is
  recommended for lazy right-associative folds.

Fixes #22847

- - - - -
85a1a575 by romes at 2023-02-14T11:34:25-05:00
fix: Mark ghci Prelude import as implicit

Fixes #22829

In GHCi, we were creating an import declaration for Prelude but we were
not setting it as an implicit declaration. Therefore, ghci's import of
Prelude triggered -Wmissing-import-lists.

Adds regression test T22829 to testsuite

- - - - -
3b019a7a by Cheng Shao at 2023-02-14T11:35:03-05: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.

- - - - -
08c0822c by doyougnu at 2023-02-15T00:16:39-05:00
docs: release notes, user guide: add js backend

Follow up from #21078

- - - - -
79d8fd65 by Bryan Richter at 2023-02-15T00:17:15-05:00
Allow failure in nightly-x86_64-linux-deb10-no_tntc-validate

See #22343

- - - - -
9ca51f9e by Cheng Shao at 2023-02-15T00:17:53-05:00
rts: add the rts_clearMemory function

This patch adds the rts_clearMemory function that does its best to
zero out unused RTS memory for a wasm backend use case. See the
comment above rts_clearMemory() prototype declaration for more
detailed explanation. Closes #22920.

- - - - -
26df73fb by Oleg Grenrus at 2023-02-15T22:20:57-05:00
Add -single-threaded flag to force single threaded rts

This is the small part of implementing
https://github.com/ghc-proposals/ghc-proposals/pull/240

- - - - -
631c6c72 by Cheng Shao at 2023-02-16T06:43:09-05:00
docs: add a section for the wasm backend

Fixes #22658

- - - - -
1878e0bd by Bryan Richter at 2023-02-16T06:43:47-05:00
tests: Mark T12903 fragile everywhere

See #21184

- - - - -
b9420eac by Bryan Richter at 2023-02-16T06:43:47-05:00
Mark all T5435 variants as fragile

See #22970.

- - - - -
df3d94bd by Sylvain Henry at 2023-02-16T06:44:33-05:00
Testsuite: mark T13167 as fragile for JS (#22921)

- - - - -
324e925b by Sylvain Henry at 2023-02-16T06:45:15-05:00
JS: disable debugging info for heap objects

- - - - -
518af814 by Josh Meredith at 2023-02-16T10:16:32-05:00
Factor JS Rts generation for h$c{_,0,1,2} into h$c{n} and improve name caching

- - - - -
34cd308e by Ben Gamari at 2023-02-16T10:17:08-05:00
base: Note move of GHC.Stack.CCS.whereFrom to GHC.InfoProv in changelog

Fixes #22883.

- - - - -
12965aba by Simon Peyton Jones at 2023-02-16T10:17:46-05: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

- - - - -
5b038888 by Andrew Lelechenko at 2023-02-16T10:18:24-05:00
Documentation: add an example of SPEC usage

- - - - -
681e0e8c by sheaf at 2023-02-16T14:09:56-05: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

- - - - -
b3ac17ad by Matthew Pickering at 2023-02-16T14:10:31-05: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
-------------------------

- - - - -
8988eeef by sheaf at 2023-02-16T20:32:27-05: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

- - - - -
3dd50e2f by Matthew Pickering at 2023-02-16T20:33:03-05:00
ghcup-metadata: Add test artifact

Add the released testsuite tarball to the generated ghcup metadata.

- - - - -
c6a967d9 by Matthew Pickering at 2023-02-16T20:33:03-05: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.

- - - - -
be0b7209 by Matthew Pickering at 2023-02-17T09:37:16+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

- - - - -
a203ad85 by Sylvain Henry at 2023-02-17T15:59:16-05:00
Merge libiserv with ghci

`libiserv` serves no purpose. As it depends on `ghci` and doesn't have
more dependencies than the `ghci` package, its code could live in the
`ghci` package too.

This commit also moves most of the code from the `iserv` program into
the `ghci` package as well so that it can be reused. This is especially
useful for the implementation of TH for the JS backend (#22261, !9779).

- - - - -
7080a93f by Simon Peyton Jones at 2023-02-20T12:06:32+01:00
Improve GHC.Tc.Gen.App.tcInstFun

It wasn't behaving right when inst_final=False, and the
function had no type variables
   f :: Foo => Int

Rather a corner case, but we might as well do it right.

Fixes #22908

Unexpectedly, three test cases (all using :type in GHCi) got
slightly better output as a result:
  T17403, T14796, T12447

- - - - -
2592ab69 by Cheng Shao at 2023-02-20T10:35:30-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.

- - - - -
26243de1 by Alexis King at 2023-02-20T15:27:17-05:00
Handle top-level Addr# literals in the bytecode compiler

Fixes #22376.

- - - - -
0196cc2b by romes at 2023-02-20T15:27:52-05:00
fix: Explicitly flush stdout on plugin

Because of #20791, the plugins tests often fail.  This is a temporary
fix to stop the tests from failing due to unflushed outputs on windows
and the explicit flush should be removed when #20791 is fixed.

- - - - -
4327d635 by Ryan Scott at 2023-02-20T20:44:34-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.

- - - - -
96dc58b9 by Ryan Scott at 2023-02-20T20:44:35-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.

- - - - -
ff8e99f6 by Ryan Scott at 2023-02-20T20:44:35-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.

- - - - -
8e765aff by Andrew Lelechenko at 2023-02-21T12:03:24-05:00
Bump submodule text to 2.0.2

- - - - -
172ff88f by Georgi Lyubenov at 2023-02-21T18:35:56-05:00
GHC proposal 496 - Nullary record wildcards

This patch implements GHC proposal 496, which allows record wildcards
to be used for nullary constructors, e.g.

  data A = MkA1 | MkA2 { fld1 :: Int }
  f :: A -> Int
  f (MkA1 {..}) = 0
  f (MkA2 {..}) = fld1

To achieve this, we add arity information to the record field
environment, so that we can accept a constructor which has no fields
while continuing to reject non-record constructors with more than 1
field. See Note [Nullary constructors and empty record wildcards],
as well as the more general overview in Note [Local constructor info in the renamer],
both in the newly introduced GHC.Types.ConInfo module.

Fixes #22161

- - - - -
f70a0239 by sheaf at 2023-02-21T18:36:35-05:00
ghc-prim: levity-polymorphic array equality ops

This patch changes the pointer-equality comparison operations in
GHC.Prim.PtrEq to work with arrays of unlifted values, e.g.

  sameArray# :: forall {l} (a :: TYPE (BoxedRep l)). Array# a -> Array# a -> Int#

Fixes #22976

- - - - -
9296660b by Andreas Klebinger at 2023-02-21T23:58:05-05:00
base: Correct @since annotation for FP<->Integral bit cast operations.

Fixes #22708

- - - - -
f11d9c27 by romes at 2023-02-21T23:58:42-05:00
fix: Update documentation links

Closes #23008

Additionally batches some fixes to pointers to the Note [Wired-in units],
and a typo in said note.

- - - - -
fb60339f by Bryan Richter at 2023-02-23T14:45:17+02:00
Propagate failure if unable to push notes

- - - - -
8e170f86 by Alexis King at 2023-02-23T16:59:22-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

- - - - -
e9e7a00d by sheaf at 2023-02-23T17:00:01-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

- - - - -
4eb9c234 by Sylvain Henry at 2023-02-24T17:27:45-05:00
JS: make some arithmetic primops faster (#22835)

Don't use BigInt for wordAdd2, mulWord32, and timesInt32.

Co-authored-by: Matthew Craven <5086-clyring at users.noreply.gitlab.haskell.org>

- - - - -
92e76483 by Ben Gamari at 2023-02-24T17:28:20-05:00
Bump terminfo submodule to 0.4.1.6

- - - - -
f229db14 by Ben Gamari at 2023-02-24T17:28:20-05:00
Bump unix submodule to 2.8.1.0

- - - - -
47bd48c1 by Ben Gamari at 2023-02-24T17:28:20-05:00
Bump deepseq submodule to 1.4.8.1

- - - - -
d2012594 by Ben Gamari at 2023-02-24T17:28:20-05:00
Bump directory submodule to 1.3.8.1

- - - - -
df6f70d1 by Ben Gamari at 2023-02-24T17:28:20-05:00
Bump process submodule to v1.6.17.0

- - - - -
4c869e48 by Ben Gamari at 2023-02-24T17:28:20-05:00
Bump hsc2hs submodule to 0.68.8

- - - - -
81d96642 by Ben Gamari at 2023-02-24T17:28:20-05:00
Bump array submodule to 0.5.4.0

- - - - -
6361f771 by Ben Gamari at 2023-02-24T17:28:20-05:00
Bump Cabal submodule to 3.9 pre-release

- - - - -
4085fb6c by Ben Gamari at 2023-02-24T17:28:20-05:00
Bump filepath submodule to 1.4.100.1

- - - - -
2bfad50f by Ben Gamari at 2023-02-24T17:28:20-05:00
Bump haskeline submodule to 0.8.2.1

- - - - -
fdc89a8d by Ben Gamari at 2023-02-24T21:29:32-05:00
gitlab-ci: Run nix-build with -v0

This significantly cuts down on the amount of
noise in the job log.

Addresses #22861.
- - - - -
69fb0b13 by Aaron Allen at 2023-02-24T21:30:10-05:00
Fix ParallelListComp out of scope suggestion

This patch makes it so vars from one block of a parallel list
comprehension are not in scope in a subsequent block during type
checking. This was causing GHC to emit a faulty suggestion when an out
of scope variable shared the occ name of a var from a different block.

Fixes #22940

- - - - -
ece092d0 by Simon Peyton Jones at 2023-02-24T21:30:45-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].

- - - - -
7825fef9 by Sylvain Henry at 2023-02-24T21:31:25-05:00
JS: Store CI perf results (fix #22923)

- - - - -
b56025f4 by Gergő Érdi at 2023-02-27T13:34:22+00:00
Don't specialise incoherent instance applications

Using incoherent instances, there can be situations where two
occurrences of the same overloaded function at the same type use two
different instances (see #22448). For incoherently resolved instances,
we must mark them with `nospec` to avoid the specialiser rewriting one
to the other. This marking is done during the desugaring of the
`WpEvApp` wrapper.

Fixes #22448

Metric Increase:
    T15304

- - - - -
d0c7bbed by Tom Ellis at 2023-02-27T20:04:07-05:00
Fix SCC grouping example

- - - - -
f84a8cd4 by Bryan Richter at 2023-02-28T05:58:37-05:00
Mark setnumcapabilities001 fragile

- - - - -
29a04d6e by Bryan Richter at 2023-02-28T05:58:37-05:00
Allow nightly-x86_64-linux-deb10-validate+thread_sanitizer to fail

See #22520

- - - - -
9fa54572 by Cheng Shao at 2023-02-28T05:59:15-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.

- - - - -
0c200ab7 by Simon Peyton Jones at 2023-02-28T11:10:31-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

- - - - -
8b77f9bf by Sylvain Henry at 2023-02-28T11:11:21-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.

- - - - -
239202a2 by Sylvain Henry at 2023-02-28T11:12:03-05:00
Testsuite: replace some js_skip with req_cmm

req_cmm is more informative than js_skip

- - - - -
7192ef91 by Simon Peyton Jones at 2023-02-28T18:54:59-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

- - - - -
bb500e2a by Simon Peyton Jones at 2023-02-28T18:55:35-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.

- - - - -
79ffa170 by Ben Gamari at 2023-03-01T04:17:20-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.

- - - - -
a2a1a1c0 by Sebastian Graf at 2023-03-01T04:17:56-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

- - - - -
cf118e2f by Simon Peyton Jones at 2023-03-01T04:18:33-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.

- - - - -
86f240ca by romes at 2023-03-01T04:19:10-05:00
fix: Consider strictness annotation in rep_bind

Fixes #23036

- - - - -
1ed573a5 by Richard Eisenberg at 2023-03-02T22:42:06-05:00
Don't suppress *all* Wanteds

Code in GHC.Tc.Errors.reportWanteds suppresses a Wanted if its
rewriters have unfilled coercion holes; see
Note [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint.

But if we thereby suppress *all* errors that's really confusing,
and as #22707 shows, GHC goes on without even realising that the
program is broken. Disaster.

This MR arranges to un-suppress them all if they all get suppressed.

Close #22707

- - - - -
8919f341 by Luite Stegeman at 2023-03-02T22:42:45-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

- - - - -
db83f8bb by Ben Gamari at 2023-03-02T22:43:22-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.

- - - - -
5f7a4a6d by Ben Gamari at 2023-03-02T22:43:22-05:00
rts: Introduce stgMallocAlignedBytes

- - - - -
8a6f745d by Ben Gamari at 2023-03-02T22:43:22-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.

- - - - -
5464c73f by Ben Gamari at 2023-03-02T22:43:22-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.

- - - - -
a86aae8b by Matthew Pickering at 2023-03-02T22:43:59-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

- - - - -
68dd64ff by Zubin Duggal at 2023-03-02T22:44:35-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

- - - - -
2f97c861 by Simon Peyton Jones at 2023-03-02T22:45:11-05:00
Get the right in-scope set in etaBodyForJoinPoint

Fixes #23026

- - - - -
45af8482 by David Feuer at 2023-03-03T11:40:47-05:00
Export getSolo from Data.Tuple

Proposed in
[CLC proposal #113](https://github.com/haskell/core-libraries-committee/issues/113)
and
[approved by the CLC](https://github.com/haskell/core-libraries-committee/issues/113#issuecomment-1452452191)

- - - - -
0c694895 by David Feuer at 2023-03-03T11:40:47-05:00
Document getSolo

- - - - -
bd0536af by Simon Peyton Jones at 2023-03-03T11:41:23-05:00
More fixes for `type data` declarations

This MR fixes #23022 and #23023.  Specifically

* Beef up Note [Type data declarations] in GHC.Rename.Module,
  to make invariant (I1) explicit, and to name the several
  wrinkles.

  And add references to these specific wrinkles.

* Add a Lint check for invariant (I1) above.
  See GHC.Core.Lint.checkTypeDataConOcc

* Disable the `caseRules` for dataToTag# for `type data` values.
  See Wrinkle (W2c) in the Note above.  Fixes #23023.

* Refine the assertion in dataConRepArgTys, so that it does not
  complain about the absence of a wrapper for a `type data` constructor
  Fixes #23022.

Acked-by: Simon Peyton Jones <simon.peytonjones at gmail.com>

- - - - -
858f34d5 by Oleg Grenrus at 2023-03-04T01:13:55+02:00
Add decideSymbol, decideChar, decideNat, decTypeRep, decT and hdecT

These all type-level equality decision procedures.

Implementes a CLC proposal https://github.com/haskell/core-libraries-committee/issues/98

- - - - -
bf43ba92 by Simon Peyton Jones at 2023-03-04T01:18:23-05:00
Add test for T22793

- - - - -
c6e1f3cd by Chris Wendt at 2023-03-04T03:35:18-07:00
Fix typo in docs referring to threadLabel

- - - - -
232cfc24 by Simon Peyton Jones at 2023-03-05T19:57:30-05:00
Add regression test for #22328

- - - - -
5ed77deb by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
Enable response files for linker if supported

- - - - -
1e0f6c89 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
Synchronize `configure.ac` and `distrib/configure.ac.in`

- - - - -
70560952 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
Fix `hadrian/bindist/config.mk.in`

… as suggested by @bgamari

- - - - -
b042b125 by sheaf at 2023-03-06T17:06:50-05:00
Apply 1 suggestion(s) to 1 file(s)
- - - - -
674b6b81 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
Try to create somewhat portable `ld` command

I cannot figure out a good way to generate an `ld` command
that works on both Linux and macOS.  Normally you'd use something
like `AC_LINK_IFELSE` for this purpose (I think), but that won't
let us test response file support.

- - - - -
83b0177e by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
Quote variables

… as suggested by @bgamari

- - - - -
845f404d by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
Fix configure failure on alpine linux

- - - - -
c56a3ae6 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
Small fixes to configure script

- - - - -
cad5c576 by Andrei Borzenkov at 2023-03-06T17:07:33-05:00
Convert diagnostics in GHC.Rename.Module to proper TcRnMessage (#20115)

I've turned almost all occurrences of TcRnUnknownMessage in GHC.Rename.Module
module into a proper TcRnMessage.
Instead, these TcRnMessage messages were introduced:
  TcRnIllegalInstanceHeadDecl
  TcRnUnexpectedStandaloneDerivingDecl
  TcRnUnusedVariableInRuleDecl
  TcRnUnexpectedStandaloneKindSig
  TcRnIllegalRuleLhs
  TcRnBadAssocRhs
  TcRnDuplicateRoleAnnot
  TcRnDuplicateKindSig
  TcRnIllegalDerivStrategy
  TcRnIllegalMultipleDerivClauses
  TcRnNoDerivStratSpecified
  TcRnStupidThetaInGadt
  TcRnBadImplicitSplice
  TcRnShadowedTyVarNameInFamResult
  TcRnIncorrectTyVarOnLhsOfInjCond
  TcRnUnknownTyVarsOnRhsOfInjCond

Was introduced one helper type:
  RuleLhsErrReason

- - - - -
c6432eac by Apoorv Ingle at 2023-03-06T23:26:12+00:00
Constraint simplification loop now depends on `ExpansionFuel`
instead of a boolean flag for `CDictCan.cc_pend_sc`.
Pending givens get a fuel of 3 while Wanted and quantified constraints get a fuel of 1.
This helps pending given constraints to keep up with pending wanted constraints in case of
`UndecidableSuperClasses` and superclass expansions while simplifying the infered type.

Adds 3 dynamic flags for controlling the fuels for each type of constraints
`-fgivens-expansion-fuel` for givens `-fwanteds-expansion-fuel` for wanteds and `-fqcs-expansion-fuel` for quantified constraints

Fixes #21909
Added Tests T21909, T21909b
Added Note [Expanding Recursive Superclasses and ExpansionFuel]

- - - - -
a5afc8ab by Andrew Lelechenko at 2023-03-06T22:51:01-05:00
Documentation: describe laziness of several function from Data.List

- - - - -
fa559c28 by Ollie Charles at 2023-03-07T20:56:21+00:00
Add `Data.Functor.unzip`

This function is currently present in `Data.List.NonEmpty`, but `Data.Functor`
is a better home for it. This change was discussed and approved by the CLC
at https://github.com/haskell/core-libraries-committee/issues/88.

- - - - -
2aa07708 by MorrowM at 2023-03-07T21:22:22-05:00
Fix documentation for traceWith and friends

- - - - -
f3ff7cb1 by David Binder at 2023-03-08T01:24:17-05:00
Remove utils/hpc subdirectory and its contents

- - - - -
cf98e286 by David Binder at 2023-03-08T01:24:17-05:00
Add git submodule for utils/hpc

- - - - -
605fbbb2 by David Binder at 2023-03-08T01:24:18-05:00
Update commit for utils/hpc git submodule

- - - - -
606793d4 by David Binder at 2023-03-08T01:24:18-05:00
Update commit for utils/hpc git submodule

- - - - -
4158722a by Sylvain Henry at 2023-03-08T01:24:58-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).

- - - - -
1e0d8fdb by Greg Steuck at 2023-03-08T08:59:05-05:00
Change hostSupportsRPaths to report False on OpenBSD

OpenBSD does support -rpath but ghc build process relies on some
related features that don't work there. See ghc/ghc#23011

- - - - -
bed3a292 by Alexis King at 2023-03-08T08:59:53-05:00
bytecode: Fix bitmaps for BCOs used to tag tuples and prim call args

fixes #23068

- - - - -
321d46d9 by Ben Gamari at 2023-03-08T15:02:30-05:00
rts: Drop redundant prototype

- - - - -
abb6070f by Ben Gamari at 2023-03-08T15:02:30-05:00
nonmoving: Fix style

- - - - -
be278901 by Ben Gamari at 2023-03-08T15:02:30-05:00
nonmoving: Deduplicate assertion

- - - - -
b9034639 by Ben Gamari at 2023-03-08T15:02:30-05:00
rts: Fix type issues in Sparks.h

Adds explicit casts to satisfy a C++ compiler.

- - - - -
da7b2b94 by Ben Gamari at 2023-03-08T15:02:30-05:00
rts: Use release ordering when storing thread labels

Since this makes the ByteArray# visible from other cores.

- - - - -
5b7f6576 by Ben Gamari at 2023-03-08T15:02:30-05: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.

- - - - -
6283144f by Ben Gamari at 2023-03-08T15:02:30-05:00
rts/Sanity: Mark pinned_object_blocks

- - - - -
9b528404 by Ben Gamari at 2023-03-08T15:02:30-05:00
rts/Sanity: Look at nonmoving saved_filled lists

- - - - -
0edc5438 by Ben Gamari at 2023-03-08T15:02:30-05:00
Evac: Squash data race in eval_selector_chain

- - - - -
7eab831a by Ben Gamari at 2023-03-08T15:02:30-05:00
nonmoving: Clarify implementation

This makes the intent of this implementation a bit clearer.

- - - - -
532262b9 by Ben Gamari at 2023-03-08T15:02:30-05:00
nonmoving: Clarify comment

- - - - -
bd9cd84b by Ben Gamari at 2023-03-08T15:02:30-05:00
nonmoving: Add missing no-op in busy-wait loop

- - - - -
c4e6bfc8 by Ben Gamari at 2023-03-08T15:02:30-05: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.

- - - - -
92227b60 by Ben Gamari at 2023-03-08T15:02:30-05: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.

- - - - -
ba7e7972 by Ben Gamari at 2023-03-08T15:02:30-05:00
nonmoving: Sanity check nonmoving large objects and compacts

- - - - -
71b038a1 by Ben Gamari at 2023-03-08T15:02:30-05: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.

- - - - -
99d144d5 by Ben Gamari at 2023-03-08T15:02:30-05:00
nonmoving: Don't show occupancy if we didn't collect live words

- - - - -
81d6cc55 by Ben Gamari at 2023-03-08T15:02:30-05: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.

- - - - -
58e53bc4 by Ben Gamari at 2023-03-08T15:02:30-05:00
nonmoving: Assert state of swept segments

- - - - -
2db92e01 by Ben Gamari at 2023-03-08T15:02:30-05: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.

- - - - -
e4c3249f by Ben Gamari at 2023-03-08T15:02:30-05: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.

- - - - -
1b069671 by Ben Gamari at 2023-03-08T15:02:30-05: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.

- - - - -
d4032690 by Ben Gamari at 2023-03-08T15:02:30-05:00
nonmoving: Post-sweep sanity checking

- - - - -
0baa8752 by Ben Gamari at 2023-03-08T15:02:30-05:00
nonmoving: Avoid n_caps race

- - - - -
5d3232ba by Ben Gamari at 2023-03-08T15:02:31-05:00
nonmoving: Don't push if nonmoving collector isn't enabled

- - - - -
0a7eb0aa by Ben Gamari at 2023-03-08T15:02:31-05: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.

- - - - -
7c817c0a by Ben Gamari at 2023-03-08T15:02:31-05: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.

- - - - -
ce22a3e2 by Ben Gamari at 2023-03-08T15:02:31-05:00
nonmoving: Allow pinned gen0 objects to be WEAK keys

- - - - -
78746906 by Ben Gamari at 2023-03-08T15:02:31-05:00
rts: Reenable assertion

- - - - -
b500867a by Ben Gamari at 2023-03-08T15:02:31-05: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.

- - - - -
56e669c1 by Ben Gamari at 2023-03-08T15:02:31-05:00
nonmoving: Fix Note references

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

- - - - -
4a7650d7 by Ben Gamari at 2023-03-08T15:02:31-05: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.

- - - - -
96a5aaed by Ben Gamari at 2023-03-08T15:02:31-05: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.

- - - - -
6c6674ca by Ben Gamari at 2023-03-08T15:02:31-05:00
rts: Encapsulate block allocator spinlock

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

- - - - -
e84f7167 by Ben Gamari at 2023-03-08T15:02:31-05:00
testsuite: Skip some tests when sanity checking is enabled

- - - - -
3ae0f368 by Ben Gamari at 2023-03-08T15:02:31-05:00
nonmoving: Fix unregisterised build

- - - - -
4eb9d06b by Ben Gamari at 2023-03-08T15:02:31-05:00
nonmoving: Ensure that sanity checker accounts for saved_filled segments

- - - - -
f0cf384d by Ben Gamari at 2023-03-08T15:02:31-05:00
hadrian: Add +boot_nonmoving_gc flavour transformer

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

- - - - -
581e58ac by Ben Gamari at 2023-03-08T15:02:31-05:00
gitlab-ci: Add job bootstrapping with nonmoving GC

- - - - -
487a8b58 by Ben Gamari at 2023-03-08T15:02:31-05:00
nonmoving: Move allocator into new source file

- - - - -
8f374139 by Ben Gamari at 2023-03-08T15:02:31-05:00
nonmoving: Split out nonmovingAllocateGC

- - - - -
662b6166 by Ben Gamari at 2023-03-08T15:02:31-05:00
testsuite: Only run T22795* in the normal way

It doesn't make sense to run these in multiple ways as they merely test
whether `-threaded`/`-single-threaded` flags.

- - - - -
0af21dfa by Ben Gamari at 2023-03-08T15:02:31-05:00
rts: Rename clear_segment(_free_blocks)?

To reflect the fact that these are to do with the nonmoving collector,
now since they are exposed no longer static.

- - - - -
7bcb192b by Ben Gamari at 2023-03-08T15:02:31-05:00
rts: Fix incorrect STATIC_INLINE

This should be INLINE_HEADER lest we get unused declaration warnings.

- - - - -
f1fd3ffb by Ben Gamari at 2023-03-08T15:02:31-05:00
testsuite: Mark ffi023 as broken due to #23089

- - - - -
a57f12b3 by Ben Gamari at 2023-03-08T15:02:31-05:00
testsuite: Skip T7160 in the nonmoving way

Finalization order is different under the nonmoving collector.

- - - - -
f6f12a36 by Ben Gamari at 2023-03-08T15:02:31-05:00
rts: Capture GC configuration in a struct

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

- - - - -
ba73a807 by Ben Gamari at 2023-03-08T15:02:31-05:00
nonmoving: Non-concurrent collection

- - - - -
7c813d06 by Alexis King at 2023-03-08T15:03:10-05:00
hadrian: Fix flavour compiler stage options off-by-one error

!9193 pointed out that ghcDebugAssertions was supposed to be a predicate
on the stage of the built compiler, but in practice it was a predicate
on the stage of the compiler used to build. Unfortunately, while it
fixed that issue for ghcDebugAssertions, it documented every other
similar option as behaving the same way when in fact they all used the
old behavior.

The new behavior of ghcDebugAssertions seems more intuitive, so this
commit changes the interpretation of every other option to match. It
also improves the enableProfiledGhc and debugGhc flavour transformers by
making them more selective about which stages in which they build
additional library/RTS ways.

- - - - -
f97c7f6d by Luite Stegeman at 2023-03-09T09:52:09-05:00
Delete created temporary subdirectories at end of session.

This patch adds temporary subdirectories to the list of
paths do clean up at the end of the GHC session. This
fixes warnings about non-empty temporary directories.

Fixes #22952

- - - - -
9ea719f2 by Apoorv Ingle at 2023-03-09T09:52:45-05:00
Fixes #19627.

Previously the solver failed with an unhelpful "solver reached too may iterations" error.
With the fix for #21909 in place we no longer have the possibility of generating such an error if we have `-fconstraint-solver-iteration` > `-fgivens-fuel > `-fwanteds-fuel`. This is true by default, and the said fix also gives programmers a knob to control how hard the solver should try before giving up.

This commit adds:
* Reference to ticket #19627 in the Note [Expanding Recursive Superclasses and ExpansionFuel]
* Test `typecheck/should_fail/T19627.hs` for regression purposes

- - - - -
ec2d93eb by Sebastian Graf at 2023-03-10T10:18:54-05:00
DmdAnal: Fix a panic on OPAQUE and trivial/PAP RHS (#22997)

We should not panic in `add_demands` (now `set_lam_dmds`), because that code
path is legimitely taken for OPAQUE PAP bindings, as in T22997.

Fixes #22997.

- - - - -
5b4628ae by Sylvain Henry at 2023-03-10T10:19:34-05:00
JS: remove dead code for old integer-gmp

- - - - -
bab23279 by Josh Meredith at 2023-03-10T23:24:49-05:00
JS: Fix implementation of MK_JSVAL

- - - - -
ec263a59 by Sebastian Graf at 2023-03-10T23:25:25-05:00
Simplify: Move `wantEtaExpansion` before expensive `do_eta_expand` check

There is no need to run arity analysis and what not if we are not in a
Simplifier phase that eta-expands or if we don't want to eta-expand the
expression in the first place.

Purely a refactoring with the goal of improving compiler perf.

- - - - -
047e9d4f by Josh Meredith at 2023-03-13T03:56:03+00:00
JS: fix implementation of forceBool to use JS backend syntax

- - - - -
559a4804 by Sebastian Graf at 2023-03-13T07:31:23-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

- - - - -
536d1f90 by Matthew Pickering at 2023-03-13T14:04:49+00:00
Bump Win32 to 2.13.4.0

Updates Win32 submodule

- - - - -
ee17001e by Ben Gamari at 2023-03-13T21:18:24-04:00
ghc-bignum: Drop redundant include-dirs field
- - - - -
c9c26cd6 by Teo Camarasu at 2023-03-16T12:17:50-04:00
Fix BCO creation setting caps when -j > -N

* Remove calls to 'setNumCapabilities' in 'createBCOs'
These calls exist to ensure that 'createBCOs' can benefit from
parallelism. But this is not the right place to call
`setNumCapabilities`. Furthermore the logic differs from that in the
driver causing the capability count to be raised and lowered at each TH
call if -j > -N.

* Remove 'BCOOpts'
No longer needed as it was only used to thread the job count down to `createBCOs`

Resolves #23049

- - - - -
5ddbf5ed by Teo Camarasu at 2023-03-16T12:17:50-04:00
Add changelog entry for #23049

- - - - -
6e3ce9a4 by Ben Gamari at 2023-03-16T12:18:26-04:00
configure: Fix FIND_CXX_STD_LIB test on Darwin

Annoyingly, Darwin's <cstddef> includes <version> and APFS is
case-insensitive. Consequently, it will end up #including the
`VERSION` file generated by the `configure` script on the second
and subsequent runs of the `configure` script.

See #23116.
- - - - -
19d6d039 by sheaf at 2023-03-16T21:31:22+01:00
ghci: only keep the GlobalRdrEnv in ModInfo

The datatype GHC.UI.Info.ModInfo used to store a ModuleInfo,
which includes a TypeEnv. This can easily cause space leaks as we
have no way of forcing everything in a type environment.

In GHC, we only use the GlobalRdrEnv, which we can force completely.
So we only store that instead of a fully-fledged ModuleInfo.

- - - - -
73d07c6e by Torsten Schmits at 2023-03-17T14:36:49-04:00
Add structured error messages for GHC.Tc.Utils.Backpack

Tracking ticket: #20119

MR: !10127

This converts uses of `mkTcRnUnknownMessage` to newly added constructors
of `TcRnMessage`.
One occurrence, when handing a nested error from the interface loading
machinery, was omitted. It will be handled by a subsequent changeset
that addresses interface errors.

- - - - -
a13affce by Andrei Borzenkov at 2023-03-21T11:17:17-04:00
Rename () into Unit, (,,...,,) into Tuple<n> (#21294)

This patch implements a part of GHC Proposal #475.
The key change is in GHC.Tuple.Prim:

  - data () = ()
  - data (a,b) = (a,b)
  - data (a,b,c) = (a,b,c)
  ...
  + data Unit = ()
  + data Tuple2 a b = (a,b)
  + data Tuple3 a b c = (a,b,c)
  ...

And the rest of the patch makes sure that Unit and Tuple<n>
are pretty-printed as () and (,,...,,) in various contexts.

Updates the haddock submodule.

Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com>

- - - - -
23642bf6 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00
docs: fix some wrongs in the eventlog format documentation

- - - - -
90159773 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00
docs: explain the BLOCK_MARKER event

- - - - -
ab1c25e8 by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00
docs: add BlockedOnMVarRead thread status in eventlog encodings

- - - - -
898afaef by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00
docs: add TASK_DELETE event in eventlog encodings

- - - - -
bb05b4cc by Adam Sandberg Ericsson at 2023-03-21T11:17:53-04:00
docs: add WALL_CLOCK_TIME event in eventlog encodings

- - - - -
eeea0343 by Torsten Schmits at 2023-03-21T11:18:34-04:00
Add structured error messages for GHC.Tc.Utils.Env

Tracking ticket: #20119

MR: !10129

This converts uses of `mkTcRnUnknownMessage` to newly added constructors
of `TcRnMessage`.

- - - - -
be1d4be8 by Andrew Lelechenko at 2023-03-21T11:19:13-04:00
Document pdep / pext primops

- - - - -
e8b4aac4 by Alex Mason at 2023-03-21T18:11:04-04:00
Allow LLVM backend to use HDoc for faster file generation.

Also remove the MetaStmt constructor from LlvmStatement and places the annotations into the Store statement.

Includes “Implement a workaround for -no-asm-shortcutting bug“ (https://gitlab.haskell.org/ghc/ghc/-/commit/2fda9e0df886cc551e2cd6b9c2a384192bdc3045)

- - - - -
ea24360d by Luite Stegeman at 2023-03-21T18:11:44-04:00
Compute LambdaFormInfo when using JavaScript backend.

CmmCgInfos is needed to write interface files, but the
JavaScript backend does not generate it, causing
"Name without LFInfo" warnings.

This patch adds a conservative but always correct
CmmCgInfos when the JavaScript backend is used.

Fixes #23053

- - - - -
926ad6de by Simon Peyton Jones at 2023-03-22T01:03:08-04:00
Be more careful about quantification

This MR is driven by #23051. It does several things:

* It is guided by the generalisation plan described in #20686.
  But it is still far from a complete implementation of that plan.

* Add Note [Inferred type with escaping kind] to GHC.Tc.Gen.Bind.
  This explains that we don't (yet, pending #20686) directly
  prevent generalising over escaping kinds.

* In `GHC.Tc.Utils.TcMType.defaultTyVar` we default RuntimeRep
  and Multiplicity variables, beause we don't want to quantify over
  them.  We want to do the same for a Concrete tyvar, but there is
  nothing sensible to default it to (unless it has kind RuntimeRep,
  in which case it'll be caught by an earlier case). So we promote
  instead.

* Pure refactoring in GHC.Tc.Solver:
  * Rename decideMonoTyVars to decidePromotedTyVars, since that's
    what it does.

  * Move the actual promotion of the tyvars-to-promote from
    `defaultTyVarsAndSimplify` to `decidePromotedTyVars`.  This is a
    no-op; just tidies up the code.  E.g then we don't need to
    return the promoted tyvars from `decidePromotedTyVars`.

  * A little refactoring in `defaultTyVarsAndSimplify`, but no
    change in behaviour.

* When making a TauTv unification variable into a ConcreteTv
  (in GHC.Tc.Utils.Concrete.makeTypeConcrete), preserve the occ-name
  of the type variable.  This just improves error messages.

* Kill off dead code: GHC.Tc.Utils.TcMType.newConcreteHole

- - - - -
0ab0cc11 by Sylvain Henry at 2023-03-22T01:03:48-04:00
Testsuite: use appropriate predicate for ManyUbxSums test (#22576)

- - - - -
048c881e by romes at 2023-03-22T01:04:24-04:00
fix: Incorrect @since annotations in GHC.TypeError

Fixes #23128

- - - - -
a1528b68 by Sylvain Henry at 2023-03-22T01:05:04-04:00
Testsuite: use req_interp predicate for T16318 (#22370)

- - - - -
ad765b6f by Sylvain Henry at 2023-03-22T01:05:04-04:00
Testsuite: use req_interp predicate for T20214

- - - - -
e0b8eaf3 by Simon Peyton Jones at 2023-03-22T09:50:13+00:00
Refactor the constraint solver pipeline

The big change is to put the entire type-equality solver into
GHC.Tc.Solver.Equality, rather than scattering it over Canonical
and Interact.  Other changes

* EqCt becomes its own data type, a bit like QCInst.  This is
  great because EqualCtList is then just [EqCt]

* New module GHC.Tc.Solver.Dict has come of the class-contraint
  solver.  In due course it will be all.  One step at a time.

This MR is intended to have zero change in behaviour: it is a
pure refactor.  It opens the way to subsequent tidying up, we
believe.

- - - - -
cedf9a3b by Torsten Schmits at 2023-03-22T15:31:18-04:00
Add structured error messages for GHC.Tc.Utils.TcMType

Tracking ticket: #20119

MR: !10138

This converts uses of `mkTcRnUnknownMessage` to newly added constructors
of `TcRnMessage`.

- - - - -
30d45e97 by Sylvain Henry at 2023-03-22T15:32:01-04:00
Testsuite: use js_skip for T2615 (#22374)

- - - - -
8c98deba by Armando Ramirez at 2023-03-23T09:19:32-04:00
Optimized Foldable methods for Data.Functor.Compose

Explicitly define length, elem, etc. in Foldable instance for Data.Functor.Compose

Implementation of https://github.com/haskell/core-libraries-committee/issues/57

- - - - -
bc066108 by Armando Ramirez at 2023-03-23T09:19:32-04:00
Additional optimized versions

- - - - -
80fce576 by Andrew Lelechenko at 2023-03-23T09:19:32-04:00
Simplify minimum/maximum in instance Foldable (Compose f g)

- - - - -
8cb88a5a by Andrew Lelechenko at 2023-03-23T09:19:32-04:00
Update changelog to mention changes to instance Foldable (Compose f g)

- - - - -
e1c8c41d by Torsten Schmits at 2023-03-23T09:20:13-04:00
Add structured error messages for GHC.Tc.TyCl.PatSyn

Tracking ticket: #20117

MR: !10158

This converts uses of `mkTcRnUnknownMessage` to newly added constructors
of `TcRnMessage`.

- - - - -
f932c589 by Adam Gundry at 2023-03-24T02:36:09-04:00
Allow WARNING pragmas to be controlled with custom categories

Closes #17209. This implements GHC Proposal 541, allowing a WARNING
pragma to be annotated with a category like so:

    {-# WARNING in "x-partial" head "This function is undefined on empty lists." #-}

The user can then enable, disable and set the severity of such warnings
using command-line flags `-Wx-partial`, `-Werror=x-partial` and so on.  There
is a new warning group `-Wextended-warnings` containing all these warnings.
Warnings without a category are treated as if the category was `deprecations`,
and are (still) controlled by the flags `-Wdeprecations`
and `-Wwarnings-deprecations`.

Updates Haddock submodule.

- - - - -
0426515b by Adam Gundry at 2023-03-24T02:36:09-04:00
Move mention of warning groups change to 9.8.1 release notes

- - - - -
b8d783d2 by Ben Gamari at 2023-03-24T02:36:45-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.

- - - - -
46120bb6 by Joachim Breitner at 2023-03-24T13:09:43-04:00
User's guide: Improve docs for -Wall

previously it would list the warnings _not_ enabled by -Wall. That’s
unnecessary round-about and was out of date. So let's just name
the relevant warnings (based on `compiler/GHC/Driver/Flags.hs`).

- - - - -
509d1f11 by Ben Gamari at 2023-03-24T13:10:20-04:00
codeGen/tsan: Disable instrumentation of unaligned stores

There is some disagreement regarding the prototype of
`__tsan_unaligned_write` (specifically whether it takes just the written
address, or the address and the value as an argument). Moreover, I have
observed crashes which appear to be due to it. Disable instrumentation
of unaligned stores as a temporary mitigation.

Fixes #23096.

- - - - -
6a73655f by Li-yao Xia at 2023-03-25T00:02:44-04:00
base: Document GHC versions associated with past base versions in the changelog

- - - - -
43bd7694 by Teo Camarasu at 2023-03-25T00:03:24-04:00
Add regression test for #17574

This test currently fails in the nonmoving way

- - - - -
f2d56bf7 by Teo Camarasu at 2023-03-25T00:03:24-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

- - - - -
7131b705 by David Feuer at 2023-03-25T00:04:04-04:00
Modify ThreadId documentation and comments

For a long time, `GHC.Conc.Sync` has said

```haskell
-- ToDo: data ThreadId = ThreadId (Weak ThreadId#)
-- But since ThreadId# is unlifted, the Weak type must use open
-- type variables.
```

We are now actually capable of using `Weak# ThreadId#`, but the
world has moved on. To support the `Show` and `Ord` instances, we'd
need to store the thread ID number in the `ThreadId`. And it seems
very difficult to continue to support `threadStatus` in that regime,
since it needs to be able to explain how threads died. In addition,
garbage collection of weak references can be quite expensive, and it
would be hard to evaluate the cost over he whole ecosystem. As discussed
in
[this CLC issue](https://github.com/haskell/core-libraries-committee/issues/125),
it doesn't seem very likely that we'll actually switch to weak
references here.

- - - - -
c421bbbb by Ben Gamari at 2023-03-25T00:04:41-04:00
rts: Fix barriers of IND and IND_STATIC

Previously IND and IND_STATIC lacked the acquire barriers enjoyed by
BLACKHOLE. As noted in the (now updated) Note [Heap memory barriers],
this barrier is critical to ensure that the indirectee is visible to the
entering core.

Fixes #22872.

- - - - -
62fa7faa by Andrew Lelechenko at 2023-03-25T00:05:22-04:00
Improve documentation of atomicModifyMutVar2#

- - - - -
b2d14d0b by Cheng Shao at 2023-03-25T03:46:43-04:00
rts: use performBlockingMajorGC in hs_perform_gc and fix ffi023

This patch does a few things:

- Add the missing RtsSymbols.c entry of performBlockingMajorGC
- Make hs_perform_gc call performBlockingMajorGC, which restores
  previous behavior
- Use hs_perform_gc in ffi023
- Remove rts_clearMemory() call in ffi023, it now works again in some
  test ways previously marked as broken. Fixes #23089

- - - - -
d9ae24ad by Cheng Shao at 2023-03-25T03:46:44-04:00
testsuite: add the rts_clearMemory test case

This patch adds a standalone test case for rts_clearMemory that mimics
how it's typically used by wasm backend users and ensures this RTS API
isn't broken by future RTS refactorings. Fixes #23901.

- - - - -
80729d96 by Andrew Lelechenko at 2023-03-25T03:47:22-04:00
Improve documentation for resizing of byte arrays

- - - - -
c6ec4cd1 by Ben Gamari at 2023-03-25T20:23:47-04:00
rts: Don't rely on EXTERN_INLINE for slop-zeroing logic

Previously we relied on calling EXTERN_INLINE functions defined in
ClosureMacros.h from Cmm to zero slop. However, as far as I can tell,
this is no longer safe to do in C99 as EXTERN_INLINE definitions may be emitted
in each compilation unit.

Fix this by explicitly declaring a new set of non-inline functions in
ZeroSlop.c which can be called from Cmm and marking the ClosureMacros.h
definitions as INLINE_HEADER.

In the future we should try to eliminate EXTERN_INLINE.

- - - - -
c32abd4b by Ben Gamari at 2023-03-25T20:23:48-04:00
rts: Fix capability-count check in zeroSlop

Previously `zeroSlop` examined `RtsFlags` to determine whether the
program was single-threaded. This is wrong; a program may be started
with `+RTS -N1` yet the process may later increase the capability count
with `setNumCapabilities`. This lead to quite subtle and rare crashes.

Fixes #23088.

- - - - -
656d4cb3 by Ryan Scott at 2023-03-25T20:24:23-04:00
Add Eq/Ord instances for SSymbol, SChar, and SNat

This implements [CLC proposal #148](https://github.com/haskell/core-libraries-committee/issues/148).

- - - - -
4f93de88 by David Feuer at 2023-03-26T15:33:02-04:00
Update and expand atomic modification Haddocks

* The documentation for `atomicModifyIORef` and `atomicModifyIORef'`
  were incomplete, and the documentation for `atomicModifyIORef` was
  out of date. Update and expand.

* Remove a useless lazy pattern match in the definition of
  `atomicModifyIORef`. The pair it claims to match lazily
  was already forced by `atomicModifyIORef2`.

- - - - -
e1fb56b2 by David Feuer at 2023-03-26T15:33:41-04:00
Document the constructor name for lists

Derived `Data` instances use raw infix constructor names when applicable.
The `Data.Data [a]` instance, if derived, would have a constructor name
of `":"`. However, it actually uses constructor name `"(:)"`. Document this
peculiarity.

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

- - - - -
c1f755c4 by Simon Peyton Jones at 2023-03-27T22:09:41+01:00
Make exprIsConApp_maybe a bit cleverer

Addresses #23159.

See Note Note [Exploit occ-info in exprIsConApp_maybe]
in GHC.Core.SimpleOpt.

Compile times go down very slightly, but always go down,
never up.  Good!

Metrics: compile_time/bytes allocated
------------------------------------------------
 CoOpt_Singletons(normal)   -1.8%
           T15703(normal)   -1.2% GOOD

                geo. mean   -0.1%
                minimum     -1.8%
                maximum     +0.0%

Metric Decrease:
    CoOpt_Singletons
    T15703

- - - - -
76bb4c58 by Ryan Scott at 2023-03-28T08:12:08-04:00
Add COMPLETE pragmas to TypeRep, SSymbol, SChar, and SNat

This implements
[CLC proposal #149](https://github.com/haskell/core-libraries-committee/issues/149).

- - - - -
3f374399 by sheaf at 2023-03-29T13:57:33+02:00
Handle records in the renamer

This patch moves the field-based logic for disambiguating record updates
to the renamer. The type-directed logic, scheduled for removal, remains
in the typechecker.

To do this properly (and fix the myriad of bugs surrounding the treatment
of duplicate record fields), we took the following main steps:

  1. Create GREInfo, a renamer-level equivalent to TyThing which stores
     information pertinent to the renamer.
     This allows us to uniformly treat imported and local Names in the
     renamer, as described in Note [GREInfo].

  2. Remove GreName. Instead of a GlobalRdrElt storing GreNames, which
     distinguished between normal names and field names, we now store
     simple Names in GlobalRdrElt, along with the new GREInfo information
     which allows us to recover the FieldLabel for record fields.

  3. Add namespacing for record fields, within the OccNames themselves.
     This allows us to remove the mangling of duplicate field selectors.

     This change ensures we don't print mangled names to the user in
     error messages, and allows us to handle duplicate record fields
     in Template Haskell.

  4. Move record disambiguation to the renamer, and operate on the
     level of data constructors instead, to handle #21443.

     The error message text for ambiguous record updates has also been
     changed to reflect that type-directed disambiguation is on the way
     out.

(3) means that OccEnv is now a bit more complex: we first key on the
textual name, which gives an inner map keyed on NameSpace:

  OccEnv a ~ FastStringEnv (UniqFM NameSpace a)

Note that this change, along with (2), both increase the memory residency
of GlobalRdrEnv = OccEnv [GlobalRdrElt], which causes a few tests to
regress somewhat in compile-time allocation.

Even though (3) simplified a lot of code (in particular the treatment of
field selectors within Template Haskell and in error messages), it came
with one important wrinkle: in the situation of

  -- M.hs-boot
  module M where { data A; foo :: A -> Int }
  -- M.hs
  module M where { data A = MkA { foo :: Int } }

we have that M.hs-boot exports a variable foo, which is supposed to match
with the record field foo that M exports. To solve this issue, we add a
new impedance-matching binding to M

  foo{var} = foo{fld}

This mimics the logic that existed already for impedance-binding DFunIds,
but getting it right was a bit tricky.
See Note [Record field impedance matching] in GHC.Tc.Module.

We also needed to be careful to avoid introducing space leaks in GHCi.
So we dehydrate the GlobalRdrEnv before storing it anywhere, e.g. in
ModIface. This means stubbing out all the GREInfo fields, with the
function forceGlobalRdrEnv.
When we read it back in, we rehydrate with rehydrateGlobalRdrEnv.
This robustly avoids any space leaks caused by retaining old type
environments.

Fixes #13352 #14848 #17381 #17551 #19664 #21443 #21444 #21720 #21898 #21946 #21959 #22125 #22160 #23010 #23062 #23063

Updates haddock submodule

-------------------------
Metric Increase:
    MultiComponentModules
    MultiLayerModules
    MultiLayerModulesDefsGhci
    MultiLayerModulesNoCode
    T13701
    T14697
    hard_hole_fits
-------------------------

- - - - -
4f1940f0 by sheaf at 2023-03-29T13:57:33+02:00
Avoid repeatedly shadowing in shadowNames

This commit refactors GHC.Type.Name.Reader.shadowNames to first
accumulate all the shadowing arising from the introduction of a new
set of GREs, and then applies all the shadowing to the old GlobalRdrEnv
in one go.

- - - - -
d246049c by sheaf at 2023-03-29T13:57:34+02:00
igre_prompt_env: discard "only-qualified" names

We were unnecessarily carrying around names only available qualified
in igre_prompt_env, violating the icReaderEnv invariant.
We now get rid of these, as they aren't needed for the shadowing
computation that igre_prompt_env exists for.

Fixes #23177

-------------------------
Metric Decrease:
    T14052
    T14052Type
-------------------------

- - - - -
41a572f6 by Matthew Pickering at 2023-03-29T16:17:21-04:00
hadrian: Fix path to HpcParser.y

The source for this project has been moved into a src/ folder so we also
need to update this path.

Fixes #23187

- - - - -
b159e0e9 by doyougnu at 2023-03-30T01:40:08-04:00
js: split JMacro into JS eDSL and JS syntax

This commit:

Splits JExpr and JStat into two nearly identical DSLs:
- GHC.JS.Syntax is the JMacro based DSL without unsaturation, i.e., a
value cannot be unsaturated, or, a value of this DSL is a witness that a
value of GHC.JS.Unsat has been saturated
- GHC.JS.Unsat is the JMacro DSL from GHCJS with Unsaturation.

Then all binary and outputable instances are changed to use
GHC.JS.Syntax.

This moves us closer to closing out #22736 and #22352. See #22736 for
roadmap.

-------------------------
Metric Increase:
    CoOpt_Read
    LargeRecord
    ManyAlternatives
    PmSeriesS
    PmSeriesT
    PmSeriesV
    T10421
    T10858
    T11195
    T11374
    T11822
    T12227
    T12707
    T13035
    T13253
    T13253-spj
    T13379
    T14683
    T15164
    T15703
    T16577
    T17096
    T17516
    T17836
    T18140
    T18282
    T18304
    T18478
    T18698a
    T18698b
    T18923
    T1969
    T19695
    T20049
    T21839c
    T3064
    T4801
    T5321FD
    T5321Fun
    T5631
    T5642
    T783
    T9198
    T9233
    T9630
    TcPlugin_RewritePerf
    WWRec
-------------------------

- - - - -
f4f1f14f by Sylvain Henry at 2023-03-30T01:40:49-04:00
ghc-heap: remove wrong Addr# coercion (#23181)

Conversion from Addr# to I# isn't correct with the JS backend.

Also used the opportunity to reenable 64-bit Word/Int tests

- - - - -
a5360490 by Ben Gamari at 2023-03-30T01:41:25-04:00
testsuite: Fix racing prints in T21465

As noted in #23155, we previously failed to add flushes necessary to
ensure predictable output.

Fixes #23155.

- - - - -
98b5cf67 by Matthew Pickering at 2023-03-30T09:58:40+01:00
Revert "ghc-heap: remove wrong Addr# coercion (#23181)"

This reverts commit f4f1f14f8009c3c120b8b963ec130cbbc774ec02.

This fails to build with GHC-9.2 as a boot compiler.

See #23195 for tracking this issue.

- - - - -
61a2dfaa by Andrew Lelechenko at 2023-03-30T14:35:57-04:00
Add {-# WARNING #-} to Data.List.{head,tail}

- - - - -
8f15c47c by Andrew Lelechenko at 2023-03-30T14:35:57-04:00
Fixes to accomodate Data.List.{head,tail} with {-# WARNING #-}

- - - - -
7c7dbade by Andrew Lelechenko at 2023-03-30T14:35:57-04:00
Bump submodules

- - - - -
d2d8251b by Andrew Lelechenko at 2023-03-30T14:35:57-04:00
Fix tests

- - - - -
3d38dcb6 by sheaf at 2023-03-30T14:35:57-04:00
Proxies for head and tail: review suggestions
- - - - -
930edcfd by sheaf at 2023-03-30T14:36:33-04:00
docs: move RecordUpd changelog entry to 9.8

This was accidentally included in the 9.6 changelog
instead of the 9.6 changelog.
- - - - -
6f885e65 by sheaf at 2023-03-30T14:37:09-04:00
Add LANGUAGE GADTs to GHC.Rename.Env

We need to enable this extension for the file to compile with ghc 9.2,
as we are pattern matching on a GADT and this required the GADT extension
to be enabled until 9.4.
- - - - -
6d6a37a8 by Cheng Shao at 2023-03-30T18:42:56+00:00
ci: make lint-ci-config job fast again

We don't pin our nixpkgs revision and tracks the default
nixpkgs-unstable channel anyway. Instead of using
haskell.packages.ghc924, we should be using haskell.packages.ghc92 to
maximize the binary cache hit rate and make lint-ci-config job fast
again. Also bumps the nix docker image to the latest revision.

- - - - -
ef1548c4 by Cheng Shao at 2023-03-30T18:42:56+00:00
ci: ensure that all non-i386 pipelines do parallel xz compression

We can safely enable parallel xz compression for non-i386 pipelines.
However, previously we didn't export XZ_OPT, so the xz process won't
see it if XZ_OPT hasn't already been set in the current job.

- - - - -
20432d16 by Cheng Shao at 2023-03-30T18:42:56+00:00
ci: unset CROSS_EMULATOR for js job

- - - - -
4a24dbbe by Cheng Shao at 2023-03-30T18:42:56+00:00
ci: fix lint-testsuite job

The list_broken make target will transitively depend on the
calibrate.out target, which used STAGE1_GHC instead of TEST_HC. It
really should be TEST_HC since that's what get passed in the gitlab CI
config.

- - - - -
cea56ccc by Cheng Shao at 2023-03-30T18:42:56+00:00
ci: use alpine3_17-wasm image for wasm jobs

Bump the ci-images dependency and use the new alpine3_17-wasm docker
image for wasm jobs.

- - - - -
79d0cb32 by Ben Gamari at 2023-03-30T18:43:53+00:00
testsuite/driver: Add basic support for testing cross-compilers

- - - - -
e7392b4e by Ben Gamari at 2023-03-30T18:43:53+00:00
testsuite/driver: Normalize away differences in ghc executable name

- - - - -
ee160d06 by Ben Gamari at 2023-03-30T18:43:53+00:00
hadrian: Pass CROSS_EMULATOR to runtests.py

- - - - -
30c84511 by Cheng Shao at 2023-03-30T18:43:53+00:00
testsuite: don't add optllvm way for wasm32

- - - - -
f1beee36 by Cheng Shao at 2023-03-30T18:43:53+00:00
testsuite: normalize the .wasm extension

- - - - -
a984a103 by Cheng Shao at 2023-03-30T18:43:53+00:00
testsuite: strip the cross ghc prefix in output and error message

- - - - -
f7478d95 by Cheng Shao at 2023-03-30T18:43:53+00:00
testsuite: handle target executable extension

- - - - -
8fe8b653 by Cheng Shao at 2023-03-30T18:43:53+00:00
testsuite: mypy typing error fixes

This patch fixes some mypy typing errors which weren't caught in
previous linting jobs.

- - - - -
0149f32f by Cheng Shao at 2023-03-30T18:43:53+00:00
testsuite: use context variable instead of thread-local variable

This patch changes a thread-local variable to context variable
instead, which works as intended when the testsuite transitions to use
asyncio & coroutines instead of multi-threading to concurrently run
test cases. Note that this also raises the minimum Python version to
3.7.

- - - - -
ea853ff0 by Cheng Shao at 2023-03-30T18:43:53+00:00
testsuite: asyncify the testsuite driver

This patch refactors the testsuite driver, gets rid of multi-threading
logic for running test cases concurrently, and uses asyncio &
coroutines instead. This is not yak shaving for its own sake; the
previous multi-threading logic is prone to livelock/deadlock
conditions for some reason, even if the total number of threads is
bounded to a thread pool's capacity.

The asyncify change is an internal implementation detail of the
testsuite driver and does not impact most GHC maintainers out there.
The patch does not touch the .T files, test cases can be
added/modified the exact same way as before.

- - - - -
0077cb22 by Matthew Pickering at 2023-03-31T21:28:28-04:00
Add test for T23184

There was an outright bug, which Simon fixed in July 2021, as a little side-fix on a complicated patch:

```
commit 6656f0165a30fc2a22208532ba384fc8e2f11b46
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Fri Jul 23 23:57:01 2021 +0100

    A bunch of changes related to eta reduction

    This is a large collection of changes all relating to eta
    reduction, originally triggered by #18993, but there followed
    a long saga.

    Specifics:

...lots of lines omitted...

    Other incidental changes

    * Fix a fairly long-standing outright bug in the ApplyToVal case of
      GHC.Core.Opt.Simplify.mkDupableContWithDmds. I was failing to take the
      tail of 'dmds' in the recursive call, which meant the demands were All
      Wrong.  I have no idea why this has not caused problems before now.
```

Note this "Fix a fairly longstanding outright bug".   This is the specific fix
```
@@ -3552,8 +3556,8 @@ mkDupableContWithDmds env dmds
         --              let a = ...arg...
         --              in [...hole...] a
         -- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable
-    do  { let (dmd:_) = dmds   -- Never fails
-        ; (floats1, cont') <- mkDupableContWithDmds env dmds cont
+    do  { let (dmd:cont_dmds) = dmds   -- Never fails
+        ; (floats1, cont') <- mkDupableContWithDmds env cont_dmds cont
         ; let env' = env `setInScopeFromF` floats1
         ; (_, se', arg') <- simplArg env' dup se arg
         ; (let_floats2, arg'') <- makeTrivial env NotTopLevel dmd (fsLit "karg") arg'
```
Ticket #23184 is a report of the bug that this diff fixes.

- - - - -
62d25071 by mangoiv at 2023-04-01T04:20:01-04:00
[feat] make ($) representation polymorphic
- this change was approved by the CLC in [1] following a CLC proposal [2]
- make ($) representation polymorphic (adjust the type signature)
- change ($) implementation to allow additional polymorphism
- adjust the haddock of ($) to reflect these changes
- add additional documentation to document these changes
- add changelog entry
- adjust tests (move now succeeding tests and adjust stdout of some
  tests)

[1] https://github.com/haskell/core-libraries-committee/issues/132#issuecomment-1487456854
[2] https://github.com/haskell/core-libraries-committee/issues/132

- - - - -
77c33fb9 by Artem Pelenitsyn at 2023-04-01T04:20:41-04:00
User Guide: update copyright year: 2020->2023

- - - - -
3b5be05a by doyougnu at 2023-04-01T09:42:31-04:00
driver: Unit State Data.Map -> GHC.Unique.UniqMap

In pursuit of #22426. The driver and unit state are major contributors.

This commit also bumps the haddock submodule to reflect the API changes in
UniqMap.

-------------------------
Metric Decrease:
    MultiComponentModules
    MultiComponentModulesRecomp
    T10421
    T10547
    T12150
    T12234
    T12425
    T13035
    T16875
    T18140
    T18304
    T18698a
    T18698b
    T18923
    T20049
    T5837
    T6048
    T9198
-------------------------

- - - - -
a84fba6e by Torsten Schmits at 2023-04-01T09:43:12-04:00
Add structured error messages for GHC.Tc.TyCl

Tracking ticket: #20117

MR: !10183

This converts uses of `mkTcRnUnknownMessage` to newly added constructors
of `TcRnMessage`.

- - - - -
6e2eb275 by doyougnu at 2023-04-01T18:27:56-04:00
JS: Linker: use saturated JExpr

Follow on to MR!10142 in pursuit of #22736

- - - - -
3da69346 by sheaf at 2023-04-01T18:28:37-04:00
Improve haddocks of template-haskell Con datatype

This adds a bit more information, in particular about the lists of
constructors in the GadtC and RecGadtC cases.

- - - - -
3b7bbb39 by sheaf at 2023-04-01T18:28:37-04:00
TH: revert changes to GadtC & RecGadtC

Commit 3f374399 included a breaking-change to the template-haskell
library when it made the GadtC and RecGadtC constructors take non-empty
lists of names. As this has the potential to break many users' packages,
we decided to revert these changes for now.

- - - - -
f60f6110 by Andrew Lelechenko at 2023-04-02T18:59:30-04:00
Rework documentation for data Char

- - - - -
43ebd5dc by Andrew Lelechenko at 2023-04-02T19:00:09-04:00
cmm: implement parsing of MO_AtomicRMW from hand-written CMM files

Fixes #23206

- - - - -
ab9cd52d by Sylvain Henry at 2023-04-03T08:15:21-04:00
ghc-heap: remove wrong Addr# coercion (#23181)

Conversion from Addr# to I# isn't correct with the JS backend.

- - - - -
2b2afff3 by Matthew Pickering at 2023-04-03T08:15:58-04:00
hadrian: Update bootstrap plans for 9.2.6, 9.2.7, 9.4.4, 9.4.5, 9.6.1

Also fixes the ./generate_bootstrap_plans script which was recently
broken

We can hopefully drop the 9.2 plans soon but they still work so kept
them around for now.

- - - - -
c2605e25 by Matthew Pickering at 2023-04-03T08:15:58-04:00
ci: Add job to test 9.6 bootstrapping

- - - - -
53e4d513 by Krzysztof Gogolewski at 2023-04-03T08:16:35-04:00
hadrian: Improve option parsing

Several options in Hadrian had their argument marked as optional
(`OptArg`), but if the argument wasn't there they were just giving an
error. It's more idiomatic to mark the argument as required instead;
the code uses less Maybes, the parser can enforce that the argument
is present, --help gives better output.

- - - - -
a8e36892 by Sylvain Henry at 2023-04-03T08:17:16-04:00
JS: fix issues with FD api support

- Add missing implementations for fcntl_read/write/lock
- Fix fdGetMode

These were found while implementing TH in !9779. These functions must be
used somehow by the external interpreter code.

- - - - -
8b092910 by Haskell-mouse at 2023-04-03T19:31:26-04:00
Convert diagnostics in GHC.Rename.HsType to proper TcRnMessage

I've turned all occurrences of TcRnUnknownMessage in GHC.Rename.HsType
module into a proper TcRnMessage.
Instead, these TcRnMessage messages were introduced:

TcRnDataKindsError
TcRnUnusedQuantifiedTypeVar
TcRnIllegalKindSignature
TcRnUnexpectedPatSigType
TcRnSectionPrecedenceError
TcRnPrecedenceParsingError
TcRnIllegalKind
TcRnNegativeNumTypeLiteral
TcRnUnexpectedKindVar
TcRnBindMultipleVariables
TcRnBindVarAlreadyInScope

- - - - -
220a7a48 by Krzysztof Gogolewski at 2023-04-03T19:32:02-04:00
Fixes around unsafeCoerce#

1. `unsafeCoerce#` was documented in `GHC.Prim`. But since the overhaul
in 74ad75e87317, `unsafeCoerce#` is no longer defined there.
I've combined the documentation in `GHC.Prim` with the `Unsafe.Coerce` module.

2. The documentation of `unsafeCoerce#` stated that you should not
cast a function to an algebraic type, even if you later cast it back
before applying it. But ghci was doing that type of cast, as can be seen
with 'ghci -ddump-ds' and typing 'x = not'. I've changed it to use Any
following the documentation.

- - - - -
9095e297 by Matthew Craven at 2023-04-04T01:04:10-04:00
Add a few more memcpy-ish primops

* copyMutableByteArrayNonOverlapping#
* copyAddrToAddr#
* copyAddrToAddrNonOverlapping#
* setAddrRange#

The implementations of copyBytes, moveBytes, and fillBytes
in base:Foreign.Marshal.Utils now use these new primops,
which can cause us to work a bit harder generating code for them,
resulting in the metric increase in T21839c observed by CI on
some architectures.  But in exchange, we get better code!

Metric Increase:
    T21839c

- - - - -
f7da530c by Matthew Craven at 2023-04-04T01:04:10-04:00
StgToCmm: Upgrade -fcheck-prim-bounds behavior

Fixes #21054. Additionally, we can now check for range overlap
when generating Cmm for primops that use memcpy internally.

- - - - -
cd00e321 by sheaf at 2023-04-04T01:04:50-04:00
Relax assertion in varToRecFieldOcc

When using Template Haskell, it is possible to re-parent a field OccName
belonging to one data constructor to another data constructor. The
lsp-types package did this in order to "extend" a data constructor
with additional fields.

This ran into an assertion in 'varToRecFieldOcc'. This assertion
can simply be relaxed, as the resulting splices are perfectly sound.

Fixes #23220

- - - - -
eed0d930 by Sylvain Henry at 2023-04-04T11:09:15-04:00
GHCi.RemoteTypes: fix doc and avoid unsafeCoerce (#23201)

- - - - -
071139c3 by Ryan Scott at 2023-04-04T11:09:51-04:00
Make INLINE pragmas for pattern synonyms work with TH

Previously, the code for converting `INLINE <name>` pragmas from TH splices
used `vNameN`, which assumed that `<name>` must live in the variable namespace.
Pattern synonyms, on the other hand, live in the constructor namespace. I've
fixed the issue by switching to `vcNameN` instead, which works for both the
variable and constructor namespaces.

Fixes #23203.

- - - - -
7c16f3be by Krzysztof Gogolewski at 2023-04-04T17:13:00-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).

- - - - -
c165f079 by sheaf at 2023-04-04T17:13:40-04:00
Add testcase for #23192

This issue around solving of constraints arising from superclass
expansion using other constraints also borned from superclass expansion
was the topic of commit aed1974e. That commit made sure we don't emit
a "redundant constraint" warning in a situation in which removing the
constraint would cause errors.

Fixes #23192

- - - - -
d1bb16ed by Ben Gamari at 2023-04-06T03:40:45-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

- - - - -
04b80850 by Brandon Chinn at 2023-04-06T03:41:21-04:00
Fix reverse flag for -Wunsupported-llvm-version
- - - - -
0c990e13 by Pierre Le Marre at 2023-04-06T10:16:29+00:00
Add release note for GHC.Unicode refactor in base-4.18.

Also merge CLC proposal 130 in base-4.19 with CLC proposal 59 in
base-4.18 and add proper release date.

- - - - -
cbbfb283 by Alex Dixon at 2023-04-07T18:27:45-04:00
Improve documentation for ($) (#22963)

- - - - -
5193c2b0 by Alex Dixon at 2023-04-07T18:27:45-04:00
Remove trailing whitespace from ($) commentary

- - - - -
b384523b by Sebastian Graf at 2023-04-07T18:27:45-04:00
Adjust wording wrt representation polymorphism of ($)
- - - - -
6a788f0a by Torsten Schmits at 2023-04-07T22:29:28-04:00
Add structured error messages for GHC.Tc.TyCl.Utils

Tracking ticket: #20117

MR: !10251

This converts uses of `mkTcRnUnknownMessage` to newly added constructors
of `TcRnMessage`.

- - - - -
3ba77b36 by sheaf at 2023-04-07T22:30:07-04:00
Renamer: don't call addUsedGRE on an exact Name

When looking up a record field in GHC.Rename.Env.lookupRecFieldOcc,
we could end up calling addUsedGRE on an exact Name, which would then
lead to a panic in the bestImport function: it would be incapable of
processing a GRE which is not local but also not brought into scope
by any imports (as it is referred to by its unique instead).

Fixes #23240

- - - - -
bc4795d2 by Krzysztof Gogolewski at 2023-04-11T19:24:54-04:00
Add support for -debug in the testsuite

Confusingly, GhcDebugged referred to GhcDebugAssertions.

- - - - -
b7474b57 by Krzysztof Gogolewski at 2023-04-11T19:24:54-04:00
Add missing cases in -Di prettyprinter

Fixes #23142

- - - - -
6c392616 by Cheng Shao at 2023-04-11T19:25:31-04:00
compiler: make WasmCodeGenM an instance of MonadUnique

- - - - -
05d26a65 by Cheng Shao at 2023-04-11T19:25:31-04:00
compiler: apply cmm node-splitting for wasm backend

This patch applies cmm node-splitting for wasm32 NCG, which is
required when handling irreducible CFGs. Fixes #23237.

- - - - -
f1892cc0 by Andrew Lelechenko at 2023-04-11T19:26:09-04:00
Set base 'maintainer' field to CLC

- - - - -
ecf22da3 by Simon Peyton Jones at 2023-04-11T19:26:45-04:00
Clarify a couple of Notes about 'nospec'

- - - - -
ebd8918b by Oleg Grenrus at 2023-04-12T12:32:57-04:00
Allow generation of TTH syntax with TH

In other words allow generation of typed splices and brackets with
Untyped Template Haskell.

That is useful in cases where a library is build with TTH in mind,
but we still want to generate some auxiliary declarations,
where TTH cannot help us, but untyped TH can.
Such example is e.g. `staged-sop` which works with TTH,
but we would like to derive `Generic` declarations with TH.

An alternative approach is to use `unsafeCodeCoerce`, but then the
derived `Generic` instances would be type-checked only at use sites,
i.e. much later. Also `-ddump-splices` output is quite ugly:
user-written instances would use TTH brackets, not `unsafeCodeCoerce`.

This commit doesn't allow generating of untyped template splices
and brackets with untyped TH, as I don't know why one would want to do
that (instead of merging the splices, e.g.)

- - - - -
690d0225 by Rodrigo Mesquita at 2023-04-12T12:33:33-04:00
Add regression test for #23229

- - - - -
59321879 by Sylvain Henry at 2023-04-13T08:50:33-04:00
Add quotRem rules (#22152)

  case quotRemInt# x y of
     (# q, _ #) -> body
  ====>
   case quotInt# x y of
     q -> body

  case quotRemInt# x y of
     (# _, r #) -> body
  ====>
   case remInt# x y of
     r -> body

- - - - -
4dd02122 by Sylvain Henry at 2023-04-13T08:50:33-04:00
Add quot folding rule (#22152)

   (x / l1) / l2
   l1 and l2 /= 0
   l1*l2 doesn't overflow
   ==> x / (l1 * l2)

- - - - -
1148ac72 by Sylvain Henry at 2023-04-13T08:50:33-04:00
Make Int64/Word64 division ok for speculation too.

Only when the divisor is definitely non-zero.

- - - - -
8af401cc by Sylvain Henry at 2023-04-13T08:50:33-04:00
Make WordQuotRem2Op ok-for-speculation too

- - - - -
27d2978e by Josh Meredith at 2023-04-13T08:51:09-04:00
Base/JS: GHC.JS.Foreign.Callback module (issue 23126)

* Add the Callback module for "exporting" Haskell functions
to be available to plain JavaScript code

* Fix some primitives defined in GHC.JS.Prim

* Add a JavaScript section to the user guide with instructions
on how to use the JavaScript FFI, building up to using Callbacks
to interact with the browser

* Add tests for the JavaScript FFI and Callbacks

- - - - -
a34aa8da by Adam Sandberg Ericsson at 2023-04-14T04:17:52-04:00
rts: improve memory ordering and add some comments in the StablePtr implementation

- - - - -
d7a768a4 by Matthew Pickering at 2023-04-14T04:18:28-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

- - - - -
d48fbfea by Simon Peyton Jones at 2023-04-14T04:19:05-04:00
Stop if type constructors have kind errors

Otherwise we get knock-on errors, such as #23252.

This makes GHC fail a bit sooner, and I have not attempted to add
recovery code, to add a fake TyCon place of the erroneous one,
in an attempt to get more type errors in one pass.  We could
do that (perhaps) if there was a call for it.

- - - - -
2371d6b2 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00
Major refactor in the handling of equality constraints

This MR substantially refactors the way in which the constraint
solver deals with equality constraints.  The big thing is:

* Intead of a pipeline in which we /first/ canonicalise and /then/
  interact (the latter including performing unification) the two steps
  are more closely integreated into one.  That avoids the current
  rather indirect communication between the two steps.

The proximate cause for this refactoring is fixing #22194, which involve
solving   [W] alpha[2] ~ Maybe (F beta[4])
by doing this:
          alpha[2] := Maybe delta[2]
          [W] delta[2] ~ F beta[4]
That is, we don't promote beta[4]!  This is very like introducing a cycle
breaker, and was very awkward to do before, but now it is all nice.
See GHC.Tc.Utils.Unify Note [Promotion and level-checking] and
Note [Family applications in canonical constraints].

The big change is this:

* Several canonicalisation checks (occurs-check, cycle-breaking,
  checking for concreteness) are combined into one new function:
     GHC.Tc.Utils.Unify.checkTyEqRhs

  This function is controlled by `TyEqFlags`, which says what to do
  for foralls, type families etc.

* `canEqCanLHSFinish` now sees if unification is possible, and if so,
  actually does it: see `canEqCanLHSFinish_try_unification`.

There are loads of smaller changes:

* The on-the-fly unifier `GHC.Tc.Utils.Unify.unifyType` has a
  cheap-and-cheerful version of `checkTyEqRhs`, called
  `simpleUnifyCheck`.  If `simpleUnifyCheck` succeeds, it can unify,
  otherwise it defers by emitting a constraint. This is simpler than
  before.

* I simplified the swapping code in `GHC.Tc.Solver.Equality.canEqCanLHS`.
  Especially the nasty stuff involving `swap_for_occurs` and
  `canEqTyVarFunEq`.  Much nicer now.  See
      Note [Orienting TyVarLHS/TyFamLHS]
      Note [Orienting TyFamLHS/TyFamLHS]

* Added `cteSkolemOccurs`, `cteConcrete`, and `cteCoercionHole` to the
  problems that can be discovered by `checkTyEqRhs`.

* I fixed #23199 `pickQuantifiablePreds`, which actually allows GHC to
  to accept both cases in #22194 rather than rejecting both.

Yet smaller:

* Added a `synIsConcrete` flag to `SynonymTyCon` (alongside `synIsFamFree`)
  to reduce the need for synonym expansion when checking concreteness.
  Use it in `isConcreteType`.

* Renamed `isConcrete` to `isConcreteType`

* Defined `GHC.Core.TyCo.FVs.isInjectiveInType` as a more efficient
  way to find if a particular type variable is used injectively than
  finding all the injective variables.  It is called in
  `GHC.Tc.Utils.Unify.definitely_poly`, which in turn is used quite a
  lot.

* Moved `rewriterView` to `GHC.Core.Type`, so we can use it from the
  constraint solver.

Fixes #22194, #23199

Compile times decrease by an average of 0.1%; but there is a 7.4%
drop in compiler allocation on T15703.

Metric Decrease:
    T15703

- - - - -
99b2734b by Simon Peyton Jones at 2023-04-14T20:01:02+02:00
Add some documentation about redundant constraints

- - - - -
3f2d0eb8 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00
Improve partial signatures

This MR fixes #23223. The changes are in two places:

* GHC.Tc.Bind.checkMonomorphismRestriction
  See the new `Note [When the MR applies]`
  We now no longer stupidly attempt to apply the MR when the user
  specifies a context, e.g.   f :: Eq a => _ -> _

* GHC.Tc.Solver.decideQuantification
  See rewritten `Note [Constraints in partial type signatures]`

Fixing this bug apparently breaks three tests:

* partial-sigs/should_compile/T11192
* partial-sigs/should_fail/Defaulting1MROff
* partial-sigs/should_fail/T11122

However they are all symptoms of #23232, so I'm marking them as
expect_broken(23232).

I feel happy about this MR. Nice.

- - - - -
23e2a8a0 by Simon Peyton Jones at 2023-04-14T20:01:02+02:00
Make approximateWC a bit cleverer

This MR fixes #23224: making approximateWC more clever

See the long `Note [ApproximateWC]` in GHC.Tc.Solver

All this is delicate and ad-hoc -- but it /has/ to be: we are
talking about inferring a type for a binding in the presence of
GADTs, type families and whatnot: known difficult territory.
We just try as hard as we can.

- - - - -
2c040246 by Matthew Pickering at 2023-04-15T00:57:14-04:00
docs: Update template-haskell docs to use Code Q a rather than Q (TExp a)

Since GHC Proposal #195, the type of [|| ... ||] has been Code Q a
rather than Q (TExp a). The documentation in the `template-haskell`
library wasn't updated to reflect this change.

Fixes #23148

- - - - -
0da18eb7 by Krzysztof Gogolewski at 2023-04-15T14:35:53+02:00
Show an error when we cannot default a concrete tyvar

Fixes #23153

- - - - -
bad2f8b8 by sheaf at 2023-04-15T15:14:36+02:00
Handle ConcreteTvs in inferResultToType

inferResultToType was discarding the ir_frr information, which meant
some metavariables ended up being MetaTvs instead of ConcreteTvs.

This function now creates new ConcreteTvs as necessary, instead of
always creating MetaTvs.

Fixes #23154

- - - - -
3b0ea480 by Simon Peyton Jones at 2023-04-16T18:12:20-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

- - - - -
a1371ebb by Oleg Grenrus at 2023-04-16T18:12:59-04:00
Add import lists to few GHC.Driver.Session imports

Related to https://gitlab.haskell.org/ghc/ghc/-/issues/23261.
There are a lot of GHC.Driver.Session which only use DynFlags,
but not the parsing code.

- - - - -
51479ceb by Matthew Pickering at 2023-04-17T08:08:48-04:00
Account for special GHC.Prim import in warnUnusedPackages

The GHC.Prim import is treated quite specially primarily because there
isn't an interface file for GHC.Prim. Therefore we record separately in
the ModSummary if it's imported or not so we don't go looking for it.

This logic hasn't made it's way to `-Wunused-packages` so if you
imported GHC.Prim then the warning would complain you didn't use
`-package ghc-prim`.

Fixes #23212

- - - - -
1532a8b2 by Simon Peyton Jones at 2023-04-17T08:09:24-04:00
Add regression test for #23199

- - - - -
0158c5f1 by Ryan Scott at 2023-04-17T18:43:27-04:00
validDerivPred: Reject exotic constraints in IrredPreds

This brings the `IrredPred` case in sync with the treatment of `ClassPred`s as
described in `Note [Valid 'deriving' predicate]` in `GHC.Tc.Validity`. Namely,
we should reject `IrredPred`s that are inferred from `deriving` clauses whose
arguments contain other type constructors, as described in `(VD2) Reject exotic
constraints` of that Note.  This has the nice property that `deriving` clauses
whose inferred instance context mention `TypeError` will now emit the type
error in the resulting error message, which better matches existing intuitions
about how `TypeError` should work.

While I was in town, I noticed that much of `Note [Valid 'deriving' predicate]`
was duplicated in a separate `Note [Exotic derived instance contexts]` in
`GHC.Tc.Deriv.Infer`. I decided to fold the latter Note into the former so that
there is a single authority on describing the conditions under which an
inferred `deriving` constraint can be considered valid.

This changes the behavior of `deriving` in a way that existing code might
break, so I have made a mention of this in the GHC User's Guide. It seems very,
very unlikely that much code is relying on this strange behavior, however, and
even if there is, there is a clear, backwards-compatible migration path using
`StandaloneDeriving`.

Fixes #22696.

- - - - -
10364818 by Krzysztof Gogolewski at 2023-04-17T18:44:03-04:00
Misc cleanup

- Use dedicated list functions
- Make cloneBndrs and cloneRecIdBndrs monadic
- Fix invalid haddock comments in libraries/base

- - - - -
5e1d33d7 by Matthew Pickering at 2023-04-18T10:31:02-04:00
Convert interface file loading errors into proper diagnostics

This patch converts all the errors to do with loading interface files
into proper structured diagnostics.

* DriverMessage: Sometimes in the driver we attempt to load an interface
  file so we embed the IfaceMessage into the DriverMessage.
* TcRnMessage: Most the time we are loading interface files during
  typechecking, so we embed the IfaceMessage

This patch also removes the TcRnInterfaceLookupError constructor which
is superceded by the IfaceMessage, which is now structured compared to
just storing an SDoc before.

- - - - -
df1a5811 by sheaf at 2023-04-18T10:31:43-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

- - - - -
d442ac05 by Sylvain Henry at 2023-04-19T20:04:35-04:00
JS: fix thread-related primops

- - - - -
7a96f90b by Bryan Richter at 2023-04-19T20:05:11-04:00
CI: Disable abi-test-nightly

See #23269

- - - - -
ab6c1d29 by Sylvain Henry at 2023-04-19T20:05:50-04:00
Testsuite: don't use obsolescent egrep (#22351)

Recent egrep displays the following message, breaking golden tests:

  egrep: warning: egrep is obsolescent; using grep -E

Switch to using "grep -E" instead

- - - - -
f15b0ce5 by Matthew Pickering at 2023-04-20T11:01:06-04:00
hadrian: Pass haddock file arguments in a response file

In !10119 CI was failing on windows because the command line was too
long. We can mitigate this by passing the file arguments to haddock in a
response file.

We can't easily pass all the arguments in a response file because the
`+RTS` arguments can't be placed in the response file.

Fixes #23273

- - - - -
7012ec2f by tocic at 2023-04-20T11:01:42-04:00
Fix doc typo in GHC.Read.readList

- - - - -
5c873124 by sheaf at 2023-04-20T18:33:34-04:00
Implement -jsem: parallelism controlled by semaphores

See https://github.com/ghc-proposals/ghc-proposals/pull/540/ for a
complete description for the motivation for this feature.

The `-jsem` option allows a build tool to pass a semaphore to GHC which
GHC can use in order to control how much parallelism it requests.

GHC itself acts as a client in the GHC jobserver protocol.

```
GHC Jobserver Protocol
~~~~~~~~~~~~~~~~~~~~~~

This proposal introduces the GHC Jobserver Protocol. This protocol allows
a server to dynamically invoke many instances of a client process,
while restricting all of those instances to use no more than <n> capabilities.
This is achieved by coordination over a system semaphore (either a POSIX
semaphore [6]_  in the case of Linux and Darwin, or a Win32 semaphore [7]_
in the case of Windows platforms).

There are two kinds of participants in the GHC Jobserver protocol:

- The *jobserver* creates a system semaphore with a certain number of
  available tokens.

  Each time the jobserver wants to spawn a new jobclient subprocess, it **must**
  first acquire a single token from the semaphore, before spawning
  the subprocess. This token **must** be released once the subprocess terminates.

  Once work is finished, the jobserver **must** destroy the semaphore it created.

- A *jobclient* is a subprocess spawned by the jobserver or another jobclient.

  Each jobclient starts with one available token (its *implicit token*,
  which was acquired by the parent which spawned it), and can request more
  tokens through the Jobserver Protocol by waiting on the semaphore.

  Each time a jobclient wants to spawn a new jobclient subprocess, it **must**
  pass on a single token to the child jobclient. This token can either be the
  jobclient's implicit token, or another token which the jobclient acquired
  from the semaphore.

  Each jobclient **must** release exactly as many tokens as it has acquired from
  the semaphore (this does not include the implicit tokens).
```

Build tools such as cabal act as jobservers in the protocol and are
responsibile for correctly creating, cleaning up and managing the
semaphore.

Adds a new submodule (semaphore-compat) for managing and interacting
with semaphores in a cross-platform way.

Fixes #19349

- - - - -
52d3e9b4 by Ben Gamari at 2023-04-20T18:34:11-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

- - - - -
1db30fe1 by Ben Gamari at 2023-04-20T18:34:11-04:00
testsuite: Add test for #23071

- - - - -
dae514f9 by tocic at 2023-04-21T13:31:21-04:00
Fix doc typos in libraries/base/GHC

- - - - -
113e21d7 by Sylvain Henry at 2023-04-21T13:32:01-04:00
Testsuite: replace some js_broken/js_skip predicates with req_c

Using req_c is more precise.

- - - - -
038bb031 by Krzysztof Gogolewski at 2023-04-21T18:03:04-04:00
Minor doc fixes

- Add docs/index.html to .gitignore.
  It is created by ./hadrian/build docs, and it was the only file
  in Hadrian's templateRules not present in .gitignore.
- Mention that MultiWayIf supports non-boolean guards
- Remove documentation of optdll - removed in 2007, 763daed95
- Fix markdown syntax

- - - - -
e826cdb2 by amesgen at 2023-04-21T18:03:44-04:00
User's guide: DeepSubsumption is implied by Haskell{98,2010}

- - - - -
499a1c20 by PHO at 2023-04-23T13:39:32-04:00
Implement executablePath for Solaris and make getBaseDir less platform-dependent

Use base-4.17 executablePath when possible, and fall back on
getExecutablePath when it's not available. The sole reason why getBaseDir
had #ifdef's was apparently that getExecutablePath wasn't reliable, and we
could reduce the number of CPP conditionals by making use of
executablePath instead.

Also export executablePath on js_HOST_ARCH.

- - - - -
97a6f7bc by tocic at 2023-04-23T13:40:08-04:00
Fix doc typos in libraries/base

- - - - -
787c6e8c by Ben Gamari at 2023-04-24T12:19:06-04:00
testsuite/T20137: Avoid impl.-defined behavior

Previously we would cast pointers to uint64_t. However, implementations
are allowed to either zero- or sign-extend such casts. Instead cast to
uintptr_t to avoid this.

Fixes #23247.

- - - - -
87095f6a by Cheng Shao at 2023-04-24T12:19:44-04:00
rts: always build 64-bit atomic ops

This patch does a few things:

- Always build 64-bit atomic ops in rts/ghc-prim, even on 32-bit
  platforms
- Remove legacy "64bit" cabal flag of rts package
- Fix hs_xchg64 function prototype for 32-bit platforms
- Fix AtomicFetch test for wasm32

- - - - -
2685a12d by Cheng Shao at 2023-04-24T12:20:21-04:00
compiler: don't install signal handlers when the host platform doesn't have signals

Previously, large parts of GHC API will transitively invoke
withSignalHandlers, which doesn't work on host platforms without
signal functionality at all (e.g. wasm32-wasi). By making
withSignalHandlers a no-op on those platforms, we can make more parts
of GHC API work out of the box when signals aren't supported.

- - - - -
1338b7a3 by Cheng Shao at 2023-04-24T16:21:30-04:00
hadrian: fix non-ghc program paths passed to testsuite driver when testing cross GHC

- - - - -
1a10f556 by Andrew Lelechenko at 2023-04-24T16:22:09-04:00
Add since pragma to Data.Functor.unzip

- - - - -
0da9e882 by Soham Chowdhury at 2023-04-25T00:15:22-04:00
More informative errors for bad imports (#21826)

- - - - -
ebd5b078 by Josh Meredith at 2023-04-25T00:15:58-04:00
JS/base: provide implementation for mkdir (issue 22374)

- - - - -
8f656188 by Josh Meredith at 2023-04-25T18:12:38-04:00
JS: Fix h$base_access implementation (issue 22576)

- - - - -
74c55712 by Andrei Borzenkov at 2023-04-25T18:13:19-04:00
Give more guarntees about ImplicitParams (#23289)

- Added new section in the GHC user's guide that legends behavior of
nested implicit parameter bindings in these two cases:

  let ?f = 1 in let ?f = 2 in ?f

and

  data T where MkT :: (?f :: Int) => T

  f :: T -> T -> Int
  f MkT MkT = ?f

- Added new test case to examine this behavior.

- - - - -
c30ac25f by Sebastian Graf at 2023-04-26T14:50:51-04:00
DmdAnal: Unleash demand signatures of free RULE and unfolding binders (#23208)

In #23208 we observed that the demand signature of a binder occuring in a RULE
wasn't unleashed, leading to a transitively used binder being discarded as
absent. The solution was to use the same code path that we already use for
handling exported bindings.

See the changes to `Note [Absence analysis for stable unfoldings and RULES]`
for more details.

I took the chance to factor out the old notion of a `PlusDmdArg` (a pair of a
`VarEnv Demand` and a `Divergence`) into `DmdEnv`, which fits nicely into our
existing framework. As a result, I had to touch quite a few places in the code.

This refactoring exposed a few small bugs around correct handling of bottoming
demand environments. As a result, some strictness signatures now mention uniques
that weren't there before which caused test output changes to T13143, T19969 and
T22112. But these tests compared whole -ddump-simpl listings which is a very
fragile thing to begin with. I changed what exactly they test for based on the
symptoms in the corresponding issues.

There is a single regression in T18894 because we are more conservative around
stable unfoldings now. Unfortunately it is not easily fixed; let's wait until
there is a concrete motivation before invest more time.

Fixes #23208.

- - - - -
77f506b8 by Josh Meredith at 2023-04-26T14:51:28-04:00
Refactor GenStgRhs to include the Type in both constructors (#23280, #22576, #22364)

Carry the actual type of an expression through the PreStgRhs and into GenStgRhs
for use in later stages. Currently this is used in the JavaScript backend to fix
some tests from the above mentioned issues: EtaExpandLevPoly, RepPolyWrappedVar2,
T13822, T14749.

- - - - -
052e2bb6 by Alan Zimmerman at 2023-04-26T14:52:05-04:00
EPA: Use ExplicitBraces only in HsModule

!9018 brought in exact print annotations in LayoutInfo for open and
close braces at the top level.

But it retained them in the HsModule annotations too.

Remove the originals, so exact printing uses LayoutInfo

- - - - -
d5c4629b by Cheng Shao at 2023-04-27T16:00:35-04:00
ci: update ci.sh to actually run the entire testsuite for wasm backend

For the time being, we still need to use in-tree mode and can't test
the bindist yet.

- - - - -
533d075e by Cheng Shao at 2023-04-27T16:00:35-04:00
ci: additional wasm32 manual jobs in validate pipelines

This patch enables bignum native & unregisterised wasm32 jobs as
manual jobs in validate pipelines, which can be useful to prevent
breakage when working on wasm32 related patches.

- - - - -
b5f00811 by Cheng Shao at 2023-04-27T16:00:35-04:00
testsuite: fix cross prefix stripping

This patch fixes cross prefix stripping in the testsuite driver. The
normalization logic used to only handle prefixes of the triple form
<arch>-<vendor>-<os>, now it's relaxed to allow any number of tokens
in the prefix tuple, so the cross prefix stripping logic would work
when ghc is configured with something like --target=wasm32-wasi.

- - - - -
6f511c36 by Cheng Shao at 2023-04-27T16:00:35-04:00
testsuite: include target exe extension in heap profile filenames

This patch fixes hp2ps related framework failures when testing the
wasm backend by including target exe extension in heap profile
filenames.

- - - - -
e6416b10 by Cheng Shao at 2023-04-27T16:00:35-04:00
testsuite: exclude ghci ways if no rts linker is present

This patch implements logic to automatically exclude ghci ways when
there is no rts linker. It's way better than having to annotate
individual test cases.

- - - - -
791cce64 by Cheng Shao at 2023-04-27T16:00:35-04:00
testsuite: fix permission bits in copy_files

When the testsuite driver copy files instead of symlinking them, it
should also copy the permission bits, otherwise there'll be permission
denied errors. Also, enforce file copying when testing wasm32, since
wasmtime doesn't handle host symlinks quite well
(https://github.com/bytecodealliance/wasmtime/issues/6227).

- - - - -
aa6afe8a by Cheng Shao at 2023-04-27T16:00:35-04:00
testsuite: add the req_ghc_with_threaded_rts predicate

This patch adds the req_ghc_with_threaded_rts predicate to the
testsuite to assert the platform has threaded RTS, and mark some tests
as req_ghc_with_threaded_rts. Also makes ghc_with_threaded_rts a
config field instead of a global variable.

- - - - -
ce580426 by Cheng Shao at 2023-04-27T16:00:35-04:00
testsuite: add the req_process predicate

This patch adds the req_process predicate to the testsuite to assert
the platform has a process model, also marking tests that involve
spawning processes as req_process. Also bumps hpc & process submodule.

- - - - -
cb933665 by Cheng Shao at 2023-04-27T16:00:35-04:00
testsuite: add the req_host_target_ghc predicate

This patch adds the req_host_target_ghc predicate to the testsuite to
assert the ghc compiler being tested can compile both host/target
code. When testing cross GHCs this is not supported yet, but it may
change in the future.

- - - - -
b174a110 by Cheng Shao at 2023-04-27T16:00:35-04:00
testsuite: add missing annotations for some tests

This patch adds missing annotations (req_th, req_dynamic_lib_support,
req_rts_linker) to some tests. They were discovered when testing
wasm32, though it's better to be explicit about what features they
require, rather than simply adding when(arch('wasm32'), skip).

- - - - -
bd2bfdec by Cheng Shao at 2023-04-27T16:00:35-04:00
testsuite: wasm32-specific fixes

This patch includes all wasm32-specific testsuite fixes.

- - - - -
4eaf2c2a by Josh Meredith at 2023-04-27T16:01:11-04:00
JS: change GHC.JS.Transform.identsS/E/V to take a saturated IR (#23304)

- - - - -
57277662 by sheaf at 2023-04-29T20:23:06+02:00
Add the Unsatisfiable class

This commit implements GHC proposal #433, adding the Unsatisfiable
class to the GHC.TypeError module. This provides an alternative to
TypeError for which error reporting is more predictable: we report it
when we are reporting unsolved Wanted constraints.

Fixes #14983 #16249 #16906 #18310 #20835

- - - - -
00a8a5ff by Torsten Schmits at 2023-04-30T03:45:09-04:00
Add structured error messages for GHC.Rename.Names

Tracking ticket: #20115

MR: !10336

This converts uses of `mkTcRnUnknownMessage` to newly added constructors
of `TcRnMessage`.

- - - - -
931c8d82 by Ben Orchard at 2023-05-03T20:16:18-04:00
Add sized primitive literal syntax

Adds a new LANGUAGE pragma ExtendedLiterals, which enables defining
unboxed numeric literals such as `0xFF#Word8 :: Word8#`.

Implements GHC proposal 0451:
https://github.com/ghc-proposals/ghc-proposals/blob/b384a538b34f79d18a0201455b7b3c473bc8c936/proposals/0451-sized-literals.rst

Fixes #21422.

Bumps haddock submodule.

Co-authored-by: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io>

- - - - -
f3460845 by Andrew Lelechenko at 2023-05-03T20:16:57-04:00
Document instances of Double

- - - - -
1e9caa1a by Sylvain Henry at 2023-05-03T20:17:37-04:00
Bump Cabal submodule (#22356)

- - - - -
4eafb52a by sheaf at 2023-05-03T20:18:16-04:00
Don't forget to check the parent in an export list

Commit 3f374399 introduced a bug which caused us to forget to include
the parent of an export item of the form T(..) (that is, IEThingAll)
when checking for duplicate exports.

Fixes #23318

- - - - -
8fde4ac8 by amesgen at 2023-05-03T20:18:57-04:00
Fix unlit path in cross bindists

- - - - -
8cc9a534 by Matthew Pickering at 2023-05-04T14:58:14-04:00
hadrian: Flavour: Change args -> extraArgs

Previously in a flavour definition you could override all the flags
which were passed to GHC. This causes issues when needed to compute a
package hash because we need to know what these extra arguments are
going to be before computing the hash. The solution is to modify flavour
so that the arguments you pass here are just extra ones rather than all
the arguments that you need to compile something.

This makes things work more like how cabal.project files work when you
give extra arguments to a package and also means that flavour
transformers correctly affect the hash.

- - - - -
3fdb18f8 by romes at 2023-05-04T14:58:14-04:00
Hardwire a better unit-id for ghc

Previously, the unit-id of ghc-the-library was fixed as `ghc`.
This was done primarily because the compiler must know the unit-id of
some packages (including ghc) a-priori to define wired-in names.

However, as seen in #20742, a reinstallable `ghc` whose unit-id is fixed
to `ghc` might result in subtle bugs when different ghc's interact.

A good example of this is having GHC_A load a plugin compiled by GHC_B,
where GHC_A and GHC_B are linked to ghc-libraries that are ABI
incompatible. Without a distinction between the unit-id of the ghc library
GHC_A is linked against and the ghc library the plugin it is loading was
compiled against, we can't check compatibility.

This patch gives a slightly better unit-id to ghc (ghc-version) by
(1) Not setting -this-unit-id to ghc, but rather to the new unit-id (modulo stage0)
(2) Adding a definition to `GHC.Settings.Config` whose value is the new unit-id.
    (2.1) `GHC.Settings.Config` is generated by Hadrian
    (2.2) and also by cabal through `compiler/Setup.hs`
This unit-id definition is imported by `GHC.Unit.Types` and used to
set the wired-in unit-id of "ghc", which was previously fixed to "ghc"

The commits following this one will improve the unit-id with a
cabal-style package hash and check compatibility when loading plugins.

Note that we also ensure that ghc's unit key matches unit id both when
hadrian or cabal builds ghc, and in this way we no longer need to add
`ghc` to the WiringMap.

- - - - -
6689c9c6 by romes at 2023-05-04T14:58:14-04:00
Validate compatibility of ghcs when loading plugins

Ensure, when loading plugins, that the ghc the plugin depends on is the
ghc loading the plugin -- otherwise fail to load the plugin.

Progress towards #20742.

- - - - -
db4be339 by romes at 2023-05-04T14:58:14-04:00
Add hashes to unit-ids created by hadrian

This commit adds support for computing an inputs hash for packages
compiled by hadrian. The result is that ABI incompatible packages should
be given different hashes and therefore be distinct in a cabal store.

Hashing is enabled by the `--flag`, and is off by default as the hash
contains a hash of the source files. We enable it when we produce
release builds so that the artifacts we distribute have the right unit
ids.

- - - - -
944a9b94 by Matthew Pickering at 2023-05-04T14:58:14-04:00
Use hash-unit-ids in release jobs

Includes fix upload_ghc_libs glob

- - - - -
116d7312 by Josh Meredith at 2023-05-04T14:58:51-04:00
JS: fix bounds checking (Issue 23123)

* For ByteArray-based bounds-checking, the JavaScript backend must use the
`len` field, instead of the inbuild JavaScript `length` field.

* Range-based operations must also check both the start and end of the range
for bounds

* All indicies are valid for ranges of size zero, since they are essentially no-ops

* For cases of ByteArray accesses (e.g. read as Int), the end index is
(i * sizeof(type) + sizeof(type) - 1), while the previous implementation
uses (i + sizeof(type) - 1). In the Int32 example, this is (i * 4 + 3)

* IndexByteArrayOp_Word8As* primitives use byte array indicies (unlike
the previous point), but now check both start and end indicies

* Byte array copies now check if the arrays are the same by identity and
then if the ranges overlap.

- - - - -
2d5c1dde by Sylvain Henry at 2023-05-04T14:58:51-04:00
Fix remaining issues with bound checking (#23123)

While fixing these I've also changed the way we store addresses into
ByteArray#. Addr# are composed of two parts: a JavaScript array and an
offset (32-bit number).

Suppose we want to store an Addr# in a ByteArray# foo at offset i.
Before this patch, we were storing both fields as a tuple in the "arr"
array field:

  foo.arr[i] = [addr_arr, addr_offset];

Now we only store the array part in the "arr" field and the offset
directly in the array:

  foo.dv.setInt32(i, addr_offset):
  foo.arr[i] = addr_arr;

It avoids wasting space for the tuple.

- - - - -
98c5ee45 by Luite Stegeman at 2023-05-04T14:59:31-04:00
JavaScript: Correct arguments to h$appendToHsStringA

fixes #23278

- - - - -
ca611447 by Josh Meredith at 2023-05-04T15:00:07-04:00
base/encoding: add an allocations performance test (#22946)

- - - - -
e3ddf58d by Krzysztof Gogolewski at 2023-05-04T15:00:44-04:00
linear types: Don't add external names to the usage env

This has no observable effect, but avoids storing useless data.

- - - - -
b3226616 by Andrei Borzenkov at 2023-05-04T15:01:25-04:00
Improved documentation for the Data.OldList.nub function

There was recomentation to use map head . group . sort instead of nub
function, but containers library has more suitable and efficient
analogue

- - - - -
e8b72ff6 by Ryan Scott at 2023-05-04T15:02:02-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.

- - - - -
275836d2 by Torsten Schmits at 2023-05-05T08:43:02+00:00
Add structured error messages for GHC.Rename.Utils

Tracking ticket: #20115

MR: !10350

This converts uses of `mkTcRnUnknownMessage` to newly added constructors
of `TcRnMessage`.

- - - - -
983ce558 by Oleg Grenrus at 2023-05-05T13:11:29-04:00
Use TemplateHaskellQuotes in TH.Syntax to construct Names

- - - - -
a5174a59 by Matthew Pickering at 2023-05-05T18:42:31-04: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.

- - - - -
18a7d03d by Aaron Allen at 2023-05-05T18:42:31-04: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>

- - - - -
6e776ed3 by Matthew Pickering at 2023-05-05T18:42:31-04:00
docs: Add Note [Timing of plugin initialization]

- - - - -
e1df8511 by Matthew Pickering at 2023-05-05T18:43:07-04:00
Incrementally update ghcup metadata in ghc/ghcup-metadata

This job paves the way for distributing nightly builds

* A new repo https://gitlab.haskell.org/ghc/ghcup-metadata stores the
  metadata on the "updates" branch.
* Each night this metadata is downloaded and the nightly builds are
  appended to the end of the metadata.
* The update job only runs on the scheduled nightly pipeline, not just
  when NIGHTLY=1.

Things which are not done yet

* Modify the retention policy for nightly jobs
* Think about building release flavour compilers to distribute nightly.

Fixes #23334

- - - - -
8f303d27 by Rodrigo Mesquita at 2023-05-05T22:04:31-04:00
docs: Remove mentions of ArrayArray# from unlifted FFI section

Fixes #23277

- - - - -
994bda56 by Torsten Schmits at 2023-05-05T22:05:12-04:00
Add structured error messages for GHC.Rename.Module

Tracking ticket: #20115

MR: !10361

This converts uses of `mkTcRnUnknownMessage` to newly added constructors
of `TcRnMessage`.

Only addresses the single warning missing from the previous MR.

- - - - -
3e3a6be4 by Ben Gamari at 2023-05-08T12:15:19+00:00
rts: Fix data-race in hs_init_ghc

As noticed by @Terrorjack, `hs_init_ghc` previously used non-atomic
increment/decrement on the RTS's initialization count. This may go wrong
in a multithreaded program which initializes the runtime multiple times.

Closes #22756.

- - - - -
78c8dc50 by Torsten Schmits at 2023-05-08T21:41:51-04:00
Add structured error messages for GHC.IfaceToCore

Tracking ticket: #20114

MR: !10390

This converts uses of `mkTcRnUnknownMessage` to newly added constructors
of `TcRnMessage`.

- - - - -
0e2df4c9 by Bryan Richter at 2023-05-09T12:03:35+03:00
Fix up rules for ghcup-metadata-nightly-push

- - - - -
b970e64f by Ben Gamari at 2023-05-09T08:41:33-04:00
testsuite: Add test for atomicSwapIORef

- - - - -
81cfefd2 by Ben Gamari at 2023-05-09T08:41:53-04:00
compiler: Implement atomicSwapIORef with xchg

As requested by @treeowl in CLC#139.

- - - - -
6b29154d by Ben Gamari at 2023-05-09T08:41:53-04:00
Make atomicSwapMutVar# an inline primop

- - - - -
64064cfe by doyougnu at 2023-05-09T18:40:01-04:00
JS: add GHC.JS.Optimizer, remove RTS.Printer, add Linker.Opt

This MR changes some simple optimizations and is a first step in re-architecting
the JS backend pipeline to add the optimizer. In particular it:

- removes simple peep hole optimizations from `GHC.StgToJS.Printer` and removes that module
- adds module `GHC.JS.Optimizer`
- defines the same peep hole opts that were removed only now they are `Syntax -> Syntax` transformations rather than `Syntax -> JS code` optimizations
- hooks the optimizer into code gen
- adds FuncStat and ForStat constructors to the backend.

Working Ticket:
- #22736

Related MRs:
- MR !10142
- MR !10000

-------------------------
Metric Decrease:
    CoOpt_Read
    ManyAlternatives
    PmSeriesS
    PmSeriesT
    PmSeriesV
    T10421
    T12707
    T13253
    T13253-spj
    T15164
    T17516
    T18140
    T18282
    T18698a
    T18698b
    T18923
    T1969
    T19695
    T20049
    T3064
    T5321FD
    T5321Fun
    T783
    T9198
    T9233
    T9630
-------------------------

- - - - -
6738c01d by Krzysztof Gogolewski at 2023-05-09T18:40:38-04:00
Add a regression test for #21050

- - - - -
b2cdb7da by Ben Gamari at 2023-05-09T18:41:14-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.

- - - - -
0657b482 by Sven Tennie at 2023-05-09T22:22:42-04:00
Adjust AArch64 stackFrameHeaderSize

The prologue of each stack frame are the saved LR and FP registers, 8
byte each. I.e. the size of the stack frame header is 2 * 8 byte.

- - - - -
7788c09c by konsumlamm at 2023-05-09T22:23:23-04:00
Make `(&)` representation polymorphic in the return type

- - - - -
b3195922 by Ben Gamari at 2023-05-10T05:06:45-04:00
ghc-prim: Generalize keepAlive#/touch# in state token type

Closes #23163.

- - - - -
1e6861dd by Cheng Shao at 2023-05-10T05:07:25-04:00
Bump hsc2hs submodule

Fixes #22981.

- - - - -
0a513952 by Ben Gamari at 2023-05-11T04:10:17-04:00
base: Export GHC.Conc.Sync.fromThreadId

Closes #22706.

- - - - -
29be39ba by Matthew Pickering at 2023-05-11T04:10:54-04:00
Build vanilla alpine bindists

We currently attempt to build and distribute fully static alpine
bindists (ones which could be used on any linux platform) but most
people who use the alpine bindists want to use alpine to build their own
static applications (for which a fully static bindist is not necessary).
We should build and distribute these bindists for these users whilst the
fully-static bindist is still unusable.

Fixes #23349

- - - - -
40c7daed by Simon Peyton Jones at 2023-05-11T04:11:30-04:00
Look both ways when looking for quantified equalities

When looking up (t1 ~# t2) in the quantified constraints,
check both orientations.  Forgetting this led to #23333.

- - - - -
c17bb82f by Rodrigo Mesquita at 2023-05-11T04:12:07-04:00
Move "target has RTS linker" out of settings

We move the "target has RTS linker" information out of configure into a
predicate in GHC, and remove this option from the settings file where it
is unnecessary -- it's information statically known from the platform.

Note that previously we would consider `powerpc`s and `s390x`s other
than `powerpc-ibm-aix*` and `s390x-ibm-linux` to have an RTS linker,
but the RTS linker supports neither platform.

Closes #23361

- - - - -
bd0b056e by Krzysztof Gogolewski at 2023-05-11T04:12:44-04:00
Add a test for #17284

Since !10123 we now reject this program.

- - - - -
630b1fea by Andrew Lelechenko at 2023-05-11T04:13:24-04:00
Document unlawfulness of instance Num Fixed

Fixes #22712

- - - - -
87eebf98 by sheaf at 2023-05-11T11:55:22-04:00
Add fused multiply-add instructions

This patch adds eight new primops that fuse a multiplication and an
addition or subtraction:

  - `{fmadd,fmsub,fnmadd,fnmsub}{Float,Double}#`

fmadd x y z is x * y + z, computed with a single rounding step.

This patch implements code generation for these primops in the following
backends:

  - X86, AArch64 and PowerPC NCG,
  - LLVM
  - C

WASM uses the C implementation. The primops are unsupported in the
JavaScript backend.

The following constant folding rules are also provided:

  - compute a * b + c when a, b, c are all literals,
  - x * y + 0 ==> x * y,
  - ±1 * y + z ==> z ± y and x * ±1 + z ==> z ± x.

NB: the constant folding rules incorrectly handle signed zero.
This is a known limitation with GHC's floating-point constant folding
rules (#21227), which we hope to resolve in the future.

- - - - -
ad16a066 by Krzysztof Gogolewski at 2023-05-11T11:55:59-04:00
Add a test for #21278

- - - - -
05cea68c by Matthew Pickering at 2023-05-11T11:56:36-04:00
rts: Refine memory retention behaviour to account for pinned/compacted objects

When using the copying collector there is still a lot of data which
isn't copied (such as pinned, compacted, large objects etc). The logic
to decide how much memory to retain didn't take into account that these
wouldn't be copied. Therefore we pessimistically retained 2* the amount
of memory for these blocks even though they wouldn't be copied by the
collector.

The solution is to split up the heap into two parts, the parts which
will be copied and the parts which won't be copied. Then the appropiate
factor is applied to each part individually (2 * for copying and 1.2 *
for not copying).

The T23221 test demonstrates this improvement with a program which first
allocates many unpinned ByteArray# followed by many pinned ByteArray#
and observes the difference in the ultimate memory baseline between the
two.

There are some charts on #23221.

Fixes #23221

- - - - -
1bb24432 by Cheng Shao at 2023-05-11T11:57:15-04:00
hadrian: fix no_dynamic_libs flavour transformer

This patch fixes the no_dynamic_libs flavour transformer and make
fully_static reuse it. Previously building with no_dynamic_libs fails
since ghc program is still dynamic and transitively brings in dyn ways
of rts which are produced by no rules.

- - - - -
0ed493a3 by Josh Meredith at 2023-05-11T23:08:27-04:00
JS: refactor jsSaturate to return a saturated JStat (#23328)

- - - - -
a856d98e by Pierre Le Marre at 2023-05-11T23:09:08-04:00
Doc: Fix out-of-sync using-optimisation page

- Make explicit that default flag values correspond to their -O0 value.
- Fix -fignore-interface-pragmas, -fstg-cse, -fdo-eta-reduction,
  -fcross-module-specialise, -fsolve-constant-dicts, -fworker-wrapper.

- - - - -
c176ad18 by sheaf at 2023-05-12T06:10:57-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

- - - - -
ab63daac by Krzysztof Gogolewski at 2023-05-12T06:11:38-04:00
Allow Core optimizations when interpreting bytecode

Tracking ticket: #23056

MR: !10399

This adds the flag `-funoptimized-core-for-interpreter`, permitting use
of the `-O` flag to enable optimizations when compiling with the
interpreter backend, like in ghci.

- - - - -
c6cf9433 by Ben Gamari at 2023-05-12T06:12:14-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.

- - - - -
eb60ec18 by Andrew Lelechenko at 2023-05-12T06:12:54-04:00
Mention new implementation of GHC.IORef.atomicSwapIORef in the changelog

- - - - -
aa84cff4 by Teo Camarasu at 2023-05-12T19:27:23-04:00
rts: Ensure non-moving gc is not running when pausing

- - - - -
5ad776ab by Teo Camarasu at 2023-05-12T19:27:23-04:00
rts: Teach listAllBlocks about nonmoving heap

List all blocks on the non-moving heap.

Resolves #22627

- - - - -
d683b2e5 by Krzysztof Gogolewski at 2023-05-12T19:28:00-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.

- - - - -
59aa4676 by Alexis King at 2023-05-12T19:28:47-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.

- - - - -
4bf9fa0f by Adam Gundry at 2023-05-12T23:49:49-04:00
Less coercion optimization for non-newtype axioms

See Note [Push transitivity inside newtype axioms only] for an explanation
of the change here.  This change substantially improves the performance of
coercion optimization for programs involving transitive type family reductions.

-------------------------
Metric Decrease:
    CoOpt_Singletons
    LargeRecord
    T12227
    T12545
    T13386
    T15703
    T5030
    T8095
-------------------------

- - - - -
dc0c9574 by Adam Gundry at 2023-05-12T23:49:49-04:00
Move checkAxInstCo to GHC.Core.Lint

A consequence of the previous change is that checkAxInstCo is no longer
called during coercion optimization, so it can be moved back where it belongs.

Also includes some edits to Note [Conflict checking with AxiomInstCo] as
suggested by @simonpj.

- - - - -
8b9b7dbc by Simon Peyton Jones at 2023-05-12T23:50:25-04:00
Use the eager unifier in the constraint solver

This patch continues the refactoring of the constraint solver
described in #23070.

The Big Deal in this patch is to call the regular, eager unifier from the
constraint solver, when we want to create new equalities. This
replaces the existing, unifyWanted which amounted to
yet-another-unifier, so it reduces duplication of a rather subtle
piece of technology. See

  * Note [The eager unifier] in GHC.Tc.Utils.Unify
  * GHC.Tc.Solver.Monad.wrapUnifierTcS

I did lots of other refactoring along the way

* I simplified the treatment of right hand sides that contain CoercionHoles.
  Now, a constraint that contains a hetero-kind CoercionHole is non-canonical,
  and cannot be used for rewriting or unification alike.  This required me
  to add the ch_hertero_kind flag to CoercionHole, with consequent knock-on
  effects. See wrinkle (2) of `Note [Equalities with incompatible kinds]` in
  GHC.Tc.Solver.Equality.

* I refactored the StopOrContinue type to add StartAgain, so that after a
  fundep improvement (for example) we can simply start the pipeline again.

* I got rid of the unpleasant (and inefficient) rewriterSetFromType/Co functions.
  With Richard I concluded that they are never needed.

* I discovered Wrinkle (W1) in Note [Wanteds rewrite Wanteds] in
  GHC.Tc.Types.Constraint, and therefore now prioritise non-rewritten equalities.

Quite a few error messages change, I think always for the better.

Compiler runtime stays about the same, with one outlier: a 17% improvement in T17836

Metric Decrease:
    T17836
    T18223

- - - - -
5cad28e7 by Bartłomiej Cieślar at 2023-05-12T23:51:06-04:00
Cleanup of dynflags override in export renaming
The deprecation warnings are normally emitted whenever the name's GRE is being looked up, which calls the GHC.Rename.Env.addUsedGRE function. We do not want those warnings to be emitted when renaming export lists, so they are artificially turned off by removing all warning categories from DynFlags at the beginning of GHC.Tc.Gen.Export.rnExports. This commit removes that dependency by unifying the function used for GRE lookup in lookup_ie to lookupGreAvailRn and disabling the call to addUsedGRE in said function (the warnings are also disabled in a call to lookupSubBndrOcc_helper in lookupChildrenExport), as per #17957. This commit also changes the setting for whether to warn about deprecated names in addUsedGREs to be an explicit enum instead of a boolean.

- - - - -
d85ed900 by Alexis King at 2023-05-13T08:45:18-04:00
Use a uniform return convention in bytecode for unary results

fixes #22958

- - - - -
8a0d45f7 by Andrew Lelechenko at 2023-05-13T08:45:58-04:00
Add more instances for Compose: Enum, Bounded, Num, Real, Integral

See https://github.com/haskell/core-libraries-committee/issues/160 for discussion

- - - - -
902f0730 by Simon Peyton Jones at 2023-05-13T14:58:34-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]

- - - - -
a5451438 by sheaf at 2023-05-13T14:59:13-04:00
Fix bad multiplicity role in tyConAppFunCo_maybe

The function tyConAppFunCo_maybe produces a multiplicity coercion
for the multiplicity argument of the function arrow, except that
it could be at the wrong role if asked to produce a representational
coercion. We fix this by using the 'funRole' function, which computes
the right roles for arguments to the function arrow TyCon.

Fixes #23386

- - - - -
5b9e9300 by sheaf at 2023-05-15T11:26:59-04:00
Turn "ambiguous import" error into a panic

This error should never occur, as a lookup of a type or data constructor
should never be ambiguous. This is because a single module cannot export
multiple Names with the same OccName, as per item (1) of
Note [Exporting duplicate declarations] in GHC.Tc.Gen.Export.

This code path was intended to handle duplicate record fields, but the
rest of the code had since been refactored to handle those in a
different way.

We also remove the AmbiguousImport constructor of IELookupError, as
it is no longer used.

Fixes #23302

- - - - -
e305e60c by M Farkas-Dyck at 2023-05-15T11:27:41-04:00
Unbreak some tests with latest GNU grep, which now warns about stray '\'.

Confusingly, the testsuite mangled the error to say "stray /".

We also migrate some tests from grep to grep -E, as it seems the author actually wanted an "POSIX extended" (a.k.a. sane) regex.

Background: POSIX specifies 2 "regex" syntaxen: "basic" and "extended". Of these, only "extended" syntax is actually a regular expression. Furthermore, "basic" syntax is inconsistent in its use of the '\' character — sometimes it escapes a regex metacharacter, but sometimes it unescapes it, i.e. it makes an otherwise normal character become a metacharacter. This baffles me and it seems also the authors of these tests. Also, the regex(7) man page (at least on Linux) says "basic" syntax is obsolete. Nearly all modern tools and libraries are consistent in this use of the '\' character (of which many use "extended" syntax by default).

- - - - -
5ae81842 by sheaf at 2023-05-15T14:49:17-04:00
Improve "ambiguous occurrence" error messages

This error was sometimes a bit confusing, especially when data families
were involved. This commit improves the general presentation of the
"ambiguous occurrence" error, and adds a bit of extra context in the
case of data families.

Fixes #23301

- - - - -
2f571afe by Sylvain Henry at 2023-05-15T14:50:07-04:00
Fix GHCJS OS platform (fix #23346)

- - - - -
86aae570 by Oleg Grenrus at 2023-05-15T14:50:43-04:00
Split DynFlags structure into own module

This will allow to make command line parsing to depend on
diagnostic system (which depends on dynflags)

- - - - -
fbe3fe00 by Josh Meredith at 2023-05-15T18:01:43-04:00
Replace the implementation of CodeBuffers with unboxed types

- - - - -
21f3aae7 by Josh Meredith at 2023-05-15T18:01:43-04:00
Use unboxed codebuffers in base

Metric Decrease:
    encodingAllocations

- - - - -
18ea2295 by Ben Gamari at 2023-05-15T18:02:20-04:00
rts: Weak pointer cleanups

Various stylistic cleanups. No functional changes.

- - - - -
c343112f by Ben Gamari at 2023-05-15T18:02:20-04:00
rts: Don't force debug output to stderr

Previously `+RTS -Dw -l` would emit debug output to the eventlog while
`+RTS -l -Dw` would emit it to stderr. This was because the parser for
`-D` would unconditionally override the debug output target. Now we
instead only do so if no it is currently `TRACE_NONE`.

- - - - -
a5f5f067 by Ben Gamari at 2023-05-15T18:02:20-04:00
rts: Forcibly flush eventlog on barf

Previously we would attempt to flush via `endEventLogging` which can
easily deadlock, e.g., if `barf` fails during GC.

Using `flushEventLog` directly may result in slightly less consistent
eventlog output (since we don't take all capabilities before flushing)
but avoids deadlocking.

- - - - -
73b1e87c by Ben Gamari at 2023-05-15T18:02:20-04:00
rts: Assert that pointers aren't cleared by -DZ

This turns many segmentation faults into much easier-to-debug assertion
failures by ensuring that LOOKS_LIKE_*_PTR checks recognize bit-patterns
produced by `+RTS -DZ` clearing as invalid pointers.

This is a bit ad-hoc but this is the debug runtime.

- - - - -
37fb61d8 by Ben Gamari at 2023-05-15T18:02:20-04:00
rts: Introduce printGlobalThreads

- - - - -
451d65a6 by Ben Gamari at 2023-05-15T18:02:20-04:00
rts: Don't sanity-check StgTSO.global_link

See Note [Avoid dangling global_link pointers].

Fixes #19146.

- - - - -
d69cbd78 by sheaf at 2023-05-15T18:03:00-04:00
Split up tyThingToIfaceDecl from GHC.Iface.Make

This commit moves tyThingToIfaceDecl and coAxiomToIfaceDecl
from GHC.Iface.Make into GHC.Iface.Decl.
This avoids GHC.Types.TyThing.Ppr, which needs tyThingToIfaceDecl,
transitively depending on e.g. GHC.Iface.Load and GHC.Tc.Utils.Monad.

- - - - -
4d29ecdf by sheaf at 2023-05-15T18:03:00-04:00
Migrate errors to diagnostics in GHC.Tc.Module

This commit migrates the errors in GHC.Tc.Module to use the new
diagnostic infrastructure.

It required a significant overhaul of the compatibility checks between
an hs-boot or signature module and its implementation; we now use
a Writer monad to accumulate errors; see the BootMismatch datatype
in GHC.Tc.Errors.Types, with its panoply of subtypes.
For the sake of readability, several local functions inside the
'checkBootTyCon' function were split off into top-level functions.

We split off GHC.Types.HscSource into a "boot or sig" vs "normal hs file"
datatype, as this mirrors the logic in several other places where we
want to treat hs-boot and hsig files in a similar fashion.

This commit also refactors the Backpack checks for type synonyms
implementing abstract data, to correctly reject implementations that
contain qualified or quantified types (this fixes #23342 and #23344).

- - - - -
d986c98e by Rodrigo Mesquita at 2023-05-16T00:14:04-04:00
configure: Drop unused AC_PROG_CPP

In configure, we were calling `AC_PROG_CPP` but never making use of the
$CPP variable it sets or reads.

The issue is $CPP will show up in the --help output of configure,
falsely advertising a configuration option that does nothing.

The reason we don't use the $CPP variable is because HS_CPP_CMD is
expected to be a single command (without flags), but AC_PROG_CPP, when
CPP is unset, will set said variable to something like `/usr/bin/gcc -E`.
Instead, we configure HS_CPP_CMD through $CC.

- - - - -
a8f0435f by Cheng Shao at 2023-05-16T00:14:42-04:00
rts: fix --disable-large-address-space

This patch moves
ACQUIRE_ALLOC_BLOCK_SPIN_LOCK/RELEASE_ALLOC_BLOCK_SPIN_LOCK from
Storage.h to HeapAlloc.h. When --disable-large-address-space is passed
to configure, the code in HeapAlloc.h makes use of these two macros.
Fixes #23385.

- - - - -
bdb93cd2 by Oleg Grenrus at 2023-05-16T07:59:21+03:00
Add -Wmissing-role-annotations

Implements #22702

- - - - -
41ecfc34 by Ben Gamari at 2023-05-16T07:28:15-04:00
base: Export {get,set}ExceptionFinalizer from System.Mem.Weak

As proposed in CLC Proposal #126 [1].

[1]: https://github.com/haskell/core-libraries-committee/issues/126

- - - - -
67330303 by Ben Gamari at 2023-05-16T07:28:16-04:00
base: Introduce printToHandleFinalizerExceptionHandler

- - - - -
5e3f9bb5 by Josh Meredith at 2023-05-16T13:59:22-04:00
JS: Implement h$clock_gettime in the JavaScript RTS (#23360)

- - - - -
90e69d5d by Zubin Duggal at 2023-05-16T14:00:00-04:00
compiler: Use compact representation for SourceText

SourceText is serialized along with INLINE pragmas into interface files. Many of
these SourceTexts are identical, for example "{-# INLINE#". When deserialized,
each such SourceText was previously expanded out into a [Char], which is highly
wasteful of memory, and each such instance of the text would allocate an
independent list with its contents as deserializing breaks any sharing that might
have existed.

Instead, we use a `FastString` to represent these, so that each instance unique
text will be interned and stored in a memory efficient manner.

- - - - -
b70bc690 by Zubin Duggal at 2023-05-16T14:00:00-04:00
compiler: Use compact representation/FastStrings for `SourceNote`s

`SourceNote`s should not be stored as [Char] as this is highly wasteful
and in certain scenarios can be highly duplicated.

Metric Decrease:
  hard_hole_fits

- - - - -
6231a126 by Zubin Duggal at 2023-05-16T14:00:00-04:00
compiler: Use compact representation for UsageFile (#22744)

Use FastString to store filepaths in interface files, as this data is
highly redundant so we want to share all instances of filepaths in the
compiler session.

- - - - -
47a58150 by Zubin Duggal at 2023-05-16T14:00:00-04:00
testsuite: add test for T22744

This test checks for #22744 by compiling 100 modules which each have
a dependency on 1000 distinct external files.

Previously, when loading these interfaces from disk, each individual instance
of a filepath in the interface will would be allocated as an individual object
on the heap, meaning we have heap objects for 100*1000 files, when there are
only 1000 distinct files we care about.

This test checks this by first compiling the module normally, then measuring
the peak memory usage in a no-op recompile, as the recompilation checking will
force the allocation of all these filepaths.

- - - - -
0451bdc9 by Ben Gamari at 2023-05-16T21:31:40-04:00
users guide: Add glossary

Currently this merely explains the meaning of "technology preview" in
the context of released features.

- - - - -
0ba52e4e by Ben Gamari at 2023-05-16T21:31:40-04:00
Update glossary.rst
- - - - -
3d23060c by Ben Gamari at 2023-05-16T21:31:40-04:00
Use glossary directive
- - - - -
2972fd66 by Sylvain Henry at 2023-05-16T21:32:20-04:00
JS: fix getpid (fix #23399)

- - - - -
5fe1d3e6 by Matthew Pickering at 2023-05-17T21:42:00-04:00
Use setSrcSpan rather than setLclEnv in solveForAll

In subsequent MRs (#23409) we want to remove the TcLclEnv argument from
a CtLoc. This MR prepares us for that by removing the one place where
the entire TcLclEnv is used, by using it more precisely to just set the
contexts source location.

Fixes #23390

- - - - -
385edb65 by Torsten Schmits at 2023-05-17T21:42:40-04:00
Update the users guide paragraph on -O in GHCi

In relation to #23056

- - - - -
87626ef0 by Ben Gamari at 2023-05-18T15:18:53-04:00
base: Add test for #13660

- - - - -
9eef53b1 by Ben Gamari at 2023-05-18T15:18:53-04:00
base: Move implementation of GHC.Foreign to GHC.Internal

- - - - -
174ea2fa by Ben Gamari at 2023-05-18T15:18:53-04:00
base: Introduce {new,with}CStringLen0

These are useful helpers for implementing the internal-NUL code unit
check needed to fix #13660.

- - - - -
a46ced16 by Ben Gamari at 2023-05-18T15:18:53-04:00
base: Clean up documentation

- - - - -
b98d99cc by Ben Gamari at 2023-05-18T15:18:53-04:00
base: Ensure that FilePaths don't contain NULs

POSIX filepaths may not contain the NUL octet but previously we did not
reject such paths. This could be exploited by untrusted input to cause
discrepancies between various `FilePath` queries and the opened
filename. For instance, `readFile "hello.so\x00.txt"` would open the
file `"hello.so"` yet `takeFileExtension` would return `".txt"`.

The same argument applies to Windows FilePaths

Fixes #13660.

- - - - -
7ae45459 by Simon Peyton Jones at 2023-05-18T15:19:29-04:00
Allow the demand analyser to unpack tuple and equality dictionaries

Addresses #23398. The demand analyser usually does not unpack class
dictionaries: see Note [Do not unbox class dictionaries] in
GHC.Core.Opt.DmdAnal.

This patch makes an exception for tuple dictionaries and equality
dictionaries, for reasons explained in wrinkles (DNB1) and (DNB2) of
the above Note.

Compile times fall by 0.1% for some reason (max 0.7% on T18698b).

- - - - -
b53a9086 by Greg Steuck at 2023-05-18T15:20:08-04:00
Use a simpler and more portable construct in ld.ldd check

printf '%q\n' is a bash extension which led to incorrectly
failing an ld.lld test on OpenBSD which uses pdksh as /bin/sh

- - - - -
dd5710af by Torsten Schmits at 2023-05-18T15:20:50-04:00
Update the warning about interpreter optimizations

to reflect that they're not incompatible anymore, but guarded by a flag

- - - - -
4f6dd999 by Matthew Pickering at 2023-05-18T15:21:26-04:00
Remove stray dump flags in GHC.Rename.Names

- - - - -
4bca0486 by Oleg Grenrus at 2023-05-19T11:51:33+03:00
Make Warn = Located DriverMessage

This change makes command line argument parsing use diagnostic
framework for producing warnings.

- - - - -
525ed554 by Simon Peyton Jones at 2023-05-19T10:09:15-04:00
Type inference for data family newtype instances

This patch addresses #23408, a tricky case with data family
newtype instances.  Consider

  type family TF a where TF Char = Bool
  data family DF a
  newtype instance DF Bool = MkDF Int

and [W] Int ~R# DF (TF a), with a Given (a ~# Char).   We must fully
rewrite the Wanted so the tpye family can fire; that wasn't happening.

- - - - -
c6fb6690 by Peter Trommler at 2023-05-20T03:16:08-04:00
testsuite: fix predicate on rdynamic test

Test rdynamic requires dynamic linking support, which is
orthogonal to RTS linker support. Change the predicate accordingly.

Fixes #23316

- - - - -
735d504e by Matthew Pickering at 2023-05-20T03:16:44-04:00
docs: Use ghc-ticket directive where appropiate in users guide

Using the directive automatically formats and links the ticket
appropiately.

- - - - -
b56d7379 by Sylvain Henry at 2023-05-22T14:21:22-04:00
NCG: remove useless .align directive (#20758)

- - - - -
15b93d2f by Simon Peyton Jones at 2023-05-22T14:21:58-04:00
Add test for #23156

This program had exponential typechecking time in GHC 9.4 and 9.6

- - - - -
2b53f206 by Greg Steuck at 2023-05-22T20:23:11-04:00
Revert "Change hostSupportsRPaths to report False on OpenBSD"

This reverts commit 1e0d8fdb55a38ece34fa6cf214e1d2d46f5f5bf2.

- - - - -
882e43b7 by Greg Steuck at 2023-05-22T20:23:11-04:00
Disable T17414 on OpenBSD

Like on other systems it's not guaranteed that there's sufficient
space in /tmp to write 2G out.

- - - - -
9d531f9a by Greg Steuck at 2023-05-22T20:23:11-04:00
Bring back getExecutablePath to getBaseDir on OpenBSD

Fix #18173

- - - - -
9db0eadd by Krzysztof Gogolewski at 2023-05-22T20:23:47-04:00
Add an error origin for impedance matching (#23427)

- - - - -
33cf4659 by Ben Gamari at 2023-05-23T03:46:20-04:00
testsuite: Add tests for #23146

Both lifted and unlifted variants.

- - - - -
76727617 by Ben Gamari at 2023-05-23T03:46:21-04:00
codeGen: Fix some Haddocks

- - - - -
33a8c348 by Ben Gamari at 2023-05-23T03:46:21-04:00
codeGen: Give proper LFInfo to datacon wrappers

As noted in `Note [Conveying CAF-info and LFInfo between modules]`,
when importing a binding from another module we must ensure that it gets
the appropriate `LambdaFormInfo` if it is in WHNF to ensure that
references to it are tagged correctly.

However, the implementation responsible for doing this,
`GHC.StgToCmm.Closure.mkLFImported`, only dealt with datacon workers and
not wrappers. This lead to the crash of this program in #23146:

    module B where

    type NP :: [UnliftedType] -> UnliftedType
    data NP xs where
      UNil :: NP '[]

    module A where
    import B

    fieldsSam :: NP xs -> NP xs -> Bool
    fieldsSam UNil UNil = True

    x = fieldsSam UNil UNil

Due to its GADT nature, `UNil` produces a trivial wrapper

    $WUNil :: NP '[]
    $WUNil = UNil @'[] @~(<co:1>)

which is referenced in the RHS of `A.x`. Due to the above-mentioned bug
in `mkLFImported`, the references to `$WUNil` passed to `fieldsSam` were
not tagged. This is problematic as `fieldsSam` expected its arguments to
be tagged as they are unlifted.

The fix is straightforward: extend the logic in `mkLFImported` to cover
(nullary) datacon wrappers as well as workers. This is safe because we
know that the wrapper of a nullary datacon will be in WHNF, even if it
includes equalities evidence (since such equalities are not runtime
relevant).

Thanks to @MangoIV for the great ticket and @alt-romes for his
minimization and help debugging.

Fixes #23146.

- - - - -
2fc18e9e by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00
codeGen: Fix LFInfo of imported datacon wrappers

As noted in #23231 and in the previous commit, we were failing to give a
an LFInfo of LFCon to a nullary datacon wrapper from another module,
failing to properly tag pointers which ultimately led to the
segmentation fault in #23146.

On top of the previous commit which now considers wrappers where we
previously only considered workers, we change the order of the guards so
that we check for the arity of the binding before we check whether it is
a constructor. This allows us to
(1) Correctly assign `LFReEntrant` to imported wrappers whose worker was
nullary, which we previously would fail to do
(2) Remove the `isNullaryRepDataCon` predicate:
    (a) which was previously wrong, since it considered wrappers whose
    workers had zero-width arguments to be non-nullary and would fail to
    give `LFCon` to them
    (b) is now unnecessary, since arity == 0 guarantees
        - that the worker takes no arguments at all
        - and the wrapper takes no arguments and its RHS must be an
          application of the worker to zero-width-args only.
        - we lint these two items with an assertion that the datacon
          `hasNoNonZeroWidthArgs`

We also update `isTagged` to use the new logic in determining the
LFInfos of imported Ids.

The creation of LFInfos for imported Ids and this detail are explained
in Note [The LFInfo of Imported Ids].

Note that before the patch to those issues we would already consider these
nullary wrappers to have `LFCon` lambda form info; but failed to re-construct
that information in `mkLFImported`

Closes #23231, #23146

(I've additionally batched some fixes to documentation I found while
investigating this issue)

- - - - -
0598f7f0 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00
Make LFInfos for DataCons on construction

As a result of the discussion in !10165, we decided to amend the
previous commit which fixed the logic of `mkLFImported` with regard to
datacon workers and wrappers.

Instead of having the logic for the LFInfo of datacons be in
`mkLFImported`, we now construct an LFInfo for all data constructors on
GHC.Types.Id.Make and store it in the `lfInfo` field.

See the new Note [LFInfo of DataCon workers and wrappers] and
ammendments to Note [The LFInfo of Imported Ids]

- - - - -
12294b22 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00
Update Note [Core letrec invariant]

Authored by @simonpj

- - - - -
e93ab972 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00
Rename mkLFImported to importedIdLFInfo

The `mkLFImported` sounded too much like a constructor of sorts, when
really it got the `LFInfo` of an imported Id from its `lf_info` field
when this existed, and otherwise returned a conservative estimate of
that imported Id's LFInfo. This in contrast to functions such as
`mkLFReEntrant` which really are about constructing an `LFInfo`.

- - - - -
e54d9259 by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00
Enforce invariant on typePrimRepArgs in the types

As part of the documentation effort in !10165 I came across this
invariant on 'typePrimRepArgs' which is easily expressed at the
type-level through a NonEmpty list.

It allowed us to remove one panic.

- - - - -
b8fe6a0c by Rodrigo Mesquita at 2023-05-23T03:46:21-04:00
Merge outdated Note [Data con representation] into Note [Data constructor representation]

Introduce new Note [Constructor applications in STG] to better support
the merge, and reference it from the relevant bits in the STG syntax.

- - - - -
e1590ddc by Simon Peyton Jones at 2023-05-23T03:46:57-04:00
Add the SolverStage monad

This refactoring makes a substantial improvement in the
structure of the type-checker's constraint solver: #23070.

Specifically:

* Introduced the SolverStage monad.   See GHC.Tc.Solver.Monad
  Note [The SolverStage monad]

* Make each solver pipeline (equalities, dictionaries, irreds etc)
  deal with updating the inert set, as a separate SolverStage.  There
  is sometimes special stuff to do, and it means that each full
  pipeline can have type SolverStage Void, indicating that they never
  return anything.

* Made GHC.Tc.Solver.Equality.zonkEqTypes into a SolverStage.  Much nicer.

* Combined the remnants of GHC.Tc.Solver.Canonical and
  GHC.Tc.Solver.Interact into a new module GHC.Tc.Solver.Solve.
  (Interact and Canonical are removed.)

* Gave the same treatment to dictionary and irred constraints
  as I have already done for equality constraints:
    * New types (akin to EqCt): IrredCt and DictCt
    * Ct is now just a simple sum type
          data Ct
            = CDictCan      DictCt
            | CIrredCan     IrredCt
            | CEqCan        EqCt
            | CQuantCan     QCInst
            | CNonCanonical CtEvidence
    * inert_dicts can now have the better type DictMap DictCt, instead of
      DictMap Ct; and similarly inert_irreds.

* Significantly simplified the treatment of implicit parameters.
  Previously we had a number of special cases
    * interactGivenIP, an entire function
    * special case in maybeKickOut
    * special case in findDict, when looking up dictionaries
  But actually it's simpler than that. When adding a new Given, implicit
  parameter constraint to the InertSet, we just need to kick out any
  existing inert constraints that mention that implicit parameter.

  The main work is done in GHC.Tc.Solver.InertSet.delIPDict, along with
  its auxiliary GHC.Core.Predicate.mentionsIP.

  See Note [Shadowing of implicit parameters] in GHC.Tc.Solver.Dict.

* Add a new fast-path in GHC.Tc.Errors.Hole.tcCheckHoleFit.
  See Note [Fast path for tcCheckHoleFit].  This is a big win in some cases:
  test hard_hole_fits gets nearly 40% faster (at compile time).

* Add a new fast-path for solving /boxed/ equality constraints
  (t1 ~ t2).  See Note [Solving equality classes] in GHC.Tc.Solver.Dict.
  This makes a big difference too: test T17836 compiles 40% faster.

* Implement the PermissivePlan of #23413, which concerns what happens with
  insoluble Givens.   Our previous treatment was wildly inconsistent as that
  ticket pointed out.

  A part of this, I simplified GHC.Tc.Validity.checkAmbiguity: now we simply
  don't run the ambiguity check at all if -XAllowAmbiguousTypes is on.

Smaller points:

* In `GHC.Tc.Errors.misMatchOrCND` instead of having a special case for
  insoluble /occurs/ checks, broaden in to all insouluble constraints.
  Just generally better. See Note [Insoluble mis-match] in that module.

As noted above, compile time perf gets better.  Here are the changes
over 0.5% on Fedora.  (The figures are slightly larger on Windows for
some reason.)

Metrics: compile_time/bytes allocated
-------------------------------------
                LargeRecord(normal)   -0.9%
MultiLayerModulesTH_OneShot(normal)   +0.5%
                     T11822(normal)   -0.6%
                     T12227(normal)   -1.8% GOOD
                     T12545(normal)   -0.5%
                     T13035(normal)   -0.6%
                     T15703(normal)   -1.4% GOOD
                     T16875(normal)   -0.5%
                     T17836(normal)  -40.7% GOOD
                    T17836b(normal)  -12.3% GOOD
                    T17977b(normal)   -0.5%
                      T5837(normal)   -1.1%
                      T8095(normal)   -2.7% GOOD
                      T9020(optasm)   -1.1%
             hard_hole_fits(normal)  -37.0% GOOD

                          geo. mean   -1.3%
                          minimum    -40.7%
                          maximum     +0.5%

Metric Decrease:
    T12227
    T15703
    T17836
    T17836b
    T8095
    hard_hole_fits
    LargeRecord
    T9198
    T13035

- - - - -
6abf3648 by Simon Peyton Jones at 2023-05-23T03:46:57-04:00
Avoid an assertion failure in abstractFloats

The function GHC.Core.Opt.Simplify.Utils.abstractFloats
was carelessly calling lookupIdSubst_maybe on a CoVar;
but a precondition of the latter is being given an Id.

In fact it's harmless to call it on a CoVar, but still, the
precondition on lookupIdSubst_maybe makes sense, so I added
a test for CoVars.

This avoids a crash in a DEBUG compiler, but otherwise has
no effect. Fixes #23426.

- - - - -
838aaf4b by hainq at 2023-05-24T12:41:19-04:00
Migrate errors in GHC.Tc.Validity

This patch migrates the error messages in GHC.Tc.Validity to use
the new diagnostic infrastructure.

It adds the constructors:

  - TcRnSimplifiableConstraint
  - TcRnArityMismatch
  - TcRnIllegalInstanceDecl, with sub-datatypes for HasField errors
    and fundep coverage condition errors.

- - - - -
8539764b by Krzysztof Gogolewski at 2023-05-24T12:41:56-04:00
linear lint: Add missing processing of DEFAULT

In this correct program

f :: a %1 -> a
f x = case x of x { _DEFAULT -> x }

after checking the alternative we weren't popping the case binder 'x'
from the usage environment, which meant that the lambda-bound 'x'
was counted twice: in the scrutinee and (incorrectly) in the alternative.
In fact, we weren't checking the usage of 'x' at all.
Now the code for handling _DEFAULT is similar to the one handling
data constructors.

Fixes #23025.

- - - - -
ae683454 by Matthew Pickering at 2023-05-24T12:42:32-04:00
Remove outdated "Don't check hs-boot type family instances too early" note

This note was introduced in 25b70a29f623 which delayed performing some
consistency checks for type families. However, the change was reverted
later in 6998772043a7f0b0360116eb5ffcbaa5630b21fb but the note was not
removed.

I found it confusing when reading to code to try and work out what
special behaviour there was for hs-boot files (when in-fact there isn't
any).

- - - - -
44af57de by Matthew Pickering at 2023-05-24T12:43:08-04:00
rts: Define ticky macro stubs

These macros have long been undefined which has meant we were missing
reporting these allocations in ticky profiles.

The most critical missing definition was TICK_ALLOC_HEAP_NOCTR which was
missing all the RTS calls to allocate, this leads to a the overall
ALLOC_RTS_tot number to be severaly underreported.

Of particular interest though is the ALLOC_STACK_ctr and ALLOC_STACK_tot
counters which are useful to tracking stack allocations.

Fixes #23421

- - - - -
b2dabe3a by Matthew Pickering at 2023-05-24T12:43:08-04:00
rts: ticky: Rename TICK_ALLOC_HEAP_NOCTR to TICK_ALLOC_RTS

This macro increments the ALLOC_HEAP_tot and ALLOC_HEAP_ctr so it makes
more sense to name it after that rather than the suffix NOCTR, whose
meaning has been lost to the mists of time.

- - - - -
eac4420a by Ben Gamari at 2023-05-24T12:43:45-04:00
users guide: A few small mark-up fixes

- - - - -
a320ca76 by Rodrigo Mesquita at 2023-05-24T12:44:20-04:00
configure: Fix support check for response files.

In failing to escape the '-o' in '-o\nconftest\nconftest.o\n' argument
to printf, the writing of the arguments response file always failed.

The fix is to pass the arguments after `--` so that they are treated
positional arguments rather than flags to printf.

Closes #23435

- - - - -
f21ce0e4 by mangoiv at 2023-05-24T12:45:00-04:00
[feat] add .direnv to the .gitignore file

- - - - -
36d5944d by Andrew Lelechenko at 2023-05-24T20:58:34-04:00
Add Data.List.unsnoc

See https://github.com/haskell/core-libraries-committee/issues/165 for discussion

- - - - -
c0f2f9e3 by Bartłomiej Cieślar at 2023-05-24T20:59:14-04:00
Fix crash in backpack signature merging with -ddump-rn-trace

In some cases, backpack signature merging could crash in addUsedGRE
when -ddump-rn-trace was enabled, as pretty-printing the GREInfo would cause
unavailable interfaces to be loaded.
This commit fixes that issue by not pretty-printing the GREInfo in addUsedGRE
when -ddump-rn-trace is enabled.

Fixes #23424

Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com>

- - - - -
5a07d94a by Krzysztof Gogolewski at 2023-05-25T03:30:20-04:00
Add a regression test for #13981

The panic was fixed by 6998772043a7f0b. Fixes #13981.

- - - - -
182df90e by Krzysztof Gogolewski at 2023-05-25T03:30:57-04:00
Add a test for #23355

It was fixed by !10061, so I'm adding it in the same group.

- - - - -
1b31b039 by uhbif19 at 2023-05-25T12:08:28+02:00
Migrate errors in GHC.Rename.Splice GHC.Rename.Pat

This commit migrates the errors in GHC.Rename.Splice and GHC.Rename.Pat
to use the new diagnostic infrastructure.

- - - - -
56abe494 by sheaf at 2023-05-25T12:09:55+02:00
Common up Template Haskell errors in TcRnMessage

This commit commons up the various Template Haskell errors into a
single constructor, TcRnTHError, of TcRnMessage.

- - - - -
a487ba9e by Krzysztof Gogolewski at 2023-05-25T14:35:56-04:00
Enable ghci tests for unboxed tuples

The tests were originally skipped because ghci used not to support
unboxed tuples/sums.

- - - - -
dc3422d4 by Matthew Pickering at 2023-05-25T18:57:19-04:00
rts: Build ticky GHC with single-threaded RTS

The threaded RTS allows you to use ticky profiling but only for the
counters in the generated code. The counters used in the C portion of
the RTS are disabled. Updating the counters is also racy using the
threaded RTS which can lead to misleading or incorrect ticky results.

Therefore we change the hadrian flavour to build using the
single-threaded RTS (mainly in order to get accurate C code counter
increments)

Fixes #23430

- - - - -
fbc8e04e by sheaf at 2023-05-25T18:58:00-04:00
Propagate long-distance info in generated code

When desugaring generated pattern matches, we skip pattern match checks.
However, this ended up also discarding long-distance information, which
might be needed for user-written sub-expressions.

Example:

```haskell
okay (GADT di) cd =
  let sr_field :: ()
      sr_field = case getFooBar di of { Foo -> () }
  in case cd of { SomeRec _ -> SomeRec sr_field }
```

With sr_field a generated FunBind, we still want to propagate the outer
long-distance information from the GADT pattern match into the checks
for the user-written RHS of sr_field.

Fixes #23445

- - - - -
f8ced241 by Matthew Pickering at 2023-05-26T15:26:21-04:00
Introduce GHCiMessage to wrap GhcMessage

By introducing a wrapped message type we can control how certain
messages are printed in GHCi (to add extra information for example)

- - - - -
58e554c1 by Matthew Pickering at 2023-05-26T15:26:22-04:00
Generalise UnknownDiagnostic to allow embedded diagnostics to access
parent diagnostic options.

* Split default diagnostic options from Diagnostic class into
  HasDefaultDiagnosticOpts class.
* Generalise UnknownDiagnostic to allow embedded diagnostics to access
  options.

The principle idea here is that when wrapping an error message (such as
GHCMessage to make GHCiMessage) then we need to also be able to lift the
configuration when overriding how messages are printed (see load' for an
example).

- - - - -
b112546a by Matthew Pickering at 2023-05-26T15:26:22-04:00
Allow API users to wrap error messages created during 'load'

This allows API users to configure how messages are rendered when they
are emitted from the load function. For an example see how
'loadWithCache' is used in GHCi.

- - - - -
2e4cf0ee by Matthew Pickering at 2023-05-26T15:26:22-04:00
Abstract cantFindError and turn Opt_BuildingCabal into a print-time option

* cantFindError is abstracted so that the parts which mention specific
  things about ghc/ghci are parameters. The intention being that
  GHC/GHCi can specify the right values to put here but otherwise
  display the same error message.
* The BuildingCabalPackage argument from GenericMissing is removed and
  turned into a print-time option. The reason for the error is not
  dependent on whether `-fbuilding-cabal-package` is passed, so we don't
  want to store that in the error message.

- - - - -
34b44f7d by Matthew Pickering at 2023-05-26T15:26:22-04:00
error messages: Don't display ghci specific hints for missing packages

Tickets like #22884 suggest that it is confusing that GHC used on the
command line can suggest options which only work in GHCi.

This ticket uses the error message infrastructure to override certain
error messages which displayed GHCi specific information so that this
information is only showed when using GHCi.

The main annoyance is that we mostly want to display errors in the same
way as before, but with some additional information. This means that the
error rendering code has to be exported from the Iface/Errors/Ppr.hs
module.

I am unsure about whether the approach taken here is the best or most
maintainable solution.

Fixes #22884

- - - - -
05a1b626 by Matthew Pickering at 2023-05-26T15:26:58-04:00
ghcup-metadata: Don't override existing metadata if version already exists.

If a nightly pipeline runs twice for some reason for the same version
then we really don't want to override an existing entry with new
bindists. This could cause ABI compatability issues for users or break
ghcup's caching logic.

- - - - -
fcbcb3cc by Matthew Pickering at 2023-05-26T15:26:58-04:00
ghcup-metadata: Use proper API url for bindist download

Previously we were using links from the web interface, but it's more
robust and future-proof to use the documented links to the artifacts.

https://docs.gitlab.com/ee/api/job_artifacts.html

- - - - -
5b59c8fe by Matthew Pickering at 2023-05-26T15:26:58-04:00
ghcup-metadata: Set Nightly and LatestNightly tags

The latest nightly release needs the LatestNightly tag, and all other
nightly releases need the Nightly tag. Therefore when the metadata is
updated we need to replace all LatestNightly with Nightly.`

- - - - -
914e1468 by Matthew Pickering at 2023-05-26T15:26:58-04:00
ghcup-metadata: Download nightly metadata for correct date

The metadata now lives in https://gitlab.haskell.org/ghc/ghcup-metadata
with one metadata file per year. When we update the metadata we download
and update the right file for the current year.

- - - - -
16cf7d2e by Matthew Pickering at 2023-05-26T15:26:58-04:00
ghcup-metadata: Download metadata and update for correct year

something about pipeline date

- - - - -
14792c4b by Matthew Pickering at 2023-05-26T15:26:58-04:00
ghcup-metadata: Don't skip CI

On a push we now have a CI job which updates gitlab pages with the
metadata files.

- - - - -
1121bdd8 by Matthew Pickering at 2023-05-26T15:26:59-04:00
ghcup-metadata: Add --date flag to specify the release date

The ghcup-metadata now has a viReleaseDay field which needs to be
populated with the day of the release.

- - - - -
bc478bee by Matthew Pickering at 2023-05-26T15:26:59-04:00
ghcup-metadata: Add dlOutput field

ghcup now requires us to add this field which specifies where it should
download the bindist to. See
https://gitlab.haskell.org/ghc/ghcup-metadata/-/issues/1 for some more
discussion.

- - - - -
2bdbd9da by Josh Meredith at 2023-05-26T15:27:35-04:00
JS: Convert rendering to use HLine instead of SDoc (#22455)

- - - - -
abd9e37c by Norman Ramsey at 2023-05-26T15:28:12-04:00
testsuite: add WasmControlFlow test

This patch adds the WasmControlFlow test to test the wasm backend's
relooper component.

- - - - -
07f858eb by Sylvain Henry at 2023-05-26T15:28:53-04:00
Factorize getLinkDeps

Prepare reuse of getLinkDeps for TH implementation in the JS backend
(cf #22261 and review of !9779).

- - - - -
fad9d092 by Oleg Grenrus at 2023-05-27T13:38:08-04:00
Change GHC.Driver.Session import to .DynFlags

Also move targetPlatform selector

Plenty of GHC needs just DynFlags.
Even more can be made to use .DynFlags if more selectors is migrated.
This is a low hanging fruit.

- - - - -
69fdbece by Alan Zimmerman at 2023-05-27T13:38:45-04:00
EPA: Better fix for #22919

The original fix for #22919 simply removed the ability to match up
prior comments with the first declaration in the file.

Restore it, but add a check that the comment is on a single line, by
ensuring that it comes immediately prior to the next thing (comment or
start of declaration), and that the token preceding it is not on the
same line.

closes #22919

- - - - -
0350b186 by Josh Meredith at 2023-05-29T12:46:27+00:00
Remove JavaScriptFFI from --supported-extensions for non-JS targets (#11214)

- - - - -
b4816919 by Matthew Pickering at 2023-05-30T17:07:43-04:00
testsuite: Pass -kb16k -kc128k for performance tests

Setting a larger stack chunk size gives a greater protection
from stack thrashing (where the repeated overflow/underflow allocates a lot of
stack chunks which sigificantly impact allocations). This
stabilises some tests against differences cause by more things being
pushed onto the stack.

The performance tests are generally testing work done by the compiler,
using allocation as a proxy, so removing/stabilising the allocations due
to the stack gives us more stable tests which are also more sensitive
to actual changes in compiler performance.

The tests which increase are ones where we compile a lot of modules, and
for each module we spawn a thread to compile the module in. Therefore
increasing these numbers has a multiplying effect on these tests because
there are many more stacks which we can increase in size.

The most significant improvements though are cases such as T8095 which
reduce significantly in allocations (30%). This isn't a performance
improvement really but just helps stabilise the test against this
threshold set by the defaults.

Fixes #23439

-------------------------
Metric Decrease:
    InstanceMatching
    T14683
    T8095
    T9872b_defer
    T9872d
    T9961
    hie002
    T19695
    T3064
Metric Increase:
    MultiLayerModules
    T13701
    T14697
-------------------------

- - - - -
6629f1c5 by Ben Gamari at 2023-05-30T17:08:20-04:00
Move via-C flags into GHC

These were previously hardcoded in configure (with no option for
overriding them) and simply passed onto ghc through the settings file.

Since configure already guarantees gcc supports those flags, we simply
move them into GHC.

- - - - -
981e5e11 by Arnaud Spiwack at 2023-05-31T08:34:33-04:00
Allow CPR on unrestricted constructors

Per the new `Note [Linting linearity]`, we want optimisations over
trying to preserve linearity. This will allow CPR to handle `Ur`, in
particular.

- - - - -
bf9344d2 by Arnaud Spiwack at 2023-05-31T08:34:33-04:00
Push coercions across multiplicity boundaries

Per the new `Note [Linting linearity]`, we want optimisations over
trying to preserve linearity. This will avoid preventing inlinings and
reductions and make linear programs more efficient.

- - - - -
d56dd695 by sheaf at 2023-05-31T11:37:12-04:00
Data.Bag: add INLINEABLE to polymorphic functions

This commit allows polymorphic methods in GHC.Data.Bag to be
specialised, avoiding having to pass explicit dictionaries when they
are instantiated with e.g. a known monad.

- - - - -
5366cd35 by sheaf at 2023-05-31T11:37:12-04:00
Split off TcBinderStack into its own module

This commit splits off TcBinderStack into its own module,
to avoid module cycles: we might want to refer to it without also
pulling in the TcM monad.

- - - - -
09d4d307 by sheaf at 2023-05-31T11:37:12-04:00
Split off TcRef into its own module

This helps avoid pull in the full TcM monad when we just want access
to mutable references in the typechecker. This facilitates later patches
which introduce a slimmed down TcM monad for zonking.

- - - - -
88cc19b3 by sheaf at 2023-05-31T11:37:12-04:00
Introduce Codensity monad

The Codensity monad is useful to write state-passing computations in
continuation-passing style, e.g. to implement a State monad as
continuation-passing style over a Reader monad.

- - - - -
f62d8195 by sheaf at 2023-05-31T11:37:12-04:00
Restructure the zonker

This commit splits up the zonker into a few separate components, described
in Note [The structure of the zonker] in `GHC.Tc.Zonk.Type`.

1. `GHC.Tc.Zonk.Monad` introduces a pared-down `TcM` monad, `ZonkM`,
     which has enough information for zonking types.
     This allows us to refactor `ErrCtxt` to use `ZonkM` instead of `TcM`,
     which guarantees we don't throw an error while reporting an error.

2. `GHC.Tc.Zonk.Env` is the new home of `ZonkEnv`, and also defines
    two zonking monad transformers, `ZonkT` and `ZonkBndrT`.
    `ZonkT` is a reader monad transformer over `ZonkEnv`.
    `ZonkBndrT m` is the codensity monad over `ZonkT m`.

     `ZonkBndrT` is used for computations that accumulate binders
     in the `ZonkEnv`.

3. `GHC.Tc.Zonk.TcType` contains the code for zonking types, for use
    in the typechecker. It uses the `ZonkM` monad.

4. `GHC.Tc.Zonk.Type` contains the code for final zonking to `Type`,
    which has been refactored to use `ZonkTcM = ZonkT TcM` and
    `ZonkBndrTcM = ZonkBndrT TcM`.

Allocations slightly decrease on the whole due to using
continuation-passing style instead of manual state passing of ZonkEnv
in the final zonking to Type.

-------------------------
Metric Decrease:
    T4029
    T8095
    T14766
    T15304
    hard_hole_fits
    RecordUpdPerf
Metric Increase:
    T10421
-------------------------

- - - - -
70526f5b by mimi.vx at 2023-05-31T11:37:53-04:00
Update rdt-theme to latest upstream version

Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/23444

- - - - -
f3556d6c by Finley McIlwaine at 2023-06-01T04:53:12-04:00
Restructure IPE buffer layout

Reference ticket #21766

This commit restructures IPE buffer list entries to not contain
references to their corresponding info tables. IPE buffer list nodes now
point to two lists of equal length, one holding the list of info table
pointers and one holding the corresponding entries for each info table.
This will allow the entry data to be compressed without losing the
references to the info tables.

- - - - -
5d1f2411 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
Add IPE compression to configure

Reference ticket #21766

Adds an `--enable-ipe-data-compreesion` flag to the configure script
which will check for libzstd and set the appropriate flags to allow for
IPE data compression in the compiler

- - - - -
b7a640ac by Finley McIlwaine at 2023-06-01T04:53:12-04:00
IPE data compression

Reference ticket #21766

When IPE data compression is enabled, compress the emitted IPE buffer
entries and decompress them in the RTS.

- - - - -
5aef5658 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
Fix libzstd detection in configure and RTS

Ensure that `HAVE_LIBZSTD` gets defined to either 0 or 1 in all cases
and properly check that before IPE data decompression in the RTS. See
ticket #21766.

- - - - -
69563c97 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
Add note describing IPE data compression

See ticket #21766

- - - - -
7872e2b6 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
Fix byte order of IPE data, fix IPE tests

Make sure byte order of written IPE buffer entries matches target.

Make sure the IPE-related tests properly access the fields of IPE buffer
entry nodes with the new IPE layout.

This commit also introduces checks to avoid importing modules if IPE
compression is not enabled.

See ticket #21766.

- - - - -
0e85099b by Finley McIlwaine at 2023-06-01T04:53:12-04:00
Fix IPE data decompression buffer allocation

Capacity of buffers allocated for decompressed IPE data was
incorrect due to a misuse of the `ZSTD_findFrameCompressedSize`
function. Fix by always storing decompressed size of IPE data in IPE
buffer list nodes and using `ZSTD_findFrameCompressedSize` to determine
the size of the compressed data.

See ticket #21766

- - - - -
a0048866 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
Add optional dependencies to ./configure output

Changes the configure script to indicate whether libnuma, libzstd, or
libdw are being used as dependencies due to their optional features
being enabled.

- - - - -
09d93bd0 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
Add IPE-enabled builds to CI

- Adds an IPE job to the CI pipeline which is triggered by the ~IPE label
- Introduces CI logic to enable IPE data compression
- Enables uncompressed IPE data on debug CI job
- Regenerates jobs.yaml

MR https://gitlab.haskell.org/ghc/ci-images/-/merge_requests/112 on the
images repository is meant to ensure that the proper images have
libzstd-dev installed.

- - - - -
3ded9a1c by Finley McIlwaine at 2023-06-01T04:53:12-04:00
Update user's guide and release notes, small fixes

Add mention of IPE data compression to user's guide and the release
notes for 9.8.1. Also note the impact compression has on binary size in
both places.

Change IpeBufferListNode compression check so only the value `1`
indicates compression.

See ticket #21766

- - - - -
41b41577 by Finley McIlwaine at 2023-06-01T04:53:12-04:00
Remove IPE enabled builds from CI

We don't need to explicitly specify the +ipe transformer to test IPE data
since there are tests which manually enable IPE information. This commit does
leave zstd IPE data compression enabled on the debian CI jobs.

- - - - -
982bef3a by Krzysztof Gogolewski at 2023-06-01T04:53:49-04:00
Fix build with 9.2

GHC.Tc.Zonk.Type uses an equality constraint.
ghc.nix currently provides 9.2.

- - - - -
1c96bc3d by Krzysztof Gogolewski at 2023-06-01T10:56:11-04:00
Output Lint errors to stderr instead of stdout

This is a continuation of 7b095b99, which fixed warnings but not errors.

Refs #13342

- - - - -
8e81f140 by sheaf at 2023-06-01T10:56:51-04:00
Refactor lookupExactOrOrig & friends

This refactors the panoply of renamer lookup functions relating to
lookupExactOrOrig to more graciously handle Exact and Orig names.

In particular, we avoid the situation in which we would add Exact/Orig
GREs to the tcg_used_gres field, which could cause a panic in bestImport
like in #23240.

Fixes #23428

- - - - -
5d415bfd by Krzysztof Gogolewski at 2023-06-01T10:57:31-04:00
Use the one-shot trick for UM and RewriteM functors

As described in Note [The one-shot state monad trick],
we shouldn't use derived Functor instances for monads using
one-shot. This was done for most of them, but UM and RewriteM
were missed.

- - - - -
2c38551e by Krzysztof Gogolewski at 2023-06-01T10:58:08-04:00
Fix testsuite skipping Lint

setTestOpts() is used to modify the test options for an entire .T file,
rather than a single test.
If there was a test using collect_compiler_stats, all of the tests
in the same file had lint disabled.

Fixes #21247

- - - - -
00a1e50b by Krzysztof Gogolewski at 2023-06-01T10:58:44-04:00
Add testcases for already fixed #16432

They were fixed by 40c7daed0.

Fixes #16432

- - - - -
f6e060cc by Krzysztof Gogolewski at 2023-06-02T09:07:25-04:00
cleanup: Remove unused field from SelfBoot

It is no longer needed since Note [Extra dependencies from .hs-boot files]
was deleted in 6998772043.

I've also added tildes to Note headers, otherwise they're not detected
by the linter.

- - - - -
82eacab6 by sheaf at 2023-06-02T09:08:01-04:00
Delete GHC.Tc.Utils.Zonk

This module was split up into GHC.Tc.Zonk.Type and GHC.Tc.Zonk.TcType
in commit f62d8195, but I forgot to delete the original module
- - - - -
4a4eb761 by Ben Gamari at 2023-06-02T23:53:21-04:00
base: Add build-order import of GHC.Types in GHC.IO.Handle.Types

For reasons similar to those described in Note [Depend on
GHC.Num.Integer].

Fixes #23411.

- - - - -
f53ac0ae by Sylvain Henry at 2023-06-02T23:54:01-04:00
JS: fix and enhance non-minimized code generation (#22455)

Flag -ddisable-js-minimizer was producing invalid code. Fix that and
also a few other things to generate nicer JS code for debugging.

The added test checks that we don't regress when using the flag.

- - - - -
f7744e8e by Andrey Mokhov at 2023-06-03T16:49:44-04:00
[hadrian] Fix multiline synopsis rendering

- - - - -
b2c745db by Andrew Lelechenko at 2023-06-03T16:50:23-04:00
Elaborate on performance properties of Data.List.++

- - - - -
7cd8a61e by Matthew Pickering at 2023-06-05T11:46:23+01:00
Big TcLclEnv and CtLoc refactoring

The overall goal of this refactoring is to reduce the dependency
footprint of the parser and syntax tree. Good reasons include:

- Better module graph parallelisability
- Make it easier to migrate error messages without introducing module loops
- Philosophically, there's not reason for the AST to depend on half the
  compiler.

One of the key edges which added this dependency was

> GHC.Hs.Expr -> GHC.Tc.Types (TcLclEnv)

As this in turn depending on TcM which depends on HscEnv and so on.

Therefore the goal of this patch is to move `TcLclEnv` out of
`GHC.Tc.Types` so that `GHC.Hs.Expr` can import TcLclEnv without
incurring a huge dependency chain.

The changes in this patch are:

* Move TcLclEnv from GHC.Tc.Types to GHC.Tc.Types.LclEnv
* Create new smaller modules for the types used in TcLclEnv
  New Modules:
  - GHC.Tc.Types.ErrCtxt
  - GHC.Tc.Types.BasicTypes
  - GHC.Tc.Types.TH
  - GHC.Tc.Types.LclEnv
  - GHC.Tc.Types.CtLocEnv
  - GHC.Tc.Errors.Types.PromotionErr

  Removed Boot File:
  - {-# SOURCE #-} GHC.Tc.Types

* Introduce TcLclCtxt, the part of the TcLclEnv which doesn't
  participate in restoreLclEnv.

* Replace TcLclEnv in CtLoc with specific CtLocEnv which is defined in
  GHC.Tc.Types.CtLocEnv. Use CtLocEnv in Implic and CtLoc to record the
  location of the implication and constraint.

By splitting up TcLclEnv from GHC.Tc.Types we allow GHC.Hs.Expr to no
longer depend on the TcM monad and all that entails.

Fixes #23389 #23409

- - - - -
3d8d39d1 by Matthew Pickering at 2023-06-05T11:46:23+01:00
Remove dependency of GHC.Tc.Utils.TcType on GHC.Driver.Session

This removes the usage of DynFlags from Tc.Utils.TcType  so that it no
longer depends on GHC.Driver.Session. In general we don't want anything
which is a dependency of Language.Haskell.Syntax to depend on
GHC.Driver.Session and removing this edge gets us closer to that goal.

- - - - -
18db5ada by Matthew Pickering at 2023-06-05T11:46:23+01:00
Move isIrrefutableHsPat to GHC.Rename.Utils and rename to isIrrefutableHsPatRn

This removes edge from GHC.Hs.Pat to GHC.Driver.Session, which makes
Language.Haskell.Syntax end up depending on GHC.Driver.Session.

- - - - -
12919dd5 by Matthew Pickering at 2023-06-05T11:46:23+01:00
Remove dependency of GHC.Tc.Types.Constraint on GHC.Driver.Session

- - - - -
eb852371 by Matthew Pickering at 2023-06-05T11:46:24+01:00
hole fit plugins: Split definition into own module

The hole fit plugins are defined in terms of TcM, a type we want to
avoid depending on from `GHC.Tc.Errors.Types`. By moving it into its own
module we can remove this dependency. It also simplifies the necessary
boot file.

- - - - -
9e5246d7 by Matthew Pickering at 2023-06-05T11:46:24+01:00
Move GHC.Core.Opt.CallerCC Types into separate module

This allows `GHC.Driver.DynFlags` to depend on these types without
depending on CoreM and hence the entire simplifier pipeline.

We can also remove a hs-boot file with this change.

- - - - -
52d6a7d7 by Matthew Pickering at 2023-06-05T11:46:24+01:00
Remove unecessary SOURCE import

- - - - -
698d160c by Matthew Pickering at 2023-06-05T11:46:24+01:00
testsuite: Accept new output for CountDepsAst and CountDepsParser tests

These are in a separate commit as the improvement to these tests is the
cumulative effect of the previous set of patches rather than just the
responsibility of the last one in the patchset.

- - - - -
58ccf02e by sheaf at 2023-06-05T16:00:47-04:00
TTG: only allow VarBind at GhcTc

The VarBind constructor of HsBind is only used at the GhcTc stage.
This commit makes that explicit by setting the extension field of
VarBind to be DataConCantHappen at all other stages.

This allows us to delete a dead code path in GHC.HsToCore.Quote.rep_bind,
and remove some panics.

- - - - -
54b83253 by Matthew Craven at 2023-06-06T12:59:25-04:00
Generate Addr# access ops programmatically

The existing utils/genprimopcode/gen_bytearray_ops.py was
relocated and extended for this purpose.  Additionally, hadrian
now knows about this script and uses it when generating primops.txt

- - - - -
ecadbc7e by Matthew Pickering at 2023-06-06T13:00:01-04:00
ghcup-metadata: Only add Nightly tag when replacing LatestNightly

Previously we were always adding the Nightly tag, but this led to all
the previous builds getting an increasing number of nightly tags over
time. Now we just add it once, when we remove the LatestNightly tag.

- - - - -
4aea0a72 by Vladislav Zavialov at 2023-06-07T12:06:46+02:00
Invisible binders in type declarations (#22560)

This patch implements @k-binders introduced in GHC Proposal #425
and guarded behind the TypeAbstractions extension:

	type D :: forall k j. k -> j -> Type
	data D @k @j a b = ...
	       ^^ ^^

To represent the new syntax, we modify LHsQTyVars as follows:

	-  hsq_explicit :: [LHsTyVarBndr () pass]
	+  hsq_explicit :: [LHsTyVarBndr (HsBndrVis pass) pass]

HsBndrVis is a new data type that records the distinction between
type variable binders written with and without the @ sign:

	data HsBndrVis pass
	  = HsBndrRequired
	  | HsBndrInvisible (LHsToken "@" pass)

The rest of the patch updates GHC, template-haskell, and haddock
to handle the new syntax.

Parser:
  The PsErrUnexpectedTypeAppInDecl error message is removed.
  The syntax it used to reject is now permitted.

Renamer:
  The @ sign does not affect the scope of a binder, so the changes to
  the renamer are minimal.  See rnLHsTyVarBndrVisFlag.

Type checker:
  There are three code paths that were updated to deal with the newly
  introduced invisible type variable binders:

    1. checking SAKS: see kcCheckDeclHeader_sig, matchUpSigWithDecl
    2. checking CUSK: see kcCheckDeclHeader_cusk
    3. inference: see kcInferDeclHeader, rejectInvisibleBinders

  Helper functions bindExplicitTKBndrs_Q_Skol and bindExplicitTKBndrs_Q_Tv
  are generalized to work with HsBndrVis.

Updates the haddock submodule.

Metric Increase:
    MultiLayerModulesTH_OneShot

Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com>

- - - - -
b7600997 by Josh Meredith at 2023-06-07T13:10:21-04:00
JS: clean up FFI 'fat arrow' calls in base:System.Posix.Internals (#23481)

- - - - -
e5d3940d by Sebastian Graf at 2023-06-07T18:01:28-04:00
Update CODEOWNERS
- - - - -
960ef111 by Matthew Pickering at 2023-06-07T18:02:04-04:00
Revert "Remove IPE enabled builds from CI"

This reverts commit 41b41577c8a28c236fa37e8f73aa1c6dc368d951.

- - - - -
bad1c8cc by Matthew Pickering at 2023-06-07T18:02:04-04:00
Revert "Update user's guide and release notes, small fixes"

This reverts commit 3ded9a1cd22f9083f31bc2f37ee1b37f9d25dab7.

- - - - -
12726d90 by Matthew Pickering at 2023-06-07T18:02:04-04:00
Revert "Add IPE-enabled builds to CI"

This reverts commit 09d93bd0305b0f73422ce7edb67168c71d32c15f.

- - - - -
dbdd989d by Matthew Pickering at 2023-06-07T18:02:04-04:00
Revert "Add optional dependencies to ./configure output"

This reverts commit a00488665cd890a26a5564a64ba23ff12c9bec58.

- - - - -
240483af by Matthew Pickering at 2023-06-07T18:02:04-04:00
Revert "Fix IPE data decompression buffer allocation"

This reverts commit 0e85099b9316ee24565084d5586bb7290669b43a.

- - - - -
9b8c7dd8 by Matthew Pickering at 2023-06-07T18:02:04-04:00
Revert "Fix byte order of IPE data, fix IPE tests"

This reverts commit 7872e2b6f08ea40d19a251c4822a384d0b397327.

- - - - -
3364379b by Matthew Pickering at 2023-06-07T18:02:04-04:00
Revert "Add note describing IPE data compression"

This reverts commit 69563c97396b8fde91678fae7d2feafb7ab9a8b0.

- - - - -
fda30670 by Matthew Pickering at 2023-06-07T18:02:04-04:00
Revert "Fix libzstd detection in configure and RTS"

This reverts commit 5aef5658ad5fb96bac7719710e0ea008bf7b62e0.

- - - - -
1cbcda9a by Matthew Pickering at 2023-06-07T18:02:04-04:00
Revert "IPE data compression"

This reverts commit b7a640acf7adc2880e5600d69bcf2918fee85553.

- - - - -
fb5e99aa by Matthew Pickering at 2023-06-07T18:02:04-04:00
Revert "Add IPE compression to configure"

This reverts commit 5d1f2411f4becea8650d12d168e989241edee186.

- - - - -
2cdcb3a5 by Matthew Pickering at 2023-06-07T18:02:04-04:00
Revert "Restructure IPE buffer layout"

This reverts commit f3556d6cefd3d923b36bfcda0c8185abb1d11a91.

- - - - -
2b0c9f5e by Simon Peyton Jones at 2023-06-08T07:52:34+00:00
Don't report redundant Givens from quantified constraints

This fixes #23323

See (RC4) in Note [Tracking redundant constraints]

- - - - -
567b32e1 by David Binder at 2023-06-08T18:41:29-04:00
Update the outdated instructions in HACKING.md on how to compile GHC

- - - - -
2b1a4abe by Ryan Scott at 2023-06-09T07:56:58-04:00
Restore mingwex dependency on Windows

This partially reverts some of the changes in !9475 to make `base` and
`ghc-prim` depend on the `mingwex` library on Windows. It also restores the
RTS's stubs for `mingwex`-specific symbols such as `_lock_file`.

This is done because the C runtime provides `libmingwex` nowadays, and
moreoever, not linking against `mingwex` requires downstream users to link
against it explicitly in difficult-to-predict circumstances. Better to always
link against `mingwex` and prevent users from having to do the guesswork
themselves.

See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10360#note_495873 for
the discussion that led to this.

- - - - -
28954758 by Ryan Scott at 2023-06-09T07:56:58-04:00
RtsSymbols.c: Remove mingwex symbol stubs

As of !9475, the RTS now links against `ucrt` instead of `msvcrt` on Windows,
which means that the RTS no longer needs to declare stubs for the `__mingw_*`
family of symbols. Let's remove these stubs to avoid confusion.

Fixes #23309.

- - - - -
3ab0155b by Ryan Scott at 2023-06-09T07:57:35-04:00
Consistently use validity checks for TH conversion of data constructors

We were checking that TH-spliced data declarations do not look like this:

```hs
data D :: Type = MkD Int
```

But we were only doing so for `data` declarations' data constructors, not for
`newtype`s, `data instance`s, or `newtype instance`s. This patch factors out
the necessary validity checks into its own `cvtDataDefnCons` function and uses
it in all of the places where it needs to be.

Fixes #22559.

- - - - -
a24b83dd by Matthew Pickering at 2023-06-09T15:19:00-04:00
Fix behaviour of -keep-tmp-files when used in OPTIONS_GHC pragma

This fixes the behaviour of -keep-tmp-files when used in an OPTIONS_GHC
pragma for files with module level scope.

Instead of simple not deleting the files, we also need to remove them
from the TmpFs so they are not deleted later on when all the other files
are deleted.

There are additional complications because you also need to remove the
directory where these files live from the TmpFs so we don't try to
delete those later either.

I added two tests.

1. Tests simply that -keep-tmp-files works at all with a single module
   and --make mode.
2. The other tests that temporary files are deleted for other modules
   which don't enable -keep-tmp-files.

Fixes #23339

- - - - -
dcf32882 by Matthew Pickering at 2023-06-09T15:19:00-04:00
withDeferredDiagnostics: When debugIsOn, write landmine into IORef to catch use-after-free.

Ticket #23305 reports an error where we were attempting to use the
logger which was created by withDeferredDiagnostics after its scope had
ended.

This problem would have been caught by this patch and a validate build:

```
+*** Exception: Use after free
+CallStack (from HasCallStack):
+  error, called at compiler/GHC/Driver/Make.hs:<line>:<column> in <package-id>:GHC.Driver.Make
```

This general issue is tracked by #20981

- - - - -
432c736c by Matthew Pickering at 2023-06-09T15:19:00-04:00
Don't return complete HscEnv from upsweep

By returning a complete HscEnv from upsweep the logger (as introduced by
withDeferredDiagnostics) was escaping the scope of
withDeferredDiagnostics and hence we were losing error messages.

This is reminiscent of #20981, which also talks about writing errors
into messages after their scope has ended.

See #23305 for details.

- - - - -
26013cdc by Alexander McKenna at 2023-06-09T15:19:41-04:00
Dump `SpecConstr` specialisations separately

Introduce a `-ddump-spec-constr` flag which debugs specialisations from
`SpecConstr`. These are no longer shown when you use `-ddump-spec`.

- - - - -
4639100b by Matthew Pickering at 2023-06-09T18:50:43-04:00
Add role annotations to SNat, SSymbol and SChar

Ticket #23454 explained it was possible to implement unsafeCoerce
because SNat was lacking a role annotation.

As these are supposed to be singleton types but backed by an efficient
representation the correct annotation is nominal to ensure these kinds
of coerces are forbidden.

These annotations were missed from https://github.com/haskell/core-libraries-committee/issues/85
which was implemented in 532de36870ed9e880d5f146a478453701e9db25d.

CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/170

Fixes #23454

- - - - -
9c0dcff7 by Matthew Pickering at 2023-06-09T18:51:19-04:00
Remove non-existant bytearray-ops.txt.pp file from ghc.cabal.in

This broke the sdist generation.

Fixes #23489

- - - - -
273ff0c7 by David Binder at 2023-06-09T18:52:00-04:00
Regression test T13438 is no longer marked as "expect_broken" in the testsuite driver.

- - - - -
b84a2900 by Andrei Borzenkov at 2023-06-10T08:27:28-04:00
Fix -Wterm-variable-capture scope (#23434)

-Wterm-variable-capture wasn't accordant with type variable
scoping in associated types, in type classes. For example,
this code produced the warning:
  k = 12

  class C k a where
    type AT a :: k -> Type

I solved this issue by reusing machinery of newTyVarNameRn function
that is accordand with associated types: it does lookup for each free type
variable when we are in the type class context. And in this patch I
use result of this work to make sure that -Wterm-variable-capture warns
only on implicitly quantified type variables.

- - - - -
9d1a8d87 by Jorge Mendes at 2023-06-10T08:28:10-04:00
Remove redundant case statement in rts/js/mem.js.
- - - - -
a1f350e2 by Oleg Grenrus at 2023-06-13T09:42:16-04:00
Change WarningWithFlag to plural WarningWithFlags

Resolves #22825

Now each diagnostic can name multiple different warning flags for its reason.

There is currently one use case: missing signatures.
Currently we need to check which warning flags are enabled when
generating the diagnostic, which is against the declarative nature of
the diagnostic framework.

This patch allows a warning diagnostic to have multiple warning flags,
which makes setup more declarative.

The WarningWithFlag pattern synonym is added for backwards compatibility

The 'msgEnvReason' field is added to MsgEnvelope to store the
`ResolvedDiagnosticReason`, which accounts for the enabled flags, and
then that is used for pretty printing the diagnostic.

- - - - -
ec01f0ec by Matthew Pickering at 2023-06-13T09:42:59-04:00
Add a test Way for running ghci with Core optimizations

Tracking ticket: #23059

This runs compile_and_run tests with optimised code with bytecode
interpreter

Changed submodules: hpc, process

Co-authored-by: Torsten Schmits <git at tryp.io>

- - - - -
c6741e72 by Rodrigo Mesquita at 2023-06-13T09:43:38-04:00
Configure -Qunused-arguments instead of hardcoding it

When GHC invokes clang, it currently passes -Qunused-arguments to
discard warnings resulting from GHC using multiple options that aren't
used.

In this commit, we configure -Qunused-arguments into the Cc options
instead of checking if the compiler is clang at runtime and hardcoding
the flag into GHC.

This is part of the effort to centralise toolchain information in
toolchain target files at configure time with the end goal of a runtime
retargetable GHC.

This also means we don't need to call getCompilerInfo ever, which
improves performance considerably (see !10589).

Metric Decrease:
    PmSeriesG
    T10421
    T11303b
    T12150
    T12227
    T12234
    T12425
    T13035
    T13253-spj
    T13386
    T15703
    T16875
    T17836b
    T17977
    T17977b
    T18140
    T18282
    T18304
    T18698a
    T18698b
    T18923
    T20049
    T21839c
    T3064
    T5030
    T5321FD
    T5321Fun
    T5837
    T6048
    T9020
    T9198
    T9872d
    T9961

- - - - -
0128db87 by Victor Cacciari Miraldo at 2023-06-13T09:44:18-04:00
Improve docs for Data.Fixed; adds 'realToFrac' as an option for conversion
between different precisions.

- - - - -
95b69cfb by Ryan Scott at 2023-06-13T09:44:55-04:00
Add regression test for #23143

!10541, the fix for #23323, also fixes #23143. Let's add a regression test to
ensure that it stays fixed.

Fixes #23143.

- - - - -
ed2dbdca by Emily Martins at 2023-06-13T09:45:37-04:00
delete GHCi.UI.Tags module and remove remaining references

Co-authored-by: Tilde Rose <t1lde at protonmail.com>

- - - - -
c90d96e4 by Victor Cacciari Miraldo at 2023-06-13T09:46:26-04:00
Add regression test for 17328

- - - - -
de58080c by Victor Cacciari Miraldo at 2023-06-13T09:46:26-04:00
Skip checking whether constructors are in scope when deriving
newtype instances.

Fixes #17328

- - - - -
5e3c2b05 by Philip Hazelden at 2023-06-13T09:47:07-04:00
Don't suggest `DeriveAnyClass` when instance can't be derived.

Fixes #19692.

Prototypical cases:

    class C1 a where
      x1 :: a -> Int
    data G1 = G1 deriving C1

    class C2 a where
      x2 :: a -> Int
      x2 _ = 0
    data G2 = G2 deriving C2

Both of these used to give this suggestion, but for C1 the suggestion
would have failed (generated code with undefined methods, which compiles
but warns). Now C2 still gives the suggestion but C1 doesn't.

- - - - -
80a0b099 by David Binder at 2023-06-13T09:47:49-04:00
Add testcase for error GHC-00711 to testsuite

- - - - -
e4b33a1d by Oleg Grenrus at 2023-06-14T07:01:21-04:00
Add -Wmissing-poly-kind-signatures

Implements #22826

This is a restricted version of -Wmissing-kind-signatures shown only for polykinded types.

- - - - -
f8395b94 by doyougnu at 2023-06-14T07:02:01-04:00
ci: special case in req_host_target_ghc for JS

- - - - -
b852a5b6 by Gergő Érdi at 2023-06-14T07:02:42-04:00
When forcing a `ModIface`, force the `MINIMAL` pragmas in class definitions

Fixes #23486

- - - - -
c29b45ee by Krzysztof Gogolewski at 2023-06-14T07:03:19-04:00
Add a testcase for #20076

Remove 'recursive' in the error message, since the error
can arise without recursion.

- - - - -
b80ef202 by Krzysztof Gogolewski at 2023-06-14T07:03:56-04:00
Use tcInferFRR to prevent bad generalisation

Fixes #23176

- - - - -
bd8ef37d by Matthew Pickering at 2023-06-14T07:04:31-04:00
ci: Add dependenices on necessary aarch64 jobs for head.hackage ci

These need to be added since we started testing aarch64 on head.hackage
CI. The jobs will sometimes fail because they will start before the
relevant aarch64 job has finished.

Fixes #23511

- - - - -
a0c27cee by Vladislav Zavialov at 2023-06-14T07:05:08-04:00
Add standalone kind signatures for Code and TExp

CodeQ and TExpQ already had standalone kind signatures
even before this change:

	type TExpQ :: TYPE r -> Kind.Type
	type CodeQ :: TYPE r -> Kind.Type

Now Code and TExp have signatures too:

	type TExp :: TYPE r -> Kind.Type
	type Code :: (Kind.Type -> Kind.Type) -> TYPE r -> Kind.Type

This is a stylistic change.

- - - - -
e70c1245 by Tom Ellis at 2023-06-14T07:05:48-04:00
Warn that GHC.TypeLits.Internal should not be used

- - - - -
100650e3 by Tom Ellis at 2023-06-14T07:05:48-04:00
Warn that GHC.TypeNats.Internal should not be used

- - - - -
078250ef by Jacco Krijnen at 2023-06-14T17:17:53-04:00
Add more flags for dumping core passes (#23491)

- - - - -
1b7604af by Jacco Krijnen at 2023-06-14T17:17:53-04:00
Add tests for dumping flags (#23491)

- - - - -
42000000 by Sebastian Graf at 2023-06-14T17:18:29-04:00
Provide a demand signature for atomicModifyMutVar.# (#23047)

Fixes #23047

- - - - -
8f27023b by Ben Gamari at 2023-06-15T03:10:24-04:00
compiler: Cross-reference Note [StgToJS design]

In particular, the numeric representations are quite useful context in a
few places.

- - - - -
a71b60e9 by Andrei Borzenkov at 2023-06-15T03:11:00-04:00
Implement the -Wimplicit-rhs-quantification warning (#23510)

GHC Proposal #425 "Invisible binders in type declarations" forbids
implicit quantification of type variables that occur free on the
right-hand side of a type synonym but are not mentioned on the left-hand side.
The users are expected to rewrite this using invisible binders:

    type T1 :: forall a . Maybe a
    type T1    = 'Nothing :: Maybe a      -- old
    type T1 @a = 'Nothing :: Maybe a      -- new

Since the @k-binders are a new feature, we need to wait for three releases
before we require the use of the new syntax. In the meantime, we ought to
provide users with a new warning, -Wimplicit-rhs-quantification, that would
detect when such implicit quantification takes place, and include it in -Wcompat.

- - - - -
0078dd00 by Sven Tennie at 2023-06-15T03:11:36-04:00
Minor refactorings to mkSpillInstr and mkLoadInstr

Better error messages. And, use the existing `off` constant to reduce
duplication.

- - - - -
1792b57a by doyougnu at 2023-06-15T03:12:17-04:00
JS: merge util modules

Merge Core and StgUtil modules for StgToJS pass.
Closes: #23473

- - - - -
469ff08b by Vladislav Zavialov at 2023-06-15T03:12:57-04:00
Check visibility of nested foralls in can_eq_nc (#18863)

Prior to this change, `can_eq_nc` checked the visibility of the
outermost layer of foralls:

	forall a. forall b. forall c. phi1
	forall x. forall y. forall z. phi2
	        ^^
	     up to here

Then it delegated the rest of the work to `can_eq_nc_forall`, which
split off all foralls:

	forall a. forall b. forall c. phi1
	forall x. forall y. forall z. phi2
	                            ^^
	                         up to here

This meant that some visibility flags were completely ignored.
We fix this oversight by moving the check to `can_eq_nc_forall`.

- - - - -
59c9065b by Luite Stegeman at 2023-06-15T03:13:37-04:00
JS: use regular mask for blocking IO

Blocking IO used uninterruptibleMask which should make any thread
blocked on IO unreachable by async exceptions (such as those from
timeout). This changes it to a regular mask.

It's important to note that the nodejs runtime does not actually
interrupt the blocking IO when the Haskell thread receives an
async exception, and that file positions may be updated and buffers
may be written after the Haskell thread has already resumed.

Any file descriptor affected by an async exception interruption
should therefore be used with caution.

- - - - -
907c06c3 by Luite Stegeman at 2023-06-15T03:13:37-04:00
JS: nodejs: do not set 'readable' handler on stdin at startup

The Haskell runtime used to install a 'readable' handler on stdin
at startup in nodejs. This would cause the nodejs system to start
buffering the stream, causing data loss if the stdin file
descriptor is passed to another process.

This change delays installation of the 'readable' handler until
the first read of stdin by Haskell code.

- - - - -
a54b40a9 by Luite Stegeman at 2023-06-15T03:13:37-04:00
JS: reserve one more virtual (negative) file descriptor

This is needed for upcoming support of the process package

- - - - -
78cd1132 by Andrei Borzenkov at 2023-06-15T11:16:11+04:00
Report scoped kind variables at the type-checking phase (#16635)

This patch modifies the renamer to respect ScopedTypeVariables in kind
signatures. This means that kind variables bound by the outermost
`forall` now scope over the type:

  type F = '[Right @a @() () :: forall a. Either a ()]
  --         ^^^^^^^^^^^^^^^          ^^^
  --          in scope here        bound here

However, any use of such variables is a type error, because we don't
have type-level lambdas to bind them in Core. This is described in the
new Note [Type variable scoping errors during type check] in GHC.Tc.Types.

- - - - -
4a41ba75 by Sylvain Henry at 2023-06-15T18:09:15-04:00
JS: testsuite: use correct ticket number

Replace #22356 with #22349 for these tests because #22356 has been fixed
but now these tests fail because of #22349.

- - - - -
15f150c8 by Sylvain Henry at 2023-06-15T18:09:16-04:00
JS: testsuite: update ticket numbers

- - - - -
08d8e9ef by Sylvain Henry at 2023-06-15T18:09:16-04:00
JS: more triage

- - - - -
e8752e12 by Krzysztof Gogolewski at 2023-06-15T18:09:52-04:00
Fix test T18522-deb-ppr

Fixes #23509

- - - - -
62c56416 by Ben Price at 2023-06-16T05:52:39-04:00
Lint: more details on "Occurrence is GlobalId, but binding is LocalId"

This is helpful when debugging a pass which accidentally shadowed a
binder.

- - - - -
d4c10238 by Ryan Hendrickson at 2023-06-16T05:53:22-04:00
Clean a stray bit of text in user guide

- - - - -
93647b5c by Vladislav Zavialov at 2023-06-16T05:54:02-04:00
testsuite: Add forall visibility test cases

The added tests ensure that the type checker does not confuse
visible and invisible foralls.

VisFlag1:    kind-checking type applications and inferred type variable instantiations
VisFlag1_ql: kind-checking Quick Look instantiations
VisFlag2:    kind-checking type family instances
VisFlag3:    checking kind annotations on type parameters of associated type families
VisFlag4:    checking kind annotations on type parameters in type declarations with SAKS
VisFlag5:    checking the result kind annotation of data family instances

- - - - -
a5f0c00e by Sylvain Henry at 2023-06-16T12:25:40-04:00
JS: factorize SaneDouble into its own module

Follow-up of b159e0e9 whose ticket is #22736

- - - - -
0baf9e7c by Krzysztof Gogolewski at 2023-06-16T12:26:17-04:00
Add tests for #21973

- - - - -
640ea90e by Diego Diverio at 2023-06-16T23:07:55-04:00
Update documentation for `<**>`

- - - - -
2469a813 by Diego Diverio at 2023-06-16T23:07:55-04:00
Update text

- - - - -
1f515bbb by Diego Diverio at 2023-06-16T23:07:55-04:00
Update examples

- - - - -
7af99a0d by Diego Diverio at 2023-06-16T23:07:55-04:00
Update documentation to actually display code correctly

- - - - -
800aad7e by Andrei Borzenkov at 2023-06-16T23:08:32-04:00
Type/data instances: require that variables on the RHS are mentioned on the LHS (#23512)

GHC Proposal #425 "Invisible binders in type declarations" restricts the
scope of type and data family instances as follows:

  In type family and data family instances, require that every variable
  mentioned on the RHS must also occur on the LHS.

For example, here are three equivalent type instance definitions accepted before this patch:

  type family F1 a :: k
  type instance F1 Int = Any :: j -> j

  type family F2 a :: k
  type instance F2 @(j -> j) Int = Any :: j -> j

  type family F3 a :: k
  type instance forall j. F3 Int = Any :: j -> j

- In F1, j is implicitly quantified and it occurs only on the RHS;
- In F2, j is implicitly quantified and it occurs both on the LHS and the RHS;
- In F3, j is explicitly quantified.

Now F1 is rejected with an out-of-scope error, while F2 and F3 continue to be accepted.

- - - - -
9132d529 by Sylvain Henry at 2023-06-18T02:50:34-04:00
JS: testsuite: use correct ticket numbers

- - - - -
c3a1274c by Sylvain Henry at 2023-06-18T02:50:34-04:00
JS: don't dump eventlog to stderr by default

Fix T16707

Bump stm submodule

- - - - -
89bb8ad8 by Ryan Hendrickson at 2023-06-18T02:51:14-04:00
Fix TH name lookup for symbolic tycons (#23525)

- - - - -
cb9e1ce4 by Finley McIlwaine at 2023-06-18T21:16:45-06:00
IPE data compression

IPE data resulting from the `-finfo-table-map` flag may now be
compressed by configuring the GHC build with the
`--enable-ipe-data-compression` flag. This results in about a 20%
reduction in the size of IPE-enabled build results.

The compression library, zstd, may optionally be statically linked by
configuring with the `--enabled-static-libzstd` flag (on non-darwin
platforms)

libzstd version 1.4.0 or greater is required.

- - - - -
0cbc3ae0 by Gergő Érdi at 2023-06-19T09:11:38-04:00
Add `IfaceWarnings` to represent the `ModIface`-storable parts
of a `Warnings GhcRn`.

Fixes #23516

- - - - -
3e80c2b4 by Arnaud Spiwack at 2023-06-20T03:19:41-04:00
Avoid desugaring non-recursive lets into recursive lets

This prepares for having linear let expressions in the frontend.

When desugaring lets, SPECIALISE statements create more copies of a
let binding. Because of the rewrite rules attached to the bindings,
there are dependencies between the generated binds.

Before this commit, we simply wrapped all these in a mutually
recursive let block, and left it to the simplified to sort it out.

With this commit: we are careful to generate the bindings in
dependency order, so that we can wrap them in consecutive lets (if the
source is non-recursive).

- - - - -
9fad49e0 by Ben Gamari at 2023-06-20T03:20:19-04:00
rts: Do not call exit() from SIGINT handler

Previously `shutdown_handler` would call `stg_exit` if the scheduler was
Oalready found to be in `SCHED_INTERRUPTING` state (or higher). However,
`stg_exit` is not signal-safe as it calls `exit` (which calls `atexit`
handlers). The only safe thing to do in this situation is to call
`_exit`, which terminates with minimal cleanup.

Fixes #23417.

- - - - -
7485f848 by Andrew Lelechenko at 2023-06-20T03:20:57-04:00
Bump Cabal submodule

This requires changing the recomp007 test because now cabal passes
`this-unit-id` to executable components, and that unit-id contains a
hash which includes the ABI of the dependencies. Therefore changing the
dependencies means that -this-unit-id changes and recompilation is
triggered.

The spririt of the test is to test GHC's recompilation logic assuming
that `-this-unit-id` is constant, so we explicitly pass `-ipid` to
`./configure` rather than letting `Cabal` work it out.

- - - - -
1464a2a8 by mangoiv at 2023-06-20T03:21:34-04:00
[feat] add a hint to `HasField` error message
- add a hint that indicates that the record that the record dot is used
  on might just be missing a field
- as the intention of the programmer is not entirely clear, it is only
  shown if the type is known
- This addresses in part issue #22382

- - - - -
b65e78dd by Ben Gamari at 2023-06-20T16:56:43-04:00
rts/ipe: Fix unused lock warning

- - - - -
6086effd by Ben Gamari at 2023-06-20T16:56:44-04:00
rts/ProfilerReportJson: Fix memory leak

- - - - -
1e48c434 by Ben Gamari at 2023-06-20T16:56:44-04:00
rts: Various warnings fixes

- - - - -
471486b9 by Ben Gamari at 2023-06-20T16:56:44-04:00
rts: Fix printf format mismatch

- - - - -
80603fb3 by Ben Gamari at 2023-06-20T16:56:44-04:00
rts: Fix incorrect #include <sys/poll.h>

According to Alpine's warnings and poll(2), <poll.h> should be
preferred.

- - - - -
ff18e6fd by Ben Gamari at 2023-06-20T16:56:44-04:00
nonmoving: Fix unused definition warrnings

- - - - -
6e7fe8ee by Ben Gamari at 2023-06-20T16:56:44-04:00
Disable futimens on Darwin.

See #22938

- - - - -
b7706508 by Ben Gamari at 2023-06-20T16:56:44-04:00
rts: Fix incorrect CPP guard

- - - - -
94f00e9b by Ben Gamari at 2023-06-20T16:56:44-04:00
hadrian: Ensure that -Werror is passed when compiling the RTS.

Previously the `+werror` transformer would only pass `-Werror` to GHC,
which does not ensure that the same is passed to the C compiler when
building the RTS. Arguably this is itself a bug but for now we will just
work around this by passing `-optc-Werror` to GHC.

I tried to enable `-Werror` in all C compilations but the boot libraries
are something of a portability nightmare.

- - - - -
5fb54bf8 by Ben Gamari at 2023-06-20T16:56:44-04:00
rts: Disable `#pragma GCC`s on clang compilers

Otherwise the build fails due to warnings. See #23530.

- - - - -
cf87f380 by Ben Gamari at 2023-06-20T16:56:44-04:00
rts: Fix capitalization of prototype

- - - - -
17f250d7 by Ben Gamari at 2023-06-20T16:56:44-04:00
rts: Fix incorrect format specifier

- - - - -
0ff1c501 by Josh Meredith at 2023-06-20T16:57:20-04:00
JS: remove js_broken(22576) in favour of the pre-existing wordsize(32) condition (#22576)

- - - - -
3d1d42b7 by Finley McIlwaine at 2023-06-21T12:04:58-04:00
Memory usage fixes for Haddock

- Do not include `mi_globals` in the `NoBackend` backend. It was only included
  for Haddock, but Haddock does not actually need it. This causes a 200MB
  reduction in max residency when generating haddocks on the Agda codebase
  (roughly 1GB to 800MB).

- Make haddock_{parser,renamer}_perf tests more accurate by forcing docs to
  be written to interface files using `-fwrite-interface`

Bumps haddock submodule.

Metric Decrease:
    haddock.base

- - - - -
8185b1c2 by Finley McIlwaine at 2023-06-21T12:04:58-04:00
Fix associated data family doc structure items

Associated data families were being given their own export DocStructureItems,
which resulted in them being documented separately from their classes in
haddocks. This commit fixes it.

- - - - -
4d356ea3 by Sylvain Henry at 2023-06-21T12:04:59-04:00
JS: implement TH support

- Add ghc-interp.js bootstrap script for the JS interpreter
- Interactively link and execute iserv code from the ghci package
- Incrementally load and run JS code for splices into the running iserv

Co-authored-by: Luite Stegeman <stegeman at gmail.com>

- - - - -
3249cf12 by Sylvain Henry at 2023-06-21T12:04:59-04:00
Don't use getKey

- - - - -
f84ff161 by Sylvain Henry at 2023-06-21T12:04:59-04:00
Stg: return imported FVs

This is used to determine what to link when using the interpreter.
For now it's only used by the JS interpreter but it could easily be used
by the native interpreter too (instead of extracting names from compiled BCOs).

- - - - -
fab2ad23 by Sylvain Henry at 2023-06-21T12:04:59-04:00
Fix some recompilation avoidance tests

- - - - -
a897dc13 by Sylvain Henry at 2023-06-21T12:04:59-04:00
TH_import_loop is now broken as expected

- - - - -
dbb4ad51 by Sylvain Henry at 2023-06-21T12:04:59-04:00
JS: always recompile when TH is enabled (cf #23013)

- - - - -
711b1d24 by Bartłomiej Cieślar at 2023-06-21T12:59:27-04:00
Add support for deprecating exported items (proposal #134)

This is an implementation of the deprecated exports proposal #134.
The proposal introduces an ability to introduce warnings to exports.
This allows for deprecating a name only when it is exported from a specific
module, rather than always depreacting its usage. In this example:

    module A ({-# DEPRECATED "do not use" #-} x) where
    x = undefined
    ---
    module B where
    import A(x)

`x` will emit a warning when it is explicitly imported.

Like the declaration warnings, export warnings are first accumulated within
the `Warnings` struct, then passed into the ModIface, from which they are
then looked up and warned about in the importing module in the `lookup_ie`
helpers of the `filterImports` function (for the explicitly imported names)
and in the `addUsedGRE(s)` functions where they warn about regular usages
of the imported name.

In terms of the AST information, the custom warning is stored in the
extension field of the variants of the `IE` type (see Trees that Grow for
more information).

The commit includes a bump to the haddock submodule added in MR #28

Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com>

- - - - -
c1865854 by Ben Gamari at 2023-06-21T12:59:30-04:00
configure: Bump version to 9.8

Bumps Haddock submodule

- - - - -
4e1de71c by Ben Gamari at 2023-06-21T21:07:48-04:00
configure: Bump version to 9.9

Bumps haddock submodule.

- - - - -
5b6612bc by Ben Gamari at 2023-06-23T03:56:49-04:00
rts: Work around missing prototypes errors

Darwin's toolchain inexpliciably claims that `write_barrier` and friends
have declarations without prototypes, despite the fact that (a) they are
definitions, and (b) the prototypes appear only a few lines above. Work
around this by making the definitions proper prototypes.

- - - - -
43b66a13 by Matthew Pickering at 2023-06-23T03:57:26-04:00
ghcup-metadata: Fix date modifier (M = minutes, m = month)

Fixes #23552

- - - - -
564164ef by Luite Stegeman at 2023-06-24T10:27:29+09:00
Support large stack frames/offsets in GHCi bytecode interpreter

Bytecode instructions like PUSH_L (push a local variable) contain
an operand that refers to the stack slot. Before this patch, the
operand type was SmallOp (Word16), limiting the maximum stack
offset to 65535 words. This could cause compiler panics in some
cases (See #22888).

This patch changes the operand type for stack offsets from
SmallOp to Op, removing the stack offset limit.

Fixes #22888

- - - - -
8d6574bc by Sylvain Henry at 2023-06-26T13:15:06-04:00
JS: support levity-polymorphic datatypes (#22360,#22291)

- thread knowledge about levity into PrimRep instead of panicking
- JS: remove assumption that unlifted heap objects are rts objects (TVar#, etc.)

Doing this also fixes #22291 (test added).

There is a small performance hit (~1% more allocations).

Metric Increase:
    T18698a
    T18698b

- - - - -
5578bbad by Matthew Pickering at 2023-06-26T13:15:43-04:00
MR Review Template: Mention "Blocked on Review" label

In order to improve our MR review processes we now have the label
"Blocked on Review" which allows people to signal that a MR is waiting
on a review to happen.

See: https://mail.haskell.org/pipermail/ghc-devs/2023-June/021255.html

- - - - -
4427e9cf by Matthew Pickering at 2023-06-26T13:15:43-04:00
Move MR template to Default.md

This makes it more obvious what you have to modify to affect the default
template rather than looking in the project settings.

- - - - -
522bd584 by Arnaud Spiwack at 2023-06-26T13:16:33-04:00
Revert "Avoid desugaring non-recursive lets into recursive lets"

This (temporary) reverts commit 3e80c2b40213bebe302b1bd239af48b33f1b30ef.

Fixes #23550

- - - - -
c59fbb0b by Torsten Schmits at 2023-06-26T19:34:20+02:00
Propagate breakpoint information when inlining across modules

Tracking ticket: #23394

MR: !10448

* Add constructor `IfaceBreakpoint` to `IfaceTickish`
* Store breakpoint data in interface files
* Store `BreakArray` for the breakpoint's module, not the current module, in BCOs
* Store module name in BCOs instead of `Unique`, since the `Unique` from an `Iface` doesn't match the modules in GHCi's
  state
* Allocate module name in `ModBreaks`, like `BreakArray`
* Lookup breakpoint by module name in GHCi
* Skip creating breakpoint instructions when no `ModBreaks` are available, rather than injecting `ModBreaks` in the
  linker when breakpoints are enabled, and panicking when `ModBreaks` is missing

- - - - -
6f904808 by Greg Steuck at 2023-06-27T16:53:07-04:00
Remove undefined FP_PROG_LD_BUILD_ID from configure.ac's

- - - - -
e89aa072 by Andrei Borzenkov at 2023-06-27T16:53:44-04:00
Remove arity inference in type declarations (#23514)

Arity inference in type declarations was introduced
as a workaround for the lack of @k-binders.

They were added in 4aea0a72040, so I simplified all
of this by simply removing arity inference altogether.

This is part of GHC Proposal #425 "Invisible binders in type
declarations".

- - - - -
459dee1b by Torsten Schmits at 2023-06-27T16:54:20-04:00
Relax defaulting of RuntimeRep/Levity when printing

Fixes #16468

MR: !10702

Only default RuntimeRep to LiftedRep when variables are bound by the toplevel forall

- - - - -
151f8f18 by Torsten Schmits at 2023-06-27T16:54:57-04:00
Remove duplicate link label in linear types docs

- - - - -
ecdc4353 by Rodrigo Mesquita at 2023-06-28T12:24:57-04:00
Stop configuring unused Ld command in `settings`

GHC has no direct dependence on the linker. Rather, we depend upon the C
compiler for linking and an object-merging program (which is typically
`ld`) for production of GHCi objects and merging of C stubs into final
object files.

Despite this, for historical reasons we still recorded information about
the linker into `settings`. Remove these entries from `settings`,
`hadrian/cfg/system.config`, as well as the `configure` logic
responsible for this information.

Closes #23566.

- - - - -
bf9ec3e4 by Bryan Richter at 2023-06-28T12:25:33-04:00
Remove extraneous debug output

- - - - -
7eb68dd6 by Bryan Richter at 2023-06-28T12:25:33-04:00
Work with unset vars in -e mode

- - - - -
49c27936 by Bryan Richter at 2023-06-28T12:25:33-04:00
Pass positional arguments in their positions

By quoting $cmd, the default "bash -i" is a single argument to run, and
no file named "bash -i" actually exists to be run.

- - - - -
887dc4fc by Bryan Richter at 2023-06-28T12:25:33-04:00
Handle unset value in -e context

- - - - -
5ffc7d7b by Rodrigo Mesquita at 2023-06-28T21:07:36-04:00
Configure CPP into settings

There is a distinction to be made between the Haskell Preprocessor and
the C preprocessor. The former is used to preprocess Haskell files,
while the latter is used in C preprocessing such as Cmm files.

In practice, they are both the same program (usually the C compiler) but
invoked with different flags.

Previously we would, at configure time, configure the haskell
preprocessor and save the configuration in the settings file, but,
instead of doing the same for CPP, we had hardcoded in GHC that the CPP
program was either `cc -E` or `cpp`.

This commit fixes that asymmetry by also configuring CPP at configure
time, and tries to make more explicit the difference between HsCpp and
Cpp (see Note [Preprocessing invocations]).

Note that we don't use the standard CPP and CPPFLAGS to configure Cpp,
but instead use the non-standard --with-cpp and --with-cpp-flags.
The reason is that autoconf sets CPP to "$CC -E", whereas we expect the
CPP command to be configured as a standalone executable rather than a
command. These are symmetrical with --with-hs-cpp and
--with-hs-cpp-flags.

Cleanup: Hadrian no longer needs to pass the CPP configuration for CPP
         to be C99 compatible through -optP, since we now configure that
         into settings.

Closes #23422

- - - - -
5efa9ca5 by Ben Gamari at 2023-06-28T21:08:13-04:00
hadrian: Always canonicalize topDirectory

Hadrian's `topDirectory` is intended to provide an absolute path to the
root of the GHC tree. However, if the tree is reached via a symlink this

One question here is whether the `canonicalizePath` call is expensive
enough to warrant caching. In a quick microbenchmark I observed that
`canonicalizePath "."` takes around 10us per call; this seems
sufficiently low not to worry.

Alternatively, another approach here would have been to rather move the
canonicalization into `m4/fp_find_root.m4`. This would have avoided
repeated canonicalization but sadly path canonicalization is a hard
problem in POSIX shell.

Addresses #22451.

- - - - -
b3e1436f by aadaa_fgtaa at 2023-06-28T21:08:53-04:00
Optimise ELF linker (#23464)

- cache last elements of `relTable`, `relaTable` and `symbolTables` in `ocInit_ELF`
- cache shndx table in ObjectCode
- run `checkProddableBlock` only with debug rts

- - - - -
30525b00 by Ben Gamari at 2023-06-28T21:09:30-04:00
compiler: Introduce MO_{ACQUIRE,RELEASE}_FENCE

- - - - -
b787e259 by Ben Gamari at 2023-06-28T21:09:30-04:00
compiler: Drop MO_WriteBarrier

rts: Drop write_barrier

- - - - -
7550b4a5 by Ben Gamari at 2023-06-28T21:09:30-04:00
rts: Drop load_store_barrier()

This is no longer used.

- - - - -
d5f2875e by Ben Gamari at 2023-06-28T21:09:31-04:00
rts: Drop last instances of prim_{write,read}_barrier

- - - - -
965ac2ba by Ben Gamari at 2023-06-28T21:09:31-04:00
rts: Eliminate remaining uses of load_load_barrier

- - - - -
0fc5cb97 by Sven Tennie at 2023-06-28T21:09:31-04:00
compiler: Drop MO_ReadBarrier

- - - - -
7a7d326c by Ben Gamari at 2023-06-28T21:09:31-04:00
rts: Drop load_load_barrier

This is no longer used.

- - - - -
9f63da66 by Sven Tennie at 2023-06-28T21:09:31-04:00
Delete write_barrier function

- - - - -
bb0ed354 by Ben Gamari at 2023-06-28T21:09:31-04:00
rts: Make collectFreshWeakPtrs definition a prototype

x86-64/Darwin's toolchain inexplicably warns that collectFreshWeakPtrs
needs to be a prototype.

- - - - -
ef81a1eb by Sven Tennie at 2023-06-28T21:10:08-04:00
Fix number of free double regs

D1..D4 are defined for aarch64 and thus not free.

- - - - -
c335fb7c by Ryan Scott at 2023-06-28T21:10:44-04:00
Fix typechecking of promoted empty lists

The `'[]` case in `tc_infer_hs_type` is smart enough to handle arity-0 uses of
`'[]` (see the newly added `T23543` test case for an example), but the `'[]`
case in `tc_hs_type` was not. We fix this by changing the `tc_hs_type` case to
invoke `tc_infer_hs_type`, as prescribed in `Note [Future-proofing the type
checker]`.

There are some benign changes to test cases' expected output due to the new
code path using `forall a. [a]` as the kind of `'[]` rather than `[k]`.

Fixes #23543.

- - - - -
fcf310e7 by Rodrigo Mesquita at 2023-06-28T21:11:21-04:00
Configure MergeObjs supports response files rather than Ld

The previous configuration script to test whether Ld supported response
files was
* Incorrect (see #23542)
* Used, in practice, to check if the *merge objects tool* supported
  response files.

This commit modifies the macro to run the merge objects tool (rather
than Ld), using a response file, and checking the result with $NM

Fixes #23542

- - - - -
78b2f3cc by Sylvain Henry at 2023-06-28T21:12:02-04:00
JS: fix JS stack printing (#23565)

- - - - -
9f01d14b by Matthew Pickering at 2023-06-29T04:13:41-04:00
Add -fpolymorphic-specialisation flag (off by default at all optimisation levels)

Polymorphic specialisation has led to a number of hard to diagnose
incorrect runtime result bugs (see #23469, #23109, #21229, #23445) so
this commit introduces a flag `-fpolymorhphic-specialisation` which
allows users to turn on this experimental optimisation if they are
willing to buy into things going very wrong.

Ticket #23469

- - - - -
b1e611d5 by Ben Gamari at 2023-06-29T04:14:17-04:00
Rip out runtime linker/compiler checks

We used to choose flags to pass to the toolchain at runtime based on the
platform running GHC, and in this commit we drop all of those runtime
linker checks

Ultimately, this represents a change in policy: We no longer adapt at
runtime to the toolchain being used, but rather make final decisions
about the toolchain used at /configure time/
(we have deleted Note [Run-time linker info] altogether!).

This works towards the goal of having all toolchain configuration logic
living in the same place, which facilities the work towards a
runtime-retargetable GHC (see #19877).

As of this commit, the runtime linker/compiler logic was moved to
autoconf, but soon it, and the rest of the existing toolchain
configuration logic, will live in the standalone ghc-toolchain program
(see !9263)

In particular, what used to be done at runtime is now as follows:
* The flags -Wl,--no-as-needed for needed shared libs are configured
  into settings
* The flag -fstack-check is configured into settings
* The check for broken tables-next-to-code was outdated
* We use the configured c compiler by default as the assembler program
* We drop `asmOpts` because we already configure -Qunused-arguments flag
  into settings (see !10589)

Fixes #23562

Co-author: Rodrigo Mesquita (@alt-romes)

- - - - -
8b35e8ca by Ben Gamari at 2023-06-29T18:46:12-04:00
Define FFI_GO_CLOSURES

The libffi shipped with Apple's XCode toolchain does not contain a
definition of the FFI_GO_CLOSURES macro, despite containing references
to said macro. Work around this by defining the macro, following the
model of a similar workaround in OpenJDK [1].

[1] https://github.com/openjdk/jdk17u-dev/pull/741/files

- - - - -
d7ef1704 by Ben Gamari at 2023-06-29T18:46:12-04:00
base: Fix incorrect CPP guard

This was guarded on `darwin_HOST_OS` instead of `defined(darwin_HOST_OS)`.

- - - - -
7c7d1f66 by Ben Gamari at 2023-06-29T18:46:48-04:00
rts/Trace: Ensure that debugTrace arguments are used

As debugTrace is a macro we must take care to ensure that
the fact is clear to the compiler lest we see warnings.

- - - - -
cb92051e by Ben Gamari at 2023-06-29T18:46:48-04:00
rts: Various warnings fixes

- - - - -
dec81dd1 by Ben Gamari at 2023-06-29T18:46:48-04:00
hadrian: Ignore warnings in unix and semaphore-compat

- - - - -
d7f6448a by Matthew Pickering at 2023-06-30T12:38:43-04:00
hadrian: Fix dependencies of docs:* rule

For the docs:* rule we need to actually build the package rather than
just the haddocks for the dependent packages. Therefore we depend on the
.conf files of the packages we are trying to build documentation for as
well as the .haddock files.

Fixes #23472

- - - - -
cec90389 by sheaf at 2023-06-30T12:39:27-04:00
Add tests for #22106

Fixes #22106

- - - - -
083794b1 by Torsten Schmits at 2023-07-03T03:27:27-04:00
Add -fbreak-points to control breakpoint insertion

Rather than statically enabling breakpoints only for the interpreter,
this adds a new flag.

Tracking ticket: #23057

MR: !10466

- - - - -
fd8c5769 by Ben Gamari at 2023-07-03T03:28:04-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. This is a bit subtle
as we must handle the case of a small allocation request filling the
accumulator block, as well as large requests.

Fixes #23400.

- - - - -
98185d52 by Ben Gamari at 2023-07-03T03:28:05-04:00
testsuite: Add test for #23400

- - - - -
4aac0540 by Ben Gamari at 2023-07-03T03:28:42-04:00
ghc-heap: Support for BLOCKING_QUEUE closures

- - - - -
03f941f4 by Ben Bellick at 2023-07-03T03:29:29-04:00
Add some structured diagnostics in Tc/Validity.hs

This addresses the work of ticket #20118
Created the following constructors for TcRnMessage
 - TcRnInaccessibleCoAxBranch
 - TcRnPatersonCondFailure

- - - - -
6074cc3c by Moisés Ackerman at 2023-07-03T03:30:13-04:00
Add failing test case for #23492

- - - - -
356a2692 by Moisés Ackerman at 2023-07-03T03:30:13-04:00
Use generated src span for catch-all case of record selector functions

This fixes #23492. The problem was that we used the real source span
of the field declaration for the generated catch-all case in the
selector function, in particular in the generated call to
`recSelError`, which meant it was included in the HIE output. Using
`generatedSrcSpan` instead means that it is not included.

- - - - -
3efe7f39 by Moisés Ackerman at 2023-07-03T03:30:13-04:00
Introduce genLHsApp and genLHsLit helpers in GHC.Rename.Utils

- - - - -
dd782343 by Moisés Ackerman at 2023-07-03T03:30:13-04:00
Construct catch-all default case using helpers

GHC.Rename.Utils concrete helpers instead of wrapGenSpan + HS AST constructors

- - - - -
0e09c38e by Ryan Hendrickson at 2023-07-03T03:30:56-04:00
Add regression test for #23549

- - - - -
32741743 by Alexis King at 2023-07-03T03:31:36-04:00
perf tests: Increase default stack size for MultiLayerModules

An unhelpfully small stack size appears to have been the real culprit
behind the metric fluctuations in #19293. Debugging metric decreases
triggered by !10729 helped to finally identify the problem.

Metric Decrease:
    MultiLayerModules
    MultiLayerModulesTH_Make
    T13701
    T14697

- - - - -
82ac6bf1 by Bryan Richter at 2023-07-03T03:32:15-04:00
Add missing void prototypes to rts functions

See #23561.

- - - - -
6078b429 by Ben Gamari at 2023-07-03T03:32:51-04:00
gitlab-ci: Refactor compilation of gen_ci

Flakify and document it, making it far less sensitive to the build
environment.

- - - - -
aa2db0ae by Ben Gamari at 2023-07-03T03:33:29-04:00
testsuite: Update documentation
- - - - -
924a2362 by Gregory Gerasev at 2023-07-03T03:34:10-04:00
Better error for data deriving of type synonym/family. Closes #23522

- - - - -
4457da2a by Dave Barton at 2023-07-03T03:34:51-04:00
Fix some broken links and typos

- - - - -
de5830d0 by Ben Gamari at 2023-07-04T22:03:59-04:00
configure: Rip out Solaris dyld check

Solaris 11 was released over a decade ago and, moreover, I doubt we have
any Solaris users

- - - - -
59c5fe1d by doyougnu at 2023-07-04T22:04:56-04:00
CI: add JS release and debug builds, regen CI jobs

- - - - -
679bbc97 by Vladislav Zavialov at 2023-07-04T22:05:32-04:00
testsuite: Do not require CUSKs

Numerous tests make use of CUSKs (complete user-supplied kinds),
a legacy feature scheduled for deprecation. In order to proceed
with the said deprecation, the tests have been updated to use SAKS
instead (standalone kind signatures).

This also allows us to remove the Haskell2010 language pragmas that
were added in 115cd3c85a8 to work around the lack of CUSKs in GHC2021.

- - - - -
945d3599 by Ben Gamari at 2023-07-04T22:06:08-04:00
gitlab: Drop backport-for-8.8 MR template

Its usefulness has long passed.
- - - - -
66c721d3 by Alan Zimmerman at 2023-07-04T22:06:44-04:00
EPA: Simplify GHC/Parser.y comb2

Use the HasLoc instance from Ast.hs to allow comb2 to work with
anything with a SrcSpan

This gets rid of the custom comb2A, comb2Al, comb2N functions, and
removes various reLoc calls.

- - - - -
2be99b7e by Matthew Pickering at 2023-07-04T22:07:21-04:00
Fix deprecation warning when deprecated identifier is from another module

A stray 'Just' was being printed in the deprecation message.

Fixes #23573

- - - - -
46c9bcd6 by Ben Gamari at 2023-07-04T22:07:58-04:00
rts: Don't rely on initializers for sigaction_t

As noted in #23577, CentOS's ancient toolchain throws spurious
missing-field-initializer warnings.

- - - - -
ec55035f by Ben Gamari at 2023-07-04T22:07:58-04:00
hadrian: Don't treat -Winline warnings as fatal

Such warnings are highly dependent upon the toolchain, platform, and
build configuration. It's simply too fragile to rely on these.

- - - - -
3a09b789 by Ben Gamari at 2023-07-04T22:07:58-04:00
hadrian: Only pass -Wno-nonportable-include-path on Darwin

This flag, which was introduced due to #17798, is only understood by
Clang and consequently throws warnings on platforms using gcc. Sadly,
there is no good way to treat such warnings as non-fatal with `-Werror`
so for now we simply make this flag specific to platforms known to use
Clang and case-insensitive filesystems (Darwin and Windows).

See #23577.

- - - - -
4af7eac2 by Mario Blažević at 2023-07-04T22:08:38-04:00
Fixed ticket #23571, TH.Ppr.pprLit hanging on large numeric literals

- - - - -
2304c697 by Ben Gamari at 2023-07-04T22:09:15-04:00
compiler: Make OccSet opaque

- - - - -
cf735db8 by Andrei Borzenkov at 2023-07-04T22:09:51-04:00
Add Note about why we need forall in Code to be on the right

- - - - -
fb140f82 by Hécate Moonlight at 2023-07-04T22:10:34-04:00
Relax the constraint about the foreign function's calling convention of FinalizerPtr to capi as well as ccall.
- - - - -
9ce44336 by meooow25 at 2023-07-05T11:42:37-04:00
Improve the situation with the stimes cycle

Currently the Semigroup stimes cycle is resolved in GHC.Base by
importing stimes implementations from a hs-boot file. Resolve the cycle
using hs-boot files for required classes (Num, Integral) instead. Now
stimes can be defined directly in GHC.Base, making inlining and
specialization possible.

This leads to some new boot files for `GHC.Num` and `GHC.Real`, the
methods for those are only used to implement `stimes` so it doesn't
appear that these boot files will introduce any new performance traps.

Metric Decrease:
    T13386
    T8095
Metric Increase:
    T13253
    T13386
    T18698a
    T18698b
    T19695
    T8095

- - - - -
9edcb1fb by Jaro Reinders at 2023-07-05T11:43:24-04:00
Refactor Unique to be represented by Word64

In #22010 we established that Int was not always sufficient to store all
the uniques we generate during compilation on 32-bit platforms. This
commit addresses that problem by using Word64 instead of Int for
uniques.

The core of the change is in GHC.Core.Types.Unique and
GHC.Core.Types.Unique.Supply. However, the representation of uniques is
used in many other places, so those needed changes too. Additionally, the RTS
has been extended with an atomic_inc64 operation.

One major change from this commit is the introduction of the Word64Set and
Word64Map data types. These are adapted versions of IntSet and IntMap
from the containers package. These are planned to be upstreamed in the
future.

As a natural consequence of these changes, the compiler will be a bit
slower and take more space on 32-bit platforms. Our CI tests indicate
around a 5% residency increase.

Metric Increase:
    CoOpt_Read
    CoOpt_Singletons
    LargeRecord
    ManyAlternatives
    ManyConstructors
    MultiComponentModules
    MultiComponentModulesRecomp
    MultiLayerModulesTH_OneShot
    RecordUpdPerf
    T10421
    T10547
    T12150
    T12227
    T12234
    T12425
    T12707
    T13035
    T13056
    T13253
    T13253-spj
    T13379
    T13386
    T13719
    T14683
    T14697
    T14766
    T15164
    T15703
    T16577
    T16875
    T17516
    T18140
    T18223
    T18282
    T18304
    T18698a
    T18698b
    T18923
    T1969
    T19695
    T20049
    T21839c
    T3064
    T3294
    T4801
    T5030
    T5321FD
    T5321Fun
    T5631
    T5642
    T5837
    T6048
    T783
    T8095
    T9020
    T9198
    T9233
    T9630
    T9675
    T9872a
    T9872b
    T9872b_defer
    T9872c
    T9872d
    T9961
    TcPlugin_RewritePerf
    UniqLoop
    WWRec
    hard_hole_fits

- - - - -
6b9db7d4 by Brandon Chinn at 2023-07-05T11:44:03-04:00
Fix docs for __GLASGOW_HASKELL_FULL_VERSION__ macro
- - - - -
40f4ef7c by Torsten Schmits at 2023-07-05T18:06:19-04:00
Substitute free variables captured by breakpoints in SpecConstr

Fixes #23267

- - - - -
2b55cb5f by sheaf at 2023-07-05T18:07:07-04:00
Reinstate untouchable variable error messages

This extra bit of information was accidentally being discarded after
a refactoring of the way we reported problems when unifying a type
variable with another type. This patch rectifies that.

- - - - -
53ed21c5 by Rodrigo Mesquita at 2023-07-05T18:07:47-04:00
configure: Drop Clang command from settings

Due to 01542cb7227614a93508b97ecad5b16dddeb6486 we no longer use the
`runClang` function, and no longer need to configure into settings the
Clang command. We used to determine options at runtime to pass clang when
it was used as an assembler, but now that we configure at configure time
we no longer need to.

- - - - -
6fdcf969 by Torsten Schmits at 2023-07-06T12:12:09-04:00
Filter out nontrivial substituted expressions in substTickish

Fixes #23272

- - - - -
41968fd6 by Sylvain Henry at 2023-07-06T12:13:02-04:00
JS: testsuite: use req_c predicate instead of js_broken

- - - - -
74a4dd2e by Sylvain Henry at 2023-07-06T12:13:02-04:00
JS: implement some file primitives (lstat,rmdir) (#22374)

- Implement lstat and rmdir.
- Implement base_c_s_is* functions (testing a file type)
- Enable passing tests

- - - - -
7e759914 by Sylvain Henry at 2023-07-07T02:39:38-04:00
JS: cleanup utils (#23314)

- Removed unused code
- Don't export unused functions
- Move toTypeList to Closure module

- - - - -
f617655c by Sylvain Henry at 2023-07-07T02:39:38-04:00
JS: rename VarType/Vt into JSRep

- - - - -
19216ca5 by Sylvain Henry at 2023-07-07T02:39:38-04:00
JS: remove custom PrimRep conversion (#23314)

We use the usual conversion to PrimRep and then we convert these
PrimReps to JSReps.

- - - - -
d3de8668 by Sylvain Henry at 2023-07-07T02:39:38-04:00
JS: don't use isRuntimeRepKindedTy in JS FFI

- - - - -
8d1b75cb by Matthew Pickering at 2023-07-07T02:40:15-04:00
ghcup-metadata: Also updates ghcup-nightlies-0.0.7.yaml file

Fixes #23600

- - - - -
e524fa7f by Matthew Pickering at 2023-07-07T02:40:15-04:00
ghcup-metadata: Use dynamically linked alpine bindists

In theory these will work much better on alpine to allow people to build
statically linked applications there. We don't need to distribute a
statically linked application ourselves in order to allow that.

Fixes #23602

- - - - -
b9e7beb9 by Ben Gamari at 2023-07-07T11:32:22-04:00
Drop circle-ci-job.sh

- - - - -
9955eead by Ben Gamari at 2023-07-07T11:32:22-04:00
testsuite: Allow preservation of unexpected output

Here we introduce a new flag to the testsuite driver,
--unexpected-output-dir=<dir>, which allows the user to ask
the driver to preserve unexpected output from tests. The intent is for
this to be used in CI to allow users to more easily fix unexpected
platform-dependent output.

- - - - -
48f80968 by Ben Gamari at 2023-07-07T11:32:22-04:00
gitlab-ci: Preserve unexpected output

Here we enable use of the testsuite driver's `--unexpected-output-dir`
flag by CI, preserving the result as an artifact for use by users.

- - - - -
76983a0d by Matthew Pickering at 2023-07-07T11:32:58-04:00
driver: Fix -S with .cmm files

There was an oversight in the driver which assumed that you would always
produce a `.o` file when compiling a .cmm file.

Fixes #23610

- - - - -
6df15e93 by Mike Pilgrem at 2023-07-07T11:33:40-04:00
Update Hadrian's stack.yaml
- - - - -
1dff43cf by Ben Gamari at 2023-07-08T05:05:37-04:00
compiler: Rework ShowSome

Previously the field used to filter the sub-declarations to show
was rather ad-hoc and was only able to show at most one sub-declaration.

- - - - -
8165404b by Ben Gamari at 2023-07-08T05:05:37-04:00
testsuite: Add test to catch changes in core libraries

This adds testing infrastructure to ensure that changes in core
libraries (e.g. `base` and `ghc-prim`) are caught in CI.

- - - - -
ec1c32e2 by Melanie Phoenix at 2023-07-08T05:06:14-04:00
Deprecate Data.List.NonEmpty.unzip

- - - - -
5d2442b8 by Ben Gamari at 2023-07-08T05:06:51-04:00
Drop latent mentions of -split-objs

Closes #21134.

- - - - -
a9bc20cb by Oleg Grenrus at 2023-07-08T05:07:31-04:00
Add warn_and_run test kind

This is a compile_and_run variant which also captures the GHC's
stderr. The warn_and_run name is best I can come up with,
as compile_and_run is taken.

This is useful specifically for testing warnings.  We want to test that
when warning triggers, and it's not a false positive, i.e. that the
runtime behaviour is indeed "incorrect".

As an example a single test is altered to use warn_and_run

- - - - -
c7026962 by Ben Gamari at 2023-07-08T05:08:11-04:00
configure: Don't use ld.gold on i386

ld.gold appears to produce invalid static constructor tables on i386.
While ideally we would add an autoconf check to check for this
brokenness, sadly such a check isn't easy to compose. Instead to
summarily reject such linkers on i386.

Somewhat hackily closes #23579.

- - - - -
054261dd by Andrew Lelechenko at 2023-07-08T19:32:47-04:00
Add since annotations for Data.Foldable1

- - - - -
550af505 by Sylvain Henry at 2023-07-08T19:33:28-04:00
JS: support -this-unit-id for programs in the linker (#23613)

- - - - -
d284470a by Andrew Lelechenko at 2023-07-08T19:34:08-04:00
Bump text submodule

- - - - -
8e11630e by jade at 2023-07-10T16:58:40-04:00
Add a hint to enable ExplicitNamespaces for type operator imports (Fixes/Enhances #20007)

As suggested in #20007 and implemented in !8895, trying to import type operators
will suggest a fix to use the 'type' keyword, without considering whether
ExplicitNamespaces is enabled. This patch will query whether ExplicitNamespaces
is enabled and add a hint to suggest enabling ExplicitNamespaces if it isn't enabled,
alongside the suggestion of adding the 'type' keyword.

- - - - -
61b1932e by sheaf at 2023-07-10T16:59:26-04:00
tyThingLocalGREs: include all DataCons for RecFlds

The GREInfo for a record field should include the collection of all
the data constructors of the parent TyCon that have this record field.
This information was being incorrectly computed in the tyThingLocalGREs
function for a DataCon, as we were not taking into account other
DataCons with the same parent TyCon.

Fixes #23546

- - - - -
e6627cbd by Alan Zimmerman at 2023-07-10T17:00:05-04:00
EPA: Simplify GHC/Parser.y comb3

A follow up to !10743

- - - - -
ee20da34 by Andrew Lelechenko at 2023-07-10T17:01:01-04:00
Document that compareByteArrays# is available since ghc-prim-0.5.2.0

- - - - -
4926af7b by Matthew Pickering at 2023-07-10T17:01:38-04:00
Revert "Bump text submodule"

This reverts commit d284470a77042e6bc17bdb0ab0d740011196958a.

This commit requires that we bootstrap with ghc-9.4, which we do not
require until #23195 has been completed.

Subsequently this has broken nighty jobs such as the rocky8 job which in
turn has broken nightly releases.

- - - - -
d1c92bf3 by Ben Gamari at 2023-07-11T08:07:02-04:00
compiler: Fingerprint more code generation flags

Previously our recompilation check was quite inconsistent in its
coverage of non-optimisation code generation flags. Specifically, we
failed to account for most flags that would affect the behavior of
generated code in ways that might affect the result of a program's
execution (e.g. `-feager-blackholing`, `-fstrict-dicts`)

Closes #23369.

- - - - -
eb623149 by Ben Gamari at 2023-07-11T08:07:02-04:00
compiler: Record original thunk info tables on stack

Here we introduce a new code generation option, `-forig-thunk-info`,
which ensures that an `stg_orig_thunk_info` frame is pushed before every
update frame. This can be invaluable when debugging thunk cycles and
similar.

See Note [Original thunk info table frames] for details.

Closes #23255.

- - - - -
4731f44e by Jaro Reinders at 2023-07-11T08:07:40-04:00
Fix wrong MIN_VERSION_GLASGOW_HASKELL macros

I forgot to change these after rebasing.

- - - - -
dd38aca9 by Andreas Schwab at 2023-07-11T13:55:56+00:00
Hadrian: enable GHCi support on riscv64

- - - - -
09a5c6cc by Josh Meredith at 2023-07-12T11:25:13-04:00
JavaScript: support unicode code points > 2^16 in toJSString using String.fromCodePoint (#23628)

- - - - -
29fbbd4e by Matthew Pickering at 2023-07-12T11:25:49-04:00
Remove references to make build system in mk/build.mk

Fixes #23636

- - - - -
630e3026 by sheaf at 2023-07-12T11:26:43-04:00
Valid hole fits: don't panic on a Given

The function GHC.Tc.Errors.validHoleFits would end up panicking when
encountering a Given constraint. To fix this, it suffices to filter out
the Givens before continuing.

Fixes #22684

- - - - -
c39f279b by Matthew Pickering at 2023-07-12T23:18:38-04:00
Use deb10 for i386 bindists

deb9 is now EOL so it's time to upgrade the i386 bindist to use deb10

Fixes #23585

- - - - -
bf9b9de0 by Krzysztof Gogolewski at 2023-07-12T23:19:15-04:00
Fix #23567, a specializer bug

Found by Simon in https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507834

The testcase isn't ideal because it doesn't detect the bug in master,
unless doNotUnbox is removed as in
https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507692.
But I have confirmed that with that modification, it fails before
and passes afterwards.

- - - - -
84c1a4a2 by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00
Comments

- - - - -
b2846cb5 by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00
updates to comments

- - - - -
2af23f0e by Bartłomiej Cieślar at 2023-07-12T23:20:08-04:00
changes

- - - - -
6143838a by sheaf at 2023-07-13T08:02:17-04:00
Fix deprecation of record fields

Commit 3f374399 inadvertently broke the deprecation/warning mechanism
for record fields due to its introduction of record field namespaces.

This patch ensures that, when a top-level deprecation is applied to
an identifier, it applies to all the record fields as well.
This is achieved by refactoring GHC.Rename.Env.lookupLocalTcNames, and
GHC.Rename.Env.lookupBindGroupOcc, to not look up a fixed number of
NameSpaces but to look up all NameSpaces and filter out the irrelevant
ones.

- - - - -
6fd8f566 by sheaf at 2023-07-13T08:02:17-04:00
Introduce greInfo, greParent

These are simple helper functions that wrap the internal
field names gre_info, gre_par.

- - - - -
7f0a86ed by sheaf at 2023-07-13T08:02:17-04:00
Refactor lookupGRE_... functions

This commit consolidates all the logic for looking up something in
the Global Reader Environment into the single function lookupGRE.
This allows us to declaratively specify all the different modes of
looking up in the GlobalRdrEnv, and avoids manually passing around
filtering functions as was the case in e.g. the function
GHC.Rename.Env.lookupSubBndrOcc_helper.

-------------------------
Metric Decrease:
    T8095
-------------------------
-------------------------
Metric Increase:
    T8095
-------------------------

- - - - -
5e951395 by Rodrigo Mesquita at 2023-07-13T08:02:54-04:00
configure: Drop DllWrap command

We used to configure into settings a DllWrap command for windows
builds and distributions, however, we no longer do, and dllwrap is
effectively unused.

This simplification is motivated in part by the larger
toolchain-selection project (#19877, !9263)

- - - - -
e10556b6 by Teo Camarasu at 2023-07-14T16:28:46-04:00
base: fix haddock syntax in GHC.Profiling

- - - - -
0f3fda81 by Matthew Pickering at 2023-07-14T16:29:23-04:00
Revert "CI: add JS release and debug builds, regen CI jobs"

This reverts commit 59c5fe1d4b624423b1c37891710f2757bb58d6af.

This commit added two duplicate jobs on all validate pipelines, so we
are reverting for now whilst we work out what the best way forward is.

Ticket #23618

- - - - -
54bca324 by Alan Zimmerman at 2023-07-15T03:23:26-04:00
EPA: Simplify GHC/Parser.y sLL

Follow up to !10743

- - - - -
c8863828 by sheaf at 2023-07-15T03:24:06-04:00
Configure: canonicalise PythonCmd on Windows

This change makes PythonCmd resolve to a canonical absolute path on
Windows, which prevents HLS getting confused (now that we have a
build-time dependency on python).

fixes #23652

- - - - -
ca1e636a by Rodrigo Mesquita at 2023-07-15T03:24:42-04:00
Improve Note [Binder-swap during float-out]

- - - - -
cf86f3ec by Matthew Craven at 2023-07-16T01:42:09+02:00
Equality of forall-types is visibility aware

This patch finally (I hope) nails the question of whether
   (forall a. ty) and (forall a -> ty)
are `eqType`: they aren't!

There is a long discussion in #22762, plus useful Notes:

* Note [ForAllTy and type equality] in GHC.Core.TyCo.Compare
* Note [Comparing visiblities] in GHC.Core.TyCo.Compare
* Note [ForAllCo] in GHC.Core.TyCo.Rep

It also establishes a helpful new invariant for ForAllCo,
and ForAllTy, when the bound variable is a CoVar:in that
case the visibility must be coreTyLamForAllTyFlag.

All this is well documented in revised Notes.

- - - - -
7f13acbf by Vladislav Zavialov at 2023-07-16T01:56:27-04:00
List and Tuple<n>: update documentation

Add the missing changelog.md entries and @since-annotations.

- - - - -
2afbddb0 by Andrei Borzenkov at 2023-07-16T10:21:24+04:00
Type patterns (#22478, #18986)

Improved name resolution and type checking of type patterns in constructors:

1. HsTyPat: a new dedicated data type that represents type patterns in
   HsConPatDetails instead of reusing HsPatSigType

2. rnHsTyPat: a new function that renames a type
   pattern and collects its binders into three groups:
    - explicitly bound type variables, excluding locally bound
      variables
    - implicitly bound type variables from kind signatures
      (only if ScopedTypeVariables are enabled)
    - named wildcards (only from kind signatures)
2a. rnHsPatSigTypeBindingVars: removed in favour of rnHsTyPat
2b. rnImplcitTvBndrs: removed because no longer needed

3. collect_pat: updated to collect type variable binders from type patterns
   (this means that types and terms use the same infrastructure to detect
   conflicting bindings, unused variables and name shadowing)
3a. CollVarTyVarBinders: a new CollectFlag constructor that enables
    collection of type variables

4. tcHsTyPat: a new function that typechecks type patterns, capable of
   handling polymorphic kinds.
   See Note [Type patterns: binders and unifiers]

Examples of code that is now accepted:

   f = \(P @a) -> \(P @a) -> ...  -- triggers -Wname-shadowing

   g :: forall a. Proxy a -> ...
   g (P @a) = ...                 -- also triggers -Wname-shadowing

   h (P @($(TH.varT (TH.mkName "t")))) = ...
                                  -- t is bound at splice time

   j (P @(a :: (x,x))) = ...      -- (x,x) is no longer rejected

   data T where
     MkT :: forall (f :: forall k. k -> Type).
       f Int -> f Maybe -> T
   k :: T -> ()
   k (MkT @f (x :: f Int) (y :: f Maybe)) = ()
                                  -- f :: forall k. k -> Type

Examples of code that is rejected with better error messages:

  f (Left @a @a _) = ...
  -- new message:
  --     • Conflicting definitions for ‘a’
  --       Bound at: Test.hs:1:11
  --                 Test.hs:1:14

Examples of code that is now rejected:

  {-# OPTIONS_GHC -Werror=unused-matches #-}
  f (P @a) = ()
  -- Defined but not used: type variable ‘a’

- - - - -
eb1a6ab1 by sheaf at 2023-07-16T09:20:45-04:00
Don't use substTyUnchecked in newMetaTyVar

There were some comments that explained that we needed to use an
unchecked substitution function because of issue #12931, but that
has since been fixed, so we should be able to use substTy instead now.

- - - - -
c7bbad9a by sheaf at 2023-07-17T02:48:19-04:00
rnImports: var shouldn't import NoFldSelectors

In an import declaration such as

  import M ( var )

the import of the variable "var" should **not** bring into scope record
fields named "var" which are defined with NoFieldSelectors.
Doing so can cause spurious "unused import" warnings, as reported in
ticket #23557.

Fixes #23557

- - - - -
1af2e773 by sheaf at 2023-07-17T02:48:19-04:00
Suggest similar names in imports

This commit adds similar name suggestions when importing. For example

  module A where { spelling = 'o' }
  module B where { import B ( speling ) }

will give rise to the error message:

  Module ‘A’ does not export ‘speling’.
  Suggested fix: Perhaps use ‘spelling’

This also provides hints when users try to import record fields defined
with NoFieldSelectors.

- - - - -
654fdb98 by Alan Zimmerman at 2023-07-17T02:48:55-04:00
EPA: Store leading AnnSemi for decllist in al_rest

This simplifies the markAnnListA implementation in ExactPrint

- - - - -
22565506 by sheaf at 2023-07-17T21:12:59-04:00
base: add COMPLETE pragma to BufferCodec PatSyn

This implements CLC proposal #178, rectifying an oversight in the
implementation of CLC proposal #134 which could lead to spurious
pattern match warnings.

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

- - - - -
860f6269 by sheaf at 2023-07-17T21:13:00-04:00
exactprint: silence incomplete record update warnings

- - - - -
df706de3 by sheaf at 2023-07-17T21:13:00-04:00
Re-instate -Wincomplete-record-updates

Commit e74fc066 refactored the handling of record updates to use
the HsExpanded mechanism. This meant that the pattern matching inherent
to a record update was considered to be "generated code", and thus we
stopped emitting "incomplete record update" warnings entirely.

This commit changes the "data Origin = Source | Generated" datatype,
adding a field to the Generated constructor to indicate whether we
still want to perform pattern-match checking. We also have to do a bit
of plumbing with HsCase, to record that the HsCase arose from an
HsExpansion of a RecUpd, so that the error message continues to mention
record updates as opposed to a generic "incomplete pattern matches in case"
error.

Finally, this patch also changes the way we handle inaccessible code
warnings. Commit e74fc066 was also a regression in this regard, as we
were emitting "inaccessible code" warnings for case statements spuriously
generated when desugaring a record update (remember: the desugaring mechanism
happens before typechecking; it thus can't take into account e.g. GADT information
in order to decide which constructors to include in the RHS of the desugaring
of the record update).
We fix this by changing the mechanism through which we disable inaccessible
code warnings: we now check whether we are in generated code in
GHC.Tc.Utils.TcMType.newImplication in order to determine whether to
emit inaccessible code warnings.

Fixes #23520
Updates haddock submodule, to avoid incomplete record update warnings

- - - - -
1d05971e by sheaf at 2023-07-17T21:13:00-04:00
Propagate long-distance information in do-notation

The preceding commit re-enabled pattern-match checking inside record
updates. This revealed that #21360 was in fact NOT fixed by e74fc066.

This commit makes sure we correctly propagate long-distance information
in do blocks, e.g. in

```haskell
data T = A { fld :: Int } | B

f :: T -> Maybe T
f r = do
  a at A{} <- Just r
  Just $ case a of { A _ -> A 9 }
```

we need to propagate the fact that "a" is headed by the constructor "A"
to see that the case expression "case a of { A _ -> A 9 }" cannot fail.

Fixes #21360

- - - - -
bea0e323 by sheaf at 2023-07-17T21:13:00-04:00
Skip PMC for boring patterns

Some patterns introduce no new information to the pattern-match
checker (such as plain variable or wildcard patterns). We can thus
skip doing any pattern-match checking on them when the sole purpose
for doing so was introducing new long-distance information.

See Note [Boring patterns] in GHC.Hs.Pat.

Doing this avoids regressing in performance now that we do additional
pattern-match checking inside do notation.

- - - - -
ddcdd88c by Rodrigo Mesquita at 2023-07-17T21:13:36-04:00
Split GHC.Platform.ArchOS from ghc-boot into ghc-platform

Split off the `GHC.Platform.ArchOS` module from the `ghc-boot` package
into this reinstallable standalone package which abides by the PVP, in
part motivated by the ongoing work on `ghc-toolchain` towards runtime
retargetability.

- - - - -
b55a8ea7 by Sylvain Henry at 2023-07-17T21:14:27-04:00
JS: better implementation for plusWord64 (#23597)

- - - - -
889c2bbb by sheaf at 2023-07-18T06:37:32-04:00
Do primop rep-poly checks when instantiating

This patch changes how we perform representation-polymorphism checking
for primops (and other wired-in Ids such as coerce).
When instantiating the primop, we check whether each type variable
is required to instantiated to a concrete type, and if so we create a
new concrete metavariable (a ConcreteTv) instead of a simple MetaTv.
(A little subtlety is the need to apply the substitution obtained from
instantiating to the ConcreteTvOrigins, see
Note [substConcreteTvOrigin] in GHC.Tc.Utils.TcMType.)

This allows us to prevent representation-polymorphism in non-argument
position, as that is required for some of these primops.

We can also remove the logic in tcRemainingValArgs, except for
the part concerning representation-polymorphic unlifted newtypes.
The function has been renamed rejectRepPolyNewtypes; all it does now
is reject unsaturated occurrences of representation-polymorphic newtype
constructors when the representation of its argument isn't a concrete
RuntimeRep (i.e. still a PHASE 1 FixedRuntimeRep check).
The Note [Eta-expanding rep-poly unlifted newtypes] in GHC.Tc.Gen.Head
gives more explanation about a possible path to PHASE 2, which would be
in line with the treatment for primops taken in this patch.

We also update the Core Lint check to handle this new framework. This
means Core Lint now checks representation-polymorphism in continuation
position like needed for catch#.

Fixes #21906

-------------------------
Metric Increase:
    LargeRecord
-------------------------

- - - - -
00648e5d by Krzysztof Gogolewski at 2023-07-18T06:38:10-04:00
Core Lint: distinguish let and letrec in locations

Lint messages were saying "in the body of letrec" even for non-recursive
let.

I've also renamed BodyOfLetRec to BodyOfLet in stg, since there's no
separate letrec.

- - - - -
787bae96 by Krzysztof Gogolewski at 2023-07-18T06:38:50-04:00
Use extended literals when deriving Show

This implements GHC proposal
https://github.com/ghc-proposals/ghc-proposals/pull/596

Also add support for Int64# and Word64#; see testcase ShowPrim.

- - - - -
257f1567 by Jaro Reinders at 2023-07-18T06:39:29-04:00
Add StgFromCore and StgCodeGen linting

- - - - -
34d08a20 by Ben Gamari at 2023-07-19T03:33:22-04:00
Reg.Liveness: Strictness

- - - - -
c5deaa27 by Ben Gamari at 2023-07-19T03:33:22-04:00
Reg.Liveness: Don't repeatedly construct UniqSets

- - - - -
b947250b by Ben Gamari at 2023-07-19T03:33:22-04:00
compiler/Types: Ensure that fromList-type operations can fuse

In #20740 I noticed that mkUniqSet does not fuse. In practice, allowing
it to do so makes a considerable difference in allocations due to the
backend.

Metric Decrease:
    T12707
    T13379
    T3294
    T4801
    T5321FD
    T5321Fun
    T783

- - - - -
6c88c2ba by Sven Tennie at 2023-07-19T03:33:59-04:00
x86 Codegen: Implement MO_S_MulMayOflo for W16

- - - - -
5f1154e0 by Sven Tennie at 2023-07-19T03:33:59-04:00
x86 CodeGen: MO_S_MulMayOflo better error message for rep > W64

It's useful to see which value made the pattern match fail. (If it ever
occurs.)

- - - - -
e8c9a95f by Sven Tennie at 2023-07-19T03:33:59-04:00
x86 CodeGen: Implement MO_S_MulMayOflo for W8

This case wasn't handled before. But, the test-primops test suite showed
that it actually might appear.

- - - - -
a36f9dc9 by Sven Tennie at 2023-07-19T03:33:59-04:00
Add test for %mulmayoflo primop

The test expects a perfect implementation with no false positives.

- - - - -
38a36248 by Matthew Pickering at 2023-07-19T03:34:36-04:00
lint-ci-config: Generate jobs-metadata.json

We also now save the jobs-metadata.json and jobs.yaml file as artifacts
as:

* It might be useful for someone who is modifying CI to copy jobs.yaml
  if they are having trouble regenerating locally.
* jobs-metadata.json is very useful for downstream pipelines to work out
  the right job to download.

Fixes #23654

- - - - -
1535a671 by Vladislav Zavialov at 2023-07-19T03:35:12-04:00
Initialize 9.10.1-notes.rst

Create new release notes for the next GHC release (GHC 9.10)

- - - - -
3bd4d5b5 by sheaf at 2023-07-19T03:35:53-04:00
Prioritise Parent when looking up class sub-binder

When we look up children GlobalRdrElts of a given Parent, we sometimes
would rather prioritise those GlobalRdrElts which have the right Parent,
and sometimes prioritise those that have the right NameSpace:

  - in export lists, we should prioritise NameSpace
  - for class/instance binders, we should prioritise Parent

See Note [childGREPriority] in GHC.Types.Name.Reader.

fixes #23664

- - - - -
9c8fdda3 by Alan Zimmerman at 2023-07-19T03:36:29-04:00
EPA: Improve annotation management in getMonoBind

Ensure the LHsDecl for a FunBind has the correct leading comments and
trailing annotations.

See the added note for details.

- - - - -
ff884b77 by Matthew Pickering at 2023-07-19T11:42:02+01:00
Remove unused files in .gitlab

These were left over after 6078b429

- - - - -
29ef590c by Matthew Pickering at 2023-07-19T11:42:52+01:00
gen_ci: Add hie.yaml file

This allows you to load `gen_ci.hs` into HLS, and now it is a huge
module, that is quite useful.

- - - - -
808b55cf by Matthew Pickering at 2023-07-19T12:24:41+01:00
ci: Make "fast-ci" the default validate configuration

We are trying out a lighter weight validation pipeline where by default
we just test on 5 platforms:

* x86_64-deb10-slow-validate
* windows
* x86_64-fedora33-release
* aarch64-darwin
* aarch64-linux-deb10

In order to enable the "full" validation pipeline you can apply the
`full-ci` label which will enable all the validation pipelines.

All the validation jobs are still run on a marge batch.

The goal is to reduce the overall CI capacity so that pipelines start
faster for MRs and marge bot batches are faster.

Fixes #23694

- - - - -
0b23db03 by Alan Zimmerman at 2023-07-20T05:28:47-04:00
EPA: Simplify GHC/Parser.y sL1

This is the next patch in a series simplifying location management in
GHC/Parser.y

This one simplifies sL1, to use the HasLoc instances introduced in
!10743 (closed)

- - - - -
3ece9856 by Ben Gamari at 2023-07-21T07:30:45-04:00
nativeGen: Explicitly set flags of text sections on Windows

The binutils documentation (for COFF) claims,

> If no flags are specified, the default flags depend upon the section
> name. If the section name is not recognized, the default will be for the
> section to be loaded and writable.

We previously assumed that this would do the right thing for split
sections (e.g. a section named `.text$foo` would be correctly inferred
to be a text section). However, we have observed that this is not the
case (at least under the clang toolchain used on Windows): when
split-sections is enabled, text sections are treated by the assembler as
data (matching the "default" behavior specified by the documentation).

Avoid this by setting section flags explicitly. This should fix split
sections on Windows.

Fixes #22834.

- - - - -
db7f7240 by Ben Gamari at 2023-07-21T07:30:45-04:00
nativeGen: Set explicit section types on all platforms

- - - - -
b444c16f by Finley McIlwaine at 2023-07-21T07:31:28-04:00
Insert documentation into parsed signature modules

Causes haddock comments in signature modules to be properly
inserted into the AST (just as they are for regular modules)
if the `-haddock` flag is given.

Also adds a test that compares `-ddump-parsed-ast` output
for a signature module to prevent further regressions.

Fixes #23315

- - - - -
c30cea53 by Ben Gamari at 2023-07-21T23:23:49-04:00
primops: Introduce unsafeThawByteArray#

This addresses an odd asymmetry in the ByteArray# primops, which
previously provided unsafeFreezeByteArray# but no corresponding
thaw operation.

Closes #22710

- - - - -
87f9bd47 by Ben Gamari at 2023-07-21T23:23:49-04:00
testsuite: Elaborate in interface stability README

This discussion didn't make it into the original MR.

- - - - -
e4350b41 by Matthew Pickering at 2023-07-21T23:24:25-04:00
Allow users to override non-essential haddock options in a Flavour

We now supply the non-essential options to haddock using the `extraArgs`
field, which can be specified in a Flavour so that if an advanced user
wants to change how documentation is generated then they can use
something other than the `defaultHaddockExtraArgs`.

This does have the potential to regress some packaging if a user has
overridden `extraArgs` themselves, because now they also need to add
the haddock options to extraArgs. This can easily be done by appending
`defaultHaddockExtraArgs` to their extraArgs invocation but someone
might not notice this behaviour has changed.

In any case, I think passing the non-essential options in this manner is
the right thing to do and matches what we do for the "ghc" builder,
which by default doesn't pass any optmisation levels, and would likewise
be very bad if someone didn't pass suitable `-O` levels for builds.

Fixes #23625

- - - - -
fc186b0c by Ilias Tsitsimpis at 2023-07-21T23:25:03-04:00
ghc-prim: Link against libatomic

Commit b4d39adbb58 made 'hs_cmpxchg64()' available to all architectures.
Unfortunately this made GHC to fail to build on armel, since armel needs
libatomic to support atomic operations on 64-bit word sizes.

Configure libraries/ghc-prim/ghc-prim.cabal to link against libatomic,
the same way as we do in rts/rts.cabal.

- - - - -
4f5538a8 by Matthew Pickering at 2023-07-21T23:25:39-04:00
simplifier: Correct InScopeSet in rule matching

The in-scope set passedto the `exprIsLambda_maybe` call lacked all the
in-scope binders. @simonpj suggests this fix where we augment the
in-scope set with the free variables of expression which fixes this
failure mode in quite a direct way.

Fixes #23630

- - - - -
5ad8d597 by Krzysztof Gogolewski at 2023-07-21T23:26:17-04:00
Add a test for #23413

It was fixed by commit e1590ddc661d6: Add the SolverStage monad.

- - - - -
7e05f6df by sheaf at 2023-07-21T23:26:56-04:00
Finish migration of diagnostics in GHC.Tc.Validity

This patch finishes migrating the error messages in GHC.Tc.Validity
to use the new diagnostic infrastructure.

It also refactors the error message datatypes for class and family
instances, to common them up under a single datatype as much as possible.

- - - - -
4876fddc by Matthew Pickering at 2023-07-21T23:27:33-04:00
ci: Enable some more jobs to run in a marge batch

In !10907 I made the majority of jobs not run on a validate pipeline but
then forgot to renable a select few jobs on the marge batch MR.

- - - - -
026991d7 by Jens Petersen at 2023-07-21T23:28:13-04:00
user_guide/flags.py: python-3.12 no longer includes distutils

packaging.version seems able to handle this fine

- - - - -
b91bbc2b by Matthew Pickering at 2023-07-21T23:28:50-04:00
ci: Mention ~full-ci label in MR template

We mention that if you need a full validation pipeline then you can
apply the ~full-ci label to your MR in order to test against the full
validation pipeline (like we do for marge).

- - - - -
42b05e9b by sheaf at 2023-07-22T12:36:00-04: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

- - - - -
a72015d6 by sheaf at 2023-07-22T12:36:01-04:00
Mark plugins-external as broken on Windows

This test is broken on Windows, so we explicitly mark it as such now
that we stop skipping plugin tests on Windows.

- - - - -
cb9c93d7 by sheaf at 2023-07-22T12:36:01-04:00
Stop marking plugin tests as fragile on Windows

Now that b2bb3e62 has landed we are in a better situation with
regards to plugins on Windows, allowing us to unmark many plugin tests
as fragile.

Fixes #16405

- - - - -
a7349217 by Krzysztof Gogolewski at 2023-07-22T12:36:37-04:00
Misc cleanup

- Remove unused RDR names
- Fix typos in comments
- Deriving: simplify boxConTbl and remove unused litConTbl
- chmod -x GHC/Exts.hs, this seems accidental

- - - - -
33b6850a by Vladislav Zavialov at 2023-07-23T10:27:37-04:00
Visible forall in types of terms: Part 1 (#22326)

This patch implements part 1 of GHC Proposal #281,
introducing explicit `type` patterns and `type` arguments.

Summary of the changes:

1. New extension flag:
     RequiredTypeArguments

2. New user-facing syntax:
     `type p` patterns    (represented by EmbTyPat)
     `type e` expressions (represented by HsEmbTy)

3. Functions with required type arguments (visible forall)
   can now be defined and applied:
      idv :: forall a -> a -> a    -- signature   (relevant change: checkVdqOK in GHC/Tc/Validity.hs)
      idv (type a) (x :: a) = x    -- definition  (relevant change: tcPats in GHC/Tc/Gen/Pat.hs)
      x = idv (type Int) 42        -- usage       (relevant change: tcInstFun in GHC/Tc/Gen/App.hs)

4. template-haskell support:
      TH.TypeE corresponds to HsEmbTy
      TH.TypeP corresponds to EmbTyPat

5. Test cases and a new User's Guide section

Changes *not* included here are the t2t (term-to-type) transformation
and term variable capture; those belong to part 2.

- - - - -
73b5c7ce by sheaf at 2023-07-23T10:28:18-04:00
Add test for #22424

This is a simple Template Haskell test in which we refer to
record selectors by their exact Names, in two different ways.

Fixes #22424

- - - - -
83cbc672 by Ben Gamari at 2023-07-24T07:40:49+00:00
ghc-toolchain: Initial commit

- - - - -
31dcd26c by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00
ghc-toolchain: Toolchain Selection

This commit integrates ghc-toolchain, the brand new way of configuring
toolchains for GHC, with the Hadrian build system, with configure, and
extends and improves the first iteration of ghc-toolchain.

The general overview is

* We introduce a program invoked `ghc-toolchain --triple=...` which, when run,
  produces a file with a `Target`. A `GHC.Toolchain.Target.Target`
  describes the properties of a target and the toolchain (executables
  and configured flags) to produce code for that target

* Hadrian was modified to read Target files, and will both
  * Invoke the toolchain configured in the Target file as needed
  * Produce a `settings` file for GHC based on the Target file for that stage

* `./configure` will invoke ghc-toolchain to generate target files, but
  it will also generate target files based on the flags configure itself
  configured (through `.in` files that are substituted)

  * By default, the Targets generated by configure are still (for now) the ones used by Hadrian

  * But we additionally validate the Target files generated by
    ghc-toolchain against the ones generated by configure, to get a head
    start on catching configuration bugs before we transition
    completely.

  * When we make that transition, we will want to drop a lot of the
    toolchain configuration logic from configure, but keep it otherwise.

* For each compiler stage we should have 1 target file (up to a stage compiler we can't run in our machine)
  * We just have a HOST target file, which we use as the target for stage0
  * And a TARGET target file, which we use for stage1 (and later stages, if not cross compiling)
  * Note there is no BUILD target file, because we only support cross compilation where BUILD=HOST
  * (for more details on cross-compilation see discussion on !9263)

See also
* Note [How we configure the bundled windows toolchain]
* Note [ghc-toolchain consistency checking]
* Note [ghc-toolchain overview]

Ticket: #19877
MR: !9263

- - - - -
a732b6d3 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00
Add flag to enable/disable ghc-toolchain based configurations

This flag is disabled by default, and we'll use the
configure-generated-toolchains by default until we remove the toolchain
configuration logic from configure.

- - - - -
61eea240 by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00
Split ghc-toolchain executable to new packge

In light of #23690, we split the ghc-toolchain executable out of the
library package to be able to ship it in the bindist using Hadrian.

Ideally, we eventually revert this commit.

- - - - -
38e795ff by Rodrigo Mesquita at 2023-07-24T07:40:49+00:00
Ship ghc-toolchain in the bindist

Add the ghc-toolchain binary to the binary distribution we ship to
users, and teach the bindist configure to use the existing ghc-toolchain.

- - - - -
32cae784 by Matthew Craven at 2023-07-24T16:48:24-04:00
Kill off gen_bytearray_addr_access_ops.py

The relevant primop descriptions are now
generated directly by genprimopcode.

This makes progress toward fixing #23490, but it is not
a complete fix since there is more than one way in which
cabal-reinstall (hadrian/build build-cabal) is broken.

- - - - -
02e6a6ce by Matthew Pickering at 2023-07-24T16:49:00-04:00
compiler: Remove unused `containers.h` include

Fixes #23712

- - - - -
822ef66b by Matthew Pickering at 2023-07-25T08:44:50-04:00
Fix pretty printing of WARNING pragmas

There is still something quite unsavoury going on with WARNING pragma
printing because the printing relies on the fact that for decl
deprecations the SourceText of WarningTxt is empty. However, I let that
lion sleep and just fixed things directly.

Fixes #23465

- - - - -
e7b38ede by Matthew Pickering at 2023-07-25T08:45:28-04:00
ci-images: Bump to commit which has 9.6 image

The test-bootstrap job has been failing for 9.6 because we accidentally
used a non-master commit.

- - - - -
bb408936 by Matthew Pickering at 2023-07-25T08:45:28-04:00
Update bootstrap plans for 9.6.2 and 9.4.5

- - - - -
355e1792 by Alan Zimmerman at 2023-07-26T10:17:32-04:00
EPA: Simplify GHC/Parser.y comb4/comb5

Use the HasLoc instance from Ast.hs to allow comb4/comb5 to work with
anything with a SrcSpan

Also get rid of some more now unnecessary reLoc calls.

- - - - -
9393df83 by Gavin Zhao at 2023-07-26T10:18:16-04:00
compiler: make -ddump-asm work with wasm backend NCG

Fixes #23503.

Now the `-ddump-asm` flag is respected in the wasm backend
NCG, so developers can directly view the generated ASM instead of
needing to pass `-S` or `-keep-tmp-files` and manually find & open
the assembly file.

Ideally, we should be able to output the assembly files in smaller
chunks like in other NCG backends. This would also make dumping assembly
stats easier. However, this would require a large refactoring, so for
short-term debugging purposes I think the current approach works fine.

Signed-off-by: Gavin Zhao <git at gzgz.dev>

- - - - -
79463036 by Krzysztof Gogolewski at 2023-07-26T10:18:54-04:00
llvm: Restore accidentally deleted code in 0fc5cb97

Fixes #23711

- - - - -
20db7e26 by Rodrigo Mesquita at 2023-07-26T10:19:33-04:00
configure: Default missing options to False when preparing ghc-toolchain Targets

This commit fixes building ghc with 9.2 as the boostrap compiler.

The ghc-toolchain patch assumed all _STAGE0 options were available, and
forgot to account for this missing information in 9.2.

Ghc 9.2 does not have in settings whether ar supports -l, hence can't
report it with --info (unliked 9.4 upwards).

The fix is to default the missing information (we default "ar supports
-l" and other missing options to False)

- - - - -
fac9e84e by Naïm Favier at 2023-07-26T10:20:16-04:00
docs: Fix typo
- - - - -
503fd647 by Bartłomiej Cieślar at 2023-07-26T17:23:10-04:00
This MR is an implementation of the proposal #516.

It adds a warning -Wincomplete-record-selectors for usages of a record
field access function (either a record selector or getField @"rec"),
while trying to silence the warning whenever it can be sure that a constructor
without the record field would not be invoked (which would otherwise cause
the program to fail). For example:

    data T = T1 | T2 {x :: Bool}

    f a = x a -- this would throw an error

    g T1 = True
    g a = x a -- this would not throw an error

    h :: HasField "x" r Bool => r -> Bool
    h = getField @"x"

    j :: T -> Bool
    j = h -- this would throw an error because of the `HasField`
          -- constraint being solved

See the tests DsIncompleteRecSel* and TcIncompleteRecSel for more examples of the warning.
See Note [Detecting incomplete record selectors] in GHC.HsToCore.Expr for implementation details

- - - - -
af6fdf42 by Arnaud Spiwack at 2023-07-26T17:23:52-04:00
Fix user-facing label in MR template

- - - - -
5d45b92a by Matthew Pickering at 2023-07-27T05:46:46-04:00
ci: Test bootstrapping configurations with full-ci and on marge batches

There have been two incidents recently where bootstrapping has been
broken by removing support for building with 9.2.*.

The process for bumping the minimum required version starts with bumping
the configure version and then other CI jobs such as the bootstrap jobs
have to be updated. We must not silently bump the minimum required
version.

Now we are running a slimmed down validate pipeline it seems worthwile
to test these bootstrap configurations in the full-ci pipeline.

- - - - -
25d4fee7 by Matthew Pickering at 2023-07-27T05:46:46-04:00
bootstrap: Remove ghc-9_2_* plans

We are anticipating shortly making it necessary to use ghc-9.4 to boot
the compiler.

- - - - -
2f66da16 by Matthew Pickering at 2023-07-27T05:46:46-04:00
Update bootstrap plans for ghc-platform and ghc-toolchain dependencies

Fixes #23735

- - - - -
c8c6eab1 by Matthew Pickering at 2023-07-27T05:46:46-04:00
bootstrap: Disable -selftest flag from bootstrap plans

This saves on building one dependency (QuickCheck) which is unecessary
for bootstrapping.

- - - - -
a80ca086 by Andrew Lelechenko at 2023-07-27T05:47:26-04:00
Link reference paper and package from System.Mem.{StableName,Weak}

- - - - -
a5319358 by David Knothe at 2023-07-28T13:13:10-04:00
Update Match Datatype

EquationInfo currently contains a list of the equation's patterns together with a CoreExpr that is to be evaluated after a successful match on this equation.
All the match-functions only operate on the first pattern of an equation - after successfully matching it, match is called recursively on the tail of the pattern list.
We can express this more clearly and make the code a little more elegant by updating the datatype of EquationInfo as follows:

data EquationInfo
    = EqnMatch { eqn_pat = Pat GhcTc, eqn_rest = EquationInfo }
    | EqnDone { eqn_rhs = MatchResult CoreExpr }

An EquationInfo now explicitly exposes its first pattern which most functions operate on, and exposes the equation that remains after processing the first pattern. An EqnDone signifies an empty equation where the CoreExpr can now be evaluated.

- - - - -
86ad1af9 by David Binder at 2023-07-28T13:13:53-04:00
Improve documentation for Data.Fixed

- - - - -
f8fa1d08 by Ben Gamari at 2023-07-28T13:14:31-04:00
ghc-prim: Use C11 atomics

Previously `ghc-prim`'s atomic wrappers used the legacy `__sync_*`
family of C builtins. Here we refactor these to rather use the
appropriate C11 atomic equivalents, allowing us to be more explicit
about the expected ordering semantics.

- - - - -
0bfc8908 by Finley McIlwaine at 2023-07-28T18:46:26-04:00
Include -haddock in DynFlags fingerprint

The -haddock flag determines whether or not the resulting .hi files
contain haddock documentation strings. If the existing .hi files do
not contain haddock documentation strings and the user requests them,
we should recompile.

- - - - -
40425c50 by Andreas Klebinger at 2023-07-28T18:47:02-04:00
Aarch64 NCG: Use encoded immediates for literals.

Try to generate

    instr x2, <imm>

instead of

    mov x1, lit
    instr x2, x1

When possible. This get's rid if quite a few redundant
mov instructions.

I believe this causes a metric decrease for LargeRecords as
we reduce register pressure.

-------------------------
Metric Decrease:
    LargeRecord
-------------------------

- - - - -
e9a0fa3f by Andrew Lelechenko at 2023-07-28T18:47:42-04:00
Bump filepath submodule to 1.4.100.4

Resolves #23741

Metric Decrease:
    MultiComponentModules
    MultiComponentModulesRecomp
    MultiLayerModules
    MultiLayerModulesRecomp
    T10421
    T12234
    T12425
    T13035
    T13701
    T13719
    T16875
    T18304
    T18698a
    T18698b
    T21839c
    T9198
    TcPlugin_RewritePerf
    hard_hole_fits

Metric decrease on Windows can be probably attributed to https://github.com/haskell/filepath/pull/183

- - - - -
ee93edfd by Andrew Lelechenko at 2023-07-28T18:48:21-04:00
Add since pragmas to GHC.IO.Handle.FD

- - - - -
d0369802 by Simon Peyton Jones at 2023-07-30T09:24:48+01:00
Make the occurrence analyser smarter about join points

This MR addresses #22404.  There is a big Note

   Note [Occurrence analysis for join points]

that explains it all.  Significant changes

* New field occ_join_points in OccEnv

* The NonRec case of occAnalBind splits into two cases:
  one for existing join points (which does the special magic for
  Note [Occurrence analysis for join points], and one for other
  bindings.

* mkOneOcc adds in info from occ_join_points.

* All "bring into scope" activity is centralised in the
  new function `addInScope`.

* I made a local data type LocalOcc for use inside the occurrence analyser
  It is like OccInfo, but lacks IAmDead and IAmALoopBreaker, which in turn
  makes computationns over it simpler and more efficient.

* I found quite a bit of allocation in GHC.Core.Rules.getRules
  so I optimised it a bit.

More minor changes

* I found I was using (Maybe Arity) a lot, so I defined a new data
  type JoinPointHood and used it everwhere.  This touches a lot of
  non-occ-anal files, but it makes everything more perspicuous.

* Renamed data constructor WithUsageDetails to WUD, and
  WithTailUsageDetails to WTUD

This also fixes #21128, on the way.

--------- Compiler perf -----------
I spent quite a time on performance tuning, so even though it
does more than before, the occurrence analyser runs slightly faster
on average.  Here are the compile-time allocation changes over 0.5%

      CoOpt_Read(normal) ghc/alloc    766,025,520    754,561,992  -1.5%
CoOpt_Singletons(normal) ghc/alloc    759,436,840    762,925,512  +0.5%
     LargeRecord(normal) ghc/alloc  1,814,482,440  1,799,530,456  -0.8%
       PmSeriesT(normal) ghc/alloc     68,159,272     67,519,720  -0.9%
          T10858(normal) ghc/alloc    120,805,224    118,746,968  -1.7%
          T11374(normal) ghc/alloc    164,901,104    164,070,624  -0.5%
          T11545(normal) ghc/alloc     79,851,808     78,964,704  -1.1%
          T12150(optasm) ghc/alloc     73,903,664     71,237,544  -3.6% GOOD
          T12227(normal) ghc/alloc    333,663,200    331,625,864  -0.6%
          T12234(optasm) ghc/alloc     52,583,224     52,340,344  -0.5%
          T12425(optasm) ghc/alloc     81,943,216     81,566,720  -0.5%
          T13056(optasm) ghc/alloc    294,517,928    289,642,512  -1.7%
      T13253-spj(normal) ghc/alloc    118,271,264     59,859,040 -49.4% GOOD
          T15164(normal) ghc/alloc  1,102,630,352  1,091,841,296  -1.0%
          T15304(normal) ghc/alloc  1,196,084,000  1,166,733,000  -2.5%
          T15630(normal) ghc/alloc    148,729,632    147,261,064  -1.0%
          T15703(normal) ghc/alloc    379,366,664    377,600,008  -0.5%
          T16875(normal) ghc/alloc     32,907,120     32,670,976  -0.7%
          T17516(normal) ghc/alloc  1,658,001,888  1,627,863,848  -1.8%
          T17836(normal) ghc/alloc    395,329,400    393,080,248  -0.6%
          T18140(normal) ghc/alloc     71,968,824     73,243,040  +1.8%
          T18223(normal) ghc/alloc    456,852,568    453,059,088  -0.8%
          T18282(normal) ghc/alloc    129,105,576    131,397,064  +1.8%
          T18304(normal) ghc/alloc     71,311,712     70,722,720  -0.8%
         T18698a(normal) ghc/alloc    208,795,112    210,102,904  +0.6%
         T18698b(normal) ghc/alloc    230,320,736    232,697,976  +1.0%  BAD
          T19695(normal) ghc/alloc  1,483,648,128  1,504,702,976  +1.4%
          T20049(normal) ghc/alloc     85,612,024     85,114,376  -0.6%
         T21839c(normal) ghc/alloc    415,080,992    410,906,216  -1.0% GOOD
           T4801(normal) ghc/alloc    247,590,920    250,726,272  +1.3%
           T6048(optasm) ghc/alloc     95,699,416     95,080,680  -0.6%
            T783(normal) ghc/alloc    335,323,384    332,988,120  -0.7%
           T9233(normal) ghc/alloc    709,641,224    685,947,008  -3.3% GOOD
           T9630(normal) ghc/alloc    965,635,712    948,356,120  -1.8%
           T9675(optasm) ghc/alloc    444,604,152    428,987,216  -3.5% GOOD
           T9961(normal) ghc/alloc    303,064,592    308,798,800  +1.9%  BAD
           WWRec(normal) ghc/alloc    503,728,832    498,102,272  -1.1%

               geo. mean                                          -1.0%
               minimum                                           -49.4%
               maximum                                            +1.9%

In fact these figures seem to vary between platforms; generally worse
on i386 for some reason.  The Windows numbers vary by 1% espec in
benchmarks where the total allocation is low. But the geom mean stays
solidly negative, which is good.  The "increase/decrease" list below
covers all platforms.

The big win on T13253-spj comes because it has a big nest of join
points, each occurring twice in the next one.  The new occ-anal takes
only one iteration of the simplifier to do the inlining; the old one
took four.  Moreover, we get much smaller code with the new one:

  New: Result size of Tidy Core
    = {terms: 429, types: 84, coercions: 0, joins: 14/14}

  Old: Result size of Tidy Core
    = {terms: 2,437, types: 304, coercions: 0, joins: 10/10}

--------- Runtime perf -----------
No significant changes in nofib results, except a 1% reduction in
compiler allocation.

Metric Decrease:
    CoOpt_Read
    T13253-spj
    T9233
    T9630
    T9675
    T12150
    T21839c
    LargeRecord
    MultiComponentModulesRecomp
    T10421
    T13701
    T10421
    T13701
    T12425

Metric Increase:
    T18140
    T9961
    T18282
    T18698a
    T18698b
    T19695

- - - - -
42aa7fbd by Julian Ospald at 2023-07-30T17:22:01-04:00
Improve documentation around IOException and ioe_filename

See:

* https://github.com/haskell/core-libraries-committee/issues/189
* https://github.com/haskell/unix/pull/279
* https://github.com/haskell/unix/pull/289

- - - - -
33598ecb by Sylvain Henry at 2023-08-01T14:45:54-04:00
JS: implement getMonotonicTime (fix #23687)

- - - - -
d2bedffd by Bartłomiej Cieślar at 2023-08-01T14:46:40-04:00
Implementation of the Deprecated Instances proposal #575

This commit implements the ability to deprecate certain instances,
which causes the compiler to emit the desired deprecation message
whenever they are instantiated. For example:

  module A where
  class C t where
  instance {-# DEPRECATED "dont use" #-} C Int where

  module B where
  import A
  f :: C t => t
  f = undefined
  g :: Int
  g = f -- "dont use" emitted here

The implementation is as follows:
  - In the parser, we parse deprecations/warnings attached to instances:

      instance {-# DEPRECATED "msg" #-} Show X
      deriving instance {-# WARNING "msg2" #-} Eq Y

    (Note that non-standalone deriving instance declarations do not support
    this mechanism.)

  - We store the resulting warning message in `ClsInstDecl` (respectively, `DerivDecl`).
    In `GHC.Tc.TyCl.Instance.tcClsInstDecl` (respectively, `GHC.Tc.Deriv.Utils.newDerivClsInst`),
    we pass on that information to `ClsInst` (and eventually store it in `IfaceClsInst` too).

  - Finally, when we solve a constraint using such an instance, in
    `GHC.Tc.Instance.Class.matchInstEnv`, we emit the appropriate warning
    that was stored in `ClsInst`.
    Note that we only emit a warning when the instance is used in a different module
    than it is defined, which keeps the behaviour in line with the deprecation of
    top-level identifiers.

Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com>

- - - - -
d5a65af6 by Ben Gamari at 2023-08-01T14:47:18-04:00
compiler: Style fixes

- - - - -
7218c80a by Ben Gamari at 2023-08-01T14:47:19-04:00
rts: Fix implicit cast

This ensures that Task.h can be built with a C++ compiler.

- - - - -
d6d5aafc by Ben Gamari at 2023-08-01T14:47:19-04:00
testsuite: Fix warning in hs_try_putmvar001

- - - - -
d9eddf7a by Ben Gamari at 2023-08-01T14:47:19-04:00
testsuite: Add AtomicModifyIORef test

- - - - -
f9eea4ba by Ben Gamari at 2023-08-01T14:47:19-04:00
rts: Introduce NO_WARN macro

This allows fine-grained ignoring of warnings.

- - - - -
497b24ec by Ben Gamari at 2023-08-01T14:47:19-04:00
rts: Simplify atomicModifyMutVar2# implementation

Previously we would perform a redundant load in the non-threaded RTS in
atomicModifyMutVar2# implementation for the benefit of the non-moving
GC's write barrier. Eliminate this.

- - - - -
52ee082b by Ben Gamari at 2023-08-01T14:47:19-04:00
rts: Introduce more principled fence operations

- - - - -
cd3c0377 by Ben Gamari at 2023-08-01T14:47:19-04:00
rts: Introduce SET_INFO_RELAXED

- - - - -
6df2352a by Ben Gamari at 2023-08-01T14:47:19-04:00
rts: Style fixes

- - - - -
4ef6f319 by Ben Gamari at 2023-08-01T14:47:19-04:00
codeGen/tsan: Rework handling of spilling

- - - - -
f9ca7e27 by Ben Gamari at 2023-08-01T14:47:19-04:00
hadrian: More debug information

- - - - -
df4153ac by Ben Gamari at 2023-08-01T14:47:19-04:00
Improve TSAN documentation

- - - - -
fecae988 by Ben Gamari at 2023-08-01T14:47:19-04:00
hadrian: More selective TSAN instrumentation

- - - - -
465a9a0b by Alan Zimmerman at 2023-08-01T14:47:56-04:00
EPA: Provide correct annotation span for ImportDecl

Use the whole declaration, rather than just the span of the 'import'
keyword.

Metric Decrease:
   T9961
   T5205
Metric Increase:
  T13035

- - - - -
ae63d0fa by Bartłomiej Cieślar at 2023-08-01T14:48:40-04:00
Add cases to T23279: HasField for deprecated record fields

This commit adds additional tests from ticket #23279 to ensure that we don't
regress on reporting deprecated record fields in conjunction with HasField,
either when using overloaded record dot syntax or directly through `getField`.

Fixes #23279

- - - - -
00fb6e6b by Andreas Klebinger at 2023-08-01T14:49:17-04:00
AArch NCG: Pure refactor

Combine some alternatives. Add some line breaks for overly long lines

- - - - -
8f3b3b78 by Andreas Klebinger at 2023-08-01T14:49:54-04:00
Aarch ncg: Optimize immediate use for address calculations

When the offset doesn't fit into the immediate we now just reuse the
general getRegister' code path which is well optimized to compute the
offset into a register instead of a special case for CmmRegOff.

This means we generate a lot less code under certain conditions which is
why performance metrics for these improve.

-------------------------
Metric Decrease:
    T4801
    T5321FD
    T5321Fun
-------------------------

- - - - -
74a882dc by MorrowM at 2023-08-02T06:00:03-04:00
Add a RULE to make lookup fuse

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

Metric Increase:
    T18282

- - - - -
cca74dab by Ben Gamari at 2023-08-02T06:00:39-04:00
hadrian: Ensure that way-flags are passed to CC

Previously the way-specific compilation flags (e.g. `-DDEBUG`,
`-DTHREADED_RTS`) would not be passed to the CC invocations. This meant
that C dependency files would not correctly reflect
dependencies predicated on the way, resulting in the rather
painful #23554.

Closes #23554.

- - - - -
622b483c by Jaro Reinders at 2023-08-02T06:01:20-04:00
Native 32-bit Enum Int64/Word64 instances

This commits adds more performant Enum Int64 and Enum Word64 instances
for 32-bit platforms, replacing the Integer-based implementation.

These instances are a copy of the Enum Int and Enum Word instances with
minimal changes to manipulate Int64 and Word64 instead.

On i386 this yields a 1.5x performance increase and for the JavaScript
back end it even yields a 5.6x speedup.

Metric Decrease:
    T18964

- - - - -
c8bd7fa4 by Sylvain Henry at 2023-08-02T06:02:03-04:00
JS: fix typos in constants (#23650)

- - - - -
b9d5bfe9 by Josh Meredith at 2023-08-02T06:02:40-04:00
JavaScript: update MK_TUP macros to use current tuple constructors (#23659)

- - - - -
28211215 by Matthew Pickering at 2023-08-02T06:03:19-04:00
ci: Pass -Werror when building hadrian in hadrian-ghc-in-ghci job

Warnings when building Hadrian can end up cluttering the output of HLS,
and we've had bug reports in the past about these warnings when building
Hadrian. It would be nice to turn on -Werror on at least one build of
Hadrian in CI to avoid a patch introducing warnings when building
Hadrian.

Fixes #23638

- - - - -
aca20a5d by Ben Gamari at 2023-08-02T06:03:55-04:00
codeGen: Ensure that TSAN is aware of writeArray# write barriers

By using a proper release store instead of a fence.

- - - - -
453c0531 by Ben Gamari at 2023-08-02T06:03:55-04:00
codeGen: Ensure that array reads have necessary barriers

This was the cause of #23541.

- - - - -
93a0d089 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00
Add test for #23550

- - - - -
6a2f4a20 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00
Desugar non-recursive lets to non-recursive lets (take 2)

This reverts commit 522bd584f71ddeda21efdf0917606ce3d81ec6cc. And
takes care of the case that I missed in my previous attempt. Namely
the case of an AbsBinds with no type variables and no dictionary
variable.

Ironically, the comment explaining why non-recursive lets were
desugared to recursive lets were pointing specifically at this case
as the reason. I just failed to understand that it was until Simon PJ
pointed it out to me.

See #23550 for more discussion.

- - - - -
ff81d53f by jade at 2023-08-02T06:05:20-04:00
Expand documentation of List & Data.List

This commit aims to improve the documentation and examples
of symbols exported from Data.List

- - - - -
fa4e5913 by Jade at 2023-08-02T06:06:03-04:00
Improve documentation of Semigroup & Monoid

This commit aims to improve the documentation of various symbols
exported from Data.Semigroup and Data.Monoid

- - - - -
e2c91bff by Gergő Érdi at 2023-08-03T02:55:46+01:00
Desugar bindings in the context of their evidence

Closes #23172

- - - - -
481f4a46 by Gergő Érdi at 2023-08-03T07:48:43+01:00
Add flag to `-f{no-}specialise-incoherents` to enable/disable specialisation of
incoherent instances

Fixes #23287

- - - - -
d751c583 by Profpatsch at 2023-08-04T12:24:26-04:00
base: Improve String & IsString documentation

- - - - -
01db1117 by Ben Gamari at 2023-08-04T12:25:02-04:00
rts/win32: Ensure reliability of IO manager shutdown

When the Win32 threaded IO manager shuts down, `ioManagerDie` sends an
`IO_MANAGER_DIE` event to the IO manager thread using the
`io_manager_event` event object. Finally, it will closes the event object,
and invalidate `io_manager_event`.

Previously, `readIOManagerEvent` would see that `io_manager_event` is
invalid and return `0`, suggesting that everything is right with the
world. This meant that if `ioManagerDie` invalidated the handle before
the event manager was blocked on the event we would end up in a
situation where the event manager would never realize it was asked to
shut down.

Fix this by ensuring that `readIOManagerEvent` instead returns
`IO_MANAGER_DIE` when we detect that the event object has been
invalidated by `ioManagerDie`.

Fixes #23691.

- - - - -
fdef003a by Ryan Scott at 2023-08-04T12:25:39-04:00
Look through TH splices in splitHsApps

This modifies `splitHsApps` (a key function used in typechecking function
applications) to look through untyped TH splices and quasiquotes. Not doing so
was the cause of #21077. This builds on !7821 by making `splitHsApps` match on
`HsUntypedSpliceTop`, which contains the `ThModFinalizers` that must be run as
part of invoking the TH splice. See the new `Note [Looking through Template
Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`.

Along the way, I needed to make the type of `splitHsApps.set` slightly more
general to accommodate the fact that the location attached to a quasiquote is
a `SrcAnn NoEpAnns` rather than a `SrcSpanAnnA`.

Fixes #21077.

- - - - -
e77a0b41 by Ben Gamari at 2023-08-04T12:26:15-04:00
Bump deepseq submodule to 1.5.

And bump bounds

(cherry picked from commit 1228d3a4a08d30eaf0138a52d1be25b38339ef0b)

- - - - -
cebb5819 by Ben Gamari at 2023-08-04T12:26:15-04:00
configure: Bump minimal boot GHC version to 9.4

(cherry picked from commit d3ffdaf9137705894d15ccc3feff569d64163e8e)

- - - - -
83766dbf by Ben Gamari at 2023-08-04T12:26:15-04:00
template-haskell: Bump version to 2.21.0.0

Bumps exceptions submodule.

(cherry picked from commit bf57fc9aea1196f97f5adb72c8b56434ca4b87cb)

- - - - -
1211112a by Ben Gamari at 2023-08-04T12:26:15-04:00
base: Bump version to 4.19

Updates all boot library submodules.

(cherry picked from commit 433d99a3c24a55b14ec09099395e9b9641430143)

- - - - -
3ab5efd9 by Ben Gamari at 2023-08-04T12:26:15-04:00
testsuite: Normalise versions more aggressively

In backpack hashes can contain `+` characters.

(cherry picked from commit 024861af51aee807d800e01e122897166a65ea93)

- - - - -
d52be957 by Ben Gamari at 2023-08-04T12:26:15-04:00
testsuite: Declare bkpcabal08 as fragile

Due to spurious output changes described in #23648.

(cherry picked from commit c046a2382420f2be2c4a657c56f8d95f914ea47b)

- - - - -
e75a58d1 by Ben Gamari at 2023-08-04T12:26:15-04:00
gitlab-ci: Only mark linker_unload_native as broken in static jobs

This test passes on dynamically-linked Alpine.

(cherry picked from commit f356a7e8ec8ec3d6b2b30fd175598b9b80065d87)

- - - - -
8b176514 by Ben Gamari at 2023-08-04T12:26:15-04:00
testsuite: Update base-exports

- - - - -
4b647936 by Ben Gamari at 2023-08-04T12:26:15-04:00
testsuite/interface-stability: normalise versions

This eliminates spurious changes from version bumps.

- - - - -
0eb54c05 by Ben Gamari at 2023-08-04T12:26:51-04:00
linker/PEi386: Don't sign-extend symbol section number

Previously we incorrectly interpreted PE section numbers as signed
values. However, this isn't the case; rather, it's an unsigned 16-bit number
with a few special bit-patterns (0xffff and 0xfffe). This resulted in #22941
as the linker would conclude that the sections were invalid.

Fixing this required quite a bit of refactoring.

Closes #22941.

- - - - -
fd7ce39c by Ben Gamari at 2023-08-04T12:27:28-04:00
testsuite: Mark MulMayOflo_full as broken rather than skipping

To ensure that we don't accidentally fix it.

See #23742.

- - - - -
824092f2 by Ben Gamari at 2023-08-04T12:27:28-04:00
nativeGen/AArch64: Fix sign extension in MulMayOflo

Previously the 32-bit implementations of MulMayOflo would use the
a non-sensical sign-extension mode. Rewrite these to reflect what gcc 11
produces. Also similarly rework the 16- and 8-bit cases.

This now passes the MulMayOflo tests in ghc/test-primops> in all four
widths, including the precision tests.

Fixes #23721.

- - - - -
1b15dbc4 by Jan Hrček at 2023-08-04T12:28:08-04:00
Fix haddock markup in code example for coerce

- - - - -
46fd8ced by Vladislav Zavialov at 2023-08-04T12:28:44-04:00
Fix (~) and (@) infix operators in TH splices (#23748)

8168b42a "Whitespace-sensitive bang patterns" allows GHC to accept
the following infix operators:

	a ~ b = ()
	a @ b = ()

But not if TH is used to generate those declarations:

	$([d| a ~ b = ()
	      a @ b = ()
	    |])

	-- Test.hs:5:2: error: [GHC-55017]
	--    Illegal variable name: ‘~’
	--    When splicing a TH declaration: (~_0) a_1 b_2 = GHC.Tuple.Prim.()

This is easily fixed by modifying `reservedOps` in GHC.Utils.Lexeme

- - - - -
a1899d8f by Aaron Allen at 2023-08-04T12:29:24-04:00
[#23663] Show Flag Suggestions in GHCi

Makes suggestions when using `:set` in GHCi with a misspelled flag. This
mirrors how invalid flags are handled when passed to GHC directly. Logic
for producing flag suggestions was moved to GHC.Driver.Sesssion so it
can be shared.

resolves #23663

- - - - -
03f2debd by Rodrigo Mesquita at 2023-08-04T12:30:00-04:00
Improve ghc-toolchain validation configure warning

Fixes the layout of the ghc-toolchain validation warning produced by
configure.

- - - - -
de25487d by Alan Zimmerman at 2023-08-04T12:30:36-04:00
EPA make getLocA a synonym for getHasLoc

This is basically a no-op change, but allows us to make future changes
that can rely on the HasLoc instances

And I presume this means we can use more precise functions based on
class resolution, so the Windows CI build reports

Metric Decrease:
    T12234
    T13035

- - - - -
3ac423b9 by Ben Gamari at 2023-08-04T12:31:13-04:00
ghc-platform: Add upper bound on base

Hackage upload requires this.
- - - - -
8ba20b21 by Matthew Craven at 2023-08-04T17:22:59-04:00
Adjust and clarify handling of primop effects

Fixes #17900; fixes #20195.

The existing "can_fail" and "has_side_effects" primop attributes
that previously governed this were used in inconsistent and
confusingly-documented ways, especially with regard to raising
exceptions.  This patch replaces them with a single "effect"
attribute, which has four possible values: NoEffect, CanFail,
ThrowsException, and ReadWriteEffect.  These are described in
Note [Classifying primop effects].

A substantial amount of related documentation has been re-drafted
for clarity and accuracy.

In the process of making this attribute format change for literally
every primop, several existing mis-classifications were detected and
corrected.  One of these mis-classifications was tagToEnum#, which
is now considered CanFail; this particular fix is known to cause a
regression in performance for derived Enum instances.  (See #23782.)
Fixing this is left as future work.

New primop attributes "cheap" and "work_free" were also added,
and used in the corresponding parts of GHC.Core.Utils.

In view of their actual meaning and uses, `primOpOkForSideEffects`
and `exprOkForSideEffects` have been renamed to `primOpOkToDiscard`
and `exprOkToDiscard`, respectively.

Metric Increase:
    T21839c

- - - - -
41bf2c09 by sheaf at 2023-08-04T17:23:42-04:00
Update inert_solved_dicts for ImplicitParams

When adding an implicit parameter dictionary to the inert set, we must
make sure that it replaces any previous implicit parameter dictionaries
that overlap, in order to get the appropriate shadowing behaviour, as in

  let ?x = 1 in let ?x = 2 in ?x

We were already doing this for inert_cans, but we weren't doing the same
thing for inert_solved_dicts, which lead to the bug reported in #23761.

The fix is thus to make sure that, when handling an implicit parameter
dictionary in updInertDicts, we update **both** inert_cans and
inert_solved_dicts to ensure a new implicit parameter dictionary
correctly shadows old ones.

Fixes #23761

- - - - -
43578d60 by Matthew Craven at 2023-08-05T01:05:36-04:00
Bump bytestring submodule to 0.11.5.1

- - - - -
91353622 by Ben Gamari at 2023-08-05T01:06:13-04:00
Initial commit of Note [Thunks, blackholes, and indirections]

This Note attempts to summarize the treatment of thunks, thunk update,
and indirections.

This fell out of work on #23185.

- - - - -
8d686854 by sheaf at 2023-08-05T01:06:54-04:00
Remove zonk in tcVTA

This removes the zonk in GHC.Tc.Gen.App.tc_inst_forall_arg and its
accompanying Note [Visible type application zonk]. Indeed, this zonk
is no longer necessary, as we no longer maintain the invariant that
types are well-kinded without zonking; only that typeKind does not
crash; see Note [The Purely Kinded Type Invariant (PKTI)].

This commit removes this zonking step (as well as a secondary zonk),
and replaces the aforementioned Note with the explanatory
Note [Type application substitution], which justifies why the
substitution performed in tc_inst_forall_arg remains valid without
this zonking step.

Fixes #23661

- - - - -
19dea673 by Ben Gamari at 2023-08-05T01:07:30-04:00
Bump nofib submodule

Ensuring that nofib can be build using the same range of bootstrap
compilers as GHC itself.

- - - - -
aa07402e by Luite Stegeman at 2023-08-05T23:15:55+09:00
JS: Improve compatibility with recent emsdk

The JavaScript code in libraries/base/jsbits/base.js had some
hardcoded offsets for fields in structs, because we expected
the layout of the data structures to remain unchanged. Emsdk
3.1.42 changed the layout of the stat struct, breaking this
assumption, and causing code in .hsc files accessing the
stat struct to fail.

This patch improves compatibility with recent emsdk by
removing the assumption that data layouts stay unchanged:

    1. offsets of fields in structs used by JavaScript code are
       now computed by the configure script, so both the .js and
       .hsc files will automatically use the new layout if anything
       changes.
    2. the distrib/configure script checks that the emsdk version
       on a user's system is the same version that a bindist was
       booted with, to avoid data layout inconsistencies

See #23641

- - - - -
b938950d by Luite Stegeman at 2023-08-07T06:27:51-04:00
JS: Fix missing local variable declarations

This fixes some missing local variable declarations that were
found by running the testsuite in strict mode.

Fixes #23775

- - - - -
6c0e2247 by sheaf at 2023-08-07T13:31:21-04:00
Update Haddock submodule to fix #23368

This submodule update adds the following three commits:

bbf1c8ae - Check for puns
0550694e - Remove fake exports for (~), List, and Tuple<n>
5877bceb - Fix pretty-printing of Solo and MkSolo

These commits fix the issues with Haddock HTML rendering reported in
ticket #23368.

Fixes #23368

- - - - -
5b5be3ea by Matthew Pickering at 2023-08-07T13:32:00-04:00
Revert "Bump bytestring submodule to 0.11.5.1"

This reverts commit 43578d60bfc478e7277dcd892463cec305400025.

Fixes #23789

- - - - -
01961be3 by Ben Gamari at 2023-08-08T02:47:14-04:00
configure: Derive library version from ghc-prim.cabal.in

Since ghc-prim.cabal is now generated by Hadrian, we cannot depend upon
it.

Closes #23726.

- - - - -
3b373838 by Ryan Scott at 2023-08-08T02:47:49-04:00
tcExpr: Push expected types for untyped TH splices inwards

In !10911, I deleted a `tcExpr` case for `HsUntypedSplice` in favor of a much
simpler case that simply delegates to `tcApp`. Although this passed the test
suite at the time, this was actually an error, as the previous `tcExpr` case
was critically pushing the expected type inwards. This actually matters for
programs like the one in #23796, which GHC would not accept with type inference
alone—we need full-blown type _checking_ to accept these.

I have added back the previous `tcExpr` case for `HsUntypedSplice` and now
explain why we have two different `HsUntypedSplice` cases (one in `tcExpr` and
another in `splitHsApps`) in `Note [Looking through Template Haskell splices in
splitHsApps]` in `GHC.Tc.Gen.Head`.

Fixes #23796.

- - - - -
0ef1d8ae by sheaf at 2023-08-08T21:26:51-04:00
Compute all emitted diagnostic codes

This commit introduces in GHC.Types.Error.Codes the function

  constructorCodes :: forall diag. (...) => Map DiagnosticCode String

which computes a collection of all the diagnostic codes that correspond
to a particular type. In particular, we can compute the collection of
all diagnostic codes emitted by GHC using the invocation

  constructorCodes @GhcMessage

We then make use of this functionality in the new "codes" test which
checks consistency and coverage of GHC diagnostic codes.
It performs three checks:

  - check 1: all non-outdated GhcDiagnosticCode equations
    are statically used.
  - check 2: all outdated GhcDiagnosticCode equations
    are statically unused.
  - check 3: all statically used diagnostic codes are covered by
    the testsuite (modulo accepted exceptions).

- - - - -
4bc7b1e5 by Fraser Tweedale at 2023-08-08T21:27:32-04:00
numberToRangedRational: fix edge cases for exp ≈ (maxBound :: Int)

Currently a negative exponent less than `minBound :: Int` results in
Infinity, which is very surprising and obviously wrong.

```
λ> read "1e-9223372036854775808" :: Double
0.0
λ> read "1e-9223372036854775809" :: Double
Infinity
```

There is a further edge case where the exponent can overflow when
increased by the number of tens places in the integer part, or
underflow when decreased by the number of leading zeros in the
fractional part if the integer part is zero:

```
λ> read "10e9223372036854775807" :: Double
0.0
λ> read "0.01e-9223372036854775808" :: Double
Infinity
```

To resolve both of these issues, perform all arithmetic and
comparisons involving the exponent in type `Integer`.  This approach
also eliminates the need to explicitly check the exponent against
`maxBound :: Int` and `minBound :: Int`, because the allowed range
of the exponent (i.e. the result of `floatRange` for the target
floating point type) is certainly within those bounds.

This change implements CLC proposal 192:
https://github.com/haskell/core-libraries-committee/issues/192

- - - - -
6eab07b2 by Alan Zimmerman at 2023-08-08T21:28:10-04:00
EPA: Remove Location from WarningTxt source

This is not needed.

- - - - -
1a98d673 by Sebastian Graf at 2023-08-09T16:24:29-04:00
Cleanup a TODO introduced in 1f94e0f7

The change must have slipped through review of !4412

- - - - -
2274abc8 by Sebastian Graf at 2023-08-09T16:24:29-04:00
More explicit strictness in GHC.Real

- - - - -
ce8aa54c by Sebastian Graf at 2023-08-09T16:24:30-04:00
exprIsTrivial: Factor out shared implementation

The duplication between `exprIsTrivial` and `getIdFromTrivialExpr_maybe` has
been bugging me for a long time.

This patch introduces an inlinable worker function `trivial_expr_fold` acting
as the single, shared decision procedure of triviality. It "returns" a
Church-encoded `Maybe (Maybe Id)`, so when it is inlined, it fuses to similar
code as before.
(Better code, even, in the case of `getIdFromTrivialExpr` which presently
allocates a `Just` constructor that cancels away after this patch.)

- - - - -
d004a36d by Sebastian Graf at 2023-08-09T16:24:30-04:00
Simplify: Simplification of arguments in a single function

The Simplifier had a function `simplArg` that wasn't called in `rebuildCall`,
which seems to be the main way to simplify args. Hence I consolidated the code
path to call `simplArg`, too, renaming to `simplLazyArg`.

- - - - -
8c73505e by Sebastian Graf at 2023-08-09T16:24:30-04:00
Core.Ppr: Omit case binder for empty case alternatives

A minor improvement to pretty-printing

- - - - -
d8d993f1 by Sebastian Graf at 2023-08-09T16:24:30-04:00
Disable tests RepPolyWrappedVar2 and RepPolyUnsafeCoerce1 in JS backend

... because those coerce between incompatible/unknown PrimReps.

- - - - -
f06e87e4 by Sebastian Graf at 2023-08-09T16:24:30-04:00
Inlining literals into boring contexts is OK

- - - - -
4a6b7c87 by Sebastian Graf at 2023-08-09T16:24:30-04:00
Clarify floating of unsafeEqualityProofs (#23754)

- - - - -
b0f4752e by Sebastian Graf at 2023-08-09T16:24:30-04:00
Kill SetLevel.notWorthFloating.is_triv (#23270)

We have had it since b84ba676034, when it operated on annotated expressions.
Nowadays it operates on vanilla `CoreExpr` though, so we should just call
`exprIsTrivial`; thus handling empty cases and string literals correctly.

- - - - -
7e0c8b3b by Sebastian Graf at 2023-08-09T16:24:30-04:00
ANFise string literal arguments (#23270)

This instates the invariant that a trivial CoreExpr translates to an atomic
StgExpr. Nice.

Annoyingly, in -O0 we sometimes generate
```
foo = case "blah"# of sat { __DEFAULT -> unpackCString# sat }
```
which makes it a bit harder to spot that we can emit a standard
`stg_unpack_cstring` thunk.

Fixes #23270.

- - - - -
357f2738 by Sebastian Graf at 2023-08-09T16:24:30-04:00
Deactivate -fcatch-nonexhaustive-cases in ghc-bignum (#23345)

- - - - -
59202c80 by Sebastian Graf at 2023-08-09T16:24:30-04:00
CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead

We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now.
The main reason is that it plays far better in conjunction with eta expansion
(as we aim to do for arguments in CorePrep, #23083), because we can discard
any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta`
it's impossible to discard the argument.

We do also give the same treatment to unsafeCoerce proofs and treat them as
trivial iff their RHS is trivial.

It is also both much simpler to describe than the previous mechanism of emitting
an unsafe coercion and simpler to implement, removing quite a bit of commentary
and `CorePrepProv`.

In the ghc/alloc perf test `LargeRecord`, we introduce an additional Simplifier
iteration due to #17910. E.g., FloatOut produces a binding
```
lvl_s6uK [Occ=Once1] :: GHC.Types.Int
[LclId]
lvl_s6uK = GHC.Types.I# 2#

lvl_s6uL [Occ=Once1] :: GHC.Types.Any
[LclId]
lvl_s6uL
  = case Unsafe.Coerce.unsafeEqualityProof ... of
    { Unsafe.Coerce.UnsafeRefl v2_i6tr -> lvl_s6uK `cast` (... v2_i6tr ...)
    }
```
That occurs once and hence is pre-inlined unconditionally in the next Simplifier
pass. It's non-trivial to find a way around that, but not really harmful
otherwise. Hence we accept a 1.2% increase on some architectures.

Metric Increase:
    LargeRecord

- - - - -
00d31188 by Sebastian Graf at 2023-08-09T16:24:30-04:00
CorePrep: Eta expand arguments (#23083)

Previously, we'd only eta expand let bindings and lambdas,
now we'll also eta expand arguments such as in T23083:
```hs
g f h = f (h `seq` (h $))
```
Unless `-fpedantic-bottoms` is set, we'll now transform to
```hs
g f h = f (\eta -> h eta)
```
in CorePrep.

See the new `Note [Eta expansion of arguments in CorePrep]` for the details.

We only do this optimisation with -O2 because we saw 2-3% ghc/alloc regressions
in T4801 and T5321FD.

Fixes #23083.

- - - - -
bf885d7a by Matthew Craven at 2023-08-09T16:25:07-04:00
Bump bytestring submodule to 0.11.5, again

Fixes #23789.

The bytestring commit used here is unreleased;
a release can be made when necessary.

- - - - -
7acbf0fd by Sven Tennie at 2023-08-10T19:17:11-04:00
Serialize CmmRetInfo in .rodata

The handling of case was missing.

- - - - -
0c3136f2 by Sven Tennie at 2023-08-10T19:17:11-04:00
Reference StgRetFun payload by its struct field address

This is easier to grasp than relative pointer offsets.

- - - - -
f68ff313 by Sven Tennie at 2023-08-10T19:17:11-04:00
Better variable name: u -> frame

The 'u' was likely introduced by copy'n'paste.

- - - - -
0131bb7f by Sven Tennie at 2023-08-10T19:17:11-04:00
Make checkSTACK() public

Such that it can also be used in tests.

- - - - -
7b6e1e53 by Sven Tennie at 2023-08-10T19:17:11-04:00
Publish stack related fields in DerivedConstants.h

These will be used in ghc-heap to decode these parts of the stack.

- - - - -
907ed054 by Sven Tennie at 2023-08-10T19:17:11-04:00
ghc-heap: Decode StgStack and its stack frames

Previously, ghc-heap could only decode heap closures.

The approach is explained in detail in note
[Decoding the stack].

- - - - -
6beb6ac2 by Sven Tennie at 2023-08-10T19:17:11-04:00
Remove RetFunType from RetFun stack frame representation

It's a technical detail. The single usage is replaced by a predicate.

- - - - -
006bb4f3 by Sven Tennie at 2023-08-10T19:17:11-04:00
Better parameter name

The call-site uses the term "offset", too.

- - - - -
d4c2c1af by Sven Tennie at 2023-08-10T19:17:11-04:00
Make closure boxing pure

There seems to be no need to do something complicated. However, the
strictness of the closure pointer matters, otherwise a thunk gets
decoded.

- - - - -
8d8426c9 by Sven Tennie at 2023-08-10T19:17:11-04:00
Document entertainGC in test

It wasn't obvious why it's there and what its role is.

Also, increase the "entertainment level" a bit.

I checked in STG and Cmm dumps that this really generates closures (and
is not e.g. constant folded away.)

- - - - -
cc52c358 by Finley McIlwaine at 2023-08-10T19:17:47-04:00
Add -dipe-stats flag

This is useful for seeing which info tables have information.

- - - - -
261c4acb by Finley McIlwaine at 2023-08-10T19:17:47-04:00
Add -finfo-table-map-with-fallback -finfo-table-map-with-stack

The -fno-info-table-map-with-stack flag omits STACK info tables from the info
table map, and the -fno-info-table-map-with-fallback flag omits info tables
with defaulted source locations from the map. In a test on the Agda codebase
the build results were about 7% smaller when both of those types of tables
were omitted.

Adds a test that verifies that passing each combination of these flags
results in the correct output for -dipe-stats, which is disabled for the js
backend since profiling is not implemented.

This commit also refactors a lot of the logic around extracting info tables
from the Cmm results and building the info table map.

This commit also fixes some issues in the users guide rst source to fix
warnings that were noticed while debugging the documentation for these flags.

Fixes #23702

- - - - -
d7047e0d by Jaro Reinders at 2023-08-14T04:41:42-04:00
Add changelog entry for specialised Enum Int64/Word64 instances

- - - - -
52f5e8fb by cydparser at 2023-08-14T04:42:20-04:00
Fix -ddump-to-file and -ddump-timings interaction (#20316)

- - - - -
1274c5d6 by cydparser at 2023-08-14T04:42:20-04:00
Update release notes (#20316)

- - - - -
8e699b23 by Matthew Pickering at 2023-08-14T10:44:47-04:00
base: Add changelog entry for CLC #188

This proposal modified the implementations of copyBytes, moveBytes and
fillBytes (as detailed in the proposal)

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

- - - - -
026f040a by Matthew Pickering at 2023-08-14T10:45:23-04:00
packaging: Build manpage in separate directory to other documentation

We were installing two copies of the manpage:

* One useless one in the `share/doc` folder, because we copy the doc/
  folder into share/
* The one we deliberately installed into `share/man` etc

The solution is to build the manpage into the `manpage` directory when
building the bindist, and then just install it separately.

Fixes #23707

- - - - -
524c60c8 by Bartłomiej Cieślar at 2023-08-14T13:46:33-04:00
Report deprecated fields bound by record wildcards when used

This commit ensures that we emit the appropriate warnings when
a deprecated record field bound by a record wildcard is used.

For example:

    module A where
    data Foo = Foo {x :: Int, y :: Bool, z :: Char}

    {-# DEPRECATED x "Don't use x" #-}
    {-# WARNING y "Don't use y" #-}

    module B where
    import A

    foo (Foo {..}) = x

This will cause us to emit a "Don't use x" warning, with location the
location of the record wildcard. Note that we don't warn about `y`,
because it is unused in the RHS of `foo`.

Fixes #23382

- - - - -
d6130065 by Matthew Pickering at 2023-08-14T13:47:11-04:00
Add zstd suffix to jobs which rely on zstd

This was causing some confusion as the job was named simply
"x86_64-linux-deb10-validate", which implies a standard configuration
rather than any dependency on libzstd.

- - - - -
e24e44fc by Matthew Pickering at 2023-08-14T13:47:11-04:00
ci: Always run project-version job

This is needed for the downstream test-primops pipeline to workout what
the version of a bindist produced by a pipeline is.

- - - - -
f17b9d62 by Matthew Pickering at 2023-08-14T13:47:11-04:00
gen_ci: Rework how jobs-metadata.json is generated

* We now represent a job group a triple of Maybes, which makes it easier
  to work out when jobs are enabled/disabled on certain pipelines.

```
data JobGroup a = StandardTriple { v :: Maybe (NamedJob a)
                                 , n :: Maybe (NamedJob a)
                                 , r :: Maybe (NamedJob a) }
```

* `jobs-metadata.json`  generation is reworked using the following
  algorithm.
  - For each pipeline type, find all the platforms we are doing builds
    for.
  - Select one build per platform
  - Zip together the results

This way we can choose different pipelines for validate/nightly/release
which makes the metadata also useful for validate pipelines. This
feature is used by the test-primops downstream CI in order to select the
right bindist for testing validate pipelines.

This makes it easier to inspect which jobs are going to be enabled on a
particular pipeline.

- - - - -
f9a5563d by Matthew Pickering at 2023-08-14T13:47:11-04:00
gen_ci: Rules rework

In particular we now distinguish between whether we are dealing with a
Nightly/Release pipeline (which labels don't matter for) and a validate
pipeline where labels do matter.

The overall goal here is to allow a disjunction of labels for validate
pipelines, for example,

> Run a job if we have the full-ci label or test-primops label

Therefore the "ValidateOnly" rules are treated as a set of disjunctions
rather than conjunctions like before.

What this means in particular is that if we want to ONLY run a job if a
label is set, for example, "FreeBSD" label then we have to override the
whole label set.

Fixes #23772

- - - - -
d54b0c1d by Matthew Pickering at 2023-08-14T13:47:11-04:00
ci: set -e for lint-ci-config scripts

- - - - -
994a9b35 by Matthew Pickering at 2023-08-14T13:47:11-04:00
ci: Fix job metadata generation

- - - - -
e194ed2b by Ben Gamari at 2023-08-15T00:58:09-04:00
users-guide: Note that GHC2021 doesn't include ExplicitNamespaces

As noted in #23801.

- - - - -
d814bda9 by Ben Gamari at 2023-08-15T05:43:53-04:00
users-guide: Support both distutils and packaging

As noted in #23818, some old distributions (e.g. Debian 9) only include
`distutils` while newer distributions only include `packaging`.

Fixes #23818.

- - - - -
1726db3f by Ben Gamari at 2023-08-15T05:43:53-04:00
users-guide: Ensure extlinks is compatible with Sphinx <4

The semantics of the `extlinks` attribute annoyingly changed in Sphinx
4. Reflect this in our configuration. See #22690.

Fixes #23807.

- - - - -
173338cf by Matthew Pickering at 2023-08-15T22:00:24-04:00
ci: Run full-ci on master and release branches

Fixes #23737

- - - - -
bdab6898 by Andrew Lelechenko at 2023-08-15T22:01:03-04:00
Add @since pragmas for Data.Ord.clamp and GHC.Float.clamp

- - - - -
662d351b by Matthew Pickering at 2023-08-16T09:35:04-04:00
ghc-toolchain: Match CPP args with configure script

At the moment we need ghc-toolchain to precisely match the output as
provided by the normal configure script. The normal configure script
(FP_HSCPP_CMD_WITH_ARGS) branches on whether we are using clang or gcc
so we match that logic exactly in ghc-toolchain.

The old implementation (which checks if certain flags are supported) is
better but for now we have to match to catch any potential errors in the
configuration.

Ticket: #23720

- - - - -
09c6759e by Matthew Pickering at 2023-08-16T09:35:04-04:00
configure: Fix `-Wl,--no-as-needed` check

The check was failing because the args supplied by $$1 were quoted which
failed because then the C compiler thought they were an input file.

Fixes #23720

- - - - -
2129678b by Matthew Pickering at 2023-08-16T09:35:04-04:00
configure: Add flag which turns ghc-toolchain check into error

We want to catch these errors in CI, but first we need to a flag which
turns this check into an error.

- - - - -
6e2aa8e0 by Matthew Pickering at 2023-08-16T09:35:04-04:00
ci: Enable --enable-strict-ghc-toolchain-check for all CI jobs

This will cause any CI job to fail if we have a mismatch between what
ghc-toolchain reports and what ./configure natively reports. Fixing
these kinds of issues is highest priority for 9.10 release.

- - - - -
12d39e24 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00
Pass user-specified options to ghc-toolchain

The current user interface to configuring target toolchains is `./configure`.

In !9263 we added a new tool to configure target toolchains called
`ghc-toolchain`, but the blessed way of creating these toolchains is
still through configure.

However, we were not passing the user-specified options given with the
`./configure` invocation to the ghc-toolchain tool.

This commit remedies that by storing the user options and environment
variables in USER_* variables, which then get passed to GHC-toolchain.

The exception to the rule is the windows bundled toolchain, which
overrides the USER_* variables with whatever flags the windows bundled
toolchain requires to work.
We consider the bundled toolchain to be effectively the user specifying
options, since the actual user delegated that configuration work.

Closes #23678

- - - - -
f7b3c3a0 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00
ghc-toolchain: Parse javascript and ghcjs as a Arch and OS

- - - - -
8a0ae4ee by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00
ghc-toolchain: Fix ranlib option

- - - - -
31e9ec96 by Rodrigo Mesquita at 2023-08-16T09:35:04-04:00
Check Link Works with -Werror

- - - - -
bc1998b3 by Matthew Pickering at 2023-08-16T09:35:04-04:00
Only check for no_compact_unwind support on darwin

While writing ghc-toolchain we noticed that the
FP_PROG_LD_NO_COMPACT_UNWIND check is subtly wrong. Specifically, we
pass -Wl,-no_compact_unwind to cc. However, ld.gold interprets this as
-n o_compact_unwind, which is a valid argument.

Fixes #23676

- - - - -
0283f36e by Matthew Pickering at 2023-08-16T09:35:04-04:00
Add some javascript special cases to ghc-toolchain

On javascript there isn't a choice of toolchain but some of the
configure checks were not accurately providing the correct answer.

1. The linker was reported as gnu LD because the --version output
   mentioned gnu LD.
2. The --target flag makes no sense on javascript but it was just
   ignored by the linker, so we add a special case to stop ghc-toolchain
   thinking that emcc supports --target when used as a linker.

- - - - -
a48ec5f8 by Matthew Pickering at 2023-08-16T09:35:04-04:00
check for emcc in gnu_LD check

- - - - -
50df2e69 by Matthew Pickering at 2023-08-16T09:35:04-04:00
Add ldOverrideWhitelist to only default to ldOverride on windows/linux

On some platforms - ie darwin, javascript etc we really do not want to
allow the user to use any linker other than the default one as this
leads to all kinds of bugs. Therefore it is a bit more prudant to add a
whitelist which specifies on which platforms it might be possible to use
a different linker.

- - - - -
a669a39c by Matthew Pickering at 2023-08-16T09:35:04-04:00
Fix plaform glob in FPTOOLS_SET_C_LD_FLAGS

A normal triple may look like

x86_64-unknown-linux

but when cross-compiling you get $target set to a quad such as..

aarch64-unknown-linux-gnu

Which should also match this check.

- - - - -
c52b6769 by Matthew Pickering at 2023-08-16T09:35:04-04:00
ghc-toolchain: Pass ld-override onto ghc-toolchain

- - - - -
039b484f by Matthew Pickering at 2023-08-16T09:35:04-04:00
ld override: Make whitelist override user given option

- - - - -
d2b63cbc by Matthew Pickering at 2023-08-16T09:35:05-04:00
ghc-toolchain: Add format mode to normalise differences before diffing.

The "format" mode takes an "--input" and "--ouput" target file and
formats it.

This is intended to be useful on windows where the
configure/ghc-toolchain target files can't be diffed very easily because
the path separators are different.

- - - - -
f2b39e4a by Matthew Pickering at 2023-08-16T09:35:05-04:00
ghc-toolchain: Bump ci-images commit to get new ghc-wasm-meta

We needed to remove -Wno-unused-command-line-argument from the arguments
passed in order for the configure check to report correctly.

See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10976#note_516335

- - - - -
92103830 by Matthew Pickering at 2023-08-16T09:35:05-04:00
configure: MergeObjsCmd - distinguish between empty string and unset variable

If `MergeObjsCmd` is explicitly set to the empty string then we should
assume that MergeObjs is just not supported.

This is especially important for windows where we set MergeObjsCmd to ""
in m4/fp_setup_windows_toolchain.m4.

- - - - -
3500bb2c by Matthew Pickering at 2023-08-16T09:35:05-04:00
configure: Add proper check to see if object merging works

- - - - -
08c9a014 by Matthew Pickering at 2023-08-16T09:35:05-04:00
ghc-toolchain: If MergeObjsCmd is not set, replace setting with Nothing

If the user explicitly chooses to not set a MergeObjsCmd then it is
correct to use Nothing for tgtMergeObjs field in the Target file.

- - - - -
c9071d94 by Matthew Pickering at 2023-08-16T09:35:05-04:00
HsCppArgs: Augment the HsCppOptions

This is important when we pass -I when setting up the windows toolchain.

- - - - -
294a6d80 by Matthew Pickering at 2023-08-16T09:35:05-04:00
Set USER_CPP_ARGS when setting up windows toolchain

- - - - -
bde4b5d4 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00
Improve handling of Cc as a fallback

- - - - -
f4c1c3a3 by Rodrigo Mesquita at 2023-08-16T09:35:05-04:00
ghc-toolchain: Configure Cpp and HsCpp correctly when user specifies flags

In ghc-toolchain, we were only /not/ configuring required flags when the
user specified any flags at all for the  of the HsCpp and Cpp tools.

Otherwise, the linker takes into consideration the user specified flags
to determine whether to search for a better linker implementation, but
already configured the remaining GHC and platform-specific flags
regardless of the user options.

Other Tools consider the user options as a baseline for further
configuration (see `findProgram`), so #23689 is not applicable.

Closes #23689

- - - - -
bfe4ffac by Matthew Pickering at 2023-08-16T09:35:05-04:00
CPP_ARGS: Put new options after user specified options

This matches up with the behaviour of ghc-toolchain, so that the output
of both matches.

- - - - -
a6828173 by Gergő Érdi at 2023-08-16T09:35:41-04:00
If a defaulting plugin made progress, re-zonk wanteds before built-in defaulting

Fixes #23821.

- - - - -
e2b38115 by Sylvain Henry at 2023-08-17T07:54:06-04:00
JS: implement openat(AT_FDCWD...) (#23697)

Use `openSync` to implement `openat(AT_FDCWD...)`.

- - - - -
a975c663 by sheaf at 2023-08-17T07:54:47-04:00
Use unsatisfiable for missing methods w/ defaults

When a class instance has an Unsatisfiable constraint in its context
and the user has not explicitly provided an implementation of a method,
we now always provide a RHS of the form `unsatisfiable @msg`, even
if the method has a default definition available. This ensures that,
when deferring type errors, users get the appropriate error message
instead of a possible runtime loop, if class default methods were
defined recursively.

Fixes #23816

- - - - -
45ca51e5 by Ben Gamari at 2023-08-17T15:16:41-04:00
ghc-internal: Initial commit of the skeleton

- - - - -
88bbf8c5 by Ben Gamari at 2023-08-17T15:16:41-04:00
ghc-experimental: Initial commit

- - - - -
664468c0 by Ben Gamari at 2023-08-17T15:17:17-04:00
testsuite/cloneStackLib: Fix incorrect format specifiers

- - - - -
eaa835bb by Ben Gamari at 2023-08-17T15:17:17-04:00
rts/ipe: Fix const-correctness of IpeBufferListNode

Both info tables and the string table should be `const`

- - - - -
78f6f6fd by Ben Gamari at 2023-08-17T15:17:17-04:00
nonmoving: Drop dead debugging utilities

These are largely superceded by support in the ghc-utils GDB extension.

- - - - -
3f6e8f42 by Ben Gamari at 2023-08-17T15:17:17-04:00
nonmoving: Refactor management of mark thread

Here we refactor that treatment of the worker thread used by the
nonmoving GC for concurrent marking, avoiding creating a new thread with
every major GC cycle. As well, the new scheme is considerably easier to
reason about, consolidating all state in one place, accessed via a small
set of accessors with clear semantics.

- - - - -
88c32b7d by Ben Gamari at 2023-08-17T15:17:17-04:00
testsuite: Skip T23221 in nonmoving GC ways

This test is very dependent upon GC behavior.

- - - - -
381cfaed by Ben Gamari at 2023-08-17T15:17:17-04:00
ghc-heap: Don't expose stack dirty and marking fields

These are GC metadata and are not relevant to the end-user. Moreover,
they are unstable which makes ghc-heap harder to test than necessary.

- - - - -
16828ca5 by Luite Stegeman at 2023-08-21T18:42:53-04:00
bump process submodule to include macOS fix and JS support

- - - - -
b4d5f6ed by Matthew Pickering at 2023-08-21T18:43:29-04:00
ci: Add support for triggering test-primops pipelines

This commit adds 4 ways to trigger testing with test-primops.

1. Applying the ~test-primops label to a validate pipeline.
2. A manually triggered job on a validate pipeline
3. A nightly pipeline job
4. A release pipeline job

Fixes #23695

- - - - -
32c50daa by Matthew Pickering at 2023-08-21T18:43:29-04:00
Add test-primops label support

The test-primops CI job requires some additional builds in the
validation pipeline, so we make sure to enable these jobs when
test-primops label is set.

- - - - -
73ca8340 by Matthew Pickering at 2023-08-21T18:43:29-04:00
Revert "Aarch ncg: Optimize immediate use for address calculations"

This reverts commit 8f3b3b78a8cce3bd463ed175ee933c2aabffc631.

See #23793

- - - - -
5546ad9e by Matthew Pickering at 2023-08-21T18:43:29-04:00
Revert "AArch NCG: Pure refactor"

This reverts commit 00fb6e6b06598752414a0b9a92840fb6ca61338d.

See #23793

- - - - -
02dfcdc2 by Matthew Pickering at 2023-08-21T18:43:29-04:00
Revert "Aarch64 NCG: Use encoded immediates for literals."

This reverts commit 40425c5021a9d8eb5e1c1046e2d5fa0a2918f96c.

See #23793

-------------------------
Metric Increase:
    T4801
    T5321FD
    T5321Fun
-------------------------

- - - - -
7be4a272 by Matthew Pickering at 2023-08-22T08:55:20+01:00
ci: Remove manually triggered test-ci job

This doesn't work on slimmed down pipelines as the needed jobs don't
exist.

If you want to run test-primops then apply the label.

- - - - -
76a4d11b by Jaro Reinders at 2023-08-22T08:08:13-04:00
Remove Ptr example from roles docs

- - - - -
069729d3 by Bryan Richter at 2023-08-22T08:08:49-04:00
Guard against duplicate pipelines in forks

- - - - -
f861423b by Rune K. Svendsen at 2023-08-22T08:09:35-04:00
dump-decls: fix "Ambiguous module name"-error

Fixes errors of the following kind, which happen when dump-decls is run on a package that contains a module name that clashes with that of another package.

```
dump-decls: <no location info>: error:
    Ambiguous module name `System.Console.ANSI.Types':
      it was found in multiple packages:
      ansi-terminal-0.11.4 ansi-terminal-types-0.11.5
```

- - - - -
edd8bc43 by Krzysztof Gogolewski at 2023-08-22T12:31:20-04:00
Fix MultiWayIf linearity checking (#23814)

Co-authored-by: Thomas BAGREL <thomas.bagrel at tweag.io>

- - - - -
4ba088d1 by konsumlamm at 2023-08-22T12:32:02-04:00
Update `Control.Concurrent.*` documentation

- - - - -
015886ec by ARATA Mizuki at 2023-08-22T15:13:13-04:00
Support 128-bit SIMD on AArch64 via LLVM backend

- - - - -
52a6d868 by Krzysztof Gogolewski at 2023-08-22T15:13:51-04:00
Testsuite cleanup

- Remove misleading help text in perf_notes, ways are not metrics
- Remove no_print_summary - this was used for Phabricator
- In linters tests, run 'git ls-files' just once.
  Previously, it was called on each has_ls_files()
- Add ghc-prim.cabal to gitignore, noticed in #23726
- Remove ghc-prim.cabal, it was accidentally committed in 524c60c8cd

- - - - -
ab40aa52 by Alan Zimmerman at 2023-08-22T15:14:28-04:00
EPA: Use Introduce [DeclTag] in AnnSortKey

The AnnSortKey is used to keep track of the order of declarations for
printing when the container has split them apart.

This applies to HsValBinds and ClassDecl, ClsInstDecl.

When making modifications to the list of declarations, the new order
must be captured for when it must be printed. For each list of
declarations (binds and sigs for a HsValBind) we can just store the
list in order.

To recreate the list when printing, we must merge them, and this is
what the AnnSortKey records. It used to be indexed by SrcSpan, we now
simply index by a marker as to which list to take the next item from.

- - - - -
e7db36c1 by sheaf at 2023-08-23T08:41:28-04:00
Don't attempt pattern synonym error recovery

This commit gets rid of the pattern synonym error recovery mechanism
(recoverPSB). The rationale is that the fake pattern synonym binding
that the recovery mechanism introduced could lead to undesirable
knock-on errors, and it isn't really feasible to conjure up a
satisfactory binding as pattern synonyms can be used both in expressions
and patterns.
See Note [Pattern synonym error recovery] in GHC.Tc.TyCl.PatSyn.

It isn't such a big deal to eagerly fail compilation on a pattern synonym
that doesn't typecheck anyway.

Fixes #23467

- - - - -
6ccd9d65 by Ben Gamari at 2023-08-23T08:42:05-04:00
base: Don't use Data.ByteString.Internals.memcpy

This function is now deprecated from `bytestring`. Use
`Foreign.Marshal.Utils.copyBytes` instead.

Fixes #23880.

- - - - -
0bfa0031 by Matthew Pickering at 2023-08-23T13:43:48-04:00
hadrian: Uniformly pass buildOptions to all builders in runBuilder

In Builder.hs, runBuilderWith mostly ignores the buildOptions in BuildInfo.

This leads to hard to diagnose bugs as any build options you pass with
runBuilderWithCmdOptions are ignored for many builders.

Solution: Uniformly pass buildOptions to the invocation of cmd.

Fixes #23845

- - - - -
9cac8f11 by Matthew Pickering at 2023-08-23T13:43:48-04:00
Abstract windows toolchain setup

This commit splits up the windows toolchain setup logic into two
functions.

* FP_INSTALL_WINDOWS_TOOLCHAIN - deals with downloading the toolchain if
  it isn't already downloaded
* FP_SETUP_WINDOWS_TOOLCHAIN - sets the environment variables to point
  to the correct place

FP_SETUP_WINDOWS_TOOLCHAIN is abstracted from the location of the mingw
toolchain and also the eventual location where we will install the
toolchain in the installed bindist.

This is the first step towards #23608

- - - - -
6c043187 by Matthew Pickering at 2023-08-23T13:43:48-04:00
Generate build.mk for bindists

The config.mk.in script was relying on some variables which were
supposed to be set by build.mk but therefore never were when used to
install a bindist.

Specifically

* BUILD_PROF_LIBS to determine whether we had profiled libraries or not
* DYNAMIC_GHC_PROGRAMS to determine whether we had shared libraries or
  not

Not only were these never set but also not really accurate because you
could have shared libaries but still statically linked ghc executable.

In addition variables like GhcLibWays were just never used, so those
have been deleted from the script.

Now instead we generate a build.mk file which just directly specifies
which RtsWays we have supplied in the bindist and whether we have
DYNAMIC_GHC_PROGRAMS.

- - - - -
fe23629b by Matthew Pickering at 2023-08-23T13:43:48-04:00
hadrian: Add reloc-binary-dist-* targets

This adds a command line option to build a "relocatable" bindist.

The bindist is created by first creating a normal bindist and then
installing it using the `RelocatableBuild=YES` option. This creates a
bindist without any wrapper scripts pointing to the libdir.

The motivation for this feature is that we want to ship relocatable
bindists on windows and this method is more uniform than the ad-hoc
method which lead to bugs such as #23608 and #23476

The relocatable bindist can be built with the "reloc-binary-dist" target
and supports the same suffixes as the normal "binary-dist" command to
specify the compression style.

- - - - -
41cbaf44 by Matthew Pickering at 2023-08-23T13:43:48-04:00
packaging: Fix installation scripts on windows/RelocatableBuild case

This includes quite a lot of small fixes which fix the installation
makefile to work on windows properly. This also required fixing the
RelocatableBuild variable which seemed to have been broken for a long
while.

Sam helped me a lot writing this patch by providing a windows machine to
test the changes. Without him it would have taken ages to tweak
everything.

Co-authored-by: sheaf <sam.derbyshire at gmail.com>

- - - - -
03474456 by Matthew Pickering at 2023-08-23T13:43:48-04:00
ci: Build relocatable bindist on windows

We now build the relocatable bindist target on windows, which means we
test and distribute the new method of creating a relocatable bindist.

- - - - -
d0b48113 by Matthew Pickering at 2023-08-23T13:43:48-04:00
hadrian: Add error when trying to build binary-dist target on windows

The binary dist produced by `binary-dist` target doesn't work on windows
because of the wrapper script the makefile installs. In order to not
surprise any packagers we just give an error if someone tries to build
the old binary-dist target rather than the reloc-binary-dist target.

- - - - -
7cbf9361 by Matthew Pickering at 2023-08-23T13:43:48-04:00
hadrian: Remove query' logic to use tooldir

- - - - -
03fad42e by Matthew Pickering at 2023-08-23T13:43:48-04:00
configure: Set WindresCmd directly and removed unused variables

For some reason there was an indirection via the Windres variable before
setting WindresCmd. That indirection led to #23855.

I then also noticed that these other variables were just not used
anywhere when trying to work out what the correct condition was for this
bit of the configure script.

- - - - -
c82770f5 by sheaf at 2023-08-23T13:43:48-04:00
Apply shellcheck suggestion to SUBST_TOOLDIR
- - - - -
896e35e5 by sheaf at 2023-08-23T13:44:34-04:00
Compute hints from TcSolverReportMsg

This commit changes how hints are handled in conjunction with
constraint solver report messages.

Instead of storing `[GhcHint]` in the TcRnSolverReport error constructor,
we compute the hints depending on the underlying TcSolverReportMsg.
This disentangles the logic and makes it easier to add new hints for
certain errors.

- - - - -
a05cdaf0 by Alexander Esgen at 2023-08-23T13:45:16-04:00
users-guide: remove note about fatal Haddock parse failures

- - - - -
4908d798 by Ben Gamari at 2023-08-23T17:36:41-04:00
base: Introduce Data.Enum

- - - - -
f59707c7 by Ben Gamari at 2023-08-23T17:36:41-04:00
base: Add export list to GHC.Num.Integer

- - - - -
b1054053 by Ben Gamari at 2023-08-23T17:36:41-04:00
base: Add export list to GHC.Num

- - - - -
6baa481d by Ben Gamari at 2023-08-23T17:36:41-04:00
base: Add export list to GHC.Num.Natural

- - - - -
2ac15233 by Ben Gamari at 2023-08-23T17:36:41-04:00
base: Add export list to GHC.Float

- - - - -
f3c489de by Ben Gamari at 2023-08-23T17:36:41-04:00
base: Add export list to GHC.Real

- - - - -
94f59eaa by Ben Gamari at 2023-08-23T17:36:41-04:00
base: Eliminate module reexport in GHC.Exception

The metric increase here isn't strictly due to this commit but it's a
rather small, incidental change.

Metric Increase:
    T8095
    T13386

Metric Decrease:
    T8095
    T13386
    T18304

- - - - -
be1fc7df by Ben Gamari at 2023-08-23T17:36:41-04:00
base: Add disclaimers in internal modules

To warn users that these modules are internal and their interfaces may
change with little warning.

As proposed in Core Libraries Committee #146 [CLC146].

[CLC146]: https://github.com/haskell/core-libraries-committee/issues/146

- - - - -
0326f3f4 by sheaf at 2023-08-23T17:37:29-04:00
Bump Cabal submodule

We need to bump the Cabal submodule to include commit ec75950
which fixes an issue with a dodgy import Rep(..) which relied
on GHC bug #23570

- - - - -
0504cd08 by Facundo Domínguez at 2023-08-23T17:38:11-04:00
Fix typos in the documentation of Data.OldList.permutations
- - - - -
1420b8cb by Antoine Leblanc at 2023-08-24T16:18:17-04:00
Be more eager in TyCon boot validity checking

This commit performs boot-file consistency checking for TyCons into
checkValidTyCl. This ensures that we eagerly catch any mismatches,
which prevents the compiler from seeing these inconsistencies and
panicking as a result.

See Note [TyCon boot consistency checking] in GHC.Tc.TyCl.

Fixes #16127

- - - - -
d99c816f by Finley McIlwaine at 2023-08-24T16:18:55-04:00
Refactor estimation of stack info table provenance

This commit greatly refactors the way we compute estimated provenance for stack
info tables. Previously, this process was done using an entirely separate traversal
of the whole Cmm code stream to build the map from info tables to source locations.
The separate traversal is now fused with the Cmm code generation pipeline in
GHC.Driver.Main.

This results in very significant code generation speed ups when -finfo-table-map is
enabled. In testing, this patch reduces code generation times by almost 30% with
-finfo-table-map and -O0, and 60% with -finfo-table-map and -O1 or -O2 .

Fixes #23103

- - - - -
d3e0124c by Finley McIlwaine at 2023-08-24T16:18:55-04:00
Add a test checking overhead of -finfo-table-map

We want to make sure we don't end up with poor codegen performance resulting from
-finfo-table-map again as in #23103. This test adds a performance test tracking
total allocations while compiling ExactPrint with -finfo-table-map.

- - - - -
fcfc1777 by Ben Gamari at 2023-08-25T10:58:16-04:00
llvmGen: Add export list to GHC.Llvm.MetaData

- - - - -
5880fff6 by Ben Gamari at 2023-08-25T10:58:16-04:00
llvmGen: Allow LlvmLits in MetaExprs

This omission appears to be an oversight.

- - - - -
86ce92a2 by Ben Gamari at 2023-08-25T10:58:16-04:00
compiler: Move platform feature predicates to GHC.Driver.DynFlags

These are useful in `GHC.Driver.Config.*`.

- - - - -
a6a38742 by Ben Gamari at 2023-08-25T10:58:16-04:00
llvmGen: Introduce infrastructure for module flag metadata

- - - - -
e9af2cf3 by Ben Gamari at 2023-08-25T10:58:16-04:00
llvmGen: Don't pass stack alignment via command line

As of https://reviews.llvm.org/D103048 LLVM no longer supports the
`-stack-alignment=...` flag. Instead this information is passed via a
module flag metadata node.

This requires dropping support for LLVM 11 and 12.

Fixes #23870

- - - - -
a936f244 by Alan Zimmerman at 2023-08-25T10:58:56-04:00
EPA: Keep track of "in" token for WarningTxt category

A warning can now be written with a category, e.g.

    {-# WARNInG in "x-c" e "d" #-}

Keep track of the location of the 'in' keyword and string, as well as
the original SourceText of the label, in case it uses character escapes.

- - - - -
3df8a653 by Matthew Pickering at 2023-08-25T17:42:18-04:00
Remove redundant import in InfoTableProv

The copyBytes function is provided by the import of Foreign.

Fixes #23889

- - - - -
d6f807ec by Ben Gamari at 2023-08-25T17:42:54-04:00
gitlab/issue-template: Mention report-a-bug
- - - - -
50b9f75d by Artin Ghasivand at 2023-08-26T20:02:50+03:30
Added StandaloneKindSignature examples to replace CUSKs ones

- - - - -
2f6309a4 by Vladislav Zavialov at 2023-08-27T03:47:37-04:00
Remove outdated CPP in compiler/* and template-haskell/*

The boot compiler was bumped to 9.4 in cebb5819b43.
There is no point supporting older GHC versions with CPP.

- - - - -
5248fdf7 by Zubin Duggal at 2023-08-28T15:01:09+05:30
testsuite: Add regression test for #23861

Simon says this was fixed by

commit 8d68685468d0b6e922332a3ee8c7541efbe46137
Author: sheaf <sam.derbyshire at gmail.com>
Date:   Fri Aug 4 15:28:45 2023 +0200

    Remove zonk in tcVTA

- - - - -
b6903f4d by Zubin Duggal at 2023-08-28T12:33:58-04:00
testsuite: Add regression test for #23864

Simon says this was fixed by

commit 59202c800f2c97c16906120ab2561f6e1556e4af
Author: Sebastian Graf <sebastian.graf at kit.edu>
Date:   Fri Mar 31 17:35:22 2023 +0200

    CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead

    We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now.
    The main reason is that it plays far better in conjunction with eta expansion
    (as we aim to do for arguments in CorePrep, #23083), because we can discard
    any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta`
    it's impossible to discard the argument.

- - - - -
9eecdf33 by sheaf at 2023-08-28T18:54:06+00:00
Remove ScopedTypeVariables => TypeAbstractions

This commit implements [amendment 604](https://github.com/ghc-proposals/ghc-proposals/pull/604/)
to [GHC proposal 448](https://github.com/ghc-proposals/ghc-proposals/pull/448)
by removing the implication of language extensions

  ScopedTypeVariables => TypeAbstractions

To limit breakage, we now allow type arguments in constructor patterns
when both ScopedTypeVariables and TypeApplications are enabled, but
we emit a warning notifying the user that this is deprecated behaviour
that will go away starting in GHC 9.12.

Fixes #23776

- - - - -
fadd5b4d by sheaf at 2023-08-28T18:54:06+00:00
.stderr: ScopedTypeVariables =/> TypeAbstractions

This commit accepts testsuite changes for the changes in the previous
commit, which mean that TypeAbstractions is no longer implied by
ScopedTypeVariables.

- - - - -
4f5fb500 by Greg Steuck at 2023-08-29T07:55:13-04:00
Repair `codes` test on OpenBSD by explicitly requesting extended RE

- - - - -
6bbde581 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00
Add test for #23540

`T23540.hs` makes use of `explainEv` from `HieQueries.hs`, so
`explainEv` has been moved to `TestUtils.hs`.

- - - - -
257bb3bd by Vasily Sterekhov at 2023-08-29T12:06:58-04:00
Add test for #23120

- - - - -
4f192947 by Vasily Sterekhov at 2023-08-29T12:06:58-04:00
Make some evidence uses reachable by toHie

Resolves #23540, #23120

This adds spans to certain expressions in the typechecker and renamer,
and lets 'toHie' make use of those spans. Therefore the relevant
evidence uses for the following syntax will now show up under the
expected nodes in 'HieAst's:

- Overloaded literals ('IsString', 'Num', 'Fractional')

- Natural patterns and N+k patterns ('Eq', 'Ord', and instances from the
  overloaded literals being matched on)

- Arithmetic sequences ('Enum')

- Monadic bind statements ('Monad')

- Monadic body statements ('Monad', 'Alternative')

- ApplicativeDo ('Applicative', 'Functor')

- Overloaded lists ('IsList')

Also see Note [Source locations for implicit function calls]

In the process of handling overloaded lists I added an extra 'SrcSpan'
field to 'VAExpansion' - this allows us to more accurately reconstruct
the locations from the renamer in 'rebuildHsApps'. This also happens to
fix #23120.

See the additions to Note [Looking through HsExpanded]

- - - - -
fe9fcf9d by Sylvain Henry at 2023-08-29T12:07:50-04:00
ghc-heap: rename C file (fix #23898)

- - - - -
b60d6576 by Krzysztof Gogolewski at 2023-08-29T12:08:29-04:00
Misc cleanup

- Builtin.PrimOps: ReturnsAlg was used only for unboxed tuples.
  Rename to ReturnsTuple.
- Builtin.Utils: use SDoc for a panic message.
  The comment about <<details unavailable>> was obsoleted by e8d356773b56.
- TagCheck: fix wrong logic. It was zipping a list 'args' with its
  version 'args_cmm' after filtering.
- Core.Type: remove an outdated 1999 comment about unlifted polymorphic types
- hadrian: remove leftover debugging print

- - - - -
3054fd6d by Krzysztof Gogolewski at 2023-08-29T12:09:08-04:00
Add a regression test for #23903

The bug has been fixed by commit bad2f8b8aa8424.

- - - - -
21584b12 by Ben Gamari at 2023-08-29T19:52:02-04:00
README: Refer to ghc-hq repository for contributor and governance information

- - - - -
e542d590 by sheaf at 2023-08-29T19:52:40-04:00
Export setInertSet from GHC.Tc.Solver.Monad

We used to export getTcSInerts and setTcSInerts from GHC.Tc.Solver.Monad.
These got renamed to getInertSet/setInertSet in e1590ddc. That commit also removed
the export of setInertSet, but that function is useful for the GHC API.

- - - - -
694ec5b1 by sheaf at 2023-08-30T10:18:32-04:00
Don't bundle children for non-parent Avails

We used to bundle all children of the parent Avail with things that
aren't the parent, e.g. with

  class C a where
    type T a
    meth :: ..

we would bundle the whole Avail (C, T, meth) with all of C, T and meth,
instead of only with C.

Avoiding this fixes #23570

- - - - -
d926380d by Krzysztof Gogolewski at 2023-08-30T10:19:08-04:00
Fix typos

- - - - -
d07080d2 by Josh Meredith at 2023-08-30T19:42:32-04:00
JS: Implement missing C functions `rename`, `realpath`, and `getcwd` (#23806)

- - - - -
e2940272 by David Binder at 2023-08-30T19:43:08-04:00
Bump submodules of hpc and hpc-bin to version 0.7.0.0

hpc 0.7.0.0 dropped SafeHaskell safety guarantees in order to simplify
compatibility with newer versions of the directory package which
dropped all SafeHaskell guarantees.

- - - - -
5d56d05c by David Binder at 2023-08-30T19:43:08-04:00
Bump hpc bound in ghc.cabal.in

- - - - -
99fff496 by Dominik Schrempf at 2023-08-31T00:04:46-04:00
ghc classes documentation: rm redundant comment

- - - - -
fe021bab by Dominik Schrempf at 2023-08-31T00:04:46-04:00
prelude documentation: various nits

- - - - -
48c84547 by Dominik Schrempf at 2023-08-31T00:04:46-04:00
integer documentation: minor corrections

- - - - -
20cd12f4 by Dominik Schrempf at 2023-08-31T00:04:46-04:00
real documentation: nits

- - - - -
dd39bdc0 by sheaf at 2023-08-31T00:05:27-04:00
Add a test for #21765

This issue (of reporting a constraint as being redundant even though
removing it causes typechecking to fail) was fixed in aed1974e.
This commit simply adds a regression test.

Fixes #21765

- - - - -
f1ec3628 by Andrew Lelechenko at 2023-08-31T23:53:30-04:00
Export foldl' from Prelude and bump submodules

See https://github.com/haskell/core-libraries-committee/issues/167 for discussion

Metric Decrease:
    T8095
    T13386
Metric Increase:
    T13386
    T8095

T8095 ghc/alloc decreased on x86_64, but increased on aarch64.
T13386 ghc/alloc decreased on x86_64-windows, but increased on other platforms.
Neither has anything to do with `foldl'`, so I conclude that both are flaky.

- - - - -
3181b97d by Gergő Érdi at 2023-08-31T23:54:06-04:00
Allow cross-tyvar defaulting proposals from plugins

Fixes #23832.

- - - - -
e4af506e by Sebastian Graf at 2023-09-01T14:29:12-04:00
Clarify Note [GlobalId/LocalId] after CorePrep (#23797)

Fixes #23797.

- - - - -
ac29787c by Sylvain Henry at 2023-09-01T14:30:02-04:00
Fix warning with UNPACK on sum type (#23921)

- - - - -
9765ac7b by Zubin Duggal at 2023-09-05T00:37:45-04:00
hadrian: track python dependencies in doc rules

- - - - -
1578215f by sheaf at 2023-09-05T00:38:26-04:00
Bump Haddock to fix #23616

This commit updates the Haddock submodule to include
the fix to #23616.

Fixes #23616

- - - - -
5a2fe35a by David Binder at 2023-09-05T00:39:07-04:00
Fix example in GHC user guide in SafeHaskell section

The example given in the SafeHaskell section uses an implementation of
Monad which no longer works. This MR removes the non-canonical return
instance and adds the necessary instances of Functor and Applicative.

- - - - -
291d81ae by Matthew Pickering at 2023-09-05T14:03:10-04:00
driver: Check transitive closure of haskell package dependencies when deciding whether to relink

We were previously just checking whether direct package dependencies had
been modified. This caused issues when compiling without optimisations
as we wouldn't relink the direct dependency if one of its dependenices
changed.

Fixes #23724

- - - - -
35da0775 by Krzysztof Gogolewski at 2023-09-05T14:03:47-04:00
Re-export GHC.Utils.Panic.Plain from GHC.Utils.Panic

Fixes #23930

- - - - -
3930d793 by Jaro Reinders at 2023-09-06T18:42:55-04:00
Make STG rewriter produce updatable closures

- - - - -
0104221a by Krzysztof Gogolewski at 2023-09-06T18:43:32-04:00
configure: update message to use hadrian (#22616)

- - - - -
b34f8586 by Alan Zimmerman at 2023-09-07T10:58:38-04:00
EPA: Incorrect locations for UserTyVar with '@'

In T13343.hs, the location for the @ is not within the span of the
surrounding UserTyVar.

  type Bad @v = (forall (v1 :: RuntimeRep) (a1 :: TYPE v). a1) :: TYPE v

Widen it so it is captured.

Closes #23887

- - - - -
8046f020 by Finley McIlwaine at 2023-09-07T10:59:15-04:00
Bump haddock submodule to fix #23920

Removes the fake export of `FUN` from Prelude. Fixes #23920.

Bumps haddock submodule.

- - - - -
e0aa8c6e by Krzysztof Gogolewski at 2023-09-07T11:00:03-04:00
Fix wrong role in mkSelCo_maybe

In the Lint failure in #23938, we start with a coercion Refl :: T a ~R T a,
and call mkSelCo (SelTyCon 1 nominal) Refl.
The function incorrectly returned Refl :: a ~R a. The returned role
should be nominal, according to the SelCo rule:

      co : (T s1..sn) ~r0 (T t1..tn)
      r = tyConRole tc r0 i
      ----------------------------------
      SelCo (SelTyCon i r) : si ~r ti

In this test case, r is nominal while r0 is representational.

- - - - -
1d92f2df by Gergő Érdi at 2023-09-08T04:04:30-04:00
If we have multiple defaulting plugins, then we should zonk in between them

after any defaulting has taken place, to avoid a defaulting plugin seeing
a metavariable that has already been filled.

Fixes #23821.

- - - - -
eaee4d29 by Gergő Érdi at 2023-09-08T04:04:30-04:00
Improvements to the documentation of defaulting plugins

Based on @simonpj's draft and comments in !11117

- - - - -
ede3df27 by Alan Zimmerman at 2023-09-08T04:05:06-04:00
EPA: Incorrect span for LWarnDec GhcPs

The code (from T23465.hs)

    {-# WARNInG in "x-c" e "d" #-}
    e = e

gives an incorrect span for the LWarnDecl GhcPs

Closes #23892

It also fixes the Test23465/Test23464 mixup

- - - - -
a0ccef7a by Krzysztof Gogolewski at 2023-09-08T04:05:42-04:00
Valid hole fits: don't suggest unsafeCoerce (#17940)

- - - - -
88b942c4 by Oleg Grenrus at 2023-09-08T19:58:42-04:00
Add warning for badly staged types.

Resolves #23829.

The stage violation results in out-of-bound names in splices.
Technically this is an error, but someone might rely on this!?

Internal changes:
- we now track stages for TyVars.
- thLevel (RunSplice _) = 0, instead of panic, as reifyInstances does
  in fact rename its argument type, and it can contain variables.

- - - - -
9861f787 by Ben Gamari at 2023-09-08T19:59:19-04:00
rts: Fix invalid symbol type

I suspect this code is dead since we haven't observed this failing
despite the obviously incorrect macro name.

- - - - -
03ed6a9a by Ben Gamari at 2023-09-08T19:59:19-04:00
testsuite: Add simple test exercising C11 atomics in GHCi

See #22012.

- - - - -
1aa5733a by Ben Gamari at 2023-09-08T19:59:19-04:00
rts/RtsSymbols: Add AArch64 outline atomic operations

Fixes #22012 by adding the symbols described in
https://github.com/llvm/llvm-project/blob/main/llvm/docs/Atomics.rst#libcalls-atomic.

Ultimately this would be better addressed by #22011, but this is a first
step in the right direction and fixes the immediate symptom.

Note that we dropped the `__arch64_cas16` operations as these provided
by all platforms's compilers. Also, we don't link directly against the
libgcc/compiler-rt definitions but rather provide our own wrappers to
work around broken toolchains (e.g. https://bugs.gentoo.org/868018).

Generated via https://gitlab.haskell.org/ghc/ghc/-/snippets/5733.

- - - - -
8f7d3041 by Matthew Pickering at 2023-09-08T19:59:55-04:00
ci: Build debian12 and fedora38 bindists

This adds builds for the latest releases for fedora and debian

We build these bindists in nightly and release pipelines.

- - - - -
a1f0d55c by Felix Leitz at 2023-09-08T20:00:37-04:00
Fix documentation around extension implication for MultiParamTypeClasses/ConstrainedClassMethods.

- - - - -
98166389 by Teo Camarasu at 2023-09-12T04:30:54-04:00
docs: move -xn flag beside --nonmoving-gc

It makes sense to have these beside each other as they are aliases.

- - - - -
f367835c by Teo Camarasu at 2023-09-12T04:30:55-04:00
nonmoving: introduce a family of dense allocators

Supplement the existing power 2 sized nonmoving allocators with a family
of dense allocators up to a configurable threshold.

This should reduce waste from rounding up block sizes while keeping the
amount of allocator sizes manageable.

This patch:
  - Adds a new configuration option `--nonmoving-dense-allocator-count`
    to control the amount of these new dense allocators.
  - Adds some constants to `NonmovingAllocator` in order to keep
    marking fast with the new allocators.

Resolves #23340

- - - - -
2b07bf2e by Teo Camarasu at 2023-09-12T04:30:55-04:00
Add changelog entry for #23340

- - - - -
f96fe681 by sheaf at 2023-09-12T04:31:44-04:00
Use printGhciException in run{Stmt, Decls}

When evaluating statements in GHCi, we need to use printGhciException
instead of the printException function that GHC provides in order to
get the appropriate error messages that are customised for ghci use.

- - - - -
d09b932b by psilospore at 2023-09-12T04:31:44-04:00
T23686: Suggest how to enable Language Extension when in ghci
Fixes #23686

- - - - -
da30f0be by Matthew Craven at 2023-09-12T04:32:24-04:00
Unarise: Split Rubbish literals in function args

Fixes #23914.  Also adds a check to STG lint that
these args are properly unary or nullary after unarisation

- - - - -
261b6747 by Matthew Pickering at 2023-09-12T04:33:04-04:00
darwin: Bump MAXOSX_DEPLOYMENT_TARGET to 10.13

This bumps the minumum supported version to 10.13 (High Sierra) which is
6 years old at this point.

Fixes #22938

- - - - -
f418f919 by Mario Blažević at 2023-09-12T04:33:45-04:00
Fix TH pretty-printing of nested GADTs, issue #23937

This commit fixes `Language.Haskell.TH.Ppr.pprint` so that it correctly
pretty-prints GADTs declarations contained within data family instances.

Fixes #23937

- - - - -
d7a64753 by John Ericson at 2023-09-12T04:34:20-04:00
Put hadrian non-bootstrap plans through `jq`

This makes it possible to review changes with conventional diffing
tools.

This is picking up where ad8cfed4195b1bbfc15b841f010e75e71f63157d left
off.

- - - - -
ff0a709a by Sylvain Henry at 2023-09-12T08:46:28-04:00
JS: fix some tests

- Tests using Setup programs need to pass --with-hc-pkg
- Several other fixes

See https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend/bug_triage
for the current status

- - - - -
fc86f0e7 by Krzysztof Gogolewski at 2023-09-12T08:47:04-04:00
Fix in-scope set assertion failure (#23918)

Patch by Simon

- - - - -
21a906c2 by Matthew Pickering at 2023-09-12T17:21:04+02:00
Add -Winconsistent-flags warning

The warning fires when inconsistent command line flags are passed.

For example:

* -dynamic-too and -dynamic
* -dynamic-too on windows
* -O and --interactive
* etc

This is on by default and allows users to control whether the warning is
displayed and whether it should be an error or not.

Fixes #22572

- - - - -
dfc4f426 by Krzysztof Gogolewski at 2023-09-12T20:31:35-04:00
Avoid serializing BCOs with the internal interpreter

Refs #23919

- - - - -
9217950b by Finley McIlwaine at 2023-09-13T08:06:03-04:00
Fix numa auto configure

- - - - -
98e7c1cf by Simon Peyton Jones at 2023-09-13T08:06:40-04:00
Add -fno-cse to T15426 and T18964

This -fno-cse change is to avoid these performance tests depending on
flukey CSE stuff.  Each contains several independent tests, and we don't
want them to interact.

See #23925.

By killing CSE we expect a 400% increase in T15426, and 100% in T18964.

Metric Increase:
    T15426
    T18964

- - - - -
236a134e by Simon Peyton Jones at 2023-09-13T08:06:40-04:00
Tiny refactor

canEtaReduceToArity was only called internally, and always with
two arguments equal to zero.  This patch just specialises the
function, and renames it to cantEtaReduceFun.

No change in behaviour.

- - - - -
56b403c9 by Ben Gamari at 2023-09-13T19:21:36-04:00
spec-constr: Lift argument limit for SPEC-marked functions

When the user adds a SPEC argument to a function, they are informing us
that they expect the function to be specialised. However, previously
this instruction could be preempted by the specialised-argument limit
(sc_max_args). Fix this.

This fixes #14003.

- - - - -
6840012e by Simon Peyton Jones at 2023-09-13T19:22:13-04:00
Fix eta reduction

Issue #23922 showed that GHC was bogusly eta-reducing a join point.
We should never eta-reduce (\x -> j x) to j, if j is a join point.

It is extremly difficult to trigger this bug.  It took me 45 mins of
trying to make a small tests case, here immortalised as T23922a.

- - - - -
e5c00092 by Andreas Klebinger at 2023-09-14T08:57:43-04:00
Profiling: Properly escape characters when using `-pj`.

There are some ways in which unusual characters like quotes or others
can make it into cost centre names. So properly escape these.

Fixes #23924

- - - - -
ec490578 by Ellie Hermaszewska at 2023-09-14T08:58:24-04:00
Use clearer example variable names for bool eliminator

- - - - -
5126a2fe by Sylvain Henry at 2023-09-15T11:18:02-04:00
Add missing int64/word64-to-double/float rules (#23907)

CLC proposal: https://github.com/haskell/core-libraries-committee/issues/203

- - - - -
566ef411 by Mario Blažević at 2023-09-15T11:18:43-04:00
Fix and test TH pretty-printing of type operator role declarations

This commit fixes and tests `Language.Haskell.TH.Ppr.pprint` so that it
correctly pretty-prints `type role` declarations for operator names.

Fixes #23954

- - - - -
8e05c54a by Simon Peyton Jones at 2023-09-16T01:42:33-04:00
Use correct FunTyFlag in adjustJoinPointType

As the Lint error in #23952 showed, the function adjustJoinPointType
was failing to adjust the FunTyFlag when adjusting the type.

I don't think this caused the seg-fault reported in the ticket,
but it is definitely.  This patch fixes it.

It is tricky to come up a small test case; Krzysztof came up with
this one, but it only triggers a failure in GHC 9.6.

- - - - -
778c84b6 by Pierre Le Marre at 2023-09-16T01:43:15-04:00
Update to Unicode 15.1.0

See: https://www.unicode.org/versions/Unicode15.1.0/

- - - - -
f9d79a6c by Alan Zimmerman at 2023-09-18T00:00:14-04:00
EPA: track unicode version for unrestrictedFunTyCon

Closes #23885

Updates haddock submodule

- - - - -
9374f116 by Andrew Lelechenko at 2023-09-18T00:00:54-04:00
Bump parsec submodule to allow text-2.1 and bytestring-0.12

- - - - -
7ca0240e by Ben Gamari at 2023-09-18T15:16:48-04:00
base: Advertise linear time of readFloat

As noted in #23538, `readFloat` has runtime that scales nonlinearly in
the size of its input. Consequently, its use on untrusted input can
be exploited as a denial-of-service vector. Point this out and suggest
use of `read` instead.

See #23538.

- - - - -
f3f58f13 by Simon Peyton Jones at 2023-09-18T15:17:24-04:00
Remove dead code GHC.CoreToStg.Prep.canFloat

This function never fires, so we can delete it: #23965.

- - - - -
ccab5b15 by Ben Gamari at 2023-09-18T15:18:02-04:00
base/changelog: Move fix for #23907 to 9.8.1 section

Since the fix was backported to 9.8.1

- - - - -
51b57d65 by Matthew Pickering at 2023-09-19T08:44:31-04:00
Add aarch64 alpine bindist

This is dynamically linked and makes creating statically linked
executables more straightforward.

Fixes #23482

- - - - -
02c87213 by Matthew Pickering at 2023-09-19T08:44:31-04:00
Add aarch64-deb11 bindist

This adds a debian 11 release job for aarch64.

Fixes #22005

- - - - -
8b61dfd6 by Alexis King at 2023-09-19T08:45:13-04:00
Don’t store the async exception masking state in CATCH frames

- - - - -
86d2971e by doyougnu at 2023-09-19T19:08:19-04:00
compiler,ghci: error codes link to HF error index

closes: #23259

- adds -fprint-error-index-links={auto|always|never} flag

- - - - -
5f826c18 by sheaf at 2023-09-19T19:09:03-04:00
Pass quantified tyvars in tcDefaultAssocDecl

This commit passes the correct set of quantified type variables written
by the user in associated type default declarations for validity
checking. This ensures that validity checking of associated type defaults
mirrors that of standalone type family instances.

Fixes #23768 (see testcase T23734 in subsequent commit)

- - - - -
aba18424 by sheaf at 2023-09-19T19:09:03-04:00
Avoid panic in mkGADTVars

This commit avoids panicking in mkGADTVars when we encounter
a type variable as in #23784 that is bound by a user-written
forall but not actually used.

Fixes #23784

- - - - -
a525a92a by sheaf at 2023-09-19T19:09:03-04:00
Adjust reporting of unused tyvars in data FamInsts

This commit adjusts the validity checking of data family
instances to improve the reporting of unused type variables.

See Note [Out of scope tvs in data family instances] in GHC.Tc.Validity.

The problem was that, in a situation such as

  data family D :: Type
  data instance forall (d :: Type). D = MkD

the RHS passed to 'checkFamPatBinders' would be the TyCon app

  R:D d

which mentions the type variable 'd' quantified in the user-written
forall. Thus, when computing the set of unused type variables in
the RHS of the data family instance, we would find that 'd' is used,
and report a strange error message that would say that 'd' is not
bound on the LHS.

To fix this, we special-case the data-family instance case,
manually extracting all the type variables that appear in the
arguments of all the data constructores of the data family instance.

Fixes #23778

- - - - -
28dd52ee by sheaf at 2023-09-19T19:09:03-04:00
Unused tyvars in FamInst: only report user tyvars

This commit changes how we perform some validity checking for
coercion axioms to mirror how we handle default declarations for
associated type families. This allows us to keep track of whether
type variables in type and data family instances were user-written
or not, in order to only report the user-written ones in
"unused type variable" error messages.

Consider for example:

  {-# LANGUAGE PolyKinds #-}
  type family F
  type instance forall a. F = ()

In this case, we get two quantified type variables,
(k :: Type) and (a :: k); the second being user-written, but the first
is introduced by the typechecker. We should only report 'a' as being
unused, as the user has no idea what 'k' is.

Fixes #23734

- - - - -
1eed645c by sheaf at 2023-09-19T19:09:03-04:00
Validity: refactor treatment of data families

This commit refactors the reporting of unused type variables in type
and data family instances to be more principled. This avoids ad-hoc
logic in the treatment of data family instances.

- - - - -
35bc506b by John Ericson at 2023-09-19T19:09:40-04:00
Remove `ghc-cabal`

It is dead code since the Make build system was removed.

I tried to go over every match of `git grep -i ghc-cabal` to find other
stray bits. Some of those might be workarounds that can be further
removed.

- - - - -
665ca116 by John Paul Adrian Glaubitz at 2023-09-19T19:10:39-04:00
Re-add unregisterised build support for sparc and sparc64

Closes #23959

- - - - -
142f8740 by Matthew Pickering at 2023-09-19T19:11:16-04:00
Bump ci-images to use updated version of Alex

Fixes #23977

- - - - -
fa977034 by John Ericson at 2023-09-21T12:55:25-04:00
Use Cabal 3.10 for Hadrian

We need the newer version for `CABAL_FLAG_*` env vars for #17191.

- - - - -
a5d22cab by John Ericson at 2023-09-21T12:55:25-04:00
hadrian: `need` any `configure` script we will call

When the script is changed, we should reconfigure.

- - - - -
db882b57 by John Ericson at 2023-09-21T12:55:25-04:00
hadrian: Make it easier to debug Cabal configure

Right now, output is squashed. This make per-package configure scripts
extremely hard to maintain, because we get vague "library is missing"
errors when the actually probably is usually completely unrelated except
for also involving the C/C++ toolchain.

(I can always pass `-VVV` to Hadrian locally, but these errors are
subtle and I often cannot reproduce them locally!)

`--disable-option-checking` was added back in
75c6e0684dda585c37b4ac254cd7a13537a59a91 but seems to be a bit overkill;
if other flags are passed that are not recognized behind the two from
Cabal mentioned in the former comment, we *do* want to know about it.

- - - - -
7ed65f5a by John Ericson at 2023-09-21T12:55:25-04:00
hadrian: Increase verbosity of certain cabal commands

This is a hack to get around the cabal function we're calling
*decreasing* the verbosity it passes to another function, which is the
stuff we often actually care about. Sigh.

Keeping this a separate commit so if this makes things too verbose it is
easy to revert.

- - - - -
a4fde569 by John Ericson at 2023-09-21T12:55:25-04:00
rts: Move most external symbols logic to the configure script

This is much more terse because we are programmatically handling the
leading underscore.

`findPtr` however is still handled in the Cabal file because we need a
newer Cabal to pass flags to the configure script automatically.

Co-Authored-By: Ben Gamari <ben at well-typed.com>

- - - - -
56cc85fb by Andrew Lelechenko at 2023-09-21T12:56:21-04:00
Bump Cabal submodule to allow text-2.1 and bytestring-0.12

- - - - -
0cd6148c by Matthew Pickering at 2023-09-21T12:56:21-04:00
hadrian: Generate Distribution/Fields/Lexer.x before creating a source-dist

- - - - -
b10ba6a3 by Andrew Lelechenko at 2023-09-21T12:56:21-04:00
Bump hadrian's index-state to upgrade alex at least to 3.2.7.3

- - - - -
11ecc37b by Luite Stegeman at 2023-09-21T12:57:03-04:00
JS: correct file size and times

Programs produced by the JavaScript backend were returning
incorrect file sizes and modification times, causing cabal
related tests to fail.

This fixes the problem and adds an additional test that verifies
basic file information operations.

fixes #23980

- - - - -
b35fd2cd by Ben Gamari at 2023-09-21T12:57:39-04:00
gitlab-ci: Drop libiserv from upload_ghc_libs

libiserv has been merged into the ghci package.

- - - - -
37ad04e8 by Ben Gamari at 2023-09-21T12:58:15-04:00
testsuite: Fix Windows line endings

- - - - -
5795b365 by Ben Gamari at 2023-09-21T12:58:15-04:00
testsuite: Use makefile_test

- - - - -
15118740 by Ben Gamari at 2023-09-21T12:58:55-04:00
system-cxx-std-lib: Add license and description
- - - - -
0208f1d5 by Ben Gamari at 2023-09-21T12:59:33-04:00
gitlab/issue-templates: Rename bug.md -> default.md

So that it is visible by default.

- - - - -
23cc3f21 by Andrew Lelechenko at 2023-09-21T20:18:11+01:00
Bump submodule text to 2.1

- - - - -
b8e4fe23 by Andrew Lelechenko at 2023-09-22T20:05:05-04:00
Bump submodule unix to 2.8.2.1

- - - - -
54b2016e by John Ericson at 2023-09-23T11:40:41-04:00
Move lib{numa,dw} defines to RTS configure

Clean up the m4 to handle the auto case always and be more consistent.
Also simplify the CPP --- we should always have both headers if we are
using libnuma.

"side effects" (AC_DEFINE, and AC_SUBST) are removed from the macros to
better separate searching from actions taken based on search results.
This might seem overkill now, but will make shuffling logic between
configure scripts easier later.

The macro comments are converted from `dnl` to `#` following the
recomendation in
https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Macro-Definitions.html

- - - - -
d51b601b by John Ericson at 2023-09-23T11:40:50-04:00
Shuffle libzstd configuring between scripts

Like the prior commit for libdw and libnuma, `AC_DEFINE` to RTS
configure, `AC_SUBST` goes to the top-level configure script, and the
documentation of the m4 macro is improved.

- - - - -
d1425af0 by John Ericson at 2023-09-23T11:41:03-04:00
Move `FP_ARM_OUTLINE_ATOMICS` to RTS configure

It is just `AC_DEFINE` it belongs there instead.

- - - - -
18de37e4 by John Ericson at 2023-09-23T11:41:03-04:00
Move mmap in the runtime linker check to the RTS configure

`AC_DEFINE` should go there instead.

- - - - -
74132c2b by Andrew Lelechenko at 2023-09-25T21:56:54-04:00
Elaborate comment on GHC_NO_UNICODE

- - - - -
de142aa2 by Ben Gamari at 2023-09-26T15:25:03-04:00
gitlab-ci: Mark T22012 as broken on CentOS 7

Due to #23979.

- - - - -
6a896ce8 by Teo Camarasu at 2023-09-26T15:25:39-04:00
hadrian: better error for failing to find file's dependencies

Resolves #24004

- - - - -
d697a6c2 by Stefan Holdermans at 2023-09-26T20:58:37+00:00
Refactor uses of `partitionEithers . map`

This patch changes occurences of the idiom
`partitionEithers (map f xs)` by the simpler form
`partitionWith f xs` where `partitionWith` is the utility function
defined in `GHC.Utils.Misc`.

Resolves: #23953

- - - - -
8a2968b7 by Stefan Holdermans at 2023-09-26T20:58:37+00:00
Refactor uses of `partitionEithers <$> mapM f xs`

This patch changes occurences of the idiom
`partitionEithers <$> mapM f xs` by the simpler form
`partitionWithM f xs` where `partitionWithM` is a utility function
newly added to `GHC.Utils.Misc`.

- - - - -
6a27eb97 by Stefan Holdermans at 2023-09-26T20:58:37+00:00
Mark `GHC.Utils.Misc.partitionWithM` as inlineable

This patch adds an `INLINEABLE` pragma for `partitionWithM` to ensure
that the right-hand side of the definition of this function remains
available for specialisation at call sites.

- - - - -
f1e5245a by David Binder at 2023-09-27T01:19:00-04:00
Add RTS option to supress tix file

- - - - -
1f43124f by David Binder at 2023-09-27T01:19:00-04:00
Add expected output to testsuite in test interface-stability/base-exports

- - - - -
b9d2c354 by David Binder at 2023-09-27T01:19:00-04:00
Expose HpcFlags and getHpcFlags from GHC.RTS.Flags

- - - - -
345675c6 by David Binder at 2023-09-27T01:19:00-04:00
Fix expected output of interface-stability test

- - - - -
146e1c39 by David Binder at 2023-09-27T01:19:00-04:00
Implement getHpcFlags

- - - - -
61ba8e20 by David Binder at 2023-09-27T01:19:00-04:00
Add section in user guide

- - - - -
ea05f890 by David Binder at 2023-09-27T01:19:01-04:00
Rename --emit-tix-file to --write-tix-file

- - - - -
cabce2ce by David Binder at 2023-09-27T01:19:01-04:00
Update the golden files for interface stability

- - - - -
1dbdb9d0 by Krzysztof Gogolewski at 2023-09-27T01:19:37-04:00
Refactor: introduce stgArgRep

The function 'stgArgType' returns the type in STG. But this violates
the abstraction: in STG we're supposed to operate on PrimReps.

This introduces
stgArgRep ty = typePrimRep (stgArgType ty)
stgArgRep1 ty = typePrimRep1 (stgArgType ty)
stgArgRep_maybe ty = typePrimRep_maybe (stgArgType ty)

stgArgType is still directly used for unboxed tuples (should be fixable), FFI
and in ticky.

- - - - -
b02f8042 by Mario Blažević at 2023-09-27T17:33:28-04:00
Fix TH pretty-printer's parenthesization

This PR Fixes `Language.Haskell.TH.Ppr.pprint` so it correctly emits parentheses where needed.

Fixes #23962, #23968, #23971, and #23986

- - - - -
79104334 by Krzysztof Gogolewski at 2023-09-27T17:34:04-04:00
Add a testcase for #17564

The code in the ticket relied on the behaviour of Derived constraints.
Derived constraints were removed in GHC 9.4 and now the code works
as expected.

- - - - -
d7a80143 by sheaf at 2023-09-28T03:25:53-04:00
lint-codes: add new modes of operation

This commit adds two new modes of operation to the lint-codes
utility:

  list - list all statically used diagnostic codes
  outdated - list all outdated diagnostic codes

The previous behaviour is now:

  test - test consistency and coverage of diagnostic codes

- - - - -
477d223c by sheaf at 2023-09-28T03:25:53-04:00
lint codes: avoid using git-grep

We manually traverse through the filesystem to find the diagnostic codes
embedded in .stdout and .stderr files, to avoid any issues with old
versions of grep.

Fixes #23843

- - - - -
a38ae69a by sheaf at 2023-09-28T03:25:53-04:00
lint-codes: add Hadrian targets

This commit adds new Hadrian targets:

  codes, codes:used - list all used diagnostic codes
  codes:outdated - list outdated diagnostic codes

This allows users to easily query GHC for used and outdated
diagnostic codes, e.g.

  hadrian/build -j --flavour=<..> codes

will list all used diagnostic codes in the command line by running
the lint-codes utility in the "list codes" mode of operation.

The diagnostic code consistency and coverage test is still run as usual,
through the testsuite:

  hadrian/build test --only="codes"

- - - - -
9cdd629b by Ben Gamari at 2023-09-28T03:26:29-04:00
hadrian: Install LICENSE files in bindists

Fixes #23548.

- - - - -
b8ebf876 by Matthew Craven at 2023-09-28T03:27:05-04:00
Fix visibility when eta-reducing a type lambda

Fixes #24014.

- - - - -
d3874407 by Torsten Schmits at 2023-09-30T16:08:10-04:00
Fix several mistakes around free variables in iface breakpoints

Fixes #23612 , #23607, #23998 and #23666.

MR: !11026

The fingerprinting logic in `Iface.Recomp` failed lookups when processing decls containing breakpoints for two reasons:

* IfaceBreakpoint created binders for free variables instead of expressions

* When collecting free names for the dependency analysis for fingerprinting, breakpoint FVs were skipped

- - - - -
ef5342cd by Simon Peyton Jones at 2023-09-30T16:08:48-04:00
Refactor to combine HsLam and HsLamCase

This MR is pure refactoring (#23916):
* Combine `HsLam` and `HsLamCase`
* Combine `HsCmdLam` and `HsCmdLamCase`

This just arranges to treat uniformly
   \x -> e
   \case pi -> ei
   \cases pis -> ie

In the exising code base the first is treated differently
to the latter two.

No change in behaviour.

More specifics:

* Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering
  * Lambda
  * `\case`
  * `\cases`

* The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases.

* Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one.

* Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.)

* Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument.

* Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument.

* Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one.

* Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one.

* In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one.

* In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one.

p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one.

Phew!

- - - - -
b048bea0 by Andreas Klebinger at 2023-09-30T16:09:24-04:00
Arm: Make ppr methods easier to use by not requiring NCGConfig

- - - - -
2adc0508 by Andreas Klebinger at 2023-09-30T16:09:24-04:00
AArch64: Fix broken conditional jumps for offsets >= 1MB

Rewrite conditional jump instructions with offsets >= 1MB to use unconditional jumps
to avoid overflowing the immediate.

Fixes #23746

- - - - -
1424f790 by Alan Zimmerman at 2023-09-30T16:10:00-04:00
EPA: Replace Monoid with NoAnn

We currently use the Monoid class as a constraint on Exact Print
Annotation functions, so we can use mempty. But this leads to
requiring Semigroup instances too, which do not always make sense.

Instead, introduce a class NoAnn, with a function noAnn analogous to
mempty.

Closes #20372

Updates haddock submodule

- - - - -
c1a3ecde by Ben Gamari at 2023-09-30T16:10:36-04:00
users-guide: Refactor handling of :base-ref: et al.

- - - - -
bc204783 by Richard Eisenberg at 2023-10-02T14:50:52+02:00
Simplify and correct nasty case in coercion opt

This fixes #21062.

No test case, because triggering this code seems challenging.

- - - - -
9c9ca67e by Andrew Lelechenko at 2023-10-04T05:42:28-04:00
Bump bytestring submodule to 0.12.0.2

- - - - -
4e46dc2b by Andrew Lelechenko at 2023-10-04T05:42:28-04:00
Inline bucket_match

- - - - -
f6b2751f by Ben Gamari at 2023-10-04T05:43:05-04:00
configure: Fix #21712 again

This is a bit of a shot in the dark to fix #24033, which appears to be
another instance of #21712. For some reason the ld-override logic
*still* appears to be active on Darwin targets (or at least one).
Consequently, on misconfigured systems we may choose a non-`ld64`
linker.

It's a bit unclear exactly what happened in #24033 but ultimately the
check added for #21712 was not quite right, checking for the
`ghc_host_os` (the value of which depends upon the bootstrap compiler)
instead of the target platform. Fix this.

Fixes #24033.

- - - - -
2f0a101d by Krzysztof Gogolewski at 2023-10-04T05:43:42-04:00
Add a regression test for #24029

- - - - -
8cee3fd7 by sheaf at 2023-10-04T05:44:22-04:00
Fix non-symbolic children lookup of fixity decl

The fix for #23664 did not correctly account for non-symbolic names
when looking up children of a given parent. This one-line fix changes
that.

Fixes #24037

- - - - -
a4785b33 by Cheng Shao at 2023-10-04T05:44:59-04:00
rts: fix incorrect ticket reference

- - - - -
e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00
users-guide: Fix discussion of -Wpartial-fields

 * fix a few typos
 * add a new example showing when the warning fires
 * clarify the existing example
 * point out -Wincomplete-record-selects

Fixes #24049.

- - - - -
8ff3134e by Matthew Pickering at 2023-10-05T05:34:58-04:00
Revert "Pass preprocessor options to C compiler when building foreign C files (#16737)"

This reverts commit 1c18d3b41f897f34a93669edaebe6069f319f9e2.

`-optP` should pass options to the preprocessor, that might be a very
different program to the C compiler, so passing the options to the C
compiler is likely to result in `-optP` being useless.

Fixes #17185 and #21291

- - - - -
8f6010b9 by Ben Gamari at 2023-10-05T05:35:36-04:00
rts/nonmoving: Fix on LLP64 platforms

Previously `NONMOVING_SEGMENT_MASK` and friends were defined with the `UL`
size suffix. However, this is wrong on LLP64 platforms like Windows,
where `long` is 32-bits.

Fixes #23003.
Fixes #24042.

- - - - -
f20d02f8 by Andreas Klebinger at 2023-10-05T05:36:14-04:00
Fix isAArch64Bitmask for 32bit immediates.

Fixes #23802

- - - - -
63afb701 by Bryan Richter at 2023-10-05T05:36:49-04:00
Work around perf note fetch failure

Addresses #24055.

- - - - -
242102f4 by Krzysztof Gogolewski at 2023-10-05T05:37:26-04:00
Add a test for #21348

- - - - -
7d390bce by Rewbert at 2023-10-05T05:38:08-04:00
Fixes #24046

- - - - -
69abb171 by Finley McIlwaine at 2023-10-06T14:06:28-07:00
Ensure unconstrained instance dictionaries get IPE info

In the `StgRhsCon` case of `GHC.Stg.Debug.collectStgRhs`, we were not coming up
with an initial source span based on the span of the binder, which was causing
instance dictionaries without dynamic superclass constraints to not have source
locations in their IPE info. Now they do.

Resolves #24005

- - - - -
390443b7 by Andreas Klebinger at 2023-10-07T10:00:20-04:00
rts: Split up rts/include/stg/MachRegs.h by arch

- - - - -
3685942f by Bryan Richter at 2023-10-07T10:00:56-04:00
Actually set hackage index state

Or at least, use a version of the cabal command that *claims* to set the
index state.

Time will tell.

- - - - -
46a0e5be by Bryan Richter at 2023-10-07T10:00:56-04:00
Update hackage index state

- - - - -
d4b037de by Bryan Richter at 2023-10-07T10:00:56-04:00
Ensure hadrian uses CI's hackage index state

- - - - -
e206be64 by Andrew Lelechenko at 2023-10-08T15:06:14-04:00
Do not use O_NONBLOCK on regular files or block devices

CLC proposal https://github.com/haskell/core-libraries-committee/issues/166

- - - - -
a06197c4 by David Binder at 2023-10-08T15:06:55-04:00
Update hpc-bin submodule to 0.69

- - - - -
ed6785b6 by David Binder at 2023-10-08T15:06:55-04:00
Update Hadrian with correct path to happy file for hpc-bin

- - - - -
94066d58 by Alan Zimmerman at 2023-10-09T21:35:53-04:00
EPA: Introduce HasAnnotation class

The class is defined as

    class HasAnnotation e where
      noAnnSrcSpan :: SrcSpan -> e

This generalises noAnnSrcSpan, and allows

    noLocA :: (HasAnnotation e) => a -> GenLocated e a
    noLocA = L (noAnnSrcSpan noSrcSpan)

- - - - -
8792a1bc by Ben Gamari at 2023-10-09T21:36:29-04:00
Bump unix submodule to v2.8.3.0

- - - - -
e96c51cb by Andreas Klebinger at 2023-10-10T16:44:27+01:00
Add a flag -fkeep-auto-rules to optionally keep auto-generated rules around.

The motivation for the flag is given in #21917.

- - - - -
3ed58cef by Matthew Pickering at 2023-10-10T19:01:22-04:00
hadrian: Add ghcToolchain to tool args list

This allows you to load ghc-toolchain and ghc-toolchain-bin into HLS.

- - - - -
476c02d4 by Matthew Pickering at 2023-10-10T19:01:22-04:00
ghc-toolchain: Normalise triple via config.sub

We were not normalising the target triple anymore like we did with the
old make build system.

Fixes #23856

- - - - -
303dd237 by Matthew Pickering at 2023-10-10T19:01:22-04:00
ghc-toolchain: Add missing vendor normalisation

This is copied from m4/ghc_convert_vendor.m4

Towards #23868

- - - - -
838026c9 by Matthew Pickering at 2023-10-10T19:01:22-04:00
ghc-toolchain: Add loongarch64 to parseArch

Towards #23868

- - - - -
1a5bc0b5 by Matthew Pickering at 2023-10-10T19:01:22-04:00
Add same LD hack to ghc-toolchain

In the ./configure script, if you pass the `LD` variable then this has
the effect of stopping use searching for a linker and hence passing
`-fuse-ld=...`.

We want to emulate this logic in ghc-toolchain, if a use explicilty
specifies `LD` variable then don't add `-fuse-ld=..` with the goal of
making ./configure and ghc-toolchain agree on which flags to use when
using the C compiler as a linker.

This is quite unsavoury as we don't bake the choice of LD into the
configuration anywhere but what's important for now is making
ghc-toolchain and ./configure agree as much as possible.

See #23857 for more discussion

- - - - -
42d50b5a by Ben Gamari at 2023-10-10T19:01:22-04:00
ghc-toolchain: Check for C99 support with -std=c99

Previously we failed to try enabling C99 support with `-std=c99`, as
`autoconf` attempts. This broke on older compilers (e.g. CentOS 7) which
don't enable C99 by default.

Fixes #23879.

- - - - -
da2961af by Matthew Pickering at 2023-10-10T19:01:22-04:00
ghc-toolchain: Add endianess check using __BYTE_ORDER__ macro

In very old toolchains the BYTE_ORDER macro is not set but thankfully
the __BYTE_ORDER__ macro can be used instead.

- - - - -
d8da73cd by Matthew Pickering at 2023-10-10T19:01:22-04:00
configure: AC_PATH_TARGET_TOOL for LD

We want to make sure that LD is set to an absolute path in order to be
consistent with the `LD=$(command -v ld)` call. The AC_PATH_TARGET_TOOL
macro uses the absolute path rather than AC_CHECK_TARGET_TOOL which
might use a relative path.

- - - - -
171f93cc by Matthew Pickering at 2023-10-10T19:01:22-04:00
ghc-toolchain: Check whether we need -std=gnu99 for CPP as well

In ./configure the C99 flag is passed to the C compiler when used as a C
preprocessor. So we also check the same thing in ghc-toolchain.

- - - - -
89a0918d by Matthew Pickering at 2023-10-10T19:01:22-04:00
Check for --target linker flag separately to C compiler

There are situations where the C compiler doesn't accept `--target` but
when used as a linker it does (but doesn't do anything most likely)

In particular with old gcc toolchains, the C compiler doesn't support
--target but when used as a linker it does.

- - - - -
37218329 by Matthew Pickering at 2023-10-10T19:01:22-04:00
Use Cc to compile test file in nopie check

We were attempting to use the C compiler, as a linker, to compile a file
in the nopie check, but that won't work in general as the flags we pass
to the linker might not be compatible with the ones we pass when using
the C compiler.

- - - - -
9b2dfd21 by Matthew Pickering at 2023-10-10T19:01:22-04:00
configure: Error when ghc-toolchain fails to compile

This is a small QOL change as if you are working on ghc-toolchain and it
fails to compile then configure will continue and can give you outdated
results.

- - - - -
1f0de49a by Matthew Pickering at 2023-10-10T19:01:22-04:00
configure: Check whether -no-pie works when the C compiler is used as a linker

`-no-pie` is a flag we pass when using the C compiler as a linker (see
pieCCLDOpts in GHC.Driver.Session) so we should test whether the C
compiler used as a linker supports the flag, rather than just the C
compiler.

- - - - -
62cd2579 by Matthew Pickering at 2023-10-10T19:01:22-04:00
ghc-toolchain: Remove javascript special case for --target detection

emcc when used as a linker seems to ignore the --target flag, and for
consistency with configure which now tests for --target, we remove this
special case.

- - - - -
0720fde7 by Ben Gamari at 2023-10-10T19:01:22-04:00
toolchain: Don't pass --target to emscripten toolchain

As noted in `Note [Don't pass --target to emscripten toolchain]`,
emscripten's `emcc` is rather inconsistent with respect to its treatment
of the `--target` flag. Avoid this by special-casing this toolchain
in the `configure` script and `ghc-toolchain`.

Fixes on aspect of #23744.

- - - - -
6354e1da by Matthew Pickering at 2023-10-10T19:01:22-04:00
hadrian: Don't pass `--gcc-options` as a --configure-arg to cabal configure

Stop passing -gcc-options which mixed together linker flags and
non-linker flags. There's no guarantee the C compiler will accept both
of these in each mode.

- - - - -
c00a4bd6 by Ben Gamari at 2023-10-10T19:01:22-04:00
configure: Probe stage0 link flags

For consistency with later stages and CC.

- - - - -
1f11e7c4 by Sebastian Graf at 2023-10-10T19:01:58-04:00
Stricter Binary.get in GHC.Types.Unit (#23964)

I noticed some thunking while looking at Core.
This change has very modest, but throughout positive ghc/alloc effect:

```
 hard_hole_fits(normal) ghc/alloc    283,057,664    281,620,872  -0.5%

              geo. mean                                          -0.1%
              minimum                                            -0.5%
              maximum                                            +0.0%
```

Fixes #23964.

- - - - -
a4f1a181 by Bryan Richter at 2023-10-10T19:02:37-04:00
rel_eng/upload.sh cleanups

- - - - -
80705335 by doyougnu at 2023-10-10T19:03:18-04:00
ci: add javascript label rule

This adds a rule which triggers the javascript job when the "javascript"
label is assigned to an MR.

- - - - -
a2c0fff6 by Matthew Craven at 2023-10-10T19:03:54-04:00
Make 'wWarningFlagsDeps' include every WarningFlag

Fixes #24071.

- - - - -
d055f099 by Jan Hrček at 2023-10-10T19:04:33-04:00
Fix pretty printing of overlap pragmas in TH splices (fixes #24074)

- - - - -
0746b868 by Andreas Klebinger at 2023-10-10T19:05:09-04:00
Aarch64 NCG: Use encoded immediates for literals.

Try to generate

    instr x2, <imm>

instead of

    mov x1, lit
    instr x2, x1

When possible. This get's rid if quite a few redundant
mov instructions.

I believe this causes a metric decrease for LargeRecords as
we reduce register pressure.

-------------------------
Metric Decrease:
    LargeRecord
-------------------------

- - - - -
739f4e6f by Andreas Klebinger at 2023-10-10T19:05:09-04:00
AArch NCG: Refactor getRegister'

Remove some special cases which can be handled just as well by the
generic case.

This increases code re-use while also fixing #23749. Since some of the
special case wasn't upholding Note [Signed arithmetic on AArch64].

- - - - -
1b213d33 by Andreas Klebinger at 2023-10-10T19:05:09-04:00
Aarch ncg: Optimize immediate use for address calculations

When the offset doesn't fit into the immediate we now just reuse the
general getRegister' code path which is well optimized to compute the
offset into a register instead of a special case for CmmRegOff.

This means we generate a lot less code under certain conditions which is
why performance metrics for these improve.

-------------------------
Metric Decrease:
    T4801
    T5321FD
    T5321Fun
-------------------------

- - - - -
b7df0732 by John Ericson at 2023-10-11T16:02:11-04:00
RTS configure: Move over mem management checks

These are for heap allocation, a strictly RTS concern.

All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
belongs in the RTS configure and should be safe to move without
modification.

The RTS configure one has a new
```
AC_CHECK_SIZEOF([void *])
```
that the top-level configure version didn't have, so that
`ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter
commits, that can go away.

Progress towards #17191

- - - - -
41130a65 by John Ericson at 2023-10-11T16:02:11-04:00
RTS configure: Move over `__thread` check

This used by (@bgamari thinks) the `GCThread` abstraction in the RTS.

All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
belongs in the RTS configure and should be safe to move without
modification.

Progress towards #17191

- - - - -
cc5ec2bd by John Ericson at 2023-10-11T16:02:11-04:00
RTS configure: Move over misc function checks

These are for general use in the RTS.

All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
belongs in the RTS configure and should be safe to move without
modification.

Progress towards #17191

- - - - -
809e7c2d by John Ericson at 2023-10-11T16:02:11-04:00
RTS configure: Move over `eventfd` check

This check is for the RTS part of the event manager and has a
corresponding part in `base`.

All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
belongs in the RTS configure and should be safe to move without
modification.

Progress towards #17191

- - - - -
58f3babf by John Ericson at 2023-10-11T16:02:48-04:00
Split `FP_CHECK_PTHREADS` and move part to RTS configure

`NEED_PTHREAD_LIB` is unused since
3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build
system), and so is no longer defined.

Progress towards #17191

- - - - -
e99cf237 by Moritz Angermann at 2023-10-11T16:03:24-04:00
nativeGen: section flags for .text$foo only

Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix
#22834 in !9810.

It does however add "xr" indiscriminatly to .text sections
even if splitSections is disabled. This leads to the assembler saying:

ghc_1.s:7849:0: error:
     Warning: Ignoring changed section attributes for .text
     |
7849 | .section .text,"xr"
     | ^

- - - - -
f383a242 by Sylvain Henry at 2023-10-11T16:04:04-04:00
Modularity: pass TempDir instead of DynFlags (#17957)

- - - - -
34fc28b0 by John Ericson at 2023-10-12T06:48:28-04:00
Test that functions from `mingwex` are available

Ryan wrote these two minimizations, but they never got added to the test
suite.

See #23309, #23378

Co-Authored-By: Ben Gamari <bgamari.foss at gmail.com>
Co-Authored-By: Ryan Scott <ryan.gl.scott at gmail.com>

- - - - -
bdb54a0e by John Ericson at 2023-10-12T06:48:28-04:00
Do not check for the `mingwex` library in `/configure`

See the recent discussion in !10360 --- Cabal will itself check for the
library for the packages that need it, and while the autoconf check
additionally does some other things like define a `HAS_LIBMINGWEX` C
Preprocessor macro, those other things are also unused and unneeded.

Progress towards #17191, which aims to get rid of `/configure` entirely.

- - - - -
43e814e1 by Ben Gamari at 2023-10-12T06:49:40-04:00
base: Introduce move modules into src

The only non-move changes here are whitespace changes to pass the
`whitespace` test and a few testsuite adaptations.

- - - - -
df81536f by Moritz Angermann at 2023-10-12T06:50:16-04:00
[PEi386 linker] Bounds check and null-deref guard

We should resonably be able to expect that we won't exceed the number of
sections if we assume to be dealing with legal object files. We can however
not guarantee that we get some negative values, and while we try to
special case most, we should exclude negative indexing into the sections
array.

We also need to ensure that we do not try to derefences targetSection,
if it is NULL, due to the switch statement.

- - - - -
c74c4f00 by John Ericson at 2023-10-12T10:31:13-04:00
Move apple compat check to RTS configure

- - - - -
c80778ea by John Ericson at 2023-10-12T10:31:13-04:00
Move clock/timer fun checks to RTS configure

Actual library check (which will set the Cabal flag) is left in the
top-level configure for now.

Progress towards #17191

- - - - -
7f9f2686 by John Ericson at 2023-10-12T10:31:13-04:00
Move visibility and "musttail" annotation checks to the RTS configure

All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
belongs in the RTS configure and should be safe to move without
modification.

Progress towards #17191

- - - - -
ffb3efe6 by John Ericson at 2023-10-12T10:31:13-04:00
Move leading underscore checks to RTS configure

`CabalLeadingUnderscore` is done via Hadrian already, so we can stop
`AC_SUBST`ing it completely.

- - - - -
25fa4b02 by John Ericson at 2023-10-12T10:31:13-04:00
Move alloca, fork, const, and big endian checks to RTS configure

All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
belongs in the RTS configure and should be safe to move without
modification.

- - - - -
5170f42a by John Ericson at 2023-10-12T10:31:13-04:00
Move libdl check to RTS configure

- - - - -
ea7a1447 by John Ericson at 2023-10-12T10:31:13-04:00
Adjust `FP_FIND_LIBFFI`

Just set vars, and `AC_SUBST` in top-level configure.

Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't
be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the
make build system).

- - - - -
f399812c by John Ericson at 2023-10-12T10:31:13-04:00
Split BFD support to RTS configure

The flag is still in the top-level configure, but the other checks
(which define various macros --- important) are in the RTS configure.

- - - - -
f64f44e9 by John Ericson at 2023-10-12T10:31:13-04:00
Split libm check between top level and RTS

- - - - -
dafc4709 by Moritz Angermann at 2023-10-12T10:31:49-04:00
CgUtils.fixStgRegStmt respect register width

This change ensure that the reg + offset computation is always of the
same size.  Before this we could end up with a 64bit register, and then
add a 32bit offset (on 32bit platforms).  This not only would fail type
sanity checking, but also incorrectly truncate 64bit values into 32bit
values silently on 32bit architectures.

- - - - -
9e6ef7ba by Matthew Pickering at 2023-10-12T20:35:00-04:00
hadrian: Decrease verbosity of cabal commands

In Normal, most tools do not produce output to stdout unless there are
error conditions.

Reverts 7ed65f5a1bc8e040e318ccff395f53a9bbfd8217

- - - - -
08fc27af by John Ericson at 2023-10-12T20:35:36-04:00
Do not substitute `@...@` for stage-specific values in cabal files

`rts` and `ghc-prim` now no longer have a `*.cabal.in` to set Cabal flag
defaults; instead manual choices are passed to configure in the usual
way.

The old way was fundamentally broken, because it meant we were baking
these Cabal files for a specific stage. Now we only do stage-agnostic
@...@ substitution in cabal files (the GHC version), and so all
stage-specific configuration is properly confined to `_build` and the
right stage dir.

Also `include-ghc-prim` is a flag that no longer exists for `ghc-prim`
(it was removed in 835d8ddbbfb11796ea8a03d1806b7cee38ba17a6) so I got
rid of it.

Co-Authored-By: Matthew Pickering <matthewtpickering at gmail.com>

- - - - -
a0ac8785 by Sebastian Graf at 2023-10-14T19:17:12-04:00
Fix restarts in .ghcid

Using the whole of `hadrian/` restarted in a loop for me.

- - - - -
fea9ecdb by Sebastian Graf at 2023-10-14T19:17:12-04:00
CorePrep: Refactor FloatingBind (#23442)

A drastically improved architecture for local floating in CorePrep
that decouples the decision of whether a float is going to be let- or case-bound
from how far it can float (out of strict contexts, out of lazy contexts, to
top-level).

There are a couple of new Notes describing the effort:

  * `Note [Floating in CorePrep]` for the overview
  * `Note [BindInfo and FloatInfo]` for the new classification of floats
  * `Note [Floats and FloatDecision]` for how FloatInfo is used to inform
    floating decisions

This is necessary ground work for proper treatment of Strict fields and
unlifted values at top-level.

Fixes #23442.

NoFib results (omitted = 0.0%):
```
--------------------------------------------------------------------------------
        Program         Allocs    Instrs
--------------------------------------------------------------------------------
         pretty           0.0%     -1.6%
            scc           0.0%     -1.7%
--------------------------------------------------------------------------------
            Min           0.0%     -1.7%
            Max           0.0%     -0.0%
 Geometric Mean          -0.0%     -0.0%
```

- - - - -
32523713 by Matthew Pickering at 2023-10-14T19:17:49-04:00
hadrian: Move ghcBinDeps into ghcLibDeps

This completes a5227080b57cb51ac34d4c9de1accdf6360b818b, the
`ghc-usage.txt` and `ghci-usage.txt` file are also used by the `ghc`
library so need to make sure they are present in the libdir even if we
are not going to build `ghc-bin`.

This also fixes things for cross compilers because the stage2
cross-compiler requires the ghc-usage.txt file, but we are using
the stage2 lib folder but not building stage3:exe:ghc-bin so
ghc-usage.txt was not being generated.

- - - - -
ec3c4488 by sheaf at 2023-10-14T19:18:29-04:00
Combine GREs when combining in mkImportOccEnv

In `GHC.Rename.Names.mkImportOccEnv`, we sometimes discard one import
item in favour of another, as explained in Note [Dealing with imports]
in `GHC.Rename.Names`. However, this can cause us to lose track of
important parent information.

Consider for example #24084:

  module M1 where { class C a where { type T a } }
  module M2 ( module M1 ) where { import M1 }
  module M3 where { import M2 ( C, T ); instance C () where T () = () }

When processing the import list of `M3`, we start off (for reasons that
are not relevant right now) with two `Avail`s attached to `T`, namely
`C(C, T)` and `T(T)`. We combine them in the `combine` function of
`mkImportOccEnv`; as described in Note [Dealing with imports] we discard
`C(C, T)` in favour of `T(T)`. However, in doing so, we **must not**
discard the information want that `C` is the parent of `T`. Indeed,
losing track of this information can cause errors when importing,
as we could get an error of the form

  ‘T’ is not a (visible) associated type of class ‘C’

We fix this by combining the two GREs for `T` using `plusGRE`.

Fixes #24084

- - - - -
257c2807 by Ilias Tsitsimpis at 2023-10-14T19:19:07-04:00
hadrian: Pass -DNOSMP to C compiler when needed

Hadrian passes the -DNOSMP flag to GHC when the target doesn't support
SMP, but doesn't pass it to CC as well, leading to the following
compilation error on mips64el:

| Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d
Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0
===> Command failed with error code: 1
In file included from rts/include/Stg.h:348,
                 from rts/include/Rts.h:38,
                 from rts/hooks/FlagDefaults.c:8:
rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture
  416 | #error memory barriers unimplemented on this architecture
      |  ^~~~~
rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture
  440 | #error memory barriers unimplemented on this architecture
      |  ^~~~~
rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture
  464 | #error memory barriers unimplemented on this architecture
      |  ^~~~~

The old make system correctly passed this flag to both GHC and CC [1].

Fix this error by passing -DNOSMP to CC as well.

[1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407

Closes #24082

- - - - -
13d3c613 by John Ericson at 2023-10-14T19:19:42-04:00
Users Guide: Drop dead code for Haddock refs to `parallel`

I noticed while working on !11451 that `@LIBRARY_parallel_UNIT_ID@` was
not substituted. It is dead code -- there is no `parallel-ref` usages
and it doesn't look like there ever was (going back to
3e5d0f188d6c8633e55e9ba6c8941c07e459fa4b), so let's delete it.

- - - - -
fe067577 by Sylvain Henry at 2023-10-18T19:40:25-04:00
Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066)

bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a".

- - - - -
cc1625b1 by Sylvain Henry at 2023-10-18T19:40:25-04:00
Bignum: fix right shift of negative BigNat with native backend

- - - - -
cbe4400d by Sylvain Henry at 2023-10-18T19:40:25-04:00
Rts: expose rtsOutOfBoundsAccess symbol

- - - - -
72c7380c by Sylvain Henry at 2023-10-18T19:40:25-04:00
Hadrian: enable `-fcheck-prim-bounds` in validate flavour

This allows T24066 to fail when the bug is present.

Otherwise the out-of-bound access isn't detected as it happens in
ghc-bignum which wasn't compiled with the bounds check.

- - - - -
f9436990 by John Ericson at 2023-10-18T19:41:01-04:00
Make Hadrian solely responsible for substituting `docs/users_guide/ghc_config.py.in`

Fixes #24091
Progress on #23966

Issue #24091 reports that `@ProjectVersion@` is no longer being
substituted in the GHC user's guide. I assume this is a recent issue,
but I am not sure how it's worked since
c1a3ecde720b3bddc2c8616daaa06ee324e602ab; it looks like both Hadrian and
configure are trying to substitute the same `.in` file!

Now only Hadrian does. That is better anyways; already something that
issue #23966 requested.

It seems like we were missing some dependencies in Hadrian. (I really,
really hate that this is possible!) Hopefully it is fixed now.

- - - - -
b12df0bb by John Ericson at 2023-10-18T19:41:37-04:00
`ghcversion.h`: No need to cope with undefined `ProjectPatchLevel*`

Since 4e6c80197f1cc46dfdef0300de46847c7cfbdcb0, these are guaranteed to
be defined. (Guaranteed including a test in the testsuite.)

- - - - -
0295375a by John Ericson at 2023-10-18T19:41:37-04:00
Generate `ghcversion.h` from a `.in` file

Now that there are no conditional sections (see the previous commit), we
can just a do simple substitution rather than pasting it together line
by line.

Progress on #23966

- - - - -
740a1b85 by Krzysztof Gogolewski at 2023-10-19T11:37:20-04:00
Add a regression test for #24064

- - - - -
921fbf2f by Hécate Moonlight at 2023-10-19T11:37:59-04:00
CLC Proposal #182: Export List from Data.List

Proposal link: https://github.com/haskell/core-libraries-committee/issues/182

- - - - -
4f02d3c1 by Sylvain Henry at 2023-10-20T04:01:32-04:00
rts: fix small argument passing on big-endian arch (fix #23387)

- - - - -
b86243b4 by Sylvain Henry at 2023-10-20T04:02:13-04:00
Interpreter: fix literal alignment on big-endian architectures (fix #19261)

Literals weren't correctly aligned on big-endian, despite what the
comment said.

- - - - -
a4b2ec47 by Sylvain Henry at 2023-10-20T04:02:54-04:00
Testsuite: recomp011 and recomp015 are fixed on powerpc

These tests have been fixed but not tested and re-enabled on big-endian
powerpc (see comments in #11260 and #11323)

- - - - -
fded7dd4 by Sebastian Graf at 2023-10-20T04:03:30-04:00
CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102)
- - - - -
02efc181 by John Ericson at 2023-10-22T02:48:55-04:00
Move function checks to RTS configure

Some of these functions are used in `base` too, but we can copy the
checks over to its configure if that's an issue.

- - - - -
5f4bccab by John Ericson at 2023-10-22T02:48:55-04:00
Move over a number of C-style checks to RTS configure

- - - - -
5cf04f58 by John Ericson at 2023-10-22T02:48:55-04:00
Move/Copy more `AC_DEFINE` to RTS config

Only exception is the LLVM version macros, which are used for GHC
itself.

- - - - -
b8ce5dfe by John Ericson at 2023-10-22T02:48:55-04:00
Define `TABLES_NEXT_TO_CODE` in the RTS configure

We create a new cabal flag to facilitate this.

- - - - -
4a40271e by John Ericson at 2023-10-22T02:48:55-04:00
Configure scripts: `checkOS`: Make a bit more robust

`mingw64` and `mingw32` are now both accepted for `OSMinGW32`. This
allows us to cope with configs/triples that we haven't normalized extra
being what GNU `config.sub` does.

- - - - -
16bec0a0 by John Ericson at 2023-10-22T02:48:55-04:00
Generate `ghcplatform.h` from RTS configure

We create a new cabal flag to facilitate this.

- - - - -
7dfcab2f by John Ericson at 2023-10-22T02:48:55-04:00
Get rid of all mention of `mk/config.h`

The RTS configure script is now solely responsible for managing its
headers; the top level configure script does not help.

- - - - -
c1e3719c by Cheng Shao at 2023-10-22T02:49:33-04:00
rts: drop stale mentions of MIN_UPD_SIZE

We used to have MIN_UPD_SIZE macro that describes the minimum reserved
size for thunks, so that the thunk can be overwritten in place as
indirections or blackholes. However, this macro has not been actually
defined or used anywhere since a long time ago; StgThunkHeader already
reserves a padding word for this purpose. Hence this patch which drops
stale mentions of MIN_UPD_SIZE.

- - - - -
d24b0d85 by Andrew Lelechenko at 2023-10-22T02:50:11-04:00
base changelog: move non-backported entries from 4.19 section to 4.20

Neither !10933 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Text.Read.Lex.html#numberToRangedRational)
nor !10189 (check https://hackage.haskell.org/package/base-4.19.0.0/docs/src/Data.List.NonEmpty.html#unzip)
were backported to `base-4.19.0.0`. Moving them to `base-4.20.0.0` section.

Also minor stylistic changes to other entries, bringing them to a uniform form.

- - - - -
de78b32a by Alan Zimmerman at 2023-10-23T09:09:41-04:00
EPA Some tweaks to annotations

- Fix span for GRHS
- Move TrailingAnns from last match to FunBind
- Fix GADT 'where' clause span
- Capture full range for a CaseAlt Match

- - - - -
d5a8780d by Simon Hengel at 2023-10-23T09:10:23-04:00
Update primitives.rst
- - - - -
4d075924 by Josh Meredith at 2023-10-24T23:04:12+11:00
JS/userguide: add explanation of writing jsbits

- - - - -
07ab5cc1 by Cheng Shao at 2023-10-24T15:40:32-04:00
testsuite: increase timeout of ghc-api tests for wasm32

ghc-api tests for wasm32 are more likely to timeout due to the large
wasm module sizes, especially when testing with wasm native tail
calls, given wasmtime's handling of tail call opcodes are suboptimal
at the moment. It makes sense to increase timeout specifically for
these tests on wasm32. This doesn't affect other targets, and for
wasm32 we don't increase timeout for all tests, so not to risk letting
major performance regressions slip through the testsuite.

- - - - -
0d6acca5 by Greg Steuck at 2023-10-26T08:44:23-04:00
Explicitly require RLIMIT_AS before use in OSMem.c

This is done elsewhere in the source tree. It also suddenly is
required on OpenBSD.

- - - - -
9408b086 by Sylvain Henry at 2023-10-26T08:45:03-04:00
Modularity: modularize external linker

Decouple runLink from DynFlags to allow calling runLink more easily.
This is preliminary work for calling Emscripten's linker (emcc) from
our JavaScript linker.

- - - - -
e0f35030 by doyougnu at 2023-10-27T08:41:12-04:00
js: add JStg IR, remove unsaturated constructor

- Major step towards #22736 and adding the optimizer in #22261

- - - - -
35587eba by Simon Peyton Jones at 2023-10-27T08:41:48-04:00
Fix a bug in tail calls with ticks

See #24078 for the diagnosis.  The change affects only
the Tick case of occurrence analysis.

It's a bit hard to test, so no regression test (yet anyway).

- - - - -
9bc5cb92 by Matthew Craven at 2023-10-28T07:06:17-04:00
Teach tag-inference about SeqOp/seq#

Fixes the STG/tag-inference analogue of #15226.

Co-Authored-By: Simon Peyton Jones <simon.peytonjones at gmail.com>

- - - - -
34f06334 by Moritz Angermann at 2023-10-28T07:06:53-04:00
[PEi386] Mask SYM_TYPE_DUP_DISCARD in makeSymbolExtra

48e391952c17ff7eab10b0b1456e3f2a2af28a9b
introduced `SYM_TYPE_DUP_DISCARD` to the bitfield.

The linker however, failed to mask the `SYM_TYPE_DUP_DISCARD` value.
Thus `== SYM_TYPE_CODE` comparisons easily failed. This lead to us
relocating DATA lookups (GOT) into E8 (call) and E9 (jump) instructions.

- - - - -
5b51b2a2 by Mario Blažević at 2023-10-28T07:07:33-04:00
Fix and test for issue #24111, TH.Ppr output of pattern synonyms

- - - - -
723bc352 by Alan Zimmerman at 2023-10-30T20:36:41-04:00
EPA: print doc comments as normal comments

And ignore the ones allocated in haddock processing.

It does not guarantee that every original haddock-like comment appears
in the output, as it discards ones that have no legal attachment point.

closes #23459

- - - - -
21b76843 by Simon Peyton Jones at 2023-10-30T20:37:17-04:00
Fix non-termination bug in equality solver

constraint left-to-right then right to left, forever.

Easily fixed.

- - - - -
270867ac by Sebastian Graf at 2023-10-30T20:37:52-04:00
ghc-toolchain: build with `-package-env=-` (#24131)

Otherwise globally installed libraries (via `cabal install --lib`)
break the build.

Fixes #24131.

- - - - -
7a90020f by Krzysztof Gogolewski at 2023-10-31T20:03:37-04:00
docs: fix ScopedTypeVariables example (#24101)

The previous example didn't compile.

Furthermore, it wasn't demonstrating the point properly.
I have changed it to an example which shows that 'a' in the signature
must be the same 'a' as in the instance head.

- - - - -
49f69f50 by Krzysztof Gogolewski at 2023-10-31T20:04:13-04:00
Fix pretty-printing of type family dependencies

"where" should be after the injectivity annotation.

- - - - -
73c191c0 by Ben Gamari at 2023-10-31T20:04:49-04:00
gitlab-ci: Bump LLVM bootstrap jobs to Debian 12

As the Debian 10 images have too old an LLVM.

Addresses #24056.

- - - - -
5b0392e0 by Matthew Pickering at 2023-10-31T20:04:49-04:00
ci: Run aarch64 llvm backend job with "LLVM backend" label

This brings it into line with the x86 LLVM backend job.

- - - - -
9f9c9227 by Ryan Scott at 2023-11-01T09:19:12-04:00
More robust checking for DataKinds

As observed in #22141, GHC was not doing its due diligence in catching code
that should require `DataKinds` in order to use. Most notably, it was allowing
the use of arbitrary data types in kind contexts without `DataKinds`, e.g.,

```hs
data Vector :: Nat -> Type -> Type where
```

This patch revamps how GHC tracks `DataKinds`. The full specification is
written out in the `DataKinds` section of the GHC User's Guide, and the
implementation thereof is described in `Note [Checking for DataKinds]` in
`GHC.Tc.Validity`. In brief:

* We catch _type_-level `DataKinds` violations in the renamer. See
  `checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in
  `GHC.Rename.Pat`.

* We catch _kind_-level `DataKinds` violations in the typechecker, as this
  allows us to catch things that appear beneath type synonyms. (We do *not*
  want to do this in type-level contexts, as it is perfectly fine for a type
  synonym to mention something that requires DataKinds while still using the
  type synonym in a module that doesn't enable DataKinds.) See `checkValidType`
  in `GHC.Tc.Validity`.

* There is now a single `TcRnDataKindsError` that classifies all manner of
  `DataKinds` violations, both in the renamer and the typechecker. The
  `NoDataKindsDC` error has been removed, as it has been subsumed by
  `TcRnDataKindsError`.

* I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit
  uses of data types at the kind level without `DataKinds`. Previously,
  `isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is
  inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`.
  Moreover, it thwarted the implementation of the `DataKinds` check in
  `checkValidType`, since we would expand `Constraint` (which was OK without
  `DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and
  reject it. Now both are allowed.

* I have added a flurry of additional test cases that test various corners of
  `DataKinds` checking.

Fixes #22141.

- - - - -
575d7690 by Sylvain Henry at 2023-11-01T09:19:53-04:00
JS: fix FFI "wrapper" and "dynamic"

Fix codegen and helper functions for "wrapper" and "dynamic" foreign
imports.

Fix tests:
- ffi006
- ffi011
- T2469
- T4038

Related to #22363

- - - - -
81fb8885 by Alan Zimmerman at 2023-11-01T22:23:56-04:00
EPA: Use full range for Anchor

This change requires a series of related changes, which must all land
at the same time, otherwise all the EPA tests break.

* Use the current Anchor end as prior end

  Use the original anchor location end as the source of truth for
  calculating print deltas.

  This allows original spacing to apply in most cases, only changed
  AST items need initial delta positions.

* Add DArrow to TrailingAnn

* EPA Introduce HasTrailing in ExactPrint

   Use [TrailingAnn] in enterAnn and remove it from
   ExactPrint (LocatedN RdrName)

* In HsDo, put TrailingAnns at top of LastStmt

* EPA: do not convert comments to deltas when balancing.

* EPA: deal with fallout from getMonoBind

* EPA fix captureLineSpacing

* EPA print any comments in the span before exiting it

* EPA: Add comments to AnchorOperation

* EPA: remove AnnEofComment, it is no longer used

Updates Haddock submodule

- - - - -
03e82511 by Rodrigo Mesquita at 2023-11-01T22:24:32-04:00
Fix in docs regarding SSymbol, SNat, SChar (#24119)

- - - - -
362cc693 by Matthew Pickering at 2023-11-01T22:25:08-04:00
hadrian: Update bootstrap plans (9.4.6, 9.4.7, 9.6.2, 9.6.3, 9.8.1)

Updating the bootstrap plans with more recent GHC versions.

- - - - -
00b9b8d3 by Matthew Pickering at 2023-11-01T22:25:08-04:00
ci: Add 9.8.1 bootstrap testing job

- - - - -
ef3d20f8 by Matthew Pickering at 2023-11-01T22:25:08-04:00
Compatibility with 9.8.1 as boot compiler

This fixes several compatability issues when using 9.8.1 as the boot
compiler.

* An incorrect version guard on the stack decoding logic in ghc-heap
* Some ghc-prim bounds need relaxing
* ghc is no longer wired in, so we have to remove the -this-unit-id ghc
  call.

Fixes #24077

- - - - -
6755d833 by Jaro Reinders at 2023-11-03T10:54:42+01:00
Add NCG support for common 64bit operations to the x86 backend.

These used to be implemented via C calls which was obviously quite bad
for performance for operations like simple addition.

Co-authored-by: Andreas Klebinger

- - - - -
0dfb1fa7 by Vladislav Zavialov at 2023-11-03T14:08:41-04:00
T2T in Expressions (#23738)

This patch implements the T2T (term-to-type) transformation in
expressions. Given a function with a required type argument
	vfun :: forall a -> ...

the user can now call it as
	vfun (Maybe Int)

instead of
	vfun (type (Maybe Int))

The Maybe Int argument is parsed and renamed as a term (HsExpr), but then
undergoes a conversion to a type (HsType).
See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs
and Note [RequiredTypeArguments and the T2T mapping]

Left as future work: checking for puns.

- - - - -
cc1c7c54 by Duncan Coutts at 2023-11-05T00:23:44-04:00
Add a test for I/O managers

It tries to cover the cases of multiple threads waiting on the same
fd for reading and multiple threads waiting for writing, including
wait cancellation by async exceptions.

It should work for any I/O manager, in-RTS or in-Haskell.
Unfortunately it will not currently work for Windows because it relies
on anonymous unix sockets. It could in principle be ported to use
Windows named pipes.

- - - - -
2e448f98 by Cheng Shao at 2023-11-05T00:23:44-04:00
Skip the IOManager test on wasm32 arch.

The test relies on the sockets API which are not (yet) available.
- - - - -
fe50eb35 by Cheng Shao at 2023-11-05T00:24:20-04:00
compiler: fix eager blackhole symbol in wasm32 NCG

- - - - -
af771148 by Cheng Shao at 2023-11-05T00:24:20-04:00
testsuite: fix optasm tests for wasm32

- - - - -
1b90735c by Matthew Pickering at 2023-11-05T00:24:20-04:00
testsuite: Add wasm32 to testsuite arches with NCG

The compiler --info reports that wasm32 compilers have a NCG, so we
should agree with that here.

- - - - -
db9a6496 by Alan Zimmerman at 2023-11-05T00:24:55-04:00
EPA: make locA a function, not a field name

And use it to generalise reLoc

The following for the windows pipeline one. 5.5%

Metric Increase:
    T5205

- - - - -
833e250c by Simon Peyton Jones at 2023-11-05T00:25:31-04:00
Update the unification count in wrapUnifierX

Omitting this caused type inference to fail in #24146.
This was an accidental omision in my refactoring of the
equality solver.

- - - - -
e451139f by Andreas Klebinger at 2023-11-05T00:26:07-04:00
Remove an accidental git conflict marker from a comment.

- - - - -
30baac7a by Tobias Haslop at 2023-11-06T10:50:32+00:00
Add laws relating between Foldable/Traversable with their Bi- superclasses

See https://github.com/haskell/core-libraries-committee/issues/205 for
discussion.

This commit also documents that the tuple instances only satisfy the
laws up to lazyness, similar to the documentation added in !9512.

- - - - -
df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00
Elaborate on the quantified superclass of Bifunctor

This was requested in the comment
https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700
for when Traversable becomes a superclass of Bitraversable, but similarly
applies to Functor/Bifunctor, which already are in a superclass relationship.

- - - - -
8217acb8 by Alan Zimmerman at 2023-11-07T02:21:12-05:00
EPA: get rid of l2l and friends

Replace them with

  l2l to convert the location
  la2la to convert a GenLocated thing

Updates haddock submodule

- - - - -
dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00
JS: remove broken newIdents from JStg Monad

GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate
identifiers being generated in h$c1, h$c2, ... .

This change removes the broken newIdents.

- - - - -
455524a2 by Matthew Craven at 2023-11-09T08:41:59-05:00
Create specially-solved DataToTag class

Closes #20532. This implements CLC proposal 104:
  https://github.com/haskell/core-libraries-committee/issues/104

The design is explained in Note [DataToTag overview]
in GHC.Tc.Instance.Class. This replaces the existing
`dataToTag#` primop.

These metric changes are not "real"; they represent Unique-related
flukes triggering on a different set of jobs than they did previously.
See also #19414.

Metric Decrease:
    T13386
    T8095
Metric Increase:
    T13386
    T8095

Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com>

- - - - -
a05f4554 by Alan Zimmerman at 2023-11-09T08:42:35-05:00
EPA: get rid of glRR and friends in GHC/Parser.y

With the HasLoc and HasAnnotation classes, we can replace a
number of type-specific helper functions in the parser with
polymorphic ones instead

Metric Decrease:
    MultiLayerModulesTH_Make

- - - - -
18498538 by Cheng Shao at 2023-11-09T16:58:12+00:00
ci: bump ci-images for wasi-sdk upgrade

- - - - -
52c0fc69 by PHO at 2023-11-09T19:16:22-05:00
Don't assume the current locale is *.UTF-8, set the encoding explicitly

primops.txt contains Unicode characters:
> LC_ALL=C ./genprimopcode --data-decl < ./primops.txt
> genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226)

Hadrian must also avoid using readFile' to read primops.txt because it
tries to decode the file with a locale-specific encoding.

- - - - -
7233b3b1 by PHO at 2023-11-09T19:17:01-05:00
Use '[' instead of '[[' because the latter is a Bash-ism

It doesn't work on platforms where /bin/sh is something other than Bash.

- - - - -
6dbab180 by Simon Peyton Jones at 2023-11-09T19:17:36-05:00
Add an extra check in kcCheckDeclHeader_sig

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

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

Metric Decrease:
    MultiLayerModulesTH_Make

- - - - -
22551364 by Sven Tennie at 2023-11-11T06:35:22-05:00
AArch64: Delete unused LDATA pseudo-instruction

Though there were consuming functions for LDATA, there were no
producers. Thus, the removed code was "dead".

- - - - -
2a0ec8eb by Alan Zimmerman at 2023-11-11T06:35:59-05:00
EPA: harmonise acsa and acsA in GHC/Parser.y

With the HasLoc class, we can remove the acsa helper function,
using acsA instead.

- - - - -
7ae517a0 by Teo Camarasu at 2023-11-12T08:04:12-05:00
nofib: bump submodule

This includes changes that:
- fix building a benchmark with HEAD
- remove a Makefile-ism that causes errors in bash scripts

Resolves #24178

- - - - -
3f0036ec by Alan Zimmerman at 2023-11-12T08:04:47-05:00
EPA: Replace Anchor with EpaLocation

An Anchor has a location and an operation, which is either that it is
unchanged or that it has moved with a DeltaPos

    data Anchor = Anchor { anchor :: RealSrcSpan
                         , anchor_op :: AnchorOperation }

An EpaLocation also has either a location or a DeltaPos

    data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan)
                     | EpaDelta !DeltaPos ![LEpaComment]

Now that we do not care about always having a location in the anchor,
we remove Anchor and replace it with EpaLocation

We do this with a type alias initially, to ease the transition.
The alias will be removed in time.

We also have helpers to reconstruct the AnchorOperation from an
EpaLocation. This is also temporary.

Updates Haddock submodule

- - - - -
a7492048 by Alan Zimmerman at 2023-11-12T13:43:07+00:00
EPA: get rid of AnchorOperation

Now that the Anchor type is an alias for EpaLocation, remove
AnchorOperation.

Updates haddock submodule

- - - - -
0745c34d by Andrew Lelechenko at 2023-11-13T16:25:07-05:00
Add since annotation for showHFloat

- - - - -
e98051a5 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00
Suppress duplicate librares linker warning of new macOS linker

Fixes #24167

XCode 15 introduced a new linker which warns on duplicate libraries being
linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as
suggested by Brad King in CMake issue #25297.

This flag isn't necessarily available to other linkers on darwin, so we must
only configure it into the CC linker arguments if valid.

- - - - -
c411c431 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00
testsuite: Encoding test witnesses recent iconv bug is fragile

A regression in the new iconv() distributed with XCode 15 and MacOS
Sonoma causes the test 'encoding004' to fail in the CP936 roundrip.

We mark this test as fragile until this is fixed upstream (rather than
broken, since previous versions of iconv pass the test)

See #24161

- - - - -
ce7fe5a9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00
testsuite: Update to LC_ALL=C no longer being ignored in darwin

MacOS seems to have fixed an issue where it used to ignore the variable
`LC_ALL` in program invocations and default to using Unicode.

Since the behaviour seems to be fixed to account for the locale
variable, we mark tests that were previously broken in spite of it as
fragile (since they now pass in recent macOS distributions)

See #24161

- - - - -
e6c803f7 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00
darwin: Fix single_module is obsolete warning

In XCode 15's linker, -single_module is the default and otherwise
passing it as a flag results in a warning being raised:

    ld: warning: -single_module is obsolete

This patch fixes this warning by, at configure time, determining whether
the linker supports -single_module (which is likely false for all
non-darwin linkers, and true for darwin linkers in previous versions of
macOS), and using that information at runtime to decide to pass or not
the flag in the invocation.

Fixes #24168

- - - - -
929ba2f9 by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00
testsuite: Skip MultiLayerModulesTH_Make on darwin

The recent toolchain upgrade on darwin machines resulted in the
MultiLayerModulesTH_Make test metrics varying too much from the
baseline, ultimately blocking the CI pipelines.

This commit skips the test on darwin to temporarily avoid failures due
to the environment change in the runners. However, the metrics
divergence is being investigated still (tracked in #24177)

- - - - -
af261ccd by Rodrigo Mesquita at 2023-11-15T13:18:58-05:00
configure: check target (not build) understands -no_compact_unwind

Previously, we were branching on whether the build system was darwin to
shortcut this check, but we really want to branch on whether the target
system (which is what we are configuring ld_prog for) is darwin.

- - - - -
2125c176 by Luite Stegeman at 2023-11-15T13:19:38-05:00
JS: Fix missing variable declarations

The JStg IR update was missing some local variable declarations
that were present earlier, causing global variables to be used
implicitly (or an error in JavaScript strict mode).

This adds the local variable declarations again.

- - - - -
99ced73b by Krzysztof Gogolewski at 2023-11-15T13:20:14-05:00
Remove loopy superclass solve mechanism

Programs with a -Wloopy-superclass-solve warning will now fail with an error.

Fixes #23017

- - - - -
2aff2361 by Zubin Duggal at 2023-11-15T13:20:50-05:00
users-guide: Fix links to libraries from the users-guide.

The unit-ids generated in c1a3ecde720b3bddc2c8616daaa06ee324e602ab include the
package name, so we don't need to explicitly add it to the links.

Fixes #24151

- - - - -
27981fac by Alan Zimmerman at 2023-11-15T13:21:25-05:00
EPA: splitLHsForAllTyInvis does not return ann

We did not use the annotations returned from splitLHsForAllTyInvis, so
do not return them.

- - - - -
a6467834 by Krzysztof Gogolewski at 2023-11-15T22:22:59-05:00
Document defaulting of RuntimeReps

Fixes #24099

- - - - -
2776920e by Simon Peyton Jones at 2023-11-15T22:23:35-05:00
Second fix to #24083

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

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

- - - - -
cee81370 by Sylvain Henry at 2023-11-16T09:57:46-05:00
Fix unusable units and module reexport interaction (#21097)

This commit fixes an issue with ModUnusable introduced in df0f148feae.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

- - - - -
3e606230 by Krzysztof Gogolewski at 2023-11-16T09:58:22-05:00
Fix IPE test

A helper function was defined in a different module than used.
To reproduce: ./hadrian/build test --test-root-dirs=testsuite/tests/rts/ipe

- - - - -
49f5264b by Andreas Klebinger at 2023-11-16T20:52:11-05:00
Properly compute unpacked sizes for -funpack-small-strict-fields.

Use rep size rather than rep count to compute the size.

Fixes #22309

- - - - -
b4f84e4b by James Henri Haydon at 2023-11-16T20:52:53-05:00
Explicit methods for Alternative Compose

Explicitly define some and many in Alternative instance for
Data.Functor.Compose

Implementation of https://github.com/haskell/core-libraries-committee/issues/181

- - - - -
9bc0dd1f by Ignat Insarov at 2023-11-16T20:53:34-05:00
Add permutations for non-empty lists.

Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837

- - - - -
5643ecf9 by Andrew Lelechenko at 2023-11-16T20:53:34-05:00
Update changelog and since annotations for Data.List.NonEmpty.permutations

Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/68#issuecomment-1221409837

- - - - -
94ff2134 by Oleg Alexander at 2023-11-16T20:54:15-05:00
Update doc string for traceShow

Updated doc string for traceShow.

- - - - -
faff671a by Luite Stegeman at 2023-11-17T14:12:51+01:00
JS: clean up some foreign imports

- - - - -
856e0a4e by Sven Tennie at 2023-11-18T06:54:11-05:00
AArch64: Remove unused instructions

As these aren't ever emitted, we don't even know if they work or will
ever be used. If one of them is needed in future, we may easily re-add
it.

Deleted instructions are:
- CMN
- ANDS
- BIC
- BICS
- EON
- ORN
- ROR
- TST
- STP
- LDP
- DMBSY

- - - - -
615441ef by Alan Zimmerman at 2023-11-18T06:54:46-05:00
EPA: Replace Monoid with NoAnn

Remove the final Monoid instances in the exact print infrastructure.

For Windows CI

Metric Decrease:
    T5205

- - - - -
5a6c49d4 by David Feuer at 2023-11-20T18:53:18-05:00
Speed up stimes in instance Semigroup Endo

As discussed at
https://github.com/haskell/core-libraries-committee/issues/4

- - - - -
cf9da4b3 by Andrew Lelechenko at 2023-11-20T18:53:18-05:00
base: reflect latest changes in the changelog

- - - - -
48bf364e by Alan Zimmerman at 2023-11-20T18:53:54-05:00
EPA: Use SrcSpan in EpaSpan

This is more natural, since we already need to deal with invalid
RealSrcSpans, and that is exactly what SrcSpan.UnhelpfulSpan is for.

Updates haddock submodule.

- - - - -
97ec37cc by Sebastian Graf at 2023-11-20T18:54:31-05:00
Add regression test for #6070

Fixes #6070.

- - - - -
e9d5ae41 by Owen Shepherd at 2023-11-21T18:32:23-05:00
chore: Correct typo in the gitlab MR template

[skip ci]

- - - - -
f158a8d0 by Rodrigo Mesquita at 2023-11-21T18:32:59-05:00
Improve error message when reading invalid `.target` files

A `.target` file generated by ghc-toolchain or by configure can become
invalid if the target representation (`Toolchain.Target`) is changed
while the files are not re-generated by calling `./configure` or
`ghc-toolchain` again. There is also the issue of hadrian caching the
dependencies on `.target` files, which makes parsing fail when reading
reading the cached value if the representation has been updated.

This patch provides a better error message in both situations, moving
away from a terrible `Prelude.read: no parse` error that you would get
otherwise.

Fixes #24199

- - - - -
955520c6 by Ben Gamari at 2023-11-21T18:33:34-05:00
users guide: Note that QuantifiedConstraints implies ExplicitForAll

Fixes #24025.

- - - - -
17ec3e97 by Owen Shepherd at 2023-11-22T09:37:28+01:00
fix: Change type signatures in NonEmpty export comments to reflect reality

This fixes several typos in the comments of
Data.List.NonEmpty export list items.

- - - - -
2fd78f9f by Samuel Thibault at 2023-11-22T11:49:13-05:00
Fix the platform string for GNU/Hurd

As commited in Cargo
https://github.com/haskell/cabal/pull/9434
there is confusion between "gnu" and "hurd". This got fixed in Cargo, we
need the converse in Hadrian.

Fixes #24180

- - - - -
a79960fe by Alan Zimmerman at 2023-11-22T11:49:48-05:00
EPA: Tuple Present no longer has annotation

The Present constructor for a Tuple argument will never have an exact
print annotation. So make this impossible.

- - - - -
121c9ab7 by David Binder at 2023-11-22T21:12:29-05:00
Unify the hpc testsuites

The hpc testsuite was split between testsuite/tests/hpc
and the submodule libraries/hpc/test. This commit unifies
the two testsuites in the GHC repository in the directory
testsuite/tests/hpc.

- - - - -
d2733a05 by Alan Zimmerman at 2023-11-22T21:13:05-05:00
EPA: empty tup_tail has noAnn

In Parser.y, the tup_tail rule had the following option
          | {- empty -} %shift   { return [Left noAnn] }

Once this works through PostProcess.hs, it means we add an extra
Missing constructor if the last item was a comma.

Change the annotation type to a Bool to indicate this, and use the
EpAnn Anchor for the print location for the others.

- - - - -
fa576eb8 by Andreas Klebinger at 2023-11-24T08:29:13-05:00
Fix FMA primops generating broken assembly on x86.

`genFMA3Code` assumed that we had to take extra precations to avoid overwriting
the result of `getNonClobberedReg`. One of these special cases caused a bug resulting
in broken assembly.

I believe we don't need to hadle these cases specially at all, which means this MR simply
deletes the special cases to fix the bug.

Fixes #24160

- - - - -
34d86315 by Alan Zimmerman at 2023-11-24T08:29:49-05:00
EPA: Remove parenthesizeHsType

This is called from PostProcess.hs, and adds spurious parens.
With the looser version of exact printing we had before we could
tolerate this, as they would be swallowed by the original at the same
place.

But with the next change (remove EpAnnNotUsed) they result in
duplicates in the output.

For Darwin build:

Metric Increase:
    MultiLayerModulesTH_OneShot

- - - - -
3ede659d by Vladislav Zavialov at 2023-11-26T06:43:32-05:00
Add name for -Wdeprecated-type-abstractions (#24154)

This warning had no name or flag and was triggered unconditionally.
Now it is part of -Wcompat.

- - - - -
7902ebf8 by Alan Zimmerman at 2023-11-26T06:44:08-05:00
EPA: Remove EpAnnNotUsed

We no longer need the EpAnnNotUsed constructor for EpAnn, as we can
represent an unused annotation with an anchor having a EpaDelta of
zero, and empty comments and annotations.

This simplifies code handling annotations considerably.

Updates haddock submodule

Metric Increase:
    parsing001

- - - - -
471b2672 by Mario Blažević at 2023-11-26T06:44:48-05:00
Bumped the upper bound of text to <2.2

- - - - -
d1bf25c7 by Vladislav Zavialov at 2023-11-26T11:45:49-05:00
Term variable capture (#23740)

This patch changes type variable lookup rules (lookupTypeOccRn) and
implicit quantification rules (filterInScope) so that variables bound
in the term namespace can be captured at the type level

  {-# LANGUAGE RequiredTypeArguments #-}
  f1 x = g1 @x                -- `x` used in a type application
  f2 x = g2 (undefined :: x)  -- `x` used in a type annotation
  f3 x = g3 (type x)          -- `x` used in an embedded type
  f4 x = ...
    where g4 :: x -> x        -- `x` used in a type signature
          g4 = ...

This change alone does not allow us to accept examples shown above,
but at least it gets them past the renamer.

- - - - -
da863d15 by Vladislav Zavialov at 2023-11-26T11:46:26-05:00
Update Note [hsScopedTvs and visible foralls]

The Note was written before GHC gained support for visible forall in
types of terms. Rewrite a few sentences and use a better example.

- - - - -
b5213542 by Matthew Pickering at 2023-11-27T12:53:59-05:00
testsuite: Add mechanism to collect generic metrics

* Generalise the metric logic by adding an additional field which
  allows you to specify how to query for the actual value. Previously
  the method of querying the baseline value was abstracted (but always
  set to the same thing).

* This requires rejigging how the stat collection works slightly but now
  it's more uniform and hopefully simpler.

* Introduce some new "generic" helper functions for writing generic
  stats tests.

  - collect_size ( deviation, path )
    Record the size of the file as a metric

  - stat_from_file ( metric, deviation, path )
    Read a value from the given path, and store that as a metric

  - collect_generic_stat ( metric, deviation, get_stat)
    Provide your own `get_stat` function, `lambda way: <Int>`, which
    can be used to establish the current value of the metric.

  - collect_generic_stats ( metric_info ):
    Like collect_generic_stat but provide the whole dictionary of metric
    definitions.

    { metric: {
        deviation: <Int>
        current: lambda way: <Int>
        } }

* Introduce two new "size" metrics for keeping track of build products.
    - `size_hello_obj` - The size of `hello.o` from compiling hello.hs
    - `libdir` - The total size of the `libdir` folder.

* Track the number of modules in the AST tests
   - CountDepsAst
   - CountDepsParser

This lays the infrastructure for #24191 #22256 #17129

- - - - -
7d9a2e44 by ARATA Mizuki at 2023-11-27T12:54:39-05:00
x86: Don't require -mavx2 when using 256-bit floating-point SIMD primitives

Fixes #24222

- - - - -
4e5ff6a4 by Alan Zimmerman at 2023-11-27T12:55:15-05:00
EPA: Remove SrcSpanAnn

Now that we only have a single constructor for EpAnn, And it uses a
SrcSpan for its location, we can do away with SrcSpanAnn completely.
It only existed to wrap the original SrcSpan in a location, and
provide a place for the exact print annotation.

For darwin only:
Metric Increase:
    MultiLayerModulesTH_OneShot

Updates haddock submodule

- - - - -
e05bca39 by Krzysztof Gogolewski at 2023-11-28T08:00:55-05:00
testsuite: don't initialize testdir to '.'

The test directory is removed during cleanup, if there's an interrupt
that could remove the entire repository.

Fixes #24219

- - - - -
af881674 by Alan Zimmerman at 2023-11-28T08:01:30-05:00
EPA: Clean up mkScope in Ast.hs

Now that we have HasLoc we can get rid of all the custom variants of
mkScope

For deb10-numa

Metric Increase:
    libdir

- - - - -
292983c8 by Ben Gamari at 2023-11-28T22:44:28-05:00
distrib: Rediscover otool and install_name_tool on Darwin

In the bindist configure script we must rediscover the `otool` and
`install_name_tool`s since they may be different from the build
environment.

Fixes #24211.

- - - - -
dfe1c354 by Stefan Schulze Frielinghaus at 2023-11-28T22:45:04-05:00
llvmGen: Align objects in the data section

Objects in the data section may be referenced via tagged pointers.
Thus, align those objects to a 4- or 8-byte boundary for 32- or 64-bit
platforms, respectively.  Note, this may need to be reconsidered if
objects with a greater natural alignment requirement are emitted as e.g.
128-bit atomics.

Fixes #24163.

- - - - -
f6c486c3 by Matthew Pickering at 2023-11-29T11:08:13-05:00
metrics: Widen libdir and size_hello_obj acceptance window

af8816740d9b8759be1a22af8adcb5f13edeb61d shows that the libdir size can
fluctuate quite significantly even when the change is quite small.
Therefore we widen the acceptance window to 10%.

- - - - -
99a6a49c by Alan Zimmerman at 2023-11-29T11:08:49-05:00
EPA: Clean up TC Monad Utils

We no longer need the alternative variant of addLocM (addLocMA)
nor wrapLocAM, wrapLocSndMA.

aarch64-darwin
Metric Increase:
    MultiLayerModulesTH_OneShot

deb10-numa-slow
Metric Decrease:
    libdir

- - - - -
cbc03fa0 by Sebastian Graf at 2023-11-30T12:37:21-05:00
perf tests: Move comments into new `Note [Sensitivity to unique increment]` (#19414)

And additionally to T12545, link from T8095, T13386 to this new Note.

- - - - -
c7623b22 by Alan Zimmerman at 2023-11-30T12:37:56-05:00
EPA: EpaDelta for comment has no comments

EpaLocation is used to position things. It has two constructors,
EpaSpan holding a SrcSpan, and EpaDelta with a delta position and a
possible list of comments.  The comment list is needed because the
location in EpaDelta has no absolute information to decide which
comments should be emitted before them when printing.

But it is also used for specifying the position of a comment.  To
prevent the absurdity of a comment position having a list of comments
in it, we make EpaLocation parameterisable, using comments for the
normal case and a constant for within comments.

Updates haddock submodule.

aarch64-darwin
Metric Decrease:
    MultiLayerModulesTH_OneShot

- - - - -
bd8acc0c by Krzysztof Gogolewski at 2023-11-30T12:38:32-05:00
Kind-check body of a required forall

We now require that in 'forall a -> ty', ty has kind TYPE r for some r.
Fixes #24176

- - - - -
010fb784 by Owen Shepherd at 2023-12-03T00:10:09-05:00
docs(NonEmpty/group): Remove incorrect haddock link quotes in code block

- - - - -
cda9c12d by Owen Shepherd at 2023-12-03T00:10:09-05:00
docs(NonEmpty/group): Remove cycle from group haddock example

- - - - -
495265b9 by Owen Shepherd at 2023-12-03T00:10:09-05:00
docs(NonEmpty/group): Use repl haddock syntax in group docs

- - - - -
d134d1de by Owen Shepherd at 2023-12-03T00:10:09-05:00
docs(NonEmpty/group): Use list [] notation in group haddock

- - - - -
dfcf629c by Owen Shepherd at 2023-12-03T00:10:10-05:00
docs(NonEmpty/group): Specify final property of group function in haddock

- - - - -
cad3b734 by Owen Shepherd at 2023-12-03T00:10:10-05:00
fix: Add missing property of List.group

- - - - -
bad37656 by Matthew Pickering at 2023-12-03T00:10:46-05:00
testsuite: Fix T21097b test with make 4.1 (deb9)

cee81370cd6ef256f66035e3116878d4cb82e28b recently added a test which
failed on deb9 because the version of make was emitting the recipe
failure to stdout rather than stderr.

One way to fix this is to be more precise in the test about which part
of the output we care about inspecting.

- - - - -
5efdf421 by Matthew Pickering at 2023-12-03T00:11:21-05:00
testsuite: Track size of libdir in bytes

For consistency it's better if we track all size metrics in bytes.

Metric Increase:
  libdir

- - - - -
f5eb0f29 by Matthew Pickering at 2023-12-03T00:11:22-05:00
testsuite: Remove rogue trace in testsuite

I accidentally left a trace in the generics metric patch.

- - - - -
d5610737 by Claudio Bley at 2023-12-06T16:13:33-05:00
Only exit ghci in -e mode when :add command fails

Previously, when running `ghci -e ':add Sample.hs'` the process would
exit with exit code 1 if the file exists and could be loaded.

Fixes #24115

- - - - -
0f0c53a5 by Vladislav Zavialov at 2023-12-06T16:14:09-05:00
T2T in Patterns (#23739)

This patch implements the T2T (term-to-type) transformation in patterns.
Patterns that are checked against a visible forall can now be written
without the `type` keyword:

	  \(type t) (x :: t) -> ...   -- old
	  \t (x :: t) -> ...          -- new

The `t` binder is parsed and renamed as a term pattern (Pat), but
then undergoes a conversion to a type pattern (HsTyPat).
See the new function pat_to_type_pat in compiler/GHC/Tc/Gen/Pat.hs

- - - - -
10a1a6c6 by Sebastian Graf at 2023-12-06T16:14:45-05:00
Pmc: Fix SrcLoc and warning for incomplete irrefutable pats (#24234)

Before, the source location would point at the surrounding function definition,
causing the confusion in #24234.
I also took the opportunity to introduce a new `LazyPatCtx :: HsMatchContext _`
to make the warning message say "irrefutable pattern" instead of "pattern
binding".

- - - - -
36b9a38c by Matthew Pickering at 2023-12-06T16:15:21-05:00
libraries: Bump filepath to 1.4.200.1 and unix to 2.8.4.0

Updates filepath submodule
Updates unix submodule

Fixes #24240

- - - - -
91ff0971 by Matthew Pickering at 2023-12-06T16:15:21-05:00
Submodule linter: Allow references to tags

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

Fixes #24241

- - - - -
86f652dc by Zubin Duggal at 2023-12-06T16:15:21-05:00
hadrian: set -Wno-deprecations for directory and Win32

The filepath bump to 1.4.200.1 introduces a deprecation warning.

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

- - - - -
7ac6006e by Sylvain Henry at 2023-12-06T16:16:02-05:00
Zap OccInfo on case binders during StgCse #14895 #24233

StgCse can revive dead binders:

  case foo of dead { Foo x y -> Foo x y; ... }
  ===>
  case foo of dead { Foo x y -> dead; ... } -- dead is no longer dead

So we must zap occurrence information on case binders.

Fix #14895 and #24233

- - - - -
57c391c4 by Sebastian Graf at 2023-12-06T16:16:37-05:00
Cpr: Turn an assertion into a check to deal with some dead code (#23862)

See the new `Note [Dead code may contain type confusions]`.

Fixes #23862.

- - - - -
c1c8abf8 by Zubin Duggal at 2023-12-08T02:25:07-05:00
testsuite: add test for #23944

- - - - -
6329d308 by Zubin Duggal at 2023-12-08T02:25:07-05:00
driver: Only run a dynamic-too pipeline if object files are going to be generated

Otherwise we run into a panic in hscMaybeWriteIface: "Unexpected DT_Dyn state
when writing simple interface" when dynamic-too is enabled

We could remove the panic and just write the interface even if the state is `DT_Dyn`,
but it seems pointless to run the pipeline twice when `hscMaybeWriteIface` is already
designed to write both `hi` and `dyn_hi` files if dynamic-too is enabled.

Fixes #23944.

- - - - -
28811f88 by Simon Peyton Jones at 2023-12-08T05:47:18-05:00
Improve duplicate elimination in SpecConstr

This partially fixes #24229.

See the new Note [Pattern duplicate elimination] in SpecConstr

- - - - -
fec7894f by Simon Peyton Jones at 2023-12-08T05:47:18-05:00
Make SpecConstr deal with casts better

This patch does two things, to fix #23209:

* It improves SpecConstr so that it no longer quantifies over
  coercion variables.  See Note [SpecConstr and casts]

* It improves the rule matcher to deal nicely with the case where
  the rule does not quantify over coercion variables, but the the
  template has a cast in it.  See Note [Casts in the template]

- - - - -
8db8d2fd by Zubin Duggal at 2023-12-08T05:47:54-05:00
driver: Don't lose track of nodes when we fail to resolve cycles

The nodes that take part in a cycle should include both hs-boot and hs files,
but when we fail to resolve a cycle, we were only counting the nodes from the
graph without boot files.

Fixes #24196

- - - - -
c5b4efd3 by Zubin Duggal at 2023-12-08T05:48:30-05:00
testsuite: Skip MultiLayerModulesTH_OneShot on darwin

See #24177

- - - - -
fae472a9 by Wendao Lee at 2023-12-08T05:49:12-05:00
docs(Data.Char):Add more detailed descriptions for some functions

Related changed function's docs:

-GHC.Unicode.isAlpha
-GHC.Unicode.isPrint
-GHC.Unicode.isAlphaNum

Add more details for what the function will return.

Co-authored-by: Bodigrim <andrew.lelechenko at gmail.com>

- - - - -
ca7510e4 by Malik Ammar Faisal at 2023-12-08T05:49:55-05:00
Fix float parsing in GHC Cmm Lexer

Add test case for bug #24224

- - - - -
d8baa1bd by Simon Peyton Jones at 2023-12-08T15:40:37+00:00
Take care when simplifying unfoldings

This MR fixes a very subtle bug exposed by #24242.

See Note [Environment for simplLetUnfolding].

I also updated a bunch of Notes on shadowing

- - - - -
03ca551d by Simon Peyton Jones at 2023-12-08T15:54:50-05:00
Comments only in FloatIn

Relevant to #3458

- - - - -
50c78779 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00
Comments only in SpecConstr

- - - - -
9431e195 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00
Add test for #22238

- - - - -
d9e4c597 by Vladislav Zavialov at 2023-12-11T04:19:34-05:00
Make forall a keyword (#23719)

Before this change, GHC used to accept `forall` as a term-level
identifier:

	-- from constraints-0.13
	forall :: forall p. (forall a. Dict (p a)) -> Dict (Forall p)
	forall d = ...

Now it is a parse error.

The -Wforall-identifier warning has served its purpose and is now
a deprecated no-op.

- - - - -
58d56644 by Zubin Duggal at 2023-12-11T04:20:10-05:00
driver: Ensure we actually clear the interactive context before reloading

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

Partially addresses #24107
Fixes #23405

- - - - -
8e5745a0 by Zubin Duggal at 2023-12-11T04:20:10-05:00
driver: Ensure we force the lookup of old build artifacts before returning the build plan

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

Fixes #24118

- - - - -
105c370c by Zubin Duggal at 2023-12-11T04:20:10-05:00
testsuite: add test for #24118 and #24107

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

Using :r catches both of these leaks

- - - - -
e822ff88 by Zubin Duggal at 2023-12-11T04:20:10-05:00
compiler: Add some strictness annotations to ImportSpec and related constructors
This prevents us from retaining entire HscEnvs.

Force these ImportSpecs when forcing the GlobalRdrEltX

Adds an NFData instance for Bag

Fixes #24107

- - - - -
522c12a4 by Zubin Duggal at 2023-12-11T04:20:10-05:00
compiler: Force IfGlobalRdrEnv in NFData instance.

- - - - -
188b280d by Arnaud Spiwack at 2023-12-11T15:33:31+01:00
LinearTypes => MonoLocalBinds

- - - - -
8e0446df by Arnaud Spiwack at 2023-12-11T15:44:28+01:00
Linear let and where bindings

For expediency, the initial implementation of linear types in GHC
made it so that let and where binders would always be considered
unrestricted. This was rather unpleasant, and probably a big obstacle
to adoption. At any rate, this was not how the proposal was designed.

This patch fixes this infelicity. It was surprisingly difficult to
build, which explains, in part, why it took so long to materialise.

As of this patch, let or where bindings marked with %1 will be
linear (respectively %p for an arbitrary multiplicity p). Unmarked let
will infer their multiplicity.

Here is a prototypical example of program that used to be rejected and
is accepted with this patch:

```haskell
f :: A %1 -> B
g :: B %1 -> C

h :: A %1 -> C
h x = g y
  where
    y = f x
```

Exceptions:
- Recursive let are unrestricted, as there isn't a clear semantics of
  what a linear recursive binding would be.
- Destructive lets with lazy bindings are unrestricted, as their
  desugaring isn't linear (see also #23461).
- (Strict) destructive lets with inferred polymorphic type are
  unrestricted. Because the desugaring isn't linear (See #18461
  down-thread).

Closes #18461 and #18739

Co-authored-by: @jackohughes

- - - - -
effa7e2d by Matthew Craven at 2023-12-12T04:37:20-05:00
Introduce `dataToTagSmall#` primop (closes #21710)

...and use it to generate slightly better code when dataToTag#
is used at a "small data type" where there is no need to mess
with "is_too_big_tag" or potentially look at an info table.

Metric Decrease:
    T18304

- - - - -
35c7aef6 by Matthew Craven at 2023-12-12T04:37:20-05:00
Fix formatting of Note [alg-alt heap check]

- - - - -
7397c784 by Oleg Grenrus at 2023-12-12T04:37:56-05:00
Allow untyped brackets in typed splices and vice versa.

Resolves #24190

Apparently the check was essentially always (as far as I can trace back: d0d47ba76f8f0501cf3c4966bc83966ab38cac27),
and while it does catch some mismatches, the type-checker will catch
them too. OTOH, it prevents writing completely reasonable programs.

- - - - -
a3ee3b99 by Moritz Angermann at 2023-12-12T19:50:58-05:00
Drop hard Xcode dependency

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

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

- - - - -
1c9496e0 by Vladislav Zavialov at 2023-12-12T19:51:34-05:00
docs: update information on RequiredTypeArguments

Update the User's Guide and Release Notes to account for the recent
progress in the implementation of RequiredTypeArguments.

- - - - -
d0b17576 by Ben Gamari at 2023-12-13T06:33:37-05:00
rts/eventlog: Fix off-by-one in assertion

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

- - - - -
a10f9b9b by Ben Gamari at 2023-12-13T06:33:37-05:00
rts/eventlog: Honor result of ensureRoomForVariableEvent is

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

- - - - -
0e0f41c0 by Ben Gamari at 2023-12-13T06:33:37-05:00
rts/eventlog: Avoid truncating event sizes

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

Fixes #24197.

- - - - -
64e724c8 by Artin Ghasivand at 2023-12-13T06:34:20-05:00
Remove the "Derived Constraint" argument of TcPluginSolver, docs

- - - - -
fe6d97dd by Vladislav Zavialov at 2023-12-13T06:34:56-05:00
EPA: Move tokens into GhcPs extension fields (#23447)

Summary of changes

* Remove Language.Haskell.Syntax.Concrete
* Move all tokens into GhcPs extension fields (LHsToken -> EpToken)
* Create new TTG extension fields as needed
* Drop the MultAnn wrapper

Updates the haddock submodule.

Co-authored-by: Alan Zimmerman <alan.zimm at gmail.com>

- - - - -
8106e695 by Zubin Duggal at 2023-12-13T06:35:34-05:00
testsuite: use copy_files in T23405

This prevents the tree from being dirtied when the file is modified.

- - - - -
ed0e4099 by Bryan Richter at 2023-12-14T04:30:53-05:00
Document ghc package's PVP-noncompliance

This changes nothing, it just makes the status quo explicit.

- - - - -
8bef8d9f by Luite Stegeman at 2023-12-14T04:31:33-05:00
JS: Mark spurious CI failures js_fragile(24259)

This marks the spurious test failures on the JS platform as
js_fragile(24259), so we don't hold up merge requests while
fixing the underlying issues.

See #24259

- - - - -
1c79526a by Finley McIlwaine at 2023-12-15T12:24:40-08:00
Late plugins

- - - - -
000c3302 by Finley McIlwaine at 2023-12-15T12:24:40-08:00
withTiming on LateCCs and late plugins

- - - - -
be4551ac by Finley McIlwaine at 2023-12-15T12:24:40-08:00
add test for late plugins

- - - - -
7c29da9f by Finley McIlwaine at 2023-12-15T12:24:40-08:00
Document late plugins

- - - - -
9a52ae46 by Ben Gamari at 2023-12-20T07:07:26-05:00
Fix thunk update ordering

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

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

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

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

      7     ... (e.g. GC)

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

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

      14    Release t.info=BLACKHOLE

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

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

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

See #23185.

- - - - -
f4b53538 by Vladislav Zavialov at 2023-12-20T07:08:02-05:00
docs: Fix link to 051-ghc-base-libraries.rst

The proposal is no longer available at the previous URL.

- - - - -
f7e21fab by Matthew Pickering at 2023-12-21T14:57:40+00:00
hadrian: Build all executables in bin/ folder

In the end the bindist creation logic copies them all into the bin
folder. There is no benefit to building a specific few binaries in the
lib/bin folder anymore.

This also removes the ad-hoc logic to copy the touchy and unlit
executables from stage0 into stage1. It takes <1s to build so we might
as well just build it.

- - - - -
0038d052 by Zubin Duggal at 2023-12-22T23:28:00-05:00
testsuite: mark jspace as fragile on i386.

This test has been flaky for some time and has been failing consistently on
i386-linux since 8e0446df landed.

See #24261

- - - - -
dfd670a0 by Ben Bellick at 2023-12-24T10:10:31-05:00
Deprecate -ddump-json and introduce -fdiagnostics-as-json

Addresses #19278

This commit deprecates the underspecified -ddump-json flag and
introduces a newer, well-specified flag -fdiagnostics-as-json.

Also included is a JSON schema as part of the documentation.

The -ddump-json flag will be slated for removal shortly after this merge.

- - - - -
609e6225 by Ben Bellick at 2023-12-24T10:10:31-05:00
Deprecate -ddump-json and introduce -fdiagnostics-as-json

Addresses #19278

This commit deprecates the underspecified -ddump-json flag and
introduces a newer, well-specified flag -fdiagnostics-as-json.

Also included is a JSON schema as part of the documentation.

The -ddump-json flag will be slated for removal shortly after this merge.

- - - - -
865513b2 by Ömer Sinan Ağacan at 2023-12-24T10:11:13-05:00
Fix BNF in user manual 6.6.8.2: formal syntax for instance declarations

- - - - -
c247b6be by Zubin Duggal at 2023-12-25T16:01:23-05:00
docs: document permissibility of -XOverloadedLabels (#24249)

Document the permissibility introduced by
https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst

- - - - -
e5b7eb59 by Ömer Sinan Ağacan at 2023-12-25T16:02:03-05:00
Fix a code block syntax in user manual sec. 6.8.8.6

- - - - -
2db11c08 by Ben Gamari at 2023-12-29T15:35:48-05:00
genSym: Reimplement via CAS on 32-bit platforms

Previously the remaining use of the C implementation on 32-bit platforms
resulted in a subtle bug, #24261. This was due to the C object (which
used the RTS's `atomic_inc64` macro) being compiled without `-threaded`
yet later being used in a threaded compiler.

Side-step this issue by using the pure Haskell `genSym` implementation on
all platforms. This required implementing `fetchAddWord64Addr#` in terms
of CAS on 64-bit platforms.

- - - - -
19328a8c by Xiaoyan Ren at 2023-12-29T15:36:30-05:00
Do not color the diagnostic code in error messages (#24172)

- - - - -
685b467c by Krzysztof Gogolewski at 2023-12-29T15:37:06-05:00
Enforce that bindings of implicit parameters are lifted

Fixes #24298

- - - - -
bc4d67b7 by Matthew Craven at 2023-12-31T06:15:42-05:00
StgToCmm: Detect some no-op case-continuations

...and generate no code for them. Fixes #24264.

- - - - -
5b603139 by Krzysztof Gogolewski at 2023-12-31T06:16:18-05:00
Revert "testsuite: mark jspace as fragile on i386."

This reverts commit 0038d052c8c80b4b430bb2aa1c66d5280be1aa95.

The atomicity bug should be fixed by !11802.

- - - - -
d55216ad by Krzysztof Gogolewski at 2024-01-01T12:05:49-05:00
Refactor: store [[PrimRep]] rather than [Type] in STG

StgConApp stored a list of types. This list was used exclusively
during unarisation of unboxed sums (mkUbxSum).
However, this is at a wrong level of abstraction:
STG shouldn't be concerned with Haskell types, only PrimReps.
Update the code to store a [[PrimRep]]. Also, there's no point in storing
this list when we're not dealing with an unboxed sum.

- - - - -
8b340bc7 by Ömer Sinan Ağacan at 2024-01-01T12:06:29-05:00
Kind signatures docs: mention that they're allowed in newtypes

- - - - -
989bf8e5 by Zubin Duggal at 2024-01-03T20:08:47-05:00
ci: Ensure we use the correct bindist name for the test artifact when generating
release ghcup metadata

Fixes #24268

- - - - -
89299a89 by Krzysztof Gogolewski at 2024-01-03T20:09:23-05:00
Refactor: remove calls to typePrimRepArgs

The function typePrimRepArgs is just a thin wrapper around
typePrimRep, adding a VoidRep if the list is empty.
However, in StgToByteCode, we were discarding that VoidRep anyway,
so there's no point in calling it.

- - - - -
c7be0c68 by mmzk1526 at 2024-01-03T20:10:07-05:00
Use "-V" for alex version check for better backward compatibility
Fixes #24302.
In recent versions of alex, "-v" is used for "--verbose" instead of "-version".

- - - - -
67dbcc0a by Krzysztof Gogolewski at 2024-01-05T02:07:18-05:00
Fix VoidRep handling in ghci debugger

'go' inside extractSubTerms was giving a bad result given a VoidRep,
attempting to round towards the next multiple of 0.
I don't understand much about the debugger but the code should be better
than it was.

Fixes #24306

- - - - -
90ea574e by Krzysztof Gogolewski at 2024-01-05T02:07:54-05:00
VoidRep-related refactor

* In GHC.StgToByteCode, replace bcIdPrimId with idPrimRep,
  bcIdArgRep with idArgRep, atomPrimRep with stgArgRep1.
  All of them were duplicates.
* In GHC.Stg.Unarise, we were converting a PrimRep to a Type and back to
  PrimRep. Remove the calls to primRepToType and typePrimRep1 which cancel out.
* In GHC.STG.Lint, GHC.StgToCmm, GHC.Types.RepType we were filtering out
  VoidRep from the result of typePrimRep. But typePrimRep never returns
  VoidRep - remove the filtering.

- - - - -
eaf72479 by brian at 2024-01-06T23:03:09-05:00
Add unaligned Addr# primops

Implements CLC proposal #154:
  https://github.com/haskell/core-libraries-committee/issues/154

* add unaligned addr primops

* add tests

* accept tests

* add documentation

* fix js primops

* uncomment in access ops

* use Word64 in tests

* apply suggestions

* remove extra file

* move docs

* remove random options

* use setByteArray# primop

* better naming

* update base-exports test

* add base-exports for other architectures

- - - - -
d471d445 by Krzysztof Gogolewski at 2024-01-06T23:03:47-05:00
Remove VoidRep from PrimRep, introduce PrimOrVoidRep

This introduces

data PrimOrVoidRep = VoidRep | NVRep PrimRep

changes typePrimRep1 to return PrimOrVoidRep, and adds a new function
typePrimRepU to be used when the argument is definitely non-void.
Details in Note [VoidRep] in GHC.Types.RepType.

Fixes #19520

- - - - -
48720a07 by Matthew Craven at 2024-01-08T18:57:36-05:00
Apply Note [Sensitivity to unique increment] to LargeRecord

- - - - -
9e2e180f by Sebastian Graf at 2024-01-08T18:58:13-05:00
Debugging: Add diffUFM for convenient diffing between UniqFMs

- - - - -
948f3e35 by Sebastian Graf at 2024-01-08T18:58:13-05:00
Rename Opt_D_dump_stranal to Opt_D_dump_dmdanal

... and Opt_D_dump_str_signatures to Opt_D_dump_dmd_signatures

- - - - -
4e217e3e by Sebastian Graf at 2024-01-08T18:58:13-05:00
Deprecate -ddump-stranal and -ddump-str-signatures

... and suggest -ddump-dmdanal and -ddump-dmd-signatures instead

- - - - -
6c613c90 by Sebastian Graf at 2024-01-08T18:58:13-05:00
Move testsuite/tests/stranal to testsuite/tests/dmdanal

A separate commit so that the rename is obvious to Git(Lab)

- - - - -
c929f02b by Sebastian Graf at 2024-01-08T18:58:13-05:00
CoreSubst: Stricten `substBndr` and `cloneBndr`

Doing so reduced allocations of `cloneBndr` by about 25%.

```
T9233(normal) ghc/alloc    672,488,656    663,083,216  -1.4% GOOD
T9675(optasm) ghc/alloc    423,029,256    415,812,200  -1.7%

    geo. mean                                          -0.1%
    minimum                                            -1.7%
    maximum                                            +0.1%
```

Metric Decrease:
    T9233

- - - - -
e3ca78f3 by Krzysztof Gogolewski at 2024-01-10T17:35:59-05:00
Deprecate -Wsemigroup

This warning was used to prepare for Semigroup becoming a superclass
of Monoid, and for (<>) being exported from Prelude. This happened in
GHC 8.4 in 8ae263ceb3566 and feac0a3bc69fd3.

The leftover logic for (<>) has been removed in GHC 9.8, 4d29ecdfcc79.
Now the warning does nothing at all and can be deprecated.

- - - - -
08d14925 by amesgen at 2024-01-10T17:36:42-05:00
WASM metadata: use correct GHC version

- - - - -
7a808419 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00
Allow SCC declarations in TH (#24081)

- - - - -
28827c51 by Xiaoyan Ren at 2024-01-10T17:37:24-05:00
Fix prettyprinting of SCC pragmas

- - - - -
ae9cc1a8 by Matthew Craven at 2024-01-10T17:38:01-05:00
Fix loopification in the presence of void arguments

This also removes Note [Void arguments in self-recursive tail calls],
which was just misleading.  It's important to count void args both
in the function's arity and at the call site.

Fixes #24295.

- - - - -
b718b145 by Zubin Duggal at 2024-01-10T17:38:36-05:00
testsuite: Teach testsuite driver about c++ sources

- - - - -
09cb57ad by Zubin Duggal at 2024-01-10T17:38:36-05:00
driver: Set -DPROFILING when compiling C++ sources with profiling

Earlier, we used to pass all preprocessor flags to the c++ compiler.
This meant that -DPROFILING was passed to the c++ compiler because
it was a part of C++ flags
However, this was incorrect and the behaviour was changed in
8ff3134ed4aa323b0199ad683f72165e51a59ab6. See #21291.

But that commit exposed this bug where -DPROFILING was no longer being passed
when compiling c++ sources.

The fix is to explicitly include -DPROFILING in `opt_cxx` when profiling is
enabled to ensure we pass the correct options for the way to both C and C++
compilers

Fixes #24286

- - - - -
2cf9dd96 by Zubin Duggal at 2024-01-10T17:38:36-05:00
testsuite: rename objcpp -> objcxx

To avoid confusion with C Pre Processsor

- - - - -
af6932d6 by Simon Peyton Jones at 2024-01-10T17:39:12-05:00
Make TYPE and CONSTRAINT not-apart

Issue #24279 showed up a bug in the logic in GHC.Core.Unify.unify_ty
which is supposed to make TYPE and CONSTRAINT be not-apart.

Easily fixed.

- - - - -
4a39b5ff by Zubin Duggal at 2024-01-10T17:39:48-05:00
ci: Fix typo in mk_ghcup_metadata.py

There was a missing colon in the fix to #24268 in 989bf8e53c08eb22de716901b914b3607bc8dd08

- - - - -
13503451 by Zubin Duggal at 2024-01-10T17:40:24-05:00
release-ci: remove release-x86_64-linux-deb11-release+boot_nonmoving_gc job

There is no reason to have this release build or distribute this variation.
This configuration is for testing purposes only.

- - - - -
afca46a4 by Sebastian Graf at 2024-01-10T17:41:00-05:00
Parser: Add a Note detailing why we need happy's `error` to implement layout

- - - - -
eaf8a06d by Krzysztof Gogolewski at 2024-01-11T00:43:17+01:00
Turn -Wtype-equality-out-of-scope on by default

Also remove -Wnoncanonical-{monoid,monad}-instances from -Wcompat,
since they are enabled by default. Refresh wcompat-warnings/ test
with new -Wcompat warnings.

Part of #24267

Co-authored-by: sheaf <sam.derbyshire at gmail.com>

- - - - -
42bee5aa by Sebastian Graf at 2024-01-12T21:16:21-05:00
Arity: Require called *exactly once* for eta exp with -fpedantic-bottoms (#24296)

In #24296, we had a program in which we eta expanded away an error despite the
presence of `-fpedantic-bottoms`.
This was caused by turning called *at least once* lambdas into one-shot lambdas,
while with `-fpedantic-bottoms` it is only sound to eta expand over lambdas that
are called *exactly* once.
An example can be found in `Note [Combining arity type with demand info]`.

Fixes #24296.

- - - - -
7e95f738 by Andreas Klebinger at 2024-01-12T21:16:57-05:00
Aarch64: Enable -mfma by default.

Fixes #24311

- - - - -
e43788d0 by Jason Shipman at 2024-01-14T12:47:38-05:00
Add more instances for Compose: Fractional, RealFrac, Floating, RealFloat

CLC proposal #226 https://github.com/haskell/core-libraries-committee/issues/226

- - - - -
ae6d8cd2 by Sebastian Graf at 2024-01-14T12:48:15-05:00
Pmc: COMPLETE pragmas associated with Family TyCons should apply to representation TyCons as well (#24326)

Fixes #24326.

- - - - -
c5fc7304 by sheaf at 2024-01-15T14:15:29-05:00
Use lookupOccRn_maybe in TH.lookupName

When looking up a value, we want to be able to find both variables
and record fields. So we should not use the lookupSameOccRn_maybe
function, as we can't know ahead of time which record field namespace
a record field with the given textual name will belong to.

Fixes #24293

- - - - -
da908790 by Krzysztof Gogolewski at 2024-01-15T14:16:05-05:00
Make the build more strict on documentation errors

* Detect undefined labels. This can be tested by adding :ref:`nonexistent`
  to a documentation rst file; attempting to build docs will fail.
  Fixed the undefined label in `9.8.1-notes.rst`.
* Detect errors. While we have plenty of warnings, we can at least enforce
  that Sphinx does not report errors.
  Fixed the error in `required_type_arguments.rst`.

Unrelated change: I have documented that the `-dlint` enables
`-fcatch-nonexhaustive-cases`, as can be verified by checking
`enableDLint`.

- - - - -
5077416e by Javier Sagredo at 2024-01-16T15:40:06-05:00
Profiling: Adds an option to not start time profiling at startup

Using the functionality provided by
d89deeba47ce04a5198a71fa4cbc203fe2c90794, this patch creates a new rts
flag `--no-automatic-time-samples` which disables the time profiling
when starting a program. It is then expected that the user starts it
whenever it is needed.

Fixes #24337

- - - - -
5776008c by Matthew Pickering at 2024-01-16T15:40:42-05:00
eventlog: Fix off-by-one error in postIPE

We were missing the extra_comma from the calculation of the size of the
payload of postIPE. This was causing assertion failures when the event
would overflow the buffer by one byte, as ensureRoomForVariable event
would report there was enough space for `n` bytes but then we would
write `n + 1` bytes into the buffer.

Fixes #24287

- - - - -
66dc09b1 by Simon Peyton Jones at 2024-01-16T15:41:18-05:00
Improve SpecConstr (esp nofib/spectral/ansi)

This MR makes three improvements to SpecConstr: see #24282

* It fixes an outright (and recently-introduced) bug in `betterPat`, which
  was wrongly forgetting to compare the lengths of the argument lists.

* It enhances ConVal to inclue a boolean for work-free-ness, so that the
  envt can contain non-work-free constructor applications, so that we
  can do more: see Note [ConVal work-free-ness]

* It rejigs `subsumePats` so that it doesn't reverse the list.  This can
  make a difference because, when patterns overlap, we arbitrarily pick
  the first.  There is no "right" way, but this retains the old
  pre-subsumePats behaviour, thereby "fixing" the regression in #24282.

Nofib results

   +========================================
   |                 spectral/ansi  -21.14%
   | spectral/hartel/comp_lab_zift   -0.12%
   |       spectral/hartel/parstof   +0.09%
   |           spectral/last-piece   -2.32%
   |           spectral/multiplier   +6.03%
   |                 spectral/para   +0.60%
   |               spectral/simple   -0.26%
   +========================================
   |                     geom mean   -0.18%
   +----------------------------------------

The regression in `multiplier` is sad, but it simply replicates GHC's
previous behaviour (e.g. GHC 9.6).

- - - - -
65da79b3 by Matthew Pickering at 2024-01-16T15:41:54-05:00
hadrian: Reduce Cabal verbosity

The comment claims that `simpleUserHooks` decrease verbosity, and it
does, but only for the `postConf` phase. The other phases are too
verbose with `-V`.

At the moment > 5000 lines of the build log are devoted to output from
`cabal copy`.

So I take the simple approach and just decrease the verbosity level
again.

If the output of `postConf` is essential then it would be better to
implement our own `UserHooks` which doesn't decrease the verbosity for
`postConf`.

Fixes #24338

- - - - -
16414d7d by Matthew Pickering at 2024-01-17T10:54:59-05:00
Stop retaining old ModGuts throughout subsequent simplifier phases

Each phase of the simplifier typically rewrites the majority of ModGuts,
so we want to be able to release the old ModGuts as soon as possible.

`name_ppr_ctxt` lives throught the whole optimiser phase and it was
retaining a reference to `ModGuts`, so we were failing to release the
old `ModGuts` until the end of the phase (potentially doubling peak
memory usage for that particular phase).

This was discovered using eras profiling (#24332)

Fixes #24328

- - - - -
7f0879e1 by Matthew Pickering at 2024-01-17T10:55:35-05:00
Update nofib submodule

- - - - -
320454d3 by Cheng Shao at 2024-01-17T23:02:40+00:00
ci: bump ci-images for updated wasm image

- - - - -
2eca52b4 by Cheng Shao at 2024-01-17T23:06:44+00:00
base: treat all FDs as "nonblocking" on wasm

On posix platforms, when performing read/write on FDs, we check the
nonblocking flag first. For FDs without this flag (e.g. stdout), we
call fdReady() first, which in turn calls poll() to wait for I/O to be
available on that FD. This is problematic for wasm32-wasi: although
select()/poll() is supported via the poll_oneoff() wasi syscall, that
syscall is rather heavyweight and runtime behavior differs in
different wasi implementations. The issue is even worse when targeting
browsers, given there's no satisfactory way to implement async I/O as
a synchronous syscall, so existing JS polyfills for wasi often give up
and simply return ENOSYS.

Before we have a proper I/O manager that avoids poll_oneoff() for
async I/O on wasm, this patch improves the status quo a lot by merely
pretending all FDs are "nonblocking". Read/write on FDs will directly
invoke read()/write(), which are much more reliably handled in
existing wasi implementations, especially those in browsers.

Fixes #23275 and the following test cases: T7773 isEOF001 openFile009
T4808 cgrun025

Approved by CLC proposal #234:
https://github.com/haskell/core-libraries-committee/issues/234

- - - - -
83c6c710 by Andrew Lelechenko at 2024-01-18T05:21:49-05:00
base: clarify how to disable warnings about partiality of Data.List.{head,tail}

- - - - -
c4078f2f by Simon Peyton Jones at 2024-01-18T05:22:25-05:00
Fix four bug in handling of (forall cv. body_ty)

These bugs are all described in #24335

It's not easy to provoke the bug, hence no test case.

- - - - -
119586ea by Alexis King at 2024-01-19T00:08:00-05:00
Always refresh profiling CCSes after running pending initializers

Fixes #24171.

- - - - -
9718d970 by Oleg Grenrus at 2024-01-19T00:08:36-05:00
Set default-language: GHC2021 in ghc library

Go through compiler/ sources, and remove
all BangPatterns (and other GHC2021 enabled extensions in these files).

- - - - -
3ef71669 by Matthew Pickering at 2024-01-19T21:55:16-05:00
testsuite: Remove unused have_library function

Also remove the hence unused testsuite option `--test-package-db`.

Fixes #24342

- - - - -
5b7fa20c by Jade at 2024-01-19T21:55:53-05:00
Fix Spelling in the compiler

Tracking: #16591

- - - - -
09875f48 by Matthew Pickering at 2024-01-20T12:20:44-05:00
testsuite: Implement `isInTreeCompiler` in a more robust way

Just a small refactoring to avoid redundantly specifying the same
strings in two different places.

- - - - -
0d12b987 by Jade at 2024-01-20T12:21:20-05:00
Change maintainer email from cvs-ghc at haskell.org to ghc-devs at haskell.org. Fixes #22142

- - - - -
1fa1c00c by Jade at 2024-01-23T19:17:03-05:00
Enhance Documentation of functions exported by Data.Function

This patch aims to improve the documentation of functions exported
in Data.Function

Tracking: #17929
Fixes: #10065

- - - - -
ab47a43d by Jade at 2024-01-23T19:17:39-05:00
Improve documentation of hGetLine.

- Add explanation for whether a newline is returned
- Add examples

Fixes #14804

- - - - -
dd4af0e5 by Cheng Shao at 2024-01-23T19:18:17-05:00
Fix genapply for cross-compilation by nuking fragile CPP logic

This commit fixes incorrectly built genapply when cross compiling
(#24347) by nuking all fragile CPP logic in it from the orbit. All
target-specific info are now read from DerivedConstants.h at runtime,
see added note for details. Also removes a legacy Makefile and adds
haskell language server support for genapply.

- - - - -
0cda2b8b by Cheng Shao at 2024-01-23T19:18:17-05:00
rts: enable wasm32 register mapping

The wasm backend didn't properly make use of all Cmm global registers
due to #24347. Now that it is fixed, this patch re-enables full
register mapping for wasm32, and we can now generate smaller & faster
wasm modules that doesn't always spill arguments onto the stack. Fixes #22460 #24152.

- - - - -
0325a6e5 by Greg Steuck at 2024-01-24T01:29:44-05:00
Avoid utf8 in primops.txt.pp comments

They don't make it through readFile' without explicitly setting the
encoding. See https://gitlab.haskell.org/ghc/ghc/-/issues/17755

- - - - -
1aaf0bd8 by David Binder at 2024-01-24T01:30:20-05:00
Bump hpc and hpc-bin submodule

Bump hpc to 0.7.0.1
Bump hpc-bin to commit d1780eb2

- - - - -
e693a4e8 by Ben Gamari at 2024-01-24T01:30:56-05:00
testsuite: Ignore stderr in T8089

Otherwise spurious "Killed: 9" messages to stderr may cause the test to fail.
Fixes #24361.
- - - - -
a40f4ab2 by sheaf at 2024-01-24T14:04:33-05:00
Fix FMA instruction on LLVM

We were emitting the wrong instructions for fused multiply-add
operations on LLVM:

  - the instruction name is "llvm.fma.f32" or "llvm.fma.f64", not "fmadd"
  - LLVM does not support other instructions such as "fmsub"; instead
    we implement these by flipping signs of some arguments
  - the instruction is an LLVM intrinsic, which requires handling it
    like a normal function call instead of a machine instruction

Fixes #24223

- - - - -
69abc786 by Andrei Borzenkov at 2024-01-24T14:05:09-05:00
Add changelog entry for renaming tuples from (,,...,,) to Tuple<n> (24291)

- - - - -
0ac8f385 by Cheng Shao at 2024-01-25T00:27:48-05:00
compiler: remove unused GHC.Linker module

The GHC.Linker module is empty and unused, other than as a hack for
the make build system. We can remove it now that make is long gone;
the note is moved to GHC.Linker.Loader instead.

- - - - -
699da01b by Hécate Moonlight at 2024-01-25T00:28:27-05:00
Clarification for newtype constructors when using `coerce`

- - - - -
b2d8cd85 by Matt Walker at 2024-01-26T09:50:08-05:00
Fix #24308

Add tests for semicolon separated where clauses

- - - - -
0da490a1 by Ben Gamari at 2024-01-26T17:34:41-05:00
hsc2hs: Bump submodule

- - - - -
3f442fd2 by Ben Gamari at 2024-01-26T17:34:41-05:00
Bump containers submodule to 0.7

- - - - -
82a1c656 by Sebastian Nagel at 2024-01-29T02:32:40-05:00
base: with{Binary}File{Blocking} only annotates own exceptions

Fixes #20886

This ensures that inner, unrelated exceptions are not misleadingly
annotated with the opened file.

- - - - -
9294a086 by Andreas Klebinger at 2024-01-29T02:33:15-05:00
Fix fma warning when using llvm on aarch64.

On aarch64 fma is always on so the +fma flag doesn't exist for that
target. Hence no need to try and pass +fma to llvm.

Fixes #24379

- - - - -
ced2e731 by sheaf at 2024-01-29T17:27:12-05:00
No shadowing warnings for NoFieldSelector fields

This commit ensures we don't emit shadowing warnings when a user
shadows a field defined with NoFieldSelectors.

Fixes #24381

- - - - -
8eeadfad by Patrick at 2024-01-29T17:27:51-05:00
Fix bug wrong span of nested_doc_comment #24378

close #24378
1. Update the start position of span in `nested_doc_comment` correctly.
and hence the spans of identifiers of haddoc can be computed correctly.
2. add test `HaddockSpanIssueT24378`.

- - - - -
a557580f by Alexey Radkov at 2024-01-30T19:41:52-05:00
Fix irrelevant dodgy-foreign-imports warning on import f-pointers by value

A test *сс018* is attached (not sure about the naming convention though).
Note that without the fix, the test fails with the *dodgy-foreign-imports*
warning passed to stderr. The warning disappears after the fix.

GHC shouldn't warn on imports of natural function pointers from C by value
(which is feasible with CApiFFI), such as

```haskell
foreign import capi "cc018.h value f" f :: FunPtr (Int -> IO ())
```

where

```c
void (*f)(int);
```

See a related real-world use-case
[here](https://gitlab.com/daniel-casanueva/pcre-light/-/merge_requests/17).
There, GHC warns on import of C function pointer `pcre_free`.

- - - - -
ca99efaf by Alexey Radkov at 2024-01-30T19:41:53-05:00
Rename test cc018 -> T24034

- - - - -
88c38dd5 by Ben Gamari at 2024-01-30T19:42:28-05:00
rts/TraverseHeap.c: Ensure that PosixSource.h is included first
- - - - -
ca2e919e by Simon Peyton Jones at 2024-01-31T09:29:45+00:00
Make decomposeRuleLhs a bit more clever

This fixes #24370 by making decomposeRuleLhs undertand
dictionary /functions/ as well as plain /dictionaries/

- - - - -
94ce031d by Teo Camarasu at 2024-02-01T05:49:49-05:00
doc: Add -Dn flag to user guide

Resolves #24394
- - - - -
31553b11 by Ben Gamari at 2024-02-01T12:21:29-05:00
cmm: Introduce MO_RelaxedRead

In hand-written Cmm it can sometimes be necessary to atomically load
from memory deep within an expression (e.g. see the `CHECK_GC` macro).
This MachOp provides a convenient way to do so without breaking the
expression into multiple statements.

- - - - -
0785cf81 by Ben Gamari at 2024-02-01T12:21:29-05:00
codeGen: Use relaxed accesses in ticky bumping

- - - - -
be423dda by Ben Gamari at 2024-02-01T12:21:29-05:00
base: use atomic write when updating timer manager

- - - - -
8a310e35 by Ben Gamari at 2024-02-01T12:21:29-05:00
Use relaxed atomics to manipulate TSO status fields

- - - - -
d6809ee4 by Ben Gamari at 2024-02-01T12:21:29-05:00
rts: Add necessary barriers when manipulating TSO owner

- - - - -
39e3ac5d by Ben Gamari at 2024-02-01T12:21:29-05:00
rts: Use `switch` to branch on why_blocked

This is a semantics-preserving refactoring.

- - - - -
515eb33d by Ben Gamari at 2024-02-01T12:21:29-05:00
rts: Fix synchronization on thread blocking state

We now use a release barrier whenever we update a thread's blocking
state. This required widening StgTSO.why_blocked as AArch64 does not
support atomic writes on 16-bit values.

- - - - -
eb38812e by Ben Gamari at 2024-02-01T12:21:29-05:00
rts: Fix data race in threadPaused

This only affects an assertion in the debug RTS and only needs relaxed
ordering.

- - - - -
26c48dd6 by Ben Gamari at 2024-02-01T12:21:29-05:00
rts: Fix data race in threadStatus#

- - - - -
6af43ab4 by Ben Gamari at 2024-02-01T12:21:29-05:00
rts: Fix data race in Interpreter's preemption check

- - - - -
9502ad3c by Ben Gamari at 2024-02-01T12:21:29-05:00
rts/Messages: Fix data race

- - - - -
60802db5 by Ben Gamari at 2024-02-01T12:21:30-05:00
rts/Prof: Fix data race

- - - - -
ef8ccef5 by Ben Gamari at 2024-02-01T12:21:30-05:00
rts: Use relaxed ordering on dirty/clean info tables updates

When changing the dirty/clean state of a mutable object we needn't have
any particular ordering.

- - - - -
76fe2b75 by Ben Gamari at 2024-02-01T12:21:30-05:00
codeGen: Use relaxed-read in closureInfoPtr

- - - - -
a6316eb4 by Ben Gamari at 2024-02-01T12:21:30-05:00
STM: Use acquire loads when possible

Full sequential consistency is not needed here.

- - - - -
6bddfd3d by Ben Gamari at 2024-02-01T12:21:30-05:00
rts: Use fence rather than redundant load

Previously we would use an atomic load to ensure acquire ordering.
However, we now have `ACQUIRE_FENCE_ON`, which allows us to express this
more directly.

- - - - -
55c65dbc by Ben Gamari at 2024-02-01T12:21:30-05:00
rts: Fix data races in profiling timer

- - - - -
856b5e75 by Ben Gamari at 2024-02-01T12:21:30-05:00
Add Note [C11 memory model]

- - - - -
6534da24 by Cheng Shao at 2024-02-01T12:22:07-05:00
compiler: move generic cmm optimization logic in NCG to a standalone module

This commit moves GHC.CmmToAsm.cmmToCmm to a standalone module,
GHC.Cmm.GenericOpt. The main motivation is enabling this logic to be
run in the wasm backend NCG code, which is defined in other modules
that's imported by GHC.CmmToAsm, causing a cyclic dependency issue.

- - - - -
87e34888 by Cheng Shao at 2024-02-01T12:22:07-05:00
compiler: explicitly disable PIC in wasm32 NCG

This commit explicitly disables the ncgPIC flag for the wasm32 target.
The wasm backend doesn't support PIC for the time being.

- - - - -
c6ce242e by Cheng Shao at 2024-02-01T12:22:07-05:00
compiler: enable generic cmm optimizations in wasm backend NCG

This commit enables the generic cmm optimizations in other NCGs to be
run in the wasm backend as well, followed by a late cmm control-flow
optimization pass. The added optimizations do catch some corner cases
not handled by the pre-NCG cmm pipeline and are useful in generating
smaller CFGs.

- - - - -
151dda4e by Andrei Borzenkov at 2024-02-01T12:22:43-05:00
Namespacing for WARNING/DEPRECATED pragmas (#24396)

New syntax for WARNING and DEPRECATED pragmas was added,
namely namespace specifierss:

  namespace_spec ::= 'type' | 'data' | {- empty -}

  warning ::= warning_category namespace_spec namelist strings

  deprecation ::= namespace_spec namelist strings

A new data type was introduced to represent these namespace specifiers:

  data NamespaceSpecifier =
    NoSpecifier |
    TypeNamespaceSpecifier (EpToken "type") |
    DataNamespaceSpecifier (EpToken "data")

Extension field XWarning now contains this NamespaceSpecifier.

lookupBindGroupOcc function was changed: it now takes NamespaceSpecifier
and checks that the namespace of the found names matches the passed flag.
With this change {-# WARNING data D "..." #-} pragma will only affect value
namespace and {-# WARNING type D "..." #-} will only affect type
namespace. The same logic is applicable to DEPRECATED pragmas.

Finding duplicated warnings inside rnSrcWarnDecls now takes into
consideration NamespaceSpecifier flag to allow warnings with the
same names that refer to different namespaces.

- - - - -
38c3afb6 by Bryan Richter at 2024-02-01T12:23:19-05:00
CI: Disable the test-cabal-reinstall job

Fixes #24363

- - - - -
27020458 by Matthew Craven at 2024-02-03T01:53:26-05:00
Bump bytestring submodule to something closer to 0.12.1

...mostly so that 16d6b7e835ffdcf9b894e79f933dd52348dedd0c
(which reworks unaligned writes in Builder) and the stuff in
https://github.com/haskell/bytestring/pull/631 can see wider testing.

The less-terrible code for unaligned writes used in Builder on
hosts not known to be ulaigned-friendly also takes less effort
for GHC to compile, resulting in a metric decrease for T21839c
on some platforms.

The metric increase on T21839r is caused by the unrelated commit
750dac33465e7b59100698a330b44de7049a345c.  It perhaps warrants
further analysis and discussion (see #23822) but is not critical.

Metric Decrease:
T21839c
Metric Increase:
T21839r

- - - - -
cdddeb0f by Rodrigo Mesquita at 2024-02-03T01:54:02-05:00
Work around autotools setting C11 standard in CC/CXX

In autoconf >=2.70, C11 is set by default for $CC and $CXX via the
-std=...11 flag. In this patch, we split the "-std" flag out of the $CC
and $CXX variables, which we traditionally assume to be just the
executable name/path, and move it to $CFLAGS/$CXXFLAGS instead.

Fixes #24324

- - - - -
5ff7cc26 by Apoorv Ingle at 2024-02-03T13:14:46-06:00
Expand `do` blocks right before typechecking using the `HsExpansion` philosophy.

- Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206

- The change is detailed in
  - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do`
  - Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr`
         expains the rational of doing expansions in type checker as opposed to in the renamer

- Adds new datatypes:
  - `GHC.Hs.Expr.XXExprGhcRn`: new datatype makes this expansion work easier
    1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`)
    2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack

  - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated
    This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam`

  - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc`

- Ensures warnings such as
  1. Pattern match checks
  2. Failable patterns
  3. non-() return in body statements are preserved

- Kill `HsMatchCtxt` in favor of `TcMatchAltChecker`

- Testcases:
  * T18324 T20020 T23147 T22788 T15598 T22086
  * T23147b (error message check),
  * DoubleMatch (match inside a match for pmc check)
  * pattern-fails (check pattern match with non-refutable pattern, eg. newtype)
  * Simple-rec (rec statements inside do statment)
  * T22788 (code snippet from #22788)
  * DoExpanion1 (Error messages for body statments)
  * DoExpansion2 (Error messages for bind statements)
  * DoExpansion3 (Error messages for let statements)

Also repoint haddock to the right submodule so that the test (haddockHypsrcTest) pass

Metric Increase 'compile_time/bytes allocated':
    T9020

The testcase is a pathalogical example of a `do`-block with many statements that do nothing.
Given that we are expanding the statements into function binds, we will have to bear
a (small) 2% cost upfront in the compiler to unroll the statements.

- - - - -
0df8ce27 by Vladislav Zavialov at 2024-02-04T03:55:14-05:00
Reduce parser allocations in allocateCommentsP

In the most common case, the comment queue is empty, so we can skip the
work of processing it. This reduces allocations by about 10% in the
parsing001 test.

Metric Decrease:
    MultiLayerModulesRecomp
    parsing001

- - - - -
cfd68290 by Simon Peyton Jones at 2024-02-05T17:58:33-05:00
Stop dropping a case whose binder is demanded

This MR fixes #24251.

See Note [Case-to-let for strictly-used binders]
in GHC.Core.Opt.Simplify.Iteration, plus #24251, for
lots of discussion.

Final Nofib changes over 0.1%:
+-----------------------------------------
|        imaginary/digits-of-e2    -2.16%
|                imaginary/rfib    -0.15%
|                    real/fluid    -0.10%
|                   real/gamteb    -1.47%
|                       real/gg    -0.20%
|                 real/maillist    +0.19%
|                      real/pic    -0.23%
|                      real/scs    -0.43%
|               shootout/n-body    -0.41%
|        shootout/spectral-norm    -0.12%
+========================================
|                     geom mean    -0.05%

Pleasingly, overall executable size is down by just over 1%.

Compile times (in perf/compiler) wobble around a bit +/- 0.5%, but the
geometric mean is -0.1% which seems good.

- - - - -
e4d137bb by Simon Peyton Jones at 2024-02-05T17:58:33-05:00
Add Note [Bangs in Integer functions]

...to document the bangs in the functions in GHC.Num.Integer

- - - - -
ce90f12f by Andrei Borzenkov at 2024-02-05T17:59:09-05:00
Hide WARNING/DEPRECATED namespacing under -XExplicitNamespaces (#24396)

- - - - -
e2ea933f by Simon Peyton Jones at 2024-02-06T10:12:04-05:00
Refactoring in preparation for lazy skolemisation

* Make HsMatchContext and HsStmtContext be parameterised over the
  function name itself, rather than over the pass.
  See [mc_fun field of FunRhs] in Language.Haskell.Syntax.Expr
    - Replace types
        HsMatchContext GhcPs --> HsMatchContextPs
        HsMatchContext GhcRn --> HsMatchContextRn
        HsMatchContext GhcTc --> HsMatchContextRn  (sic! not Tc)
        HsStmtContext  GhcRn --> HsStmtContextRn
    - Kill off convertHsMatchCtxt

* Split GHC.Tc.Type.BasicTypes.TcSigInfo so that TcCompleteSig (describing
  a complete user-supplied signature) is its own data type.
    - Split TcIdSigInfo(CompleteSig, PartialSig) into
        TcCompleteSig(CSig)
        TcPartialSig(PSig)
    - Use TcCompleteSig in tcPolyCheck, CheckGen
    - Rename types and data constructors:
        TcIdSigInfo         --> TcIdSig
        TcPatSynInfo(TPSI)  --> TcPatSynSig(PatSig)
    - Shuffle around helper functions:
        tcSigInfoName           (moved to GHC.Tc.Types.BasicTypes)
        completeSigPolyId_maybe (moved to GHC.Tc.Types.BasicTypes)
        tcIdSigName             (inlined and removed)
        tcIdSigLoc              (introduced)
    - Rearrange the pattern match in chooseInferredQuantifiers

* Rename functions and types:
    tcMatchesCase         --> tcCaseMatches
    tcMatchesFun          --> tcFunBindMatches
    tcMatchLambda         --> tcLambdaMatches
    tcPats                --> tcMatchPats
    matchActualFunTysRho  --> matchActualFunTys
    matchActualFunTySigma --> matchActualFunTy

* Add HasDebugCallStack constraints to:
    mkBigCoreVarTupTy, mkBigCoreTupTy, boxTy,
    mkPiTy, mkPiTys, splitAppTys, splitTyConAppNoView_maybe

* Use `penv` from the outer context in the inner loop of
  GHC.Tc.Gen.Pat.tcMultiple

* Move tcMkVisFunTy, tcMkInvisFunTy, tcMkScaledFunTys down the file,
  factor out and export tcMkScaledFunTy.

* Move isPatSigCtxt down the file.

* Formatting and comments

Co-authored-by: Vladislav Zavialov <vlad.z.4096 at gmail.com>

- - - - -
f5d3e03c by Andrei Borzenkov at 2024-02-06T10:12:04-05:00
Lazy skolemisation for @a-binders (#17594)

This patch is a preparation for @a-binders implementation.  The main changes are:

* Skolemisation is now prepared to deal with @binders.
  See Note [Skolemisation overview] in GHC.Tc.Utils.Unify.
  Most of the action is in
    - Utils.Unify.matchExpectedFunTys
    - Gen.Pat.tcMatchPats
    - Gen.Expr.tcPolyExprCheck
    - Gen.Binds.tcPolyCheck

Some accompanying refactoring:

* I found that funTyConAppTy_maybe was doing a lot of allocation, and
  rejigged userTypeError_maybe to avoid calling it.

- - - - -
532993c8 by Zubin Duggal at 2024-02-06T10:12:41-05:00
driver: Really don't lose track of nodes when we fail to resolve cycles

This fixes a bug in 8db8d2fd1c881032b1b360c032b6d9d072c11723, where we could lose
track of acyclic components at the start of an unresolved cycle. We now ensure we
never loose track of any of these components.

As T24275 demonstrates, a "cyclic" SCC might not really be a true SCC:

When viewed without boot files, we have a single SCC

```
[REC main:T24275B [main:T24275B {-# SOURCE #-},
                   main:T24275A {-# SOURCE #-}]
     main:T24275A [main:T24275A {-# SOURCE #-}]]
```

But with boot files this turns into

```
[NONREC main:T24275B {-# SOURCE #-} [],
 REC main:T24275B [main:T24275B {-# SOURCE #-},
                   main:T24275A {-# SOURCE #-}]
    main:T24275A {-# SOURCE #-} [main:T24275B],
 NONREC main:T24275A [main:T24275A {-# SOURCE #-}]]
```

Note that this is truly not an SCC, as no nodes are reachable from T24275B.hs-boot.
However, we treat this entire group as a single "SCC" because it seems so when we
analyse the graph without taking boot files into account.

Indeed, we must return a single ResolvedCycle element in the BuildPlan for this
as described in Note [Upsweep].

However, since after resolving this is not a true SCC anymore, `findCycle` fails
to find a cycle and we have a sub-optimal error message as a result.

To handle this, I extended `findCycle` to not assume its input is an SCC, and to
try harder to find cycles in its input.

Fixes #24275

- - - - -
b35dd613 by Zubin Duggal at 2024-02-06T10:13:17-05:00
GHCi: Lookup breakpoint CCs in the correct module

We need to look up breakpoint CCs in the module that the breakpoint
points to, and not the current module.

Fixes #24327

- - - - -
b09e6958 by Zubin Duggal at 2024-02-06T10:13:17-05:00
testsuite: Add test for #24327

- - - - -
569b4c10 by doyougnu at 2024-02-07T03:06:26-05:00
ts: add compile_artifact, ignore_extension flag

In b521354216f2821e00d75f088d74081d8b236810 the testsuite gained the
capability to collect generic metrics. But this assumed that the test
was not linking and producing artifacts and we only wanted to track
object files, interface files, or build artifacts from the compiler
build. However, some backends, such as the JS backend, produce artifacts when
compiling, such as the jsexe directory which we want to track.

This patch:

- tweaks the testsuite to collect generic metrics on any build artifact
in the test directory.

- expands the exe_extension function to consider windows and adds the
ignore_extension flag.

- Modifies certain tests to add the ignore_extension flag. Tests such as
heaprof002 expect a .ps file, but on windows without ignore_extensions
the testsuite will look for foo.exe.ps. Hence the flag.

- adds the size_hello_artifact test

- - - - -
75a31379 by doyougnu at 2024-02-07T03:06:26-05:00
ts: add wasm_arch, heapprof002 wasm extension

- - - - -
c9731d6d by Rodrigo Mesquita at 2024-02-07T03:07:03-05:00
Synchronize bindist configure for #24324

In cdddeb0f1280b40cc194028bbaef36e127175c4c, we set up a
workaround for #24324 in the in-tree configure script, but forgot to
update the bindist configure script accordingly. This updates it.

- - - - -
d309f4e7 by Matthew Pickering at 2024-02-07T03:07:38-05:00
distrib/configure: Fix typo in CONF_GCC_LINKER_OPTS_STAGE2 variable

Instead we were setting CONF_GCC_LINK_OPTS_STAGE2 which meant that we
were missing passing `--target` when invoking the linker.

Fixes #24414

- - - - -
77db84ab by Ben Gamari at 2024-02-08T00:35:22-05:00
llvmGen: Adapt to allow use of new pass manager.

We now must use `-passes` in place of `-O<n>` due to #21936.

Closes #21936.

- - - - -
3c9ddf97 by Matthew Pickering at 2024-02-08T00:35:59-05:00
testsuite: Mark length001 as fragile on javascript

Modifying the timeout multiplier is not a robust way to get this test to
reliably fail. Therefore we mark it as fragile until/if javascript ever
supports the stack limit.

- - - - -
20b702b5 by Matthew Pickering at 2024-02-08T00:35:59-05:00
Javascript: Don't filter out rtsDeps list

This logic appears to be incorrect as it would drop any dependency which
was not in a direct dependency of the package being linked.

In the ghc-internals split this started to cause errors because
`ghc-internal` is not a direct dependency of most packages, and hence
important symbols to keep which are hard coded into the js runtime were
getting dropped.

- - - - -
2df96366 by Ben Gamari at 2024-02-08T00:35:59-05:00
base: Cleanup whitespace in cbits

- - - - -
44f6557a by Ben Gamari at 2024-02-08T00:35:59-05:00
Move `base` to `ghc-internal`

Here we move a good deal of the implementation of `base` into a new
package, `ghc-internal` such that it can be evolved independently
from the user-visible interfaces of `base`.

While we want to isolate implementation from interfaces, naturally, we
would like to avoid turning `base` into a mere set of module re-exports.
However, this is a non-trivial undertaking for a variety of reasons:

 * `base` contains numerous known-key and wired-in things, requiring
   corresponding changes in the compiler

 * `base` contains a significant amount of C code and corresponding
   autoconf logic, which is very fragile and difficult to break apart

 * `base` has numerous import cycles, which are currently dealt with via
   carefully balanced `hs-boot` files

 * We must not break existing users

To accomplish this migration, I tried the following approaches:

* [Split-GHC.Base]: Break apart the GHC.Base knot to allow incremental
  migration of modules into ghc-internal: this knot is simply too
  intertwined to be easily pulled apart, especially given the rather
  tricky import cycles that it contains)

* [Move-Core]: Moving the "core" connected component of base (roughly
  150 modules) into ghc-internal. While the Haskell side of this seems
  tractable, the C dependencies are very subtle to break apart.

* [Move-Incrementally]:

  1. Move all of base into ghc-internal
  2. Examine the module structure and begin moving obvious modules (e.g.
     leaves of the import graph) back into base
  3. Examine the modules remaining in ghc-internal, refactor as necessary
     to facilitate further moves
  4. Go to (2) iterate until the cost/benefit of further moves is
     insufficient to justify continuing
  5. Rename the modules moved into ghc-internal to ensure that they don't
     overlap with those in base
  6. For each module moved into ghc-internal, add a shim module to base
     with the declarations which should be exposed and any requisite
     Haddocks (thus guaranteeing that base will be insulated from changes
     in the export lists of modules in ghc-internal

Here I am using the [Move-Incrementally] approach, which is empirically
the least painful of the unpleasant options above

Bumps haddock submodule.

Metric Decrease:
    haddock.Cabal
    haddock.base
Metric Increase:
    MultiComponentModulesRecomp
    T16875
    size_hello_artifact

- - - - -
e8fb2451 by Vladislav Zavialov at 2024-02-08T00:36:36-05:00
Haddock comments on infix constructors (#24221)

Rewrite the `HasHaddock` instance for `ConDecl GhcPs` to account for
infix constructors.

This change fixes a Haddock regression (introduced in 19e80b9af252)
that affected leading comments on infix data constructor declarations:

	-- | Docs for infix constructor
	| Int :* Bool

The comment should be associated with the data constructor (:*), not
with its left-hand side Int.

- - - - -
9060d55b by Ben Gamari at 2024-02-08T00:37:13-05:00
Add os-string as a boot package

Introduces `os-string` submodule. This will be necessary for
`filepath-1.5`.

- - - - -
9d65235a by Ben Gamari at 2024-02-08T00:37:13-05:00
gitignore: Ignore .hadrian_ghci_multi/

- - - - -
d7ee12ea by Ben Gamari at 2024-02-08T00:37:13-05:00
hadrian: Set -this-package-name

When constructing the GHC flags for a package Hadrian must take care to
set `-this-package-name` in addition to `-this-unit-id`. This hasn't
broken until now as we have not had any uses of qualified package
imports. However, this will change with `filepath-1.5` and the
corresponding `unix` bump, breaking `hadrian/multi-ghci`.

- - - - -
f2dffd2e by Ben Gamari at 2024-02-08T00:37:13-05:00
Bump filepath to 1.5.0.0

Required bumps of the following submodules:

 * `directory`
 * `filepath`
 * `haskeline`
 * `process`
 * `unix`
 * `hsc2hs`
 * `Win32`
 * `semaphore-compat`

and the addition of `os-string` as a boot package.

- - - - -
ab533e71 by Matthew Pickering at 2024-02-08T00:37:50-05:00
Use specific clang assembler when compiling with -fllvm

There are situations where LLVM will produce assembly which older gcc
toolchains can't handle. For example on Deb10, it seems that LLVM >= 13
produces assembly which the default gcc doesn't support.

A more robust solution in the long term is to require a specific LLVM
compatible assembler when using -fllvm.

Fixes #16354

- - - - -
c32b6426 by Matthew Pickering at 2024-02-08T00:37:50-05:00
Update CI images with LLVM 15, ghc-9.6.4 and cabal-install-3.10.2.0

- - - - -
5fcd58be by Matthew Pickering at 2024-02-08T00:37:50-05:00
Update bootstrap plans for 9.4.8 and 9.6.4

- - - - -
707a32f5 by Matthew Pickering at 2024-02-08T00:37:50-05:00
Add alpine 3_18 release job

This is mainly experimental and future proofing to enable a smooth
transition to newer alpine releases once 3_12 is too old.

- - - - -
c37931b3 by John Ericson at 2024-02-08T06:39:05-05:00
Generate LLVM min/max bound policy via Hadrian

Per #23966, I want the top-level configure to only generate
configuration data for Hadrian, not do any "real" tasks on its own.
This is part of that effort --- one less file generated by it.

(It is still done with a `.in` file, so in a future world non-Hadrian
also can easily create this file.)

Split modules:

- GHC.CmmToLlvm.Config
- GHC.CmmToLlvm.Version
- GHC.CmmToLlvm.Version.Bounds
- GHC.CmmToLlvm.Version.Type

This also means we can get rid of the silly `unused.h` introduced in
!6803 / 7dfcab2f4bcb7206174ea48857df1883d05e97a2 as temporary kludge.

Part of #23966

- - - - -
9f987235 by Apoorv Ingle at 2024-02-08T06:39:42-05:00
Enable mdo statements to use HsExpansions
Fixes: #24411
Added test T24411 for regression

- - - - -
762b2120 by Jade at 2024-02-08T15:17:15+00:00
Improve Monad, Functor & Applicative docs

This patch aims to improve the documentation of Functor, Applicative,
Monad and related symbols. The main goal is to make it more consistent
and make accessible. See also: !10979 (closed) and !10985 (closed)

Ticket #17929

Updates haddock submodule

- - - - -
151770ca by Josh Meredith at 2024-02-10T14:28:15-05:00
JavaScript codegen: Use GHC's tag inference where JS backend-specific evaluation inference was previously used (#24309)

- - - - -
2e880635 by Zubin Duggal at 2024-02-10T14:28:51-05:00
ci: Allow release-hackage-lint to fail

Otherwise it blocks the ghcup metadata pipeline from running.

- - - - -
b0293f78 by Matthew Pickering at 2024-02-10T14:29:28-05:00
rts: eras profiling mode

The eras profiling mode is useful for tracking the life-time of
closures. When a closure is written, the current era is recorded in the
profiling header. This records the era in which the closure was created.

* Enable with -he
* User mode: Use functions ghc-experimental module GHC.Profiling.Eras to modify the era
* Automatically: --automatic-era-increment, increases the user era on major
  collections
* The first era is era 1
* -he<era> can be used with other profiling modes to select a specific
  era

If you just want to record the era but not to perform heap profiling you
can use `-he --no-automatic-heap-samples`.

https://well-typed.com/blog/2024/01/ghc-eras-profiling/

Fixes #24332

- - - - -
be674a2c by Jade at 2024-02-10T14:30:04-05:00
Adjust error message for trailing whitespace in as-pattern.

Fixes #22524

- - - - -
53ef83f9 by doyougnu at 2024-02-10T14:30:47-05:00
gitlab: js: add codeowners

Fixes:
- #24409

Follow on from:
- #21078 and MR !9133
- When we added the JS backend this was forgotten. This patch adds the
rightful codeowners.

- - - - -
8bbe12f2 by Matthew Pickering at 2024-02-10T14:31:23-05:00
Bump CI images so that alpine3_18 image includes clang15

The only changes here are that clang15 is now installed on the
alpine-3_18 image.

- - - - -
df9fd9f7 by Sylvain Henry at 2024-02-12T12:18:42-05:00
JS: handle stored null StablePtr

Some Haskell codes unsafely cast StablePtr into ptr to compare against
NULL. E.g. in direct-sqlite:

  if castStablePtrToPtr aggStPtr /= nullPtr then

where `aggStPtr` is read (`peek`) from zeroed memory initially.

We fix this by giving these StablePtr the same representation as other
null pointers. It's safe because StablePtr at offset 0 is unused (for
this exact reason).

- - - - -
55346ede by Sylvain Henry at 2024-02-12T12:18:42-05:00
JS: disable MergeObjsMode test

This isn't implemented for JS backend objects.

- - - - -
aef587f6 by Sylvain Henry at 2024-02-12T12:18:42-05:00
JS: add support for linking C sources

Support linking C sources with JS output of the JavaScript backend.
See the added documentation in the users guide.

The implementation simply extends the JS linker to use the objects (.o)
that were already produced by the emcc compiler and which were filtered
out previously. I've also added some options to control the link with C
functions (see the documentation about pragmas).

With this change I've successfully compiled the direct-sqlite package
which embeds the sqlite.c database code. Some wrappers are still
required (see the documentation about wrappers) but everything generic
enough to be reused for other libraries have been integrated into
rts/js/mem.js.

- - - - -
b71b392f by Sylvain Henry at 2024-02-12T12:18:42-05:00
JS: avoid EMCC logging spurious failure

emcc would sometime output messages like:

  cache:INFO: generating system asset: symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/424b44514e43d789148e69e4e7d1c7fdc0350b79.json" for subsequent builds)
  cache:INFO:  - ok

Cf https://github.com/emscripten-core/emscripten/issues/18607

This breaks our tests matching the stderr output. We avoid this by setting EMCC_LOGGING=0

- - - - -
ff2c0cc9 by Simon Peyton Jones at 2024-02-12T12:19:17-05:00
Remove a dead comment

Just remove an out of date block of commented-out code, and tidy up
the relevant Notes.  See #8317.

- - - - -
bedb4f0d by Teo Camarasu at 2024-02-12T18:50:33-05:00
nonmoving: Add support for heap profiling

Add support for heap profiling while using the nonmoving collector.

We greatly simply the implementation by disabling concurrent collection for
GCs when heap profiling is enabled. This entails that the marked objects on
the nonmoving heap are exactly the live objects.

Note that we match the behaviour for live bytes accounting by taking the size
of objects on the nonmoving heap to be that of the segment's block
rather than the object itself.

Resolves #22221

- - - - -
d0d5acb5 by Teo Camarasu at 2024-02-12T18:51:09-05:00
doc: Add requires prof annotation to options that require it

Resolves #24421

- - - - -
57bb8c92 by Cheng Shao at 2024-02-13T14:07:49-05:00
deriveConstants: add needed constants for wasm backend

This commit adds needed constants to deriveConstants. They are used by
RTS code in the wasm backend to support the JSFFI logic.

- - - - -
615eb855 by Cheng Shao at 2024-02-13T14:07:49-05:00
compiler: make genSym use C-based atomic increment on non-JS 32-bit platforms

The pure Haskell implementation causes i386 regression in unrelated
work that can be fixed by using C-based atomic increment, see added
comment for details.

- - - - -
a9918891 by Cheng Shao at 2024-02-13T14:07:49-05:00
compiler: allow JSFFI for wasm32

This commit allows the javascript calling convention to be used when
the target platform is wasm32.

- - - - -
8771a53b by Cheng Shao at 2024-02-13T14:07:49-05:00
compiler: allow boxed JSVal as a foreign type

This commit allows the boxed JSVal type to be used as a foreign
argument/result type.

- - - - -
053c92b3 by Cheng Shao at 2024-02-13T14:07:49-05:00
compiler: ensure ctors have the right priority on wasm32

This commit fixes the priorities of ctors generated by GHC codegen on
wasm32, see the referred note for details.

- - - - -
b7942e0a by Cheng Shao at 2024-02-13T14:07:49-05:00
compiler: add JSFFI desugar logic for wasm32

This commit adds JSFFI desugar logic for the wasm backend.

- - - - -
2c1dca76 by Cheng Shao at 2024-02-13T14:07:49-05:00
compiler: add JavaScriptFFI to supported extension list on wasm32

This commit adds JavaScriptFFI as a supported extension when the
target platform is wasm32.

- - - - -
9ad0e2b4 by Cheng Shao at 2024-02-13T14:07:49-05:00
rts/ghc-internal: add JSFFI support logic for wasm32

This commit adds rts/ghc-internal logic to support the wasm backend's
JSFFI functionality.

- - - - -
e9ebea66 by Cheng Shao at 2024-02-13T14:07:49-05:00
ghc-internal: fix threadDelay for wasm in browsers

This commit fixes broken threadDelay for wasm when it runs in
browsers, see added note for detailed explanation.

- - - - -
f85f3fdb by Cheng Shao at 2024-02-13T14:07:49-05:00
utils: add JSFFI utility code

This commit adds JavaScript util code to utils to support the wasm
backend's JSFFI functionality:

- jsffi/post-link.mjs, a post-linker to process the linked wasm module
  and emit a small complement JavaScript ESM module to be used with it
  at runtime
- jsffi/prelude.js, a tiny bit of prelude code as the JavaScript side
  of runtime logic
- jsffi/test-runner.mjs, run the jsffi test cases

Co-authored-by: amesgen <amesgen at amesgen.de>

- - - - -
77e91500 by Cheng Shao at 2024-02-13T14:07:49-05:00
hadrian: distribute jsbits needed for wasm backend's JSFFI support

The post-linker.mjs/prelude.js files are now distributed in the
bindist libdir, so when using the wasm backend's JSFFI feature, the
user wouldn't need to fetch them from a ghc checkout manually.

- - - - -
c47ba1c3 by Cheng Shao at 2024-02-13T14:07:49-05:00
testsuite: add opts.target_wrapper

This commit adds opts.target_wrapper which allows overriding the
target wrapper on a per test case basis when testing a cross target.
This is used when testing the wasm backend's JSFFI functionality; the
rest of the cases are tested using wasmtime, though the jsffi cases
are tested using the node.js based test runner.

- - - - -
8e048675 by Cheng Shao at 2024-02-13T14:07:49-05:00
testsuite: T22774 should work for wasm JSFFI

T22774 works since the wasm backend now supports the JSFFI feature.

- - - - -
1d07f9a6 by Cheng Shao at 2024-02-13T14:07:49-05:00
testsuite: add JSFFI test cases for wasm backend

This commit adds a few test cases for the wasm backend's JSFFI
functionality, as well as a simple README to instruct future
contributors to add new test cases.

- - - - -
b8997080 by Cheng Shao at 2024-02-13T14:07:49-05:00
docs: add documentation for wasm backend JSFFI

This commit adds changelog and user facing documentation for the wasm
backend's JSFFI feature.

- - - - -
ffeb000d by David Binder at 2024-02-13T14:08:30-05:00
Add tests from libraries/process/tests and libraries/Win32/tests to GHC

These tests were previously part of the libraries, which themselves are
submodules of the GHC repository. This commit moves the tests directly
to the GHC repository.

- - - - -
5a932cf2 by David Binder at 2024-02-13T14:08:30-05:00
Do not execute win32 tests on non-windows runners

- - - - -
500d8cb8 by Jade at 2024-02-13T14:09:07-05:00
prevent GHCi (and runghc) from suggesting other symbols when not finding main

Fixes: #23996

- - - - -
b19ec331 by Cheng Shao at 2024-02-13T14:09:46-05:00
rts: update xxHash to v0.8.2

- - - - -
4a97bdb8 by Cheng Shao at 2024-02-13T14:09:46-05:00
rts: use XXH3_64bits hash on all 64-bit platforms

This commit enables XXH3_64bits hash to be used on all 64-bit
platforms. Previously it was only enabled on x86_64, so platforms like
aarch64 silently falls back to using XXH32 which degrades the hashing
function quality.

- - - - -
ee01de7d by Cheng Shao at 2024-02-13T14:09:46-05:00
rts: define XXH_INLINE_ALL

This commit cleans up how we include the xxhash.h header and only
define XXH_INLINE_ALL, which is sufficient to inline the xxHash
functions without symbol collision.

- - - - -
0e01e1db by Alan Zimmerman at 2024-02-14T02:13:22-05:00
EPA: Move EpAnn out of extension points

Leaving a few that are too tricky, maybe some other time.

Also
 - remove some unneeded helpers from Parser.y
 - reduce allocations with strictness annotations

Updates haddock submodule

Metric Decrease:
    parsing001

- - - - -
de589554 by Andreas Klebinger at 2024-02-14T02:13:59-05:00
Fix ffi callbacks with >6 args and non-64bit args.

Check for ptr/int arguments rather than 64-bit width arguments when counting
integer register arguments.
The old approach broke when we stopped using exclusively W64-sized types to represent
sub-word sized integers.

Fixes #24314

- - - - -
325b7613 by Ben Gamari at 2024-02-14T14:27:45-05:00
rts/EventLog: Place eliminate duplicate strlens

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

- - - - -
8aafa51c by Ben Gamari at 2024-02-14T14:27:46-05:00
rts/eventlog: Place upper bound on IPE string field lengths

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

- - - - -
0e60d52c by Zubin Duggal at 2024-02-14T14:27:46-05:00
rts: drop unused postString function

- - - - -
d8d1333a by Cheng Shao at 2024-02-14T14:28:23-05:00
compiler/rts: fix wasm unreg regression

This commit fixes two wasm unreg regressions caught by a nightly
pipeline:

- Unknown stg_scheduler_loopzh symbol when compiling scheduler.cmm
- Invalid _hs_constructor(101) function name when handling ctor

- - - - -
264a4fa9 by Owen Shepherd at 2024-02-15T09:41:06-05:00
feat: Add sortOn to Data.List.NonEmpty

Adds `sortOn` to `Data.List.NonEmpty`, and adds
comments describing when to use it, compared to
`sortWith` or `sortBy . comparing`.

The aim is to smooth out the API between
`Data.List`, and `Data.List.NonEmpty`.

This change has been discussed in the
[clc issue](https://github.com/haskell/core-libraries-committee/issues/227).

- - - - -
b57200de by Fendor at 2024-02-15T09:41:47-05:00
Prefer RdrName over OccName for looking up locations in doc renaming step

Looking up by OccName only does not take into account when functions are
only imported in a qualified way.

Fixes issue #24294

Bump haddock submodule to include regression test

- - - - -
8ad02724 by Luite Stegeman at 2024-02-15T17:33:32-05:00
JS: add simple optimizer

The simple optimizer reduces the size of the code generated by the
JavaScript backend without the complexity and performance penalty
of the optimizer in GHCJS.

Also see #22736

Metric Decrease:
    libdir
    size_hello_artifact

- - - - -
20769b36 by Matthew Pickering at 2024-02-15T17:34:07-05:00
base: Expose `--no-automatic-time-samples` in `GHC.RTS.Flags` API

This patch builds on 5077416e12cf480fb2048928aa51fa4c8fc22cf1 and
modifies the base API to reflect the new RTS flag.

CLC proposal #243 - https://github.com/haskell/core-libraries-committee/issues/243

Fixes #24337

- - - - -
08031ada by Teo Camarasu at 2024-02-16T13:37:00-05:00
base: export System.Mem.performBlockingMajorGC

The corresponding C function was introduced in
ba73a807edbb444c49e0cf21ab2ce89226a77f2e. As part of #22264.

Resolves #24228

The CLC proposal was disccused at: https://github.com/haskell/core-libraries-committee/issues/230

Co-authored-by: Ben Gamari <bgamari.foss at gmail.com>

- - - - -
1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00
Fix C output for modern C initiative

GCC 14 on aarch64 rejects the C code written by GHC with this kind of
error:

   error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion]
         68 | *(ffi_arg*)resp = cret;
            |                 ^

Add the correct cast.

For more information on this see:
https://fedoraproject.org/wiki/Changes/PortingToModernC

Tested-by: Richard W.M. Jones <rjones at redhat.com>

- - - - -
5d3f7862 by Matthew Craven at 2024-02-16T13:38:18-05:00
Bump bytestring submodule to 0.12.1.0

- - - - -
902ebcc2 by Ian-Woo Kim at 2024-02-17T06:01:01-05:00
Add missing BCO handling in scavenge_one.

- - - - -
97d26206 by Sylvain Henry at 2024-02-17T06:01:44-05:00
Make cast between words and floats real primops (#24331)

First step towards fixing #24331. Replace foreign prim imports with real
primops.

- - - - -
a40e4781 by Sylvain Henry at 2024-02-17T06:01:44-05:00
Perf: add constant folding for bitcast between float and word (#24331)

- - - - -
5fd2c00f by Sylvain Henry at 2024-02-17T06:01:44-05:00
Perf: replace stack checks with assertions in casting primops

There are RESERVED_STACK_WORDS free words (currently 21) on the stack,
so omit the checks.

Suggested by Cheng Shao.

- - - - -
401dfe7b by Sylvain Henry at 2024-02-17T06:01:44-05:00
Reexport primops from GHC.Float + add deprecation

- - - - -
4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00
rts/Hash: Don't iterate over chunks if we don't need to free data

When freeing a `HashTable` there is no reason to walk over the hash list
before freeing it if the user has not given us a `dataFreeFun`.

Noticed while looking at #24410.

- - - - -
bd5a1f91 by Cheng Shao at 2024-02-17T06:03:00-05:00
compiler: add SEQ_CST fence support

In addition to existing Acquire/Release fences, this commit adds
SEQ_CST fence support to GHC, allowing Cmm code to explicitly emit a
fence that enforces total memory ordering. The following logic is
added:

- The MO_SeqCstFence callish MachOp
- The %prim fence_seq_cst() Cmm syntax and the SEQ_CST_FENCE macro in Cmm.h
- MO_SeqCstFence lowering logic in every single GHC codegen backend

- - - - -
2ce2a493 by Cheng Shao at 2024-02-17T06:03:38-05:00
testsuite: fix hs_try_putmvar002 for targets without pthread.h

hs_try_putmvar002 includes pthread.h and doesn't work on targets
without this header (e.g. wasm32). It doesn't need to include this
header at all. This was previously unnoticed by wasm CI, though recent
toolchain upgrade brought in upstream changes that completely removes
pthread.h in the single-threaded wasm32-wasi sysroot, therefore we
need to handle that change.

- - - - -
1fb3974e by Cheng Shao at 2024-02-17T06:03:38-05:00
ci: bump ci-images to use updated wasm image

This commit bumps our ci-images revision to use updated wasm image.

- - - - -
56e3f097 by Andrew Lelechenko at 2024-02-17T06:04:13-05:00
Bump submodule text to 2.1.1

T17123 allocates less because of improvements to Data.Text.concat in 1a6a06a.

Metric Decrease:
    T17123

- - - - -
a7569495 by Cheng Shao at 2024-02-17T06:04:51-05:00
rts: remove redundant rCCCS initialization

This commit removes the redundant logic of initializing each
Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before
initProfiling() is called during RTS startup, each Capability's rCCCS
has already been assigned CCS_SYSTEM when they're first initialized.

- - - - -
7a0293cc by Ben Gamari at 2024-02-19T07:11:00-05:00
Drop dependence on `touch`

This drops GHC's dependence on the `touch` program, instead implementing
it within GHC. This eliminates an external dependency and means that we
have one fewer program to keep track of in the `configure` script

- - - - -
0dbd729e by Andrei Borzenkov at 2024-02-19T07:11:37-05:00
Parser, renamer, type checker for @a-binders (#17594)

GHC Proposal 448 introduces binders for invisible type arguments
(@a-binders) in various contexts. This patch implements @-binders
in lambda patterns and function equations:

  {-# LANGUAGE TypeAbstractions #-}

  id1 :: a -> a
  id1 @t x = x :: t      -- @t-binder on the LHS of a function equation

  higherRank :: (forall a. (Num a, Bounded a) => a -> a) -> (Int8, Int16)
  higherRank f = (f 42, f 42)

  ex :: (Int8, Int16)
  ex = higherRank (\ @a x -> maxBound @a - x )
                         -- @a-binder in a lambda pattern in an argument
                         -- to a higher-order function

Syntax
------

To represent those @-binders in the AST, the list of patterns in Match
now uses ArgPat instead of Pat:

  data Match p body
     = Match {
         ...
-        m_pats  :: [LPat p],
+        m_pats  :: [LArgPat p],
         ...
   }

+ data ArgPat pass
+   = VisPat (XVisPat pass) (LPat pass)
+   | InvisPat (XInvisPat pass) (HsTyPat (NoGhcTc pass))
+   | XArgPat !(XXArgPat pass)

The VisPat constructor represents patterns for visible arguments,
which include ordinary value-level arguments and required type arguments
(neither is prefixed with a @), while InvisPat represents invisible type
arguments (prefixed with a @).

Parser
------

In the grammar (Parser.y), the lambda and lambda-cases productions of
aexp non-terminal were updated to accept argpats instead of apats:

  aexp : ...
-        | '\\' apats '->' exp
+        | '\\' argpats '->' exp
         ...
-        | '\\' 'lcases' altslist(apats)
+        | '\\' 'lcases' altslist(argpats)
         ...

+ argpat : apat
+        | PREFIX_AT atype

Function left-hand sides did not require any changes to the grammar, as
they were already parsed with productions capable of parsing @-binders.
Those binders were being rejected in post-processing (isFunLhs), and now
we accept them.

In Parser.PostProcess, patterns are constructed with the help of
PatBuilder, which is used as an intermediate data structure when
disambiguating between FunBind and PatBind. In this patch we define
ArgPatBuilder to accompany PatBuilder. ArgPatBuilder is a short-lived
data structure produced in isFunLhs and consumed in checkFunBind.

Renamer
-------

Renaming of @-binders builds upon prior work on type patterns,
implemented in 2afbddb0f24, which guarantees proper scoping and
shadowing behavior of bound type variables.

This patch merely defines rnLArgPatsAndThen to process a mix of visible
and invisible patterns:

+ rnLArgPatsAndThen :: NameMaker -> [LArgPat GhcPs] -> CpsRn [LArgPat GhcRn]
+ rnLArgPatsAndThen mk = mapM (wrapSrcSpanCps rnArgPatAndThen) where
+   rnArgPatAndThen (VisPat x p)    = ... rnLPatAndThen ...
+   rnArgPatAndThen (InvisPat _ tp) = ... rnHsTyPat ...

Common logic between rnArgPats and rnPats is factored out into the
rn_pats_general helper.

Type checker
------------

Type-checking of @-binders builds upon prior work on lazy skolemisation,
implemented in f5d3e03c56f.

This patch extends tcMatchPats to handle @-binders. Now it takes and
returns a list of LArgPat rather than LPat:

  tcMatchPats ::
              ...
-             -> [LPat GhcRn]
+             -> [LArgPat GhcRn]
              ...
-             -> TcM ([LPat GhcTc], a)
+             -> TcM ([LArgPat GhcTc], a)

Invisible binders in the Match are matched up with invisible (Specified)
foralls in the type. This is done with a new clause in the `loop` worker
of tcMatchPats:

  loop :: [LArgPat GhcRn] -> [ExpPatType] -> TcM ([LArgPat GhcTc], a)
  loop (L l apat : pats) (ExpForAllPatTy (Bndr tv vis) : pat_tys)
    ...
    -- NEW CLAUSE:
    | InvisPat _ tp <- apat, isSpecifiedForAllTyFlag vis
    = ...

In addition to that, tcMatchPats no longer discards type patterns. This
is done by filterOutErasedPats in the desugarer instead.

x86_64-linux-deb10-validate+debug_info
Metric Increase:
    MultiLayerModulesTH_OneShot

- - - - -
486979b0 by Jade at 2024-02-19T07:12:13-05:00
Add specialized sconcat implementation for Data.Monoid.First and Data.Semigroup.First

Approved CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/246
Fixes: #24346

- - - - -
17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00
Fix reST in users guide

It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax.

- - - - -
35b0ad90 by Brandon Chinn at 2024-02-19T07:13:25-05:00
Fix searching for errors in sphinx build

- - - - -
4696b966 by Cheng Shao at 2024-02-19T07:14:02-05:00
hadrian: fix wasm backend post linker script permissions

The post-link.mjs script was incorrectly copied and installed as a
regular data file without executable permission, this commit fixes it.

- - - - -
a6142e0c by Cheng Shao at 2024-02-19T07:14:40-05:00
testsuite: mark T23540 as fragile on i386

See #24449 for details.

- - - - -
249caf0d by Matthew Craven at 2024-02-19T20:36:09-05:00
Add @since annotation to Data.Data.mkConstrTag

- - - - -
cdd939e7 by Jade at 2024-02-19T20:36:46-05:00
Enhance documentation of Data.Complex

- - - - -
d04f384f by Ben Gamari at 2024-02-21T04:59:23-05:00
hadrian/bindist: Ensure that phony rules are marked as such

Otherwise make may not run the rule if file with the same name as the
rule happens to exist.

- - - - -
efcbad2d by Ben Gamari at 2024-02-21T04:59:23-05:00
hadrian: Generate HSC2HS_EXTRAS variable in bindist installation

We must generate the hsc2hs wrapper at bindist installation time since
it must contain `--lflag` and `--cflag` arguments which depend upon the
installation path.

The solution here is to substitute these variables in the configure
script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in
the install rules.

Fixes #24050.

- - - - -
c540559c by Matthew Pickering at 2024-02-21T04:59:23-05:00
ci: Show --info for installed compiler

- - - - -
ab9281a2 by Matthew Pickering at 2024-02-21T04:59:23-05:00
configure: Correctly set --target flag for linker opts

Previously we were trying to use the FP_CC_SUPPORTS_TARGET with 4
arguments, when it only takes 3 arguments. Instead we need to use the
`FP_PROG_CC_LINKER_TARGET` function in order to set the linker flags.

Actually fixes #24414

- - - - -
9460d504 by Rodrigo Mesquita at 2024-02-21T04:59:59-05:00
configure: Do not override existing linker flags in FP_LD_NO_FIXUP_CHAINS

- - - - -
77629e76 by Andrei Borzenkov at 2024-02-21T05:00:35-05:00
Namespacing for fixity signatures (#14032)

Namespace specifiers were added to syntax of fixity signatures:
  - sigdecl ::= infix prec ops | ...
  + sigdecl ::= infix prec namespace_spec ops | ...

To preserve namespace during renaming MiniFixityEnv type
now has separate FastStringEnv fields for names that should be
on the term level and for name that should be on the type level.

makeMiniFixityEnv function was changed to fill MiniFixityEnv in the right way:
 - signatures without namespace specifiers fill both fields
 - signatures with 'data' specifier fill data field only
 - signatures with 'type' specifier fill type field only

Was added helper function lookupMiniFixityEnv that takes care about
looking for a name in an appropriate namespace.

Updates haddock submodule.

Metric Decrease:
    MultiLayerModulesTH_OneShot

- - - - -
84357d11 by Teo Camarasu at 2024-02-21T05:01:11-05:00
rts: only collect live words in nonmoving census when non-concurrent

This avoids segfaults when the mutator modifies closures as we examine
them.

Resolves #24393

- - - - -
9ca56dd3 by Ian-Woo Kim at 2024-02-21T05:01:53-05:00
mutex wrap in refreshProfilingCCSs

- - - - -
1387966a by Cheng Shao at 2024-02-21T05:02:32-05:00
rts: remove unused HAVE_C11_ATOMICS macro

This commit removes the unused HAVE_C11_ATOMICS macro. We used to have
a few places that have fallback paths when HAVE_C11_ATOMICS is not
defined, but that is completely redundant, since the
FP_CC_SUPPORTS__ATOMICS configure check will fail when the C compiler
doesn't support C11 style atomics. There are also many places (e.g. in
unreg backend, SMP.h, library cbits, etc) where we unconditionally use
C11 style atomics anyway which work in even CentOS 7 (gcc 4.8), the
oldest distro we test in our CI, so there's no value in keeping
HAVE_C11_ATOMICS.

- - - - -
0f40d68f by Andreas Klebinger at 2024-02-21T05:03:09-05:00
RTS: -Ds - make sure incall is non-zero before dereferencing it.

Fixes #24445

- - - - -
e5886de5 by Ben Gamari at 2024-02-21T05:03:44-05:00
rts/AdjustorPool: Use ExecPage abstraction

This is just a minor cleanup I found while reviewing the implementation.

- - - - -
65dfb60f by Ben Gamari at 2024-02-21T22:07:01-05:00
ghc-internal: Move modules into GHC.Internal.* namespace

- - - - -
e40744ad by Ben Gamari at 2024-02-21T22:07:01-05:00
ghc-internal: Rewrite `@since ` to `@since base-`

These will be incrementally moved to the export sites in `base` where
possible.

- - - - -
cb1aac38 by Ben Gamari at 2024-02-21T22:07:01-05:00
base: Migrate Haddock `not-home` pragmas from `ghc-internal`

This ensures that we do not use `base` stub modules as declarations'
homes when not appropriate.

- - - - -
4652a998 by Ben Gamari at 2024-02-21T22:07:01-05:00
base: Partially freeze exports of GHC.Base

Sadly there are still a few module reexports. However, at least we have
decoupled from the exports of `GHC.Internal.Base`.

- - - - -
751e77c1 by GHC GitLab CI at 2024-02-21T22:49:27-05:00
ifixes

- - - - -


23 changed files:

- − .appveyor.sh
- .editorconfig
- .ghcid
- .gitignore
- .gitlab-ci.yml
- .gitlab/ci.sh
- − .gitlab/circle-ci-job.sh
- .gitlab/darwin/nix/sources.json
- .gitlab/darwin/toolchain.nix
- − .gitlab/gen_ci.hs
- + .gitlab/generate-ci/LICENSE
- + .gitlab/generate-ci/README.mkd
- + .gitlab/generate-ci/flake.lock
- + .gitlab/generate-ci/flake.nix
- + .gitlab/generate-ci/gen_ci.hs
- + .gitlab/generate-ci/generate-ci.cabal
- + .gitlab/generate-ci/generate-job-metadata
- + .gitlab/generate-ci/generate-jobs
- + .gitlab/generate-ci/hie.yaml
- − .gitlab/generate_jobs
- + .gitlab/hello.hs
- − .gitlab/issue_templates/bug.md
- + .gitlab/issue_templates/default.md


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/381ab0fae399ebf63832e62724ba22734856b1b9...751e77c15278104a4530429708d936eaf87d8a9d

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/381ab0fae399ebf63832e62724ba22734856b1b9...751e77c15278104a4530429708d936eaf87d8a9d
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/20240221/a7502ecb/attachment-0001.html>


More information about the ghc-commits mailing list