From a873049e96a22cd300ee73e6ed9b517662b22feb Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Mar 2026 16:23:02 +0000 Subject: [PATCH] fix: install gcc and configure native x86_64 linker in build image rust:slim-bookworm doesn't include gcc, and aes-gcm's build deps (via cc-rs) need a C compiler. With --target x86_64-unknown-linux-gnu set explicitly, cc-rs looks for the cross-compiler 'x86_64-linux-gnu-gcc' instead of native 'gcc'. Fix: install gcc in the build stage and add a [target.x86_64-*] linker entry pointing to 'gcc' so cc-rs finds it on native x86_64 builds. https://claude.ai/code/session_01FKCW3FDjNFj6jve4niMFXH --- infra/Dockerfile.server | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/infra/Dockerfile.server b/infra/Dockerfile.server index 236ab0b..4f71b73 100644 --- a/infra/Dockerfile.server +++ b/infra/Dockerfile.server @@ -8,8 +8,10 @@ ARG TARGETPLATFORM ARG TARGETARCH ARG TARGETVARIANT -# Install cross-compilation toolchains only when actually cross-compiling. -RUN apt-get update && apt-get install -y pkg-config && \ +# Install build tools. gcc is always needed: cc-rs (used by ring/aes-gcm deps) +# calls the native compiler even on native builds, and rust:slim doesn't +# include it. Cross-compilers are added only when actually cross-compiling. +RUN apt-get update && apt-get install -y gcc pkg-config && \ if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then \ case "${TARGETARCH}:${TARGETVARIANT}" in \ "arm64:") apt-get install -y gcc-aarch64-linux-gnu ;; \ @@ -29,8 +31,13 @@ RUN case "${TARGETARCH}:${TARGETVARIANT}" in \ esac > /rust_target && \ rustup target add "$(cat /rust_target)" -# Tell Cargo which cross-linker to use (ignored on native builds). +# Tell Cargo which linker to use for each target. +# x86_64 native: use plain gcc (cc-rs would otherwise look for +# "x86_64-linux-gnu-gcc" which is the *cross* toolchain, not installed here). RUN mkdir -p /root/.cargo && printf '\ +[target.x86_64-unknown-linux-gnu]\n\ +linker = "gcc"\n\ +\n\ [target.aarch64-unknown-linux-gnu]\n\ linker = "aarch64-linux-gnu-gcc"\n\ \n\