From 1d91b2619d221fca004e9595438e4508569b91cf Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 19 Mar 2023 22:13:39 +0100 Subject: [PATCH] Fix compilation where BUILD = TARGET platform --- Dockerfile | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index ec700d4..046fbc2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,17 +21,19 @@ RUN \ mkdir .cargo && \ echo '[net]' >> .cargo/config.toml && \ echo 'git-fetch-with-cli = true' >> .cargo/config.toml && \ - if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ - echo '[target.x86_64-unknown-linux-gnu]' >> .cargo/config.toml; \ - echo 'linker = "x86-64-linux-gnu-gcc"' >> .cargo/config.toml; \ - fi && \ - if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ - echo '[target.aarch64-unknown-linux-gnu]' >> .cargo/config.toml; \ - echo 'linker = "aarch64-linux-gnu-gcc"' >> .cargo/config.toml; \ - fi && \ - if [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then \ - echo '[target.armv7-unknown-linux-gnueabihf]' >> .cargo/config.toml; \ - echo 'linker = "arm-linux-gnueabihf-gcc"' >> .cargo/config.toml; \ + if [ "${BUILDPLATFORM}" != "${TARGETPLATFORM}" ]; then \ + if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ + echo '[target.x86_64-unknown-linux-gnu]' >> .cargo/config.toml; \ + echo 'linker = "x86-64-linux-gnu-gcc"' >> .cargo/config.toml; \ + fi && \ + if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ + echo '[target.aarch64-unknown-linux-gnu]' >> .cargo/config.toml; \ + echo 'linker = "aarch64-linux-gnu-gcc"' >> .cargo/config.toml; \ + fi && \ + if [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then \ + echo '[target.armv7-unknown-linux-gnueabihf]' >> .cargo/config.toml; \ + echo 'linker = "arm-linux-gnueabihf-gcc"' >> .cargo/config.toml; \ + fi \ fi RUN rustup target add ${RUSTTARGET}