[Git][ghc/ghc][wip/T24887] 34 commits: rts: ensure gc_thread/gen_workspace is allocated with proper alignment
Simon Peyton Jones (@simonpj)
gitlab at gitlab.haskell.org
Mon Jun 3 16:35:55 UTC 2024
Simon Peyton Jones pushed to branch wip/T24887 at Glasgow Haskell Compiler / GHC
Commits:
7a660042 by Cheng Shao at 2024-05-30T14:42:29-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.
- - - - -
c77a48af by Cheng Shao at 2024-05-30T14:42:29-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.
- - - - -
05c4fafb by Cheng Shao at 2024-05-30T14:42:29-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
```
- - - - -
5ff83bfc by Sylvain Henry at 2024-05-30T14:43:10-04:00
JS: remove useless h$CLOCK_REALTIME (#23202)
- - - - -
95ef2d58 by Matthew Pickering at 2024-05-30T14:43:47-04:00
ghcup-metadata: Fix metadata generation
There were some syntax errors in the generation script which were
preventing it from running.
I have tested this with:
```
nix shell --extra-experimental-features nix-command -f .gitlab/rel_eng -c ghcup-metadata --metadata ghcup-0.0.7.yaml --date="2024-05-27" --pipeline-id=95534 --version=9.11.20240525
```
which completed successfully.
- - - - -
1bc66ee4 by Jakob Bruenker at 2024-05-30T14:44:22-04:00
Add diagrams to Arrows documentation
This adds diagrams to the documentation of Arrows, similar to the ones found on
https://www.haskell.org/arrows/.
It does not add diagrams for ArrowChoice for the time being, mainly because it's
not clear to me how to visually distinguish them from the ones for Arrow. Ideally,
you might want to do something like highlight the arrows belonging to the same
tuple or same Either in common colors, but that's not really possible with unicode.
- - - - -
d10a1c65 by Matthew Craven at 2024-05-30T23:35:48-04:00
Make UnsafeSNat et al. into pattern synonyms
...so that they do not cause coerce to bypass the nominal
role on the corresponding singleton types when they are imported.
See Note [Preventing unsafe coercions for singleton types] and
the discussion at #23478.
This also introduces unsafeWithSNatCo (and analogues for Char
and Symbol) so that users can still access the dangerous coercions
that importing the real constructors would allow, but only in a
very localized way.
- - - - -
0958937e by Cheng Shao at 2024-05-30T23:36:25-04:00
hadrian: build C/C++ with split sections when enabled
When split sections is enabled, ensure -fsplit-sections is passed to
GHC as well when invoking GHC to compile C/C++; and pass
-ffunction-sections -fdata-sections to gcc/clang when compiling C/C++
with the hadrian Cc builder. Fixes #23381.
- - - - -
02b1f91e by Cheng Shao at 2024-05-30T23:36:25-04:00
driver: build C/C++ with -ffunction-sections -fdata-sections when split sections is enabled
When -fsplit-sections is passed to GHC, pass -ffunction-sections
-fdata-sections to gcc/clang when building C/C++. Previously,
-fsplit-sections was only respected by the NCG/LLVM backends, but not
the unregisterised backend; the GHC driver did not pass
-fdata-sections and -ffunction-sections to the C compiler, which
resulted in excessive executable sizes.
Fixes #23381.
-------------------------
Metric Decrease:
size_hello_artifact
size_hello_unicode
-------------------------
- - - - -
fd47e2e3 by Cheng Shao at 2024-05-30T23:37:00-04:00
testsuite: mark process005 as fragile on JS
- - - - -
34a04ea1 by Matthew Pickering at 2024-05-31T06:08:36-04:00
Add -Wderiving-typeable to -Wall
Deriving `Typeable` does nothing, and it hasn't done for a long while.
There has also been a warning for a long while which warns you about
uselessly deriving it but it wasn't enabled in -Wall.
Fixes #24784
- - - - -
75fa7b0b by Matthew Pickering at 2024-05-31T06:08:36-04:00
docs: Fix formatting of changelog entries
- - - - -
303c4b33 by Preetham Gujjula at 2024-05-31T06:09:21-04:00
docs: Fix link to injective type families paper
Closes #24863
- - - - -
df97e9a6 by Ben Gamari at 2024-05-31T06:09:57-04:00
ghc-internal: Fix package description
The previous description was inherited from `base` and was inappropriate
for `ghc-internal`. Also fix the maintainer and bug reporting fields.
Closes #24906.
- - - - -
bf0737c0 by Cheng Shao at 2024-05-31T06:10:33-04:00
compiler: remove ArchWasm32 special case in cmmDoCmmSwitchPlans
This patch removes special consideration for ArchWasm32 in
cmmDoCmmSwitchPlans, which means the compiler will now disable
cmmImplementSwitchPlans for wasm unreg backend, just like unreg
backend of other targets. We enabled it in the past to workaround some
compile-time panic in older versions of LLVM, but those panics are no
longer present, hence no need to keep this workaround.
- - - - -
7eda4bd2 by Cheng Shao at 2024-05-31T15:52:04-04:00
utils: add hie.yaml config file for ghc-config
Add hie.yaml to ghc-config project directory so it can be edited using
HLS.
- - - - -
1e5752f6 by Cheng Shao at 2024-05-31T15:52:05-04:00
hadrian: handle findExecutable "" gracefully
hadrian may invoke findExecutable "" at run-time due to a certain
program is not found by configure script. Which is fine and
findExecutable is supposed to return Nothing in this case. However, on
Windows there's a directory bug that throws an exception (see
https://github.com/haskell/directory/issues/180), so we might as well
use a wrapper for findExecutable and handle exceptions gracefully.
- - - - -
4eb5ad09 by Cheng Shao at 2024-05-31T15:52:05-04:00
configure: do not set LLC/OPT/LLVMAS fallback values when FIND_LLVM_PROG fails
When configure fails to find LLC/OPT/LLVMAS within supported version
range, it used to set "llc"/"opt"/"clang" as fallback values. This
behavior is particularly troublesome when the user has llc/opt/clang
with other versions in their PATH and run the testsuite, since hadrian
will incorrectly assume have_llvm=True and pass that to the testsuite
driver, resulting in annoying optllvm test failures (#23186). If
configure determines llc/opt/clang wouldn't work, then we shouldn't
pretend it'll work at all, and the bindist configure will invoke
FIND_LLVM_PROG check again at install time anyway.
- - - - -
5f1afdf7 by Sylvain Henry at 2024-05-31T15:52:52-04:00
Introduce UniqueSet and use it to replace 'UniqSet Unique'
'UniqSet Unique' represents a set of uniques as a 'Map Unique Unique',
which is wasting space (associated key/value are always the same).
Fix #23572 and #23605
- - - - -
e0aa42b9 by crumbtoo at 2024-05-31T15:53:33-04:00
Improve template-haskell haddocks
Closes #15822
- - - - -
ae170155 by Olivier Benz at 2024-06-01T09:35:17-04:00
Bump max LLVM version to 19 (not inclusive)
- - - - -
92aa65ea by Matthew Pickering at 2024-06-01T09:35:17-04:00
ci: Update CI images to test LLVM 18
The debian12 image in this commit has llvm 18 installed.
- - - - -
adb1fe42 by Serge S. Gulin at 2024-06-01T09:35:53-04:00
Unicode: make ucd2haskell build-able again
ucd2haskell tool used streamly library which version in cabal was out of date. It is updated to the latest version at hackage with deprecated parts rewritten.
Also following fixes were applied to existing code in suppose that from its last run the code structure was changed and now it was required to be up to date with actual folder structures:
1. Ghc module path environment got a suffix with `src`.
2. Generated code got
2.1 `GHC.Internal` prefix for `Data.*`.
2.2 `GHC.Unicode.Internal` swapped on `GHC.Internal.Unicode` according to actual structure.
- - - - -
ad56fd84 by Jade at 2024-06-01T09:36:29-04:00
Replace 'NB' with 'Note' in error messages
- - - - -
6346c669 by Cheng Shao at 2024-06-01T09:37:04-04:00
compiler: fix -ddump-cmm-raw when compiling .cmm
This patch fixes missing -ddump-cmm-raw output when compiling .cmm,
which is useful for debugging cmm related codegen issues.
- - - - -
1c834ad4 by Ryan Scott at 2024-06-01T09:37:40-04:00
Print namespace specifiers in FixitySig's Outputable instance
For whatever reason, the `Outputable` instance for `FixitySig` simply did not
print out namespace specifiers, leading to the confusing `-ddump-splices`
output seen in #24911. This patch corrects this oversight.
Fixes #24911.
- - - - -
cf49fb5f by Sylvain Henry at 2024-06-01T09:38:19-04:00
Configure: display C++ compiler path
- - - - -
f9c1ae12 by Cheng Shao at 2024-06-02T14:01:55-04:00
hadrian: disable PIC for in-tree GMP on wasm32
This patch disables PIC for in-tree GMP on wasm32 target. Enabling PIC
unconditionally adds undesired code size and runtime overhead for
wasm32.
- - - - -
1a32f828 by Cheng Shao at 2024-06-02T14:01:55-04:00
hadrian: disable in-tree gmp fft code path for wasm32
This patch disables in-tree GMP FFT code paths for wasm32 target in
order to give up some performance of multiplying very large operands
in exchange for reduced code size.
- - - - -
06277d56 by Cheng Shao at 2024-06-02T14:01:55-04:00
hadrian: build in-tree GMP with malloc-notreentrant on wasm32
This patch makes hadrian build in-tree GMP with the
--enable-alloca=malloc-notreentrant configure option. We will only
need malloc-reentrant when we have threaded RTS and SMP support on
wasm32, which will take some time to happen, before which we should
use malloc-notreentrant to avoid undesired runtime overhead.
- - - - -
9f614270 by ARATA Mizuki at 2024-06-02T14:02:35-04:00
Set package include paths when assembling .S files
Fixes #24839.
Co-authored-by: Sylvain Henry <hsyl20 at gmail.com>
- - - - -
4998a6ed by Alex Mason at 2024-06-03T02:09:29-04:00
Improve performance of genericWordQuotRem2Op (#22966)
Implements the algorithm from compiler-rt's udiv128by64to64default. This
rewrite results in a roughly 24x improvement in runtime on AArch64 (and
likely any other arch that uses it).
- - - - -
ae50a8eb by Cheng Shao at 2024-06-03T02:10:05-04:00
testsuite: mark T7773 as fragile on wasm
- - - - -
cb61d384 by Simon Peyton Jones at 2024-06-03T17:35:46+01:00
Prioritise nominal equalities
The main payload of this patch is
* Prioritise nominal equalities in the constraint solver. This
ameliorates the incompleteness of solving for representational
constraints over newtypes: see #24887.
See (EX2) in Note [Decomposing newtype equalities] in
GHC.Tc.Solver.Equality
In doing this patch I tripped over some other things that I refactored:
* Move `isCoVarType` from `GHC.Core.Type` to `GHC.Core.Predicate`
where it seems more at home.
* Clarify the "rewrite role" of a constraint. I was very puzzled
about what the role of, say `(Eq a)` might be, but see the new
Note [The rewrite-role of a constraint].
In doing so I made predTypeEqRel crash when given a non-equality.
Usually it expects an equality; but it was being mis-used for
the above rewrite-role stuff.
- - - - -
30 changed files:
- .gitlab-ci.yml
- .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py
- compiler/GHC/Builtin/Types.hs
- compiler/GHC/Cmm/LRegSet.hs
- compiler/GHC/Cmm/Liveness.hs
- compiler/GHC/Cmm/Sink.hs
- compiler/GHC/CmmToAsm/Wasm/Asm.hs
- compiler/GHC/CmmToAsm/Wasm/FromCmm.hs
- compiler/GHC/CmmToAsm/Wasm/Types.hs
- compiler/GHC/CmmToAsm/X86/Instr.hs
- compiler/GHC/Core/DataCon.hs
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Make.hs
- compiler/GHC/Core/Predicate.hs
- compiler/GHC/Core/SimpleOpt.hs
- compiler/GHC/Core/TyCon.hs
- compiler/GHC/Core/Type.hs
- compiler/GHC/Core/Utils.hs
- compiler/GHC/Data/Word64Set/Internal.hs
- compiler/GHC/Driver/Config/Cmm.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Main.hs
- compiler/GHC/Driver/Pipeline/Execute.hs
- compiler/GHC/Hs/Binds.hs
- compiler/GHC/HsToCore/Pmc/Solver.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Ext/Types.hs
- compiler/GHC/JS/JStg/Syntax.hs
- compiler/GHC/JS/Syntax.hs
- compiler/GHC/StgToCmm/Prim.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/60d573e7ae0f1d1d924d2dca9067715a3a05de73...cb61d38413529de5a41a5d57fb4a4b80fb2b8d4a
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/60d573e7ae0f1d1d924d2dca9067715a3a05de73...cb61d38413529de5a41a5d57fb4a4b80fb2b8d4a
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/20240603/753a7c7f/attachment-0001.html>
More information about the ghc-commits
mailing list