Path: blob/main/ci/ensure_deterministic_build.sh
1685 views
#!/bin/bash12# This script makes sure that the meta crate deterministically generate files3# with a high probability.4# The current directory must be set to the repository's root.5#6# We set SKIP_ISLE=1 to skip ISLE generation, because it depends on files7# in-tree (cranelift/codegen/.../*.isle) but these are not available when we8# switch to different working directories during this test.910set -e1112BUILD_SCRIPT=$(find -wholename "./target/debug/build/cranelift-codegen-*/build-script-build")1314# First, run the script to generate a reference comparison.15rm -rf /tmp/reference16mkdir /tmp/reference17SKIP_ISLE=1 OUT_DIR=/tmp/reference TARGET=x86_64 CARGO_PKG_VERSION=0.1.0 CARGO_MANIFEST_DIR=/tmp $BUILD_SCRIPT1819# To make sure the build script doesn't depend on the current directory, we'll20# change the current working directory on every iteration. Make this easy to21# reproduce this locally by first copying the target/ directory into an initial22# temporary directory (and not move and lose the local clone's content).23rm -rf /tmp/src024mkdir /tmp/src02526echo Copying target directory...27cp -r ./target /tmp/src0/target28cd /tmp/src029echo "Done, starting loop."3031# Then, repeatedly make sure that the output is the same.32for i in {1..20}33do34# Move to a different directory, as explained above.35rm -rf /tmp/src$i36mkdir /tmp/src$i37mv ./* /tmp/src$i38cd /tmp/src$i3940rm -rf /tmp/try41mkdir /tmp/try42SKIP_ISLE=1 OUT_DIR=/tmp/try TARGET=x86_64 CARGO_PKG_VERSION=0.1.0 CARGO_MANIFEST_DIR=/tmp/src$i $BUILD_SCRIPT43diff -qr /tmp/reference /tmp/try44done454647