Skip to content

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
codemedic:fix/gcc15-zig-linker
Open

fix: strip .sframe from glibc crt objects to unblock Zig linker on GCC 15+#143
codemedic wants to merge 1 commit intopkgforge-dev:feature/issue_138from
codemedic:fix/gcc15-zig-linker

Conversation

@codemedic
Copy link
Copy Markdown

Stacks on top of #140.

Problem

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:

error: fatal linker error: unhandled relocation type R_X86_64_PC64 at offset 0x1c
    note: in /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/../../../../lib/crt1.o:.sframe

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, use objcopy (already available via binutils/base-devel) to strip .sframe and its associated relocation section .rela.sframe from the three affected crt objects:

for _crt in /usr/lib/crt1.o /usr/lib/Scrt1.o /usr/lib/rcrt1.o; do
    [ -f "$_crt" ] && objcopy --remove-section .sframe --remove-section .rela.sframe "$_crt"
done

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=1 from bundle-appimage.sh. The aarch64 dwarfs-lite uruntime variant (v0.5.7) does not support the URUNTIME_MOUNT marker patching that flag triggers, causing AppImage packaging to fail on aarch64.

Tested

Full green CI run on both x86_64 and aarch64 (stable build, v1.3.1):
https://github.com/codemedic/ghostty-appimage/actions/runs/25518466177

…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
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