fix: strip .sframe from glibc crt objects to unblock Zig linker on GCC 15+#143
Open
codemedic wants to merge 1 commit intopkgforge-dev:feature/issue_138from
Open
fix: strip .sframe from glibc crt objects to unblock Zig linker on GCC 15+#143codemedic wants to merge 1 commit intopkgforge-dev:feature/issue_138from
codemedic wants to merge 1 commit intopkgforge-dev:feature/issue_138from
Conversation
…C 15+
GCC 15+ compiles glibc crt startup objects (crt1.o, Scrt1.o, rcrt1.o)
with .sframe sections that use R_X86_64_PC64 relocations. Zig's
self-hosted linker doesn't support this relocation type, causing
build-time helpers such as ghostty-build-data to fail with:
error: fatal linker error: unhandled relocation type R_X86_64_PC64
note: in /usr/lib/crt1.o:.sframe
After pacman installs packages in setup-env.sh, use objcopy to strip
.sframe and .rela.sframe from the affected objects. This is
version-agnostic and requires no changes to the Zig invocation.
Also remove URUNTIME_PRELOAD from bundle-appimage.sh — the aarch64
dwarfs-lite uruntime variant does not support the URUNTIME_MOUNT marker
patching it requires, causing AppImage packaging to fail on aarch64.
Fixes: pkgforge-dev#138
See: https://ziggit.dev/t/linker-error-when-building-zig-from-source/14394
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.
Stacks on top of #140.
Problem
GCC 15+ compiles glibc crt startup objects (
crt1.o,Scrt1.o,rcrt1.o) with.sframesections that useR_X86_64_PC64relocations. Zig's self-hosted linker doesn't support this relocation type, causing build-time helpers such asghostty-build-datato fail:The same root cause has been discussed at https://ziggit.dev/t/linker-error-when-building-zig-from-source/14394 and a matching fix has been approved upstream in ghostty itself (ghostty-org/ghostty#11993) — but that only helps tip builds once it lands; stable releases need a workaround at the build-script level.
Fix
In
setup-env.sh, immediately after pacman installs packages, useobjcopy(already available viabinutils/base-devel) to strip.sframeand its associated relocation section.rela.sframefrom the three affected crt objects:This is version-agnostic — it works for GCC 15, 16, and beyond without requiring any changes to the Zig invocation or ghostty's build system.
Also removes
URUNTIME_PRELOAD=1frombundle-appimage.sh. Theaarch64dwarfs-liteuruntime variant (v0.5.7) does not support theURUNTIME_MOUNTmarker patching that flag triggers, causing AppImage packaging to fail on aarch64.Tested
Full green CI run on both
x86_64andaarch64(stable build, v1.3.1):https://github.com/codemedic/ghostty-appimage/actions/runs/25518466177