From 1d0cc5f0d2efdfc420f9e5f47ae2f9f4142abfb5 Mon Sep 17 00:00:00 2001 From: Lyndon Date: Fri, 12 Dec 2025 20:44:05 +0800 Subject: [PATCH 1/2] chore: fix reproducible build on mac(arm64) On mac (arm64), Docker defaults to --platform=linux/arm64, while on Linux it defaults to --platform=linux/amd64. These are slightly different. Force Docker to use a single platform/image. --- standalone-contract/scripts/reproducible_build_docker | 4 ++-- workspace/scripts/reproducible_build_docker | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/standalone-contract/scripts/reproducible_build_docker b/standalone-contract/scripts/reproducible_build_docker index dd61351..dc573ff 100755 --- a/standalone-contract/scripts/reproducible_build_docker +++ b/standalone-contract/scripts/reproducible_build_docker @@ -55,9 +55,9 @@ else TASKS+=" build " fi -$DOCKER run --rm $DOCKER_RUN_ARGS -v `pwd`:/code $DOCKER_IMAGE make $TASKS +$DOCKER run --platform=linux/amd64 --rm $DOCKER_RUN_ARGS -v `pwd`:/code $DOCKER_IMAGE make $TASKS # Reset file ownerships for all files docker might touch -$DOCKER run --rm $DOCKER_RUN_ARGS -e UID=`id -u` -e GID=`id -g` -v `pwd`:/code $DOCKER_IMAGE bash -c 'chown -R -f $UID:$GID checksums.txt build target' +$DOCKER run --platform=linux/amd64 --rm $DOCKER_RUN_ARGS -e UID=`id -u` -e GID=`id -g` -v `pwd`:/code $DOCKER_IMAGE bash -c 'chown -R -f $UID:$GID checksums.txt build target' if [[ "${UPDATE}" = "yes" ]]; then echo "${CHECKSUM_FILE_PATH} file is updated with latest binary hashes!" diff --git a/workspace/scripts/reproducible_build_docker b/workspace/scripts/reproducible_build_docker index dd61351..dc573ff 100755 --- a/workspace/scripts/reproducible_build_docker +++ b/workspace/scripts/reproducible_build_docker @@ -55,9 +55,9 @@ else TASKS+=" build " fi -$DOCKER run --rm $DOCKER_RUN_ARGS -v `pwd`:/code $DOCKER_IMAGE make $TASKS +$DOCKER run --platform=linux/amd64 --rm $DOCKER_RUN_ARGS -v `pwd`:/code $DOCKER_IMAGE make $TASKS # Reset file ownerships for all files docker might touch -$DOCKER run --rm $DOCKER_RUN_ARGS -e UID=`id -u` -e GID=`id -g` -v `pwd`:/code $DOCKER_IMAGE bash -c 'chown -R -f $UID:$GID checksums.txt build target' +$DOCKER run --platform=linux/amd64 --rm $DOCKER_RUN_ARGS -e UID=`id -u` -e GID=`id -g` -v `pwd`:/code $DOCKER_IMAGE bash -c 'chown -R -f $UID:$GID checksums.txt build target' if [[ "${UPDATE}" = "yes" ]]; then echo "${CHECKSUM_FILE_PATH} file is updated with latest binary hashes!" From 4adbf25cc9c96453470d2de783e0b060269f8325 Mon Sep 17 00:00:00 2001 From: Lyndon Date: Mon, 15 Dec 2025 09:34:27 +0800 Subject: [PATCH 2/2] ci: fix --- .github/workflows/rust.yml | 5 +++-- standalone-contract/scripts/reproducible_build_docker | 10 ++++++++-- workspace/scripts/reproducible_build_docker | 10 ++++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index cb9e53c..06c2a50 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -67,8 +67,8 @@ jobs: steps: - name: Install dependencies run: apt-get update && apt-get -y install curl git build-essential pkg-config libssl-dev lsb-release wget gnupg - - name: Install llvm 19 - run: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 19 && rm llvm.sh + - name: Install llvm 21 + run: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 21 && rm llvm.sh - uses: actions-rust-lang/setup-rust-toolchain@v1 with: components: clippy @@ -283,6 +283,7 @@ jobs: cargo generate --path . standalone-contract --name test-contract cd test-contract gmake build test check clippy + cargo clean cd .. cargo generate --path . workspace --name test-workspace cd test-workspace diff --git a/standalone-contract/scripts/reproducible_build_docker b/standalone-contract/scripts/reproducible_build_docker index dc573ff..66e2899 100755 --- a/standalone-contract/scripts/reproducible_build_docker +++ b/standalone-contract/scripts/reproducible_build_docker @@ -55,9 +55,15 @@ else TASKS+=" build " fi -$DOCKER run --platform=linux/amd64 --rm $DOCKER_RUN_ARGS -v `pwd`:/code $DOCKER_IMAGE make $TASKS +DOCKER_IMAGE_PLATFORM=linux/amd64 +if [[ "$(grep -E '^ID=' /etc/os-release 2>/dev/null | cut -d= -f2 | tr -d '"')" == "ubuntu" ]] && [[ "$(uname -m)" == "aarch64" ]]; then + echo "Ubuntu ARM64 detected. Using docker image with linux/arm64 platform. Note: This may produce different binaries than the default linux/amd64." + DOCKER_IMAGE_PLATFORM=linux/arm64 +fi + +$DOCKER run --platform=${DOCKER_IMAGE_PLATFORM} --rm $DOCKER_RUN_ARGS -v `pwd`:/code $DOCKER_IMAGE make $TASKS # Reset file ownerships for all files docker might touch -$DOCKER run --platform=linux/amd64 --rm $DOCKER_RUN_ARGS -e UID=`id -u` -e GID=`id -g` -v `pwd`:/code $DOCKER_IMAGE bash -c 'chown -R -f $UID:$GID checksums.txt build target' +$DOCKER run --platform=${DOCKER_IMAGE_PLATFORM} --rm $DOCKER_RUN_ARGS -e UID=`id -u` -e GID=`id -g` -v `pwd`:/code $DOCKER_IMAGE bash -c 'chown -R -f $UID:$GID checksums.txt build target' if [[ "${UPDATE}" = "yes" ]]; then echo "${CHECKSUM_FILE_PATH} file is updated with latest binary hashes!" diff --git a/workspace/scripts/reproducible_build_docker b/workspace/scripts/reproducible_build_docker index dc573ff..66e2899 100755 --- a/workspace/scripts/reproducible_build_docker +++ b/workspace/scripts/reproducible_build_docker @@ -55,9 +55,15 @@ else TASKS+=" build " fi -$DOCKER run --platform=linux/amd64 --rm $DOCKER_RUN_ARGS -v `pwd`:/code $DOCKER_IMAGE make $TASKS +DOCKER_IMAGE_PLATFORM=linux/amd64 +if [[ "$(grep -E '^ID=' /etc/os-release 2>/dev/null | cut -d= -f2 | tr -d '"')" == "ubuntu" ]] && [[ "$(uname -m)" == "aarch64" ]]; then + echo "Ubuntu ARM64 detected. Using docker image with linux/arm64 platform. Note: This may produce different binaries than the default linux/amd64." + DOCKER_IMAGE_PLATFORM=linux/arm64 +fi + +$DOCKER run --platform=${DOCKER_IMAGE_PLATFORM} --rm $DOCKER_RUN_ARGS -v `pwd`:/code $DOCKER_IMAGE make $TASKS # Reset file ownerships for all files docker might touch -$DOCKER run --platform=linux/amd64 --rm $DOCKER_RUN_ARGS -e UID=`id -u` -e GID=`id -g` -v `pwd`:/code $DOCKER_IMAGE bash -c 'chown -R -f $UID:$GID checksums.txt build target' +$DOCKER run --platform=${DOCKER_IMAGE_PLATFORM} --rm $DOCKER_RUN_ARGS -e UID=`id -u` -e GID=`id -g` -v `pwd`:/code $DOCKER_IMAGE bash -c 'chown -R -f $UID:$GID checksums.txt build target' if [[ "${UPDATE}" = "yes" ]]; then echo "${CHECKSUM_FILE_PATH} file is updated with latest binary hashes!"