[Git][ghc/ghc][wip/9.6.4-backports] 14 commits: AArch64: Fix broken conditional jumps for offsets >= 1MB

Zubin (@wz1000) gitlab at gitlab.haskell.org
Wed Dec 13 14:50:21 UTC 2023



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


Commits:
b71b053e by Andreas Klebinger at 2023-12-13T20:20:02+05:30
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

(cherry picked from commit 2adc050857a9c1b992040fbfd55fbe65b2851b19)

- - - - -
fc6e4003 by Ben Gamari at 2023-12-13T20:20:02+05:30
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.

(cherry picked from commit f6b2751f58df5f4f83caa7a7ca56e66659d02b09)

- - - - -
d1f94ba7 by Ben Gamari at 2023-12-13T20:20:02+05:30
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.

(cherry picked from commit 8f6010b98f560200997a9d84a4e07bfd0ad6e496)

- - - - -
7a51125d by Sylvain Henry at 2023-12-13T20:20:02+05:30
Rts: expose rtsOutOfBoundsAccess symbol

(cherry picked from commit cbe4400d2690104053ec544cf7d0a9a13ee914ee)

- - - - -
9283b7d3 by Sylvain Henry at 2023-12-13T20:20:02+05:30
Avoid out-of-bound array access in bigNatIsPowerOf2 (fix #24066)

bigNatIndex# in the `where` clause wasn't guarded by "bigNatIsZero a".

(cherry picked from commit fe0675770b66a9ed393884d96e276b8d116fa2a2)

- - - - -
c284a3e8 by Sylvain Henry at 2023-12-13T20:20:02+05:30
Bignum: fix right shift of negative BigNat with native backend

(cherry picked from commit cc1625b1ffbdf086b8380bacd35abc8d85861637)

- - - - -
d5de8a2a by Sylvain Henry at 2023-12-13T20:20:02+05:30
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.

(cherry picked from commit 72c7380cb780933825bc84924908e01ce0495dc4)

- - - - -
83775ebb by Moritz Angermann at 2023-12-13T20:20:02+05:30
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.

(cherry picked from commit dafc47091c9107dcf81e1e80a105f59211927c89)
(cherry picked from commit 8e7a2065e433aa56552b335d420b5bf925082078)

- - - - -
ab7bc679 by Moritz Angermann at 2023-12-13T20:20:02+05:30
[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.

(cherry picked from commit df81536f2e53abf521a05eb1e482a076f5849c21)

- - - - -
d35f5d1a by Moritz Angermann at 2023-12-13T20:20:02+05:30
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"
     | ^

(cherry picked from commit e99cf237f84db34be0468a893b10394d6b364bce)

- - - - -
54617f3b by Ilias Tsitsimpis at 2023-12-13T20:20:02+05:30
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

(cherry picked from commit 257c2807587624592813a42e06a05c5fc34cb38c)
(cherry picked from commit b2a03315f6336e2708ff54689f2241eb38198dd5)

- - - - -
f9ff2f06 by Moritz Angermann at 2023-12-13T20:20:02+05:30
[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.

(cherry picked from commit 34f06334025521c2440ebedb0237697fbcc3c6de)

- - - - -
9397af86 by Claudio Bley at 2023-12-13T20:20:02+05:30
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

(cherry picked from commit d561073727186c7b456c9ef113ccb7fc0df4560e)

- - - - -
aee7728a by Zubin Duggal at 2023-12-13T20:20:02+05:30
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

(cherry picked from commit 8db8d2fd1c881032b1b360c032b6d9d072c11723)

- - - - -


30 changed files:

- compiler/GHC/CmmToAsm.hs
- compiler/GHC/CmmToAsm/AArch64.hs
- compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
- compiler/GHC/CmmToAsm/AArch64/Cond.hs
- compiler/GHC/CmmToAsm/AArch64/Instr.hs
- compiler/GHC/CmmToAsm/AArch64/Ppr.hs
- compiler/GHC/CmmToAsm/BlockLayout.hs
- compiler/GHC/CmmToAsm/Monad.hs
- compiler/GHC/CmmToAsm/PPC/Instr.hs
- compiler/GHC/CmmToAsm/Ppr.hs
- compiler/GHC/CmmToAsm/X86.hs
- compiler/GHC/Driver/Make.hs
- compiler/GHC/StgToCmm/CgUtils.hs
- ghc/GHCi/UI.hs
- hadrian/doc/flavours.md
- hadrian/src/Settings/Flavours/Validate.hs
- hadrian/src/Settings/Packages.hs
- libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs
- libraries/ghc-bignum/src/GHC/Num/BigNat.hs
- m4/find_ld.m4
- rts/RtsMessages.c
- rts/RtsSymbols.c
- rts/include/rts/Messages.h
- rts/linker/PEi386.c
- rts/sm/NonMoving.h
- + testsuite/tests/driver/T24196/T24196.stderr
- + testsuite/tests/driver/T24196/T24196A.hs
- + testsuite/tests/driver/T24196/T24196A.hs-boot
- + testsuite/tests/driver/T24196/T24196B.hs
- + testsuite/tests/driver/T24196/all.T


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8fe78c4039b7080246f183cda4ee89cc9599ff64...aee7728acd04eecf12f1e3411dfb50e4e86b33eb

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8fe78c4039b7080246f183cda4ee89cc9599ff64...aee7728acd04eecf12f1e3411dfb50e4e86b33eb
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/20231213/f9ab3423/attachment-0001.html>


More information about the ghc-commits mailing list