Skip to content

primesieve-portable: fix GCC ARM SVE dispatch - #111

Closed
dimpase wants to merge 2 commits into
mainfrom
fix/primesieve-portable
Closed

dimpase wants to merge 2 commits into
mainfrom
fix/primesieve-portable

Conversation

@dimpase

@dimpase dimpase commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

The core primesieve 12.17 Linux ARM bottle crashes on a CPU without SVE, including primesieve 1000000 --count --threads=1, ECM factorization, and Sage's exponential-integral doctests. A register/disassembly capture shows cntb x9 executing in the baseline PreSieve::preSieve path even though its SVE runtime flag is false.

Add a keg-only primesieve-portable formula with a small source patch that saves and restores GCC target options around the SVE helper definitions and the matching CMake probe. Runtime SVE dispatch remains enabled; Clang builds retain their existing behavior. The separate keg allows consumers to migrate one formula per PR while the core package remains installed.

The formula runs all upstream CTests during the build, then tests the installed CLI and shared-library API with substantive prime counts. This PR changes only this formula; consumers will migrate in subsequent PRs.

Validation on Linux ARM without SVE, using the same GCC13/O2/armv8-a settings as the broken bottle:

  • The pristine source reproduces SIGILL. The patched Release and Debug builds each pass all 34 CTests, CLI self-tests, pi(10^6)=78,498, pi(10^10)=455,052,511 and the billionth-prime check.
  • With an explicitly recorded diagnostic-only preload of the isolated candidate library, the original ECM factorization, guarded exp_integral doctests and all 29 libecm doctests pass. Installed bottles and Sage source remain unchanged.
  • Disassembly retains SVE instructions only in the guarded helper functions. This machine cannot exercise the accelerated SVE path; no performance claim is made.
  • The embedded patch was applied to the SHA-verified source archive and produces byte-identical tested files. The formula's exact C++ test also compiles and passes against the installed 12.17 library. Ruby syntax, Homebrew style and whitespace checks pass.

Three-platform CI, complete bottle audits and final validation with the published consumer closure are still required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant