Build a native arm64 image instead of emulating amd64 - #201
Build a native arm64 image instead of emulating amd64#201aleksanderllada wants to merge 1 commit into
Conversation
.cargo/config.toml pins -C target-cpu=neoverse-512tvb for aarch64-unknown-linux-gnu, so an arm64 image built from source SIGILLs on anything short of Graviton3+. DOCKER.md worked around it by telling Apple Silicon users to build linux/amd64 and emulate. Assemble RUSTFLAGS in the Dockerfile instead. Overriding the pin needs RUSTFLAGS specifically, not CARGO_TARGET_<triple>_RUSTFLAGS: the latter is another source for the same config key and cargo joins config arrays, so -C target-cpu would survive. ARM64_TARGET_CPU opts back into the tuning for a Graviton deployment. RUSTFLAGS does not reach a C compiler, and lore-base pins the same -mcpu for its cc build of rpmalloc. That flag raises the architecture floor as well as the tuning -- GCC 14 emits stlur (FEAT_LRCPC2, armv8.4) and ldapr (armv8.3), undefined on Neoverse N1 parts such as Ampere Altra and Graviton2. build.rs now takes LORE_ARM64_TARGET_CPU, defaulting to the value it hardcoded, and the Dockerfile passes the choice through. Verified by disassembling both builds: with the tuning off, the allocator is clean armv8-a. EXPOSE defaults to TCP, so it was not declaring the QUIC listener sharing 41337; docker run -P left it unreachable. Signed-off-by: Aleksander Arruda <aleksander.arruda@xa.epicgames.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Built and ran on an M3 Max, which is the case main documents as impossible: No Disassembled the shipped binary rather than trusting the flags: Those last ones look like a hole in the baseline claim but are not. Every occurrence sits inside an That is rustc's Not verified here: that |
Summary
An arm64 image built from source
SIGILLs on anything short of Graviton3+, because.cargo/config.tomlpins-C target-cpu=neoverse-512tvbforaarch64-unknown-linux-gnu.DOCKER.mdworked around it by telling Apple Silicon users to build--platform linux/amd64and emulate:This builds natively instead.
docker build -f lore-server/Dockerfile .now produces a baselinearmv8-aimage on Apple Silicon, and--build-arg ARM64_TARGET_CPU=neoverse-512tvbopts back into the tuning for a Graviton deployment.Two things worth a reviewer's attention
Overriding the pin needs
RUSTFLAGSspecifically, notCARGO_TARGET_<triple>_RUSTFLAGS. The latter is only another source for the same config key, and cargo joins config arrays — the config's-C target-cpuwould survive and the build would still fault.RUSTFLAGSreplaces[build]and[target.*]outright, which is why the flags are restated in full rather than appended to.RUSTFLAGSdoes not reach a C compiler.lore-base/build.rspins the same-mcpufor itsccbuild of rpmalloc, so the Rust half alone is not enough. That flag raises the architecture floor as well as the tuning — disassembling both builds with GCC 14:No SVE, so Apple Silicon was never at risk from the C half. But
stluris FEAT_LRCPC2 (armv8.4) andldapris armv8.3, and Neoverse N1 has neither — so an otherwise-baseline image would still have faulted in the allocator on Ampere Altra and Graviton2.build.rsnow readsLORE_ARM64_TARGET_CPU, defaulting to the value it hardcoded so nothing else changes, and the Dockerfile passes the choice through.Also here:
EXPOSEdefaults to TCP, so it was not declaring the QUIC listener sharing port 41337 —docker run -Pleft it unreachable.Test evidence
linux/arm64; with the tuning off the allocator is cleanarmv8-a, and the instructions above appear only with it on.cargo fmtandcargo clippyclean onbuild.rs. (Clippy reports three pre-existing errors inlore-revision/src/{stage,state}.rs, untouched here and present on main.)Note
Split out of #180, which touches the same two sections of
DOCKER.md— whichever merges second will need a small conflict resolution.