Skip to content

Cmm: declare CPU requirements on RTS procedures - #197

Merged
angerman merged 3 commits into
stable-ghc-9.14from
review/pr194-clean
Oct 16, 2026
Merged

angerman merged 3 commits into
stable-ghc-9.14from
review/pr194-clean

Conversation

@angerman

@angerman angerman commented Oct 15, 2026 •

Copy link
Copy Markdown

Stacked on #196; supersedes #194. Backports GHC !16687 with stable-branch corrections and stronger regressions.

RTS vector procedures need AVX2/AVX-512 while scalar and V16 procedures must retain the baseline instruction set. Instead of matching source filenames in Cabal/Hadrian, procedures now declare their requirements with Cmm __attribute__((target("avx2"))) attributes. Apply/Jumps routines remain generated and compiled into the RTS at build time, preserving the existing linking arrangement.

Implementation and corrections

  • Carry attributes through Cmm lowering, deterministic renaming, procedure splitting and raw conversion.
  • Apply native backend settings per procedure during selection, register allocation, spills and printing. Adapt to stable's separate AVX feature fields and optional backend guards.
  • Preserve the complete LLVM target-default/global feature list and last-occurrence override ordering. Honor LLVM-version gates, including AVX-512 policy; retain OpenBSD retpolines and Android defaults.
  • Annotate vector apply/save and Jumps procedures under their register-availability guards. Remove per-file ISA build rules; scalar/V16 and unsupported/unregisterised targets retain baseline behavior.
  • Reject unknown or unsupported attributes. Correct the upstream test output/platform guards, strengthen LLVM output normalization and add an API regression independent of external LLVM executables.
  • Preserve Fix compiler and RTS portability issues exposed by haskell.nix #196's PIC trampoline/CFG fix while adapting its procedure metadata to RawCmmProcInfo. Retain the shared build/CI prerequisites from Fix compiler and RTS portability issues exposed by haskell.nix #196.

The attribute is additive; global RTS flags must still avoid enabling AVX for baseline procedures. It does not add runtime CPU dispatch.

Validation

The clean history is 93c3dc1716 → 09f5c34611 → 0aae70d65d (#196) → 0aaa5fa085 (#197). The feature patch is unchanged by this restacking; it now includes #196's reviewed Windows-fixture, ranlib (including resolved PATH-launcher diagnostics) and pinned-mirror bootstrap corrections. CI has restarted on both exact heads. Fast-forward only after the current candidates are green. The abandoned link-time implementation is absent.

  • Astra independently reviewed the source, stable-branch corrections, integration and shared CI repairs. Its compiled-test configuration finding is fixed.
  • The combined source previously built and linked a standalone compiler from its full 871-module dependency closure. All 11 attribute/backend/LLVM probes and four actual PIC assembly/lint cases passed. Synthetic cross settings qualify code generation, not target ABI/runtime; local boot-library validation does not replace full bootstrap/bindist CI.
  • Previous head 5e64db50c7 passed normal CI and Nix CI: all four normal suites, six Nix native suites, three MULTI cross builds and three strict artifact-consuming e2e jobs. Linux JUnits explicitly confirm the Cmm attribute, isolation/rejection and LLVM API regressions. The e2e jobs cover native/Wasm/JS hello execution and the Miso Wasm build. These are prior-head results; current CI must pass again.
  • Both complete Windows runtime suites subsequently passed at heads 5fa0da603b / f2956276fe. The shared external Wasm bootstrap failures are repaired with a pinned, checksum-verified official mirror archive, retaining full upstream setup; focused failure-path and real Darwin SDK/libffi probes pass, and Astra cleared the repair. Complete setup and consumers still require new-head CI.
  • The shared Windows failure is isolated and the corrected fixture passes all original assertions in the native A/B diagnostic. The Intel suite subsequently exposed a bare-command/resolved-path mismatch in that filter. The corrected PATH-aware filter has a failing-before/passing-after real-process regression, actual cctools launcher reproduction and independent Astra POSIX/Windows probes; rebuilt Intel static001 remains current CI qualification.
  • The previous Intel release suite also timed out compiling T26537 with -O2 -fregs-graph. A focused same-runner comparison passed the original Fix compiler and RTS portability issues exposed by haskell.nix #196 and Cmm: declare CPU requirements on RTS procedures #197 compilers in 497s and 402s with unchanged flags, outputs and 1,500-second limits. The timeout did not reproduce; one ordered pair establishes no general speedup or flakiness classification. A subsequent ARM dynamic suite timed out in the same test, while its static counterpart passed; current full platform suites remain required.

LLVM API execution is distinct from LLVM Cmm emission; actual LLVM emission was exercised locally with external LLVM tools. No timeout, assertion or expected result has been relaxed.

A previous Ubuntu 24 runtime suite (20c3c72df9) reported one T21651(threaded1) segmentation fault; the same test passed both normal Linux configurations. Its targeted retry is retained without changing assertions or classifying the crash. Current candidate platform suites must pass.

@angerman angerman changed the title Generate and link RTS application routines in GHC Cmm: declare CPU requirements on RTS procedures Oct 15, 2026
angerman added a commit that referenced this pull request Oct 15, 2026
Backport GHC !16687 (9020062), retaining
build-time generation and existing RTS ownership of apply/Jumps routines.
Carry procedure attributes through Cmm lowering, splitting and native/LLVM
code generation, and remove the per-file vector ISA build rules.

Adapt native feature handling to stable, preserve target-default and global
LLVM features with ordered overrides, and honor LLVM-version feature gates.
Keep scalar/V16 procedures at baseline and reject unsupported attributes.

Add native isolation, rejection and LLVM feature-list regressions. Check the
LLVM API independently of external LLVM tools. Preserve the portability
branch's PIC trampoline/CFG fixes when adapting raw procedure metadata.
@angerman
angerman marked this pull request as ready for review October 15, 2026 13:02
angerman added a commit that referenced this pull request Oct 15, 2026
Backport GHC !16687 (9020062), retaining
build-time generation and existing RTS ownership of apply/Jumps routines.
Carry procedure attributes through Cmm lowering, splitting and native/LLVM
code generation, and remove the per-file vector ISA build rules.

Adapt native feature handling to stable, preserve target-default and global
LLVM features with ordered overrides, and honor LLVM-version feature gates.
Keep scalar/V16 procedures at baseline and reject unsupported attributes.

Add native isolation, rejection and LLVM feature-list regressions. Check the
LLVM API independently of external LLVM tools. Preserve the portability
branch's PIC trampoline/CFG fixes when adapting raw procedure metadata.
angerman added a commit that referenced this pull request Oct 16, 2026
Backport GHC !16687 (9020062), retaining
build-time generation and existing RTS ownership of apply/Jumps routines.
Carry procedure attributes through Cmm lowering, splitting and native/LLVM
code generation, and remove the per-file vector ISA build rules.

Adapt native feature handling to stable, preserve target-default and global
LLVM features with ordered overrides, and honor LLVM-version feature gates.
Keep scalar/V16 procedures at baseline and reject unsupported attributes.

Add native isolation, rejection and LLVM feature-list regressions. Check the
LLVM API independently of external LLVM tools. Preserve the portability
branch's PIC trampoline/CFG fixes when adapting raw procedure metadata.
Restore profiling library suffixes, export the Emscripten heap views, and
apply vector ISA flags consistently on both x86 widths. Keep PIC jump-table
shortcuts within their procedure and preserve the required trampolines.

Handle Android target names, ELF visibility fallbacks and supported local
GOT definitions. Preserve BFD import types and nullable lookup outputs.
Trim Apple ranlib padding from wasm archive members with bounded decoding.

Add focused regressions, including assembler-independent local GOT and GNU
BFD fixtures. Repair Windows, FreeBSD, Debian and macOS CI prerequisites,
provide pinned native Alex/Happy for stage3, and wire Make test capabilities.

Qualify the BFD regression archive path to locate its adjacent DLL. Filter
only complete Apple ranlib warnings about empty archive members, preserving
other diagnostics and exit failures without Apple-only command-line flags.

Handle PATH launchers whose diagnostics name a resolved absolute ranlib
path, and cover both qualified and PATH invocations in the regression.
Backport GHC !16687 (9020062), retaining
build-time generation and existing RTS ownership of apply/Jumps routines.
Carry procedure attributes through Cmm lowering, splitting and native/LLVM
code generation, and remove the per-file vector ISA build rules.

Adapt native feature handling to stable, preserve target-default and global
LLVM features with ordered overrides, and honor LLVM-version feature gates.
Keep scalar/V16 procedures at baseline and reject unsupported attributes.

Add native isolation, rejection and LLVM feature-list regressions. Check the
LLVM API independently of external LLVM tools. Preserve the portability
branch's PIC trampoline/CFG fixes when adapting raw procedure metadata.
@angerman
angerman merged commit 0aaa5fa into stable-ghc-9.14 Oct 16, 2026
84 of 85 checks passed
@angerman
angerman deleted the review/pr194-clean branch October 16, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant