fix(build): use libgit2's bundled zlib so the server image builds on arm64 hosts - #9132
Open
stigi wants to merge 1 commit into
Open
fix(build): use libgit2's bundled zlib so the server image builds on arm64 hosts#9132stigi wants to merge 1 commit into
stigi wants to merge 1 commit into
Conversation
…osts
Building the server image on an arm64 host fails while linking libgit2 for
the amd64 target:
/rootfs-amd64/usr/lib/x86_64-linux-gnu/libz.a(deflate.o): relocation
R_X86_64_PC32 against symbol `z_errmsg' can not be used when making a
shared object; recompile with -fPIC
ld: final link failed: bad value
libgit2 is built with BUILD_SHARED_LIBS=ON, but the staged cross sysroot
offers only a static, non-PIC libz.a, which cannot go into a shared
object. Point libgit2 at its own bundled zlib for both cross targets; it
is compiled as part of the shared library and so is position independent.
Verified on an Apple Silicon host: `docker build --platform linux/amd64`
now links libgit2.so and proceeds to the Go build, where it failed before.
Generated-by: Claude Code (Claude Opus 5)
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
stigi
marked this pull request as ready for review
September 11, 2026 15:59
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
Building the server image on an arm64 host fails while linking libgit2 for the
amd64 target, before any Go code is compiled:
backend/Dockerfilebuilds libgit2 withBUILD_SHARED_LIBS=ON, and cmakeresolves zlib to the static
libz.ain the staged cross sysroot. That archiveis not built with
-fPIC, so it cannot be linked into a shared object. Pointlibgit2 at its own bundled zlib for both cross targets instead: it is compiled
as part of the shared library and is therefore position independent.
The failure is host-architecture dependent, which is why CI does not see it —
on an amd64 builder the amd64 target is native and picks up a usable zlib. On
Apple Silicon, which is where a lot of contributors work,
docker build --platform linux/amd64cannot produce the image at all.Why not the alternatives
zlib1g-devinto the staged sysroots would pull the same staticarchive; the shared
libz.sosymlink is what is missing, and staging itcorrectly for both architectures is more moving parts than one cmake flag.
CMAKE_POSITION_INDEPENDENT_CODE=ONdoes not help: the offending object isin a prebuilt Debian archive, not in anything this build compiles.
architectures looks deliberate, so this change leaves it alone.
Does this close any open issues?
No issue filed — the reproduction and the error are above. Happy to open one if
you would prefer the bug tracked separately.
Screenshots
Not applicable; this is a build change.
Verification
On an Apple Silicon host (Docker Desktop,
--platform linux/amd64):Dockerfile:64, the libgit2 stage, with the relocation error abovelibgit2.so, the stage completes, and the build proceeds throughthe Go plugin build to a working image
The resulting amd64 image has been running a DevLake instance, collecting from
a live data source, without issue.