fix: force LLVM backend for x86_64 app executables to avoid .sframe linker crash#93
Open
mvanhorn wants to merge 2 commits into
Open
fix: force LLVM backend for x86_64 app executables to avoid .sframe linker crash#93mvanhorn wants to merge 2 commits into
mvanhorn wants to merge 2 commits into
Conversation
|
@mvanhorn is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
Scoped follow-up to bot review on build.zig/app.zig; zig build verified locally.
Author
|
Addressed in b8899df; zig build passes locally on x86_64 and aarch64 hosts. |
|
Tested on Ubuntu 24.04.4 LTS x86_64, Zig 0.16.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The repo already contains the exact remedy:
useLlvmWorkaround(target)inbuild/app.zig(returnstrueon x86_64) is applied to the mobile static lib, the test compile, and the model-contract exe - but NOT to the main app executable created inaddAppArtifacts(b.addExecutable(.{ .name = app_options.name, .root_module = app_mod }), ~line 244). Add.use_llvm = useLlvmWorkaround(target)there so Debug app builds on x86_64 use LLVM+LLD and never hit the self-hosted linker's .sframe limitation; verify whether.use_lldmust also be set explicitly on this Zig version (the upstream workaround sets both). Extend theuseLlvmWorkarounddoc comment to record this second justification (the .sframe R_X86_64_PC64 linker crash with GCC 15 crt1.o, issue #37) alongside the existing SysV f32 miscompile rationale.Why this matters
On Linux x86_64 hosts with GCC 15+, Debug builds of Native SDK apps fail at link time with
fatal linker error: unhandled relocation type R_X86_64_PC64 ... crt1.o:.sframe. GCC 15 emits.sframesections into crt1.o, and Zig 0.15/0.16's self-hosted x86_64 linker (used for Debug builds) cannot process their R_X86_64_PC64 relocations - this is upstream Zig issue codeberg.org/ziglang/zig#31272, where the confirmed workaround is forcing the LLVM backend (.use_llvm = true), which links via LLD. Multiple users are affected (any Arch/Manjaro/CachyOS system with GCC 15), and a commenter on the issue linked the upstream fix/workaround.See #37.
Testing
zig build -Doptimize=Debug(andzig build run) for an app usingaddAppcompiles and links successfully - the emitted compile uses the LLVM backend instead of the self-hosted x86_64 backend, so noR_X86_64_PC64error. - Edge case: non-x86_64 targets (aarch64 macOS/Linux) are unaffected -useLlvmWorkaroundreturnsnullthere, preserving current backend selection. - Edge case: Release builds are unchanged (they already default to LLVM); the flag only alters Debug-mode backend choice. - Regression guard: repozig build teststill passes; the existing file-contains checker step in rootbuild.zigcan gain a pattern assertingbuild/app.zigappliesuseLlvmWorkaroundto the app exe so the workaround is not silently dropped.Fixes #37