Skip to content

Build ISA-specific sources with -fno-lto - #417

Open
bim-ba wants to merge 1 commit into
aous72:masterfrom
bim-ba:build-isa-sources-without-lto
Open

bim-ba wants to merge 1 commit into
aous72:masterfrom
bim-ba:build-isa-sources-without-lto

Conversation

@bim-ba

@bim-ba bim-ba commented Nov 2, 2026

Copy link
Copy Markdown

Fixes #416.

Compiles the 17 sources that get per-file -msse, -mavx, -mavx2 or -mavx512f flags with -fno-lto, with a comment that says why. Without it, GCC LTO merges their static initializers into the library's single load-time constructor, which can then run AVX-512 instructions on any CPU. OpenEXR 3.5.3 crashed this way with the bundled OpenJPH.

Tested with GCC 16.2.1 and -flto=auto:

  • ctest: 135 of 135 pass on master with the change.
  • OpenEXR v3.5.3 with the patched bundled copy: 0 vector instructions in the load-time constructor, and the library loads on a CPU without AVX-512. The AVX-512 kernels are still in the library for runtime dispatch.

Not tested: clang, non-x86 targets, a full HTJ2K round trip with the patched OpenEXR build.

🤖 Generated with Claude Code

With GCC LTO, the static initializers of the sources built with per-file
-msse/-mavx/-mavx2/-mavx512f flags are merged into the library's single
load-time constructor. That constructor can then contain AVX-512
instructions, so loading the library crashes with SIGILL on CPUs without
them. OpenEXR 3.5.3 hit this with its bundled copy of OpenJPH.

Keep these files out of LTO so their initializers stay in their own
functions. The AVX-512 kernels are unchanged and still selected at run time.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@aous72

aous72 commented Nov 14, 2026

Copy link
Copy Markdown
Owner

@bim-ba
Are there any updates on this. This was not a problem in 0.32.0, which has exactly the same structure.

This branch has not been deployed

No deployments
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.

GCC LTO merges initializers of ISA-flagged files into one load-time constructor (SIGILL in OpenEXR 3.5.3)

2 participants