Skip to content

Commit 1a636c3

Browse files
authored
fix: strip .sframe from glibc crt objects to unblock Zig linker on GCC 15+ (#143)
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: #138 See: https://ziggit.dev/t/linker-error-when-building-zig-from-source/14394 Co-authored-by: Dino Korah <691011+codemedic@users.noreply.github.com>
1 parent 64aa416 commit 1a636c3

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

bin/build-ghostty.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ BUILD_ARGS="${BUILD_ARGS} -Dversion-string=${GHOSTTY_VERSION}"
4242

4343
# Configure Zig: https://ziglang.org
4444
ZIG_VERSION="$(cat "ghostty-${GHOSTTY_VERSION}/build.zig.zon" | grep ".minimum_zig_version" | cut -d'"' -f2)"
45+
ZIG_PACKAGE_NAME="zig-${ARCH}-linux-${ZIG_VERSION}"
4546
CURRENT_ZIG_VERSION=$(zig version 2>/dev/null || true)
4647
if [ "$CURRENT_ZIG_VERSION" != "$ZIG_VERSION" ]; then
4748
echo "Installing Zig ${ZIG_VERSION}..."
48-
ZIG_PACKAGE_NAME="zig-${ARCH}-linux-${ZIG_VERSION}"
4949
ZIG_URL="https://ziglang.org/download/${ZIG_VERSION}/${ZIG_PACKAGE_NAME}.tar.xz"
5050
rm -rf /opt/zig*
5151
unlink /usr/local/bin/zig || true

bin/bundle-appimage.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ ARCH="$(uname -m)"
66
GHOSTTY_VERSION="$(cat VERSION)"
77

88
export UPINFO="gh-releases-zsync|$(echo "${GITHUB_REPOSITORY}" | tr '/' '|')|latest|Ghostty-*$ARCH.AppImage.zsync"
9-
export URUNTIME_PRELOAD=1
109
export DEPLOY_OPENGL=1
1110
export EXEC_WRAPPER=1
1211
export OUTNAME="Ghostty-${GHOSTTY_VERSION}-${ARCH}.AppImage"

bin/setup-env.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ ghosttyDeps="gtk4 libadwaita gtk4-layer-shell"
1414
rm -rf "/usr/share/libalpm/hooks/package-cleanup.hook"
1515
pacman -Syuq --needed --noconfirm --noprogressbar ${buildDeps} ${ghosttyDeps}
1616

17+
# GCC 15+ compiles glibc crt startup objects with .sframe sections that use R_X86_64_PC64
18+
# relocations. Zig's self-hosted linker doesn't support this relocation type, causing
19+
# build-time helpers (e.g. ghostty-build-data) to fail. Strip .sframe and its associated
20+
# relocation section from the affected objects so the linker never encounters them.
21+
for _crt in /usr/lib/crt1.o /usr/lib/Scrt1.o /usr/lib/rcrt1.o; do
22+
[ -f "$_crt" ] && objcopy --remove-section .sframe --remove-section .rela.sframe "$_crt"
23+
done
24+
1725
ARCH="$(uname -m)"
1826

1927
MINISIGN_VERSION="$(get_latest_gh_release 'jedisct1/minisign')"

0 commit comments

Comments
 (0)