[Git][ghc/ghc][wip/ghc-9.4.5-backports] 33 commits: ghc-the-library: Retain cafs in both static in dynamic builds.

Matthew Pickering (@mpickering) gitlab at gitlab.haskell.org
Thu Mar 30 19:29:07 UTC 2023



Matthew Pickering pushed to branch wip/ghc-9.4.5-backports at Glasgow Haskell Compiler / GHC


Commits:
5a0be129 by Andreas Klebinger at 2023-03-30T20:28:20+01:00
ghc-the-library: Retain cafs in both static in dynamic builds.

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

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

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

Fixes #22417.

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

(cherry picked from commit 08ba87200ff068aa37cac082e61ee7e2d534daf5)
(cherry picked from commit 96ab827a0d1ffd81bd906262b42409f2df808375)

- - - - -
7e2492db by sheaf at 2023-03-30T20:28:21+01:00
RTS: declare setKeepCAFs symbol

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

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

Fixes #22961

(cherry picked from commit cf564dd71548771394249e9bf959512a21bbcec0)
(cherry picked from commit c17668466a404de8a7fc5ef5b2931790da9440b6)

- - - - -
f2b8c9d0 by Simon Peyton Jones at 2023-03-30T20:28:21+01: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

(cherry picked from commit 3d55d8ab51ece43c51055c43c9e7aba77cce46c0)

- - - - -
56559c13 by Simon Peyton Jones at 2023-03-30T20:28:21+01: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.

(cherry picked from commit e193e53790dd5886feea3cf4c9c17625d188291b)

- - - - -
dd5b9e41 by Simon Peyton Jones at 2023-03-30T20:28:21+01:00
Fix unifier bug: failing to decompose over-saturated type family

This simple patch fixes #22647

(cherry picked from commit 317f45c154f6fe25d50ef2f3febcc5883ff1b1ca)

- - - - -
e9484ce2 by Andreas Klebinger at 2023-03-30T20:28:21+01:00
Only gc sparks locally when we can ensure marking is done.

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

Fixes #22528.

(cherry picked from commit a1491c8791c57a64d94bc08d639d585815c8d4e2)

- - - - -
02aefea2 by Matthew Pickering at 2023-03-30T20:28:21+01:00
T10955: Set DYLD_LIBRARY_PATH for darwin

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

For more reading see:

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

- - - - -
aebaf47c by Matthew Pickering at 2023-03-30T20:28:21+01:00
Skip T18623 on darwin (to add to the long list of OSs)

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

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

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

(cherry picked from commit 734847108420cf826a807c30ad54651659cf3a08)

- - - - -
42ead57b by Matthew Pickering at 2023-03-30T20:28:21+01:00
Pass -Wl,-no_fixup_chains to ld64 when appropiate

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

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

The manual explains the incompatible nature of these two flags:

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

A relevant ticket is #22429

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

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

More relevant links:

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

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

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

(cherry picked from commit 8c0ea25fb4a27d4729aabf73f4c00b912bb0c58d)

- - - - -
04028d00 by Sebastian Graf at 2023-03-30T20:28:21+01:00
Handle shadowing in DmdAnal (#22718)

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

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

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

Fixes #22718.

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

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

(cherry picked from commit e3fff7512bbf989386faaa1dccafdad1deabde84)

- - - - -
b6c0f73b by Oleg Grenrus at 2023-03-30T20:28:21+01:00
Fix #22728: Not all diagnostics in safe check are fatal

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

(cherry picked from commit 1b812b6973a25cb1962e2fc543d2c4ed3cf31f3c)

- - - - -
1d7331c9 by Viktor Dukhovni at 2023-03-30T20:28:21+01:00
Avoid unnecessary printf warnings in EventLog.c

Fixes #22778

(cherry picked from commit fc02f3bbb5f47f880465e22999ba9794f658d8f6)

- - - - -
25ec9161 by Ryan Scott at 2023-03-30T20:28:21+01:00
Add missing parenthesizeHsType in cvtSigTypeKind

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

Fixes #22784.

(cherry picked from commit 4efee43db5090aac4dde1293357bdb548ae71c24)

- - - - -
fc9daf26 by Cheng Shao at 2023-03-30T20:28:21+01:00
Fix typo in recent darwin tests fix

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

(cherry picked from commit c45a5fffef2c76efbf5d3a009c3f6d0244a63f0d)

- - - - -
35cd8915 by Ben Gamari at 2023-03-30T20:28:21+01:00
nativeGen/AArch64: Fix debugging output

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

See #22798.

(cherry picked from commit be417a47c7695998dea0adc05489a7b8838a78b6)

- - - - -
93f4714f by Ben Gamari at 2023-03-30T20:28:21+01:00
nativeGen: Teach graph-colouring allocator that x18 is unusable

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

See #22798.

(cherry picked from commit 30989d137b8f3a8fddbfd116e04b48f23c24f86c)

- - - - -
c1d3f423 by Ben Gamari at 2023-03-30T20:28:21+01:00
nativeGen/AArch64: Fix graph-colouring allocator

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

Fixes #22798.

(cherry picked from commit 7566fd9de38c67360c090f828923d41587af519c)

- - - - -
8dbb142a by Ben Gamari at 2023-03-30T20:28:21+01:00
testsuite: Add regression test for #22798

(cherry picked from commit 2cb500a5ee1a31dfe1a2cdd71f175442026eb082)

- - - - -
17686ff4 by Zubin Duggal at 2023-03-30T20:28:21+01:00
ncg/aarch64: Handle MULTILINE_COMMENT identically as COMMENTs

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

Fixes #23002

(cherry picked from commit 68dd64ffa6f164dce4ac010b9f5e1adfefeae7c7)

- - - - -
00f62d46 by Ben Gamari at 2023-03-30T20:28:21+01:00
nativeGen: Disable asm-shortcutting on Darwin

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

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

Closes #21972.

(cherry picked from commit 8bed166bb79445f90015757fd5baac69a7b835df)

- - - - -
0536cf91 by Zubin Duggal at 2023-03-30T20:28:21+01:00
bindist configure: Fail if find not found (#22691)

(cherry picked from commit c9967d137cff83c7688e26f87a8b5e196a75ec93)

- - - - -
a44aaf08 by Ben Gamari at 2023-03-30T20:28:21+01:00
nativeGen/X86: MFENCE is unnecessary for release semantics

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

Fixes #22764.

(cherry picked from commit 35a118001149eb8f5bab989be997757baa70bfec)

- - - - -
832de361 by sheaf at 2023-03-30T20:28:21+01:00
Fix tyvar scoping within class SPECIALISE pragmas

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

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

Fixes #22913

(cherry picked from commit 9ee761bf02cdd11c955454a222c85971d95dce11)

- - - - -
b76f3218 by Ben Gamari at 2023-03-30T20:28:21+01:00
rts: Statically assert alignment of Capability

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

(cherry picked from commit db83f8bbf2e0ac68df675dea6b716fb7c19c649a)

- - - - -
709249df by Ben Gamari at 2023-03-30T20:28:21+01: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.

(cherry picked from commit 70999283156f527c5aea6dee57a3d14989a9903a)

- - - - -
15f69661 by Ben Gamari at 2023-03-30T20:28:21+01:00
rts: Introduce stgMallocAlignedBytes

(cherry picked from commit 5f7a4a6d8311d2faa9c90b2b0c4431dd4427839d)

- - - - -
c22a7a22 by Ben Gamari at 2023-03-30T20:28:21+01:00
rts: Correctly align Capability allocations

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

Fixes #22965.
Fixes #22975.

(cherry picked from commit 8a6f745d963fc9b79c7b1e4b477f4fc724233655)

- - - - -
c14e490e by Ben Gamari at 2023-03-30T20:28:21+01:00
rts: Drop no-alignment special case for Windows

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

(cherry picked from commit 5464c73f192f76e75160e8992fe9720d943ae611)

- - - - -
baf26d2c by Ben Gamari at 2023-03-30T20:28:21+01:00
hadrian: Add dependency from lib/settings to mk/config.mk

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

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

Fixes #22982.

(cherry picked from commit 79ffa170a6b0b152da0e02744869311773733286)

- - - - -
0967df48 by Andreas Klebinger at 2023-03-30T20:28:21+01:00
base: Correct @since annotation for FP<->Integral bit cast operations.

Fixes #22708

(cherry picked from commit 9296660b131d42f1b1f9c421040c5746d5c56989)

- - - - -
6dd08703 by Matthew Pickering at 2023-03-30T20:28:21+01:00
constant folding: Correct type of decodeDouble_Int64 rule

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

Fixes #23019

(cherry picked from commit a86aae8b562c12bb3cee8dcae5156b647f1a74ad)

- - - - -
f8fc7720 by Sylvain Henry at 2023-03-30T20:28:21+01:00
linker: fix linking with aligned sections (#23066)

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

(cherry picked from commit 4158722a6cff5d19e228356c525946b6c4b83396)

- - - - -
23d4c60b by Ben Gamari at 2023-03-30T20:28:21+01:00
nativeGen/AArch64: Fix bitmask immediate predicate

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

Fixes #23030.

(cherry picked from commit b8d783d24b9a617ad1e3038abeb75d322703ef65)

- - - - -


30 changed files:

- compiler/GHC.hs
- compiler/GHC/CmmToAsm.hs
- compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
- compiler/GHC/CmmToAsm/AArch64/Instr.hs
- compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs
- compiler/GHC/CmmToAsm/X86/CodeGen.hs
- compiler/GHC/Core/Opt/ConstantFold.hs
- compiler/GHC/Core/Opt/DmdAnal.hs
- compiler/GHC/Core/Opt/OccurAnal.hs
- compiler/GHC/Core/Unify.hs
- compiler/GHC/Driver/Main.hs
- compiler/GHC/Rename/Bind.hs
- compiler/GHC/Tc/Solver/Types.hs
- compiler/GHC/ThToHs.hs
- compiler/cbits/keepCAFsForGHCi.c
- compiler/ghc.mk
- configure.ac
- distrib/configure.ac.in
- docs/users_guide/using-optimisation.rst
- hadrian/bindist/Makefile
- libraries/base/GHC/Float.hs
- + m4/fp_ld_no_fixup_chains.m4
- rts/Capability.c
- rts/Capability.h
- rts/Messages.h
- rts/PrimOps.cmm
- rts/Printer.c
- rts/ProfHeap.c
- rts/ProfilerReport.c
- rts/ProfilerReportJson.c


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2ec5901f4d91c053e2e996d682f5d7c4c697b731...23d4c60b1301f542d98b6df818cc9024b4bae1fb

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2ec5901f4d91c053e2e996d682f5d7c4c697b731...23d4c60b1301f542d98b6df818cc9024b4bae1fb
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/20230330/ef462b17/attachment-0001.html>


More information about the ghc-commits mailing list