fix(build): align Go ELF segments to 64KB for aarch64 64K-page kernels#915
fix(build): align Go ELF segments to 64KB for aarch64 64K-page kernels#915Pangjiping wants to merge 1 commit into
Conversation
Pass `-R 0x10000` to Go's linker so PT_LOAD segments are aligned to 64KB in every Go binary build (execd, ingress, egress, controller, task-executor, image-committer). Without this, ELF binaries built for amd64 use 4KB segment alignment by default and fail to load on aarch64 kernels configured with CONFIG_ARM64_64K_PAGES=y (NVIDIA Grace Hopper, ARM Neoverse-V2 HPC, RHEL/CentOS aarch64+64k variants). The flag is also applied to arm64 builds to lock the alignment in case Go's default ever regresses. Refs alibaba#853. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 02a8e07ef4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| RUN CGO_ENABLED=0 GOOS=windows go build ${GOFLAGS} -trimpath -buildvcs=false \ | ||
| -ldflags "${LDFLAGS} -buildid= -B none \ | ||
| -ldflags "${LDFLAGS} -buildid= -B none -R 0x10000 \ | ||
| -X 'github.com/alibaba/opensandbox/internal/version.Version=${VERSION}' \ |
There was a problem hiding this comment.
Remove -R from the Windows execd build
When this Dockerfile reaches the GOOS=windows step, the Go linker rejects -R 0x10000 for PE output (I checked go tool link -h, where -R is the address rounding quantum, and a Go 1.25.1 GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '-buildid= -B none -R 0x10000' fails with .data.VirtualAddress = 0xff000, want 0x100000). That makes every execd image build fail before the runtime stage, even though the 64K-page fix is only needed for Linux ELF binaries.
Useful? React with 👍 / 👎.
| # aarch64 kernels built with CONFIG_ARM64_64K_PAGES=y (e.g. NVIDIA Grace, | ||
| # RHEL aarch64+64k). Go's internal linker honours this for ELF/PE; on Mach-O | ||
| # the value just affects layout. See issue #853. | ||
| PROJECT_LDFLAGS := -buildid= -B none -R 0x10000 -X 'github.com/alibaba/opensandbox/internal/version.Version=$(VERSION)' \ |
There was a problem hiding this comment.
Keep -R out of multi-build's Windows targets
PROJECT_LDFLAGS is reused by make multi-build, whose loop includes windows/amd64 and windows/arm64; with this added -R 0x10000, the first Windows cross-compile fails in the linker (.data.VirtualAddress = 0xff000, want 0x100000 with Go 1.25.1). This breaks the documented multi-platform execd release build even though only the Linux ELF artifacts need the 64K PT_LOAD alignment.
Useful? React with 👍 / 👎.
|
Changed directories: components、kubernetes. 📋 Recommended labels (based on changed files):
Other available labels:
💡 Tip: Use cc @Pangjiping |
Summary
Pass
-R 0x10000to Go's linker so PT_LOAD segments are aligned to 64KB in every Go binary build (execd, ingress, egress, controller, task-executor, image-committer). Without this, ELF binaries built for amd64 use 4KB segment alignment by default and fail to load on aarch64 kernels configured with CONFIG_ARM64_64K_PAGES=y (NVIDIA Grace Hopper, ARM Neoverse-V2 HPC, RHEL/CentOS aarch64+64k variants). The flag is also applied to arm64 builds to lock the alignment in case Go's default ever regresses.Closes #853.
Testing
Breaking Changes
Checklist