Skip to content

Build Linux natives on ubuntu-24.04 to fix SIGILL on older CPUs - #188

Closed
Dominik-O22 wants to merge 1 commit into
yawkat:mainfrom
Dominik-O22:native-cpu-baseline
Closed

Dominik-O22 wants to merge 1 commit into
yawkat:mainfrom
Dominik-O22:native-cpu-baseline

Conversation

@Dominik-O22

Copy link
Copy Markdown

Since 1.13.0 the linux/amd64 and linux/riscv64 natives crash with SIGILL on CPUs that older releases supported (#186). The cause is the ubuntu-latest move to Ubuntu 26.04, which targets x86-64-v3 on amd64 and RVA23 on riscv64.

riscv64 is not in the issue, but 1.14.0 has the same problem there:

linux library 1.12.1 1.14.0
amd64, %ymm operands 0 913
riscv64, Tag_RISCV_arch rv64gc RVA23 (v, zvbb, zicond, ...)

Adding -march=rv64gc on 26.04 is not enough. RV64GC has no byte-swap instruction, so GCC calls __bswapdi2 from libgcc, and Ubuntu 26.04's libgcc is built for RVA23. Its __bswapdi2 uses rev8.

This PR builds the Linux natives on ubuntu-24.04, the toolchain 1.12.1 used, like #178 did for macOS. It also adds a step to the assemble job that fails if the amd64 library has AVX, BMI1/2, LZCNT or MOVBE instructions, or if the riscv64 library's Tag_RISCV_arch lists anything beyond RV64GC. The linker merges that tag from every input, including libgcc and the crt objects, so the check also catches the libgcc case above.

I checked the new step against:

  • the published 1.12.1 natives: passes
  • the published 1.14.0 natives: fails on both arches
  • natives built in an ubuntu:24.04 container with this workflow's flags: passes, and the riscv64 library has no V, Zb* or Zicond instructions
  • natives built in an ubuntu:26.04 container with -march=x86-64 and -march=rv64gc: amd64 passes, riscv64 fails because of libgcc

ppc64le, s390x and aarch64 gained no instructions beyond their 1.12.1 baselines, and the darwin/x86_64 library has no AVX.

I could not run this workflow itself on my fork because Actions is off for forks there.

Created with Claude Opus 5.5 in Claude Code.

ubuntu-latest moved to Ubuntu 26.04, which targets x86-64-v3 on amd64
and RVA23 on riscv64. Since 1.13.0 the amd64 and riscv64 libraries use
AVX2, BMI2 and RVV instructions and crash with SIGILL on CPUs without
them. On riscv64 -march=rv64gc is not enough: the libgcc linked into
the library is built for RVA23 too.

Pin the Linux natives job to ubuntu-24.04, the toolchain 1.12.1 used,
and check the assembled libraries for instructions above x86-64 and
RV64GC.

Fixes yawkat#186

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Dominik-O22

Copy link
Copy Markdown
Author

Note

🤖 Claude Opus 5.5 responding on behalf of Dominik-O22

Closing in favor of #187. Its latest commit does the same things: it builds on ubuntu-24.04 and checks that Tag_RISCV_arch stays within rv64gc. In an ubuntu:26.04 container I confirmed the libgcc problem it describes: with -march=rv64gc, the riscv64 library still gets rev8 from libgcc's __bswapdi2.

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