Skip to content

GH-146475: Strip CFI directives from JIT stencils to allow using Apple LLVM 21#148364

Open
savannahostrowski wants to merge 10 commits intopython:mainfrom
savannahostrowski:fix-apple-llvm
Open

GH-146475: Strip CFI directives from JIT stencils to allow using Apple LLVM 21#148364
savannahostrowski wants to merge 10 commits intopython:mainfrom
savannahostrowski:fix-apple-llvm

Conversation

@savannahostrowski
Copy link
Copy Markdown
Member

@savannahostrowski savannahostrowski commented Apr 10, 2026

After poking around at this a bit, it seems like Apple LLVM 21 is stricter about validating CFI frame nesting. In debug builds, .cfi_endproc directives can end up in blocks that the optimizer removes as unreachable, leaving unbalanced .cfi_startproc directives that the assembler rejects (and so you'll get something like this #146478 (comment) while building).

Since JIT stencils are already compiled with -fno-asynchronous-unwind-tables, I believe the CFI directives are unused and so they can be stripped out. I also tried changing the flag to -fno-unwind-tables instead to just prevent us from emitting the directives in the first place but it seems like that's a bigger change as we'd have to handle SHT_X86_64_UNWIND sections on x86_64 Linux (https://github.com/python/cpython/actions/runs/24265500635/job/70859484777?pr=148364)? I'm not totally sure why that is. We could go that route but wanted to solicit opinions first before going down that road.

This is an alternative to #146478 that tries to fix the root cause rather than blocking Apple LLVM 21.

@savannahostrowski savannahostrowski marked this pull request as draft April 10, 2026 21:25
@savannahostrowski savannahostrowski changed the title GH-146475: Strip CFI directives from JIT stencils to allow using Apple LLVM 21 GH-146475: Use -fno-unwind-tables for JIT stencils to fix Apple LLVM 21 build failures Apr 10, 2026
@savannahostrowski savannahostrowski marked this pull request as ready for review April 10, 2026 21:39
@savannahostrowski savannahostrowski changed the title GH-146475: Use -fno-unwind-tables for JIT stencils to fix Apple LLVM 21 build failures GH-146475: Strip CFI directives from JIT stencils to allow using Apple LLVM 21 Apr 10, 2026
@savannahostrowski
Copy link
Copy Markdown
Member Author

Gonna try out some other flags in a bit. Gotta assemble a new couch first.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant