[Git][ghc/ghc][wip/backports-9.8-2] 35 commits: Bump stm submodule to v2.5.3.1

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Sun Sep 29 16:05:22 UTC 2024



Ben Gamari pushed to branch wip/backports-9.8-2 at Glasgow Haskell Compiler / GHC


Commits:
5aafe259 by Ben Gamari at 2024-09-29T12:04:51-04:00
Bump stm submodule to v2.5.3.1

- - - - -
fce51010 by Andrew Lelechenko at 2024-09-29T12:04:51-04:00
Bump submodule deepseq to 1.5.1.0

(cherry picked from commit 8e462f4d4bdf2a6c34c249e7be8084565600d300)

- - - - -
d01f6cb6 by Cheng Shao at 2024-09-29T12:04:51-04:00
rts: ensure gc_thread/gen_workspace is allocated with proper alignment

gc_thread/gen_workspace are required to be aligned by 64 bytes.
However, this property has not been properly enforced before, and
numerous alignment violations at runtime has been caught by
UndefinedBehaviorSanitizer that look like:

```
rts/sm/GC.c:1167:8: runtime error: member access within misaligned address 0x0000027a3390 for type 'gc_thread' (aka 'struct gc_thread_'), which requires 64 byte alignment
0x0000027a3390: note: pointer points here
 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/sm/GC.c:1167:8

rts/sm/GC.c:1184:13: runtime error: member access within misaligned address 0x0000027a3450 for type 'gen_workspace' (aka 'struct gen_workspace_'), which requires 64 byte alignment
0x0000027a3450: note: pointer points here
 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/sm/GC.c:1184:13
```

This patch fixes the gc_thread/gen_workspace misalignment issue by
explicitly allocating them with alignment constraint.

- - - - -
8965b192 by Cheng Shao at 2024-09-29T12:04:51-04:00
rts: fix an unaligned load in nonmoving gc

This patch fixes an unaligned load in nonmoving gc by ensuring the
closure address is properly untagged first before attempting to
prefetch its header. The unaligned load is reported by
UndefinedBehaviorSanitizer:

```
rts/sm/NonMovingMark.c:921:9: runtime error: member access within misaligned address 0x0042005f3a71 for type 'StgClosure' (aka 'struct StgClosure_'), which requires 8 byte alignment
0x0042005f3a71: note: pointer points here
 00 00 00  98 43 13 8e 12 7f 00 00  50 3c 5f 00 42 00 00 00  58 17 b7 92 12 7f 00 00  89 cb 5e 00 42
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/sm/NonMovingMark.c:921:9
```

This issue had previously gone unnoticed since it didn't really harm
runtime correctness, the invalid header address directly loaded from a
tagged pointer is only used as prefetch address and will not cause
segfaults. However, it still should be corrected because the prefetch
would be rendered useless by this issue, and untagging only involves a
single bitwise operation without memory access so it's cheap enough to
add.

- - - - -
11e0c2ad by Cheng Shao at 2024-09-29T12:04:51-04:00
rts: use __builtin_offsetof to implement STG_FIELD_OFFSET

This patch fixes the STG_FIELD_OFFSET macro definition by using
__builtin_offsetof, which is what gcc/clang uses to implement offsetof
in standard C. The previous definition that uses NULL pointer involves
subtle undefined behavior in C and thus reported by
UndefinedBehaviorSanitizer as well:

```
rts/Capability.h:243:58: runtime error: member access within null pointer of type 'Capability' (aka 'struct Capability_')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/Capability.h:243:58
```

- - - - -
98582e30 by Cheng Shao at 2024-09-29T12:04:51-04:00
rts: fix checkClosure error message

This patch fixes an error message in checkClosure() when the closure
has already been evacuated. The previous logic was meant to print the
evacuated closure's type in the error message, but it was completely
wrong, given info was not really an info table, but a tagged pointer
that points to the closure's new address.

- - - - -
b1fcd271 by Andrew Lelechenko at 2024-09-29T12:04:51-04:00
Bump submodule array to 0.5.8.0

(cherry picked from commit 80769bc9f56541601796366485283a697c52a18b)

- - - - -
4aa51df6 by Matthew Pickering at 2024-09-29T12:04:51-04:00
ci: Fix variable inheritence for ghcup-metadata testing job

Downstream in ghcup-ci we use the CONFIGURE_ARGS variable to determine
how to setup all the different jobs.

On the downstream trigger this was being inherited from the default
setting in .gitlab.yml file.

Therefore this led to job failures as the necessary CONFIGURE_ARGS were
not being passed to the configure script when installing the bindist.

See docs:

* https://docs.gitlab.com/ee/ci/yaml/#inherit
* https://docs.gitlab.com/ee/ci/yaml/#triggerforward

1. inherit:variables:fals
  - This stops the global variables being inherited into the job and
    hence forwarded onto the downstream job.

2. trigger:forward:*
  - yaml_variables: true (default) pass yaml variables to downstream,
    this is important to pass the upstream pipeline id to downstream.
  - pipeline_variables: false (default) but don't pass pipeline
    variables (normal environment variables).

Fixes #25294

(cherry picked from commit 7cb7172eff9e18ed1c98f65a98018f76c4fcc9f6)

- - - - -
486b2702 by Sylvain Henry at 2024-09-29T12:04:51-04:00
Fix interaction between fork and kqueue (#24672)

A kqueue file descriptor isn't inherited by a child created with fork.
As such we mustn't try to close this file descriptor as we would close a
random one, e.g. the one used by timerfd.

Fix #24672

(cherry picked from commit e7a26d7a6faf1ea534e036c5085a0a027dbb6f5f)

- - - - -
54fd5ea5 by Sylvain Henry at 2024-09-29T12:04:51-04:00
JS: support rubbish static literals (#25177)

Support for rubbish dynamic literals was added in #24664. This patch
does the same for static literals.

Fix #25177

(cherry picked from commit 5092dbff750ee5b6fd082b7eed8574922a2b0bf4)

- - - - -
766dca00 by Sylvain Henry at 2024-09-29T12:04:51-04:00
AARCH64 linker: skip NONE relocations

This patch is part of the patches upstreamed from haskell.nix.
See https://github.com/input-output-hk/haskell.nix/pull/1960 for the
original report/patch.

(cherry picked from commit c749bdfd3e21d712dc2b966482eb010165bdeebe)

- - - - -
e0a3038e by Sylvain Henry at 2024-09-29T12:04:52-04:00
Cmm: don't perform unsound optimizations on 32-bit compiler hosts

- beef61351b240967b49169d27a9a19565cf3c4af enabled the use of
  MO_Add/MO_Sub for 64-bit operations in the C and LLVM backends
- 6755d833af8c21bbad6585144b10e20ac4a0a1ab did the same for the x86 NCG
  backend

However we store some literal values as `Int` in the compiler. As a
result, some Cmm optimizations transformed target 64-bit literals into
compiler `Int`. If the compiler is 32-bit, this leads to computing with
wrong literals (see #24893 and #24700).

This patch disables these Cmm optimizations for 32-bit compilers. This
is unsatisfying (optimizations shouldn't be compiler-word-size
dependent) but it fixes the bug and it makes the patch easy to backport.
A proper fix would be much more invasive but it shall be implemented in
the future.

Co-authored-by: amesgen <amesgen at amesgen.de>
(cherry picked from commit 7446a09a2d5b04b95cd43c03659b5647853124ce)

- - - - -
57fde2ad by sheaf at 2024-09-29T12:04:52-04:00
GHCi debugger: drop record name spaces for Ids

When binding new local variables at a breakpoint, we should create
Ids with variable namespace, and not record field namespace. Otherwise
the rest of the compiler falls over because the IdDetails are wrong.

Fixes #25109

(cherry picked from commit c29b2b5a77611b2bd6c3089765079bc43aec3e22)

- - - - -
f3b2ce65 by Sylvain Henry at 2024-09-29T12:04:52-04:00
Only lookup ghcversion.h file in the RTS include-dirs by default.

The code was introduced in 3549c952b535803270872adaf87262f2df0295a4.
It used `getPackageIncludePath` which name doesn't convey that it looks
into all include paths of the preload units too. So this behavior is
probably unintentional and it should be ok to change it.

Fix #25106

(cherry picked from commit f954f42823f6ca3588425a0d543d93ace86d89e4)

- - - - -
0a119703 by Simon Peyton Jones at 2024-09-29T12:04:52-04:00
Address #25055, by disabling case-of-runRW# in Gentle phase

See Note [Case-of-case and full laziness]
in GHC.Driver.Config.Core.Opt.Simplify

(cherry picked from commit de5d9852dbdd367611bf9e45e69c723d26351992)

- - - - -
0b6d13fc by doyougnu at 2024-09-29T12:04:52-04:00
Rts linker: add case for pc-rel 64 relocation

part of the upstream haskell.nix patches

(cherry picked from commit bfe4b3d3bbb98b39169fad063c6c32f06d167756)

- - - - -
d77c6ffc by Ben Gamari at 2024-09-29T12:04:52-04:00
docs: Add release notes for 9.8.3

- - - - -
df964112 by Andreas Klebinger at 2024-09-29T12:04:52-04:00
Fix -freg-graphs for FP and AARch64 NCG (#24941).

It seems we reserve 8 registers instead of four for global regs
based on the layout in Note [AArch64 Register assignments].

I'm not sure it's neccesary, but for now we just accept this state of
affairs and simple update -fregs-graph to account for this.

(cherry picked from commit 3f89ab92da74c4ed45da68fe92ff81e7b9caa53d)

- - - - -
0b3ebb79 by Peter Trommler at 2024-09-29T12:04:52-04:00
PPC NCG: Fix sign hints in C calls

Sign hints for parameters are in the second component of the pair.

Fixes #23034

(cherry picked from commit 7fe85b1354a13749f14d588e3cc742b8ae2d8da9)

- - - - -
139c6568 by Ben Gamari at 2024-09-29T12:04:52-04:00
X86 NCG: Fix argument promotion in foreign C calls

Promote 8 bit and 16 bit signed arguments by sign extension.

Fixes #25018

(cherry picked from commit a82121b3b6fdc2ac47211f71871b3ab21e5f6276)

- - - - -
b4a161af by Sylvain Henry at 2024-09-29T12:04:52-04:00
Linker: use m32 allocator for sections when NEED_PLT (#24432)

Use M32 allocator to avoid fragmentation when allocating ELF sections.
We already did this when NEED_PLT was undefined. Failing to do this led
to relocations impossible to fulfil (#24432).

(cherry picked from commit 5104ee615503617a1c124fe1d92f6aa2d263b7d0)

- - - - -
b58b689a by Sylvain Henry at 2024-09-29T12:04:52-04:00
RTS: allow M32 allocation outside of 4GB range when assuming -fPIC

(cherry picked from commit 52d6698479f951e07def237b0474ee22d27e621a)

- - - - -
854508d5 by Sylvain Henry at 2024-09-29T12:04:52-04:00
Linker: fix stub offset

Remove unjustified +8 offset that leads to memory corruption (cf
discussion in #24432).

(cherry picked from commit c34fef56367142fa55e9861092f64cc7b9946fa1)

- - - - -
ba347fd6 by Cheng Shao at 2024-09-29T12:04:52-04:00
compiler: emit NaturallyAligned when element type & index type are the same width

This commit fixes a subtle mistake in alignmentFromTypes that used to
generate Unaligned when element type & index type are the same width.
Fixes #24930.

(cherry picked from commit 0cff083abb24701530974872b21cf897c9955a9a)

- - - - -
e4b99959 by Andreas Klebinger at 2024-09-29T12:04:52-04:00
GHCi interpreter: Tag constructor closures when possible.

When evaluating PUSH_G try to tag the reference we are pushing if it's a
constructor. This is potentially helpful for performance and required to
fix #24870.

(cherry picked from commit 1bfa91115b8320ed99a5e946147528e21ca4f3e1)

- - - - -
19019bdc by crumbtoo at 2024-09-29T12:04:52-04:00
user_guide: Fix typo in MultiWayIf chapter

Close #24829

(cherry picked from commit c5e00c35927d574f71bf77449817b131d1749750)

- - - - -
e273ef6b by Ryan Scott at 2024-09-29T12:04:52-04:00
Add missing parenthesizePat in cvtp

We need to ensure that the output of `cvtp` is parenthesized (at precedence
`sigPrec`) so that any pattern signatures with a surrounding pattern signature
can parse correctly.

Fixes #24837.

(cherry picked from commit a3cd3a1d0d186f2aa4d0273c6b3e74a442de2ef0)

- - - - -
96a3e7e6 by Sylvain Henry at 2024-09-29T12:04:52-04:00
Reverse arguments to stgCallocBytes (fix #24828)

(cherry picked from commit 6838a7c32ca29b5d44adc9d6280d3a960f31be7c)

- - - - -
cb8e49a6 by Teo Camarasu at 2024-09-29T12:04:52-04:00
doc: Fix type error in hs_try_putmvar example

(cherry picked from commit 06f7db4001e4eee0f3076d949876f8f4af0eb6fb)

- - - - -
601468a3 by Matthew Craven at 2024-09-29T12:04:52-04:00
Add test cases for #24664

...since none are present in the original MR !12463 fixing this issue.

(cherry picked from commit a19201d42cfd3aa54faeb1b5a95b715b9a67a01a)

- - - - -
2d5c6f80 by Zubin Duggal at 2024-09-29T12:04:52-04:00
compiler: Fingerprint -fwrite-if-simplified-core

We need to recompile if this flag is changed because later modules might depend on the
simplified core for this module if -fprefer-bytecode is enabled.

Fixes #24656

(cherry picked from commit dddc9dff0547733a10e7f505612ab9df3a7c21b6)

- - - - -
44173c39 by Sylvain Henry at 2024-09-29T12:04:52-04:00
JS: correctly handle RUBBISH literals (#24664)

(cherry picked from commit daeda83478d5b800d29661408dd67cc4b23df374)

- - - - -
cbf434d3 by Matthew Pickering at 2024-09-29T12:04:52-04:00
Don't depend on registerPackage function in Cabal

More recent versions of Cabal modify the behaviour of libAbiHash which
breaks our usage of registerPackage.

It is simpler to inline the part of registerPackage that we need and
avoid any additional dependency and complication using the higher-level
function introduces.

(cherry picked from commit 3fff09779d5830549ae455a15907b7bb9fe7859a)

- - - - -
3196bfb3 by Teo Camarasu at 2024-09-29T12:04:52-04:00
Fix ghc API link in docs/index.html

This was missing part of the unit ID meaning it would 404.

Resolves #24674

(cherry picked from commit f30e4984fb048818051465698ef8e4e20dacb577)

- - - - -
aa93076c by Ben Gamari at 2024-09-29T12:04:52-04:00
Accept performance shifts

Metric Decrease:
    MultiLayerModulesTH_Make

- - - - -


30 changed files:

- .gitlab-ci.yml
- compiler/GHC/ByteCode/Instr.hs
- compiler/GHC/Cmm/Opt.hs
- compiler/GHC/CmmToAsm/AArch64/Instr.hs
- compiler/GHC/CmmToAsm/AArch64/Ppr.hs
- compiler/GHC/CmmToAsm/AArch64/Regs.hs
- compiler/GHC/CmmToAsm/PPC/CodeGen.hs
- compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs
- compiler/GHC/CmmToAsm/X86/CodeGen.hs
- compiler/GHC/Core/Opt/Arity.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Driver/Config/Core/Opt/Simplify.hs
- compiler/GHC/Iface/Recomp/Flags.hs
- compiler/GHC/Runtime/Eval.hs
- compiler/GHC/StgToCmm/Prim.hs
- compiler/GHC/StgToJS/Literal.hs
- compiler/GHC/SysTools/Cpp.hs
- compiler/GHC/ThToHs.hs
- compiler/GHC/Types/Id.hs
- compiler/GHC/Unit/Types.hs
- docs/index.html.in
- + docs/users_guide/9.8.3-notes.rst
- docs/users_guide/exts/ffi.rst
- docs/users_guide/exts/multiway_if.rst
- docs/users_guide/release-notes.rst
- hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
- hadrian/src/Rules/Generate.hs
- libraries/array
- libraries/base/GHC/Event/KQueue.hsc
- libraries/deepseq


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/31012d411b9f307debd3f0f19daa1fcd07326ee8...aa93076c5157a813699649230272749fb6511ce9

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/31012d411b9f307debd3f0f19daa1fcd07326ee8...aa93076c5157a813699649230272749fb6511ce9
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/20240929/e548f691/attachment-0001.html>


More information about the ghc-commits mailing list