From 061694d0cb3bbf5d4c7e920c892824f0020cff83 Mon Sep 17 00:00:00 2001 From: Mathijs van Veluw Date: Fri, 25 Sep 2026 21:53:06 +0200 Subject: [PATCH] Fix cortex-a53 build issues when using xx-cargo (#7774) When using xx-cargo it uses a different linker then the default one. This causes some default fixes Debian/Ubuntu add for the Cortex-A53 architectures to not be included. This commit fixes that by checking if the target architecture is arm64 and if so, will add the needed fix argument. This should prevent issues reported here #7754. We can not say this with 100% certainty since this bug sometimes appears and sometimes it does not. Fixes #7754 Signed-off-by: BlackDex --- docker/Dockerfile.debian | 24 ++++++++++++++++++++---- docker/Dockerfile.j2 | 12 ++++++++++-- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/docker/Dockerfile.debian b/docker/Dockerfile.debian index b8490609..62dff072 100644 --- a/docker/Dockerfile.debian +++ b/docker/Dockerfile.debian @@ -101,9 +101,17 @@ RUN . /env-cargo && \ # https://github.com/tonistiigi/xx/pull/108#issuecomment-3700635977 # https://github.com/dani-garcia/vaultwarden/discussions/7522 if xx-info is-cross; then \ - XX_RUSTFLAGS="-C link-arg=-Wl,-rpath-link,/usr/lib/$(xx-info triple)"; \ - export XX_RUSTFLAGS; \ + XX_RUSTFLAGS="-Clink-arg=-Wl,-rpath-link,/usr/lib/$(xx-info triple)"; \ fi && \ + # Debian's GCC adds a special fix for cortex-a53 arch's which gets losts when using xx-cargo, which uses clang + # Checking if the arch is arm64 and adding this extra link-arg should cause this fix to be applied + # This should fix issues reported when running on a RPi3 which is a Cortex-A35 chip + # See: https://salsa.debian.org/toolchain-team/gcc/-/blob/master/debian/rules2?pow_referer=#L543-548 + # See: https://github.com/dani-garcia/vaultwarden/issues/7754 + if [ "$(xx-info arch)" = "arm64" ]; then \ + XX_RUSTFLAGS="${XX_RUSTFLAGS} -Clink-arg=-Wl,--fix-cortex-a53-843419"; \ + fi && \ + export XX_RUSTFLAGS && \ PKG_CONFIG="$(command -v "$(xx-info)-pkg-config")" xx-cargo build --features ${DB} --profile "${CARGO_PROFILE}" && \ find . -not -path "./target*" -delete @@ -123,9 +131,17 @@ RUN . /env-cargo && \ # https://github.com/tonistiigi/xx/pull/108#issuecomment-3700635977 # https://github.com/dani-garcia/vaultwarden/discussions/7522 if xx-info is-cross; then \ - XX_RUSTFLAGS="-C link-arg=-Wl,-rpath-link,/usr/lib/$(xx-info triple)"; \ - export XX_RUSTFLAGS; \ + XX_RUSTFLAGS="-Clink-arg=-Wl,-rpath-link,/usr/lib/$(xx-info triple)"; \ + fi && \ + # Debian's GCC adds a special fix for cortex-a53 arch's which gets losts when using xx-cargo, which uses clang + # Checking if the arch is arm64 and adding this extra link-arg should cause this fix to be applied + # This should fix issues reported when running on a RPi3 which is a Cortex-A35 chip + # See: https://salsa.debian.org/toolchain-team/gcc/-/blob/master/debian/rules2?pow_referer=#L543-548 + # See: https://github.com/dani-garcia/vaultwarden/issues/7754 + if [ "$(xx-info arch)" = "arm64" ]; then \ + XX_RUSTFLAGS="${XX_RUSTFLAGS} -Clink-arg=-Wl,--fix-cortex-a53-843419"; \ fi && \ + export XX_RUSTFLAGS && \ PKG_CONFIG="$(command -v "$(xx-info)-pkg-config")" xx-cargo build --features ${DB} --profile "${CARGO_PROFILE}" && \ if [ "${CARGO_PROFILE}" = "dev" ] ; then \ ln -vfsr "/app/target/${CARGO_TARGET}/debug" /app/target/final ; \ diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index 633d6955..2dc175b0 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -32,9 +32,17 @@ # https://github.com/tonistiigi/xx/pull/108#issuecomment-3700635977 # https://github.com/dani-garcia/vaultwarden/discussions/7522 if xx-info is-cross; then \ - XX_RUSTFLAGS="-C link-arg=-Wl,-rpath-link,/usr/lib/$(xx-info triple)"; \ - export XX_RUSTFLAGS; \ + XX_RUSTFLAGS="-Clink-arg=-Wl,-rpath-link,/usr/lib/$(xx-info triple)"; \ fi && \ + # Debian's GCC adds a special fix for cortex-a53 arch's which gets losts when using xx-cargo, which uses clang + # Checking if the arch is arm64 and adding this extra link-arg should cause this fix to be applied + # This should fix issues reported when running on a RPi3 which is a Cortex-A35 chip + # See: https://salsa.debian.org/toolchain-team/gcc/-/blob/master/debian/rules2?pow_referer=#L543-548 + # See: https://github.com/dani-garcia/vaultwarden/issues/7754 + if [ "$(xx-info arch)" = "arm64" ]; then \ + XX_RUSTFLAGS="${XX_RUSTFLAGS} -Clink-arg=-Wl,--fix-cortex-a53-843419"; \ + fi && \ + export XX_RUSTFLAGS && \ PKG_CONFIG="$(command -v "$(xx-info)-pkg-config")" xx-cargo build --features ${DB} --profile "${CARGO_PROFILE}" {%- endmacro %} FROM --platform=linux/amd64 docker.io/vaultwarden/web-vault@{{ vault_image_digest }} AS vault