From 2f89688ca974944781878a74873801597c0b1f11 Mon Sep 17 00:00:00 2001 From: Hugo van der Wijst Date: Tue, 15 Jan 2019 22:42:50 -0800 Subject: Make builds reproducible This is done by using `BTreeMap`s and `BTreeSet`s to get deterministic ordering. Also updated the CI job to check reproducibility of all examples. --- ci/script.sh | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) (limited to 'ci/script.sh') diff --git a/ci/script.sh b/ci/script.sh index 645db3a..ab7f34b 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -81,20 +81,45 @@ main() { continue fi - if [ $ex != types ]; then - cargo run --example $ex --target $T | \ - diff -u ci/expected/$ex.run - + test_arm_example() { + local EXAMPLE=$1 + local TARGET=$2 + local BUILD_MODE=$3 + local FEATURES=$4 + + if [ $BUILD_MODE = "release" ]; then + local RELEASE_FLAG="--release" + else + local RELEASE_FLAG="" + fi + + if [ -n "$FEATURES" ]; then + local FEATURES_FLAG="--features $FEATURES" + else + local FEATURES_FLAG="" + fi + local CARGO_FLAGS="--example $EXAMPLE --target $TARGET $RELEASE_FLAG $FEATURES_FLAG" + + cargo run $CARGO_FLAGS | diff -u ci/expected/$EXAMPLE.run - + arm-none-eabi-objcopy -O ihex target/$TARGET/$BUILD_MODE/examples/$EXAMPLE ${EXAMPLE}_1.hex + + # build again to ensure that the build is reproducable + cargo clean + cargo build $CARGO_FLAGS + arm-none-eabi-objcopy -O ihex target/$TARGET/$BUILD_MODE/examples/$EXAMPLE ${EXAMPLE}_2.hex + + # compare results of both builds + cmp ${EXAMPLE}_1.hex ${EXAMPLE}_2.hex + } - cargo run --example $ex --target $T --release | \ - diff -u ci/expected/$ex.run - + if [ $ex != types ]; then + test_arm_example $ex $T "debug" "" + test_arm_example $ex $T "release" "" fi if [ $TARGET != thumbv6m-none-eabi ]; then - cargo run --features timer-queue --example $ex --target $T | \ - diff -u ci/expected/$ex.run - - - cargo run --features timer-queue --example $ex --target $T --release | \ - diff -u ci/expected/$ex.run - + test_arm_example $ex $T "debug" "timer-queue" + test_arm_example $ex $T "release" "timer-queue" fi done esac -- cgit v1.2.3 From 4f193df0efbd45d5d86eccb472fc2312aec3ca94 Mon Sep 17 00:00:00 2001 From: Hugo van der Wijst Date: Tue, 15 Jan 2019 23:21:40 -0800 Subject: Speed up CI significantly. --- ci/script.sh | 85 ++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 34 deletions(-) (limited to 'ci/script.sh') diff --git a/ci/script.sh b/ci/script.sh index ab7f34b..6a15cc6 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -1,5 +1,36 @@ set -euxo pipefail +arm_example() { + local COMMAND=$1 + local EXAMPLE=$2 + local BUILD_MODE=$3 + local FEATURES=$4 + local BUILD_NUM=$5 + + if [ $BUILD_MODE = "release" ]; then + local RELEASE_FLAG="--release" + else + local RELEASE_FLAG="" + fi + + if [ -n "$FEATURES" ]; then + local FEATURES_FLAG="--features $FEATURES" + local FEATURES_STR=${FEATURES/,/_}_ + else + local FEATURES_FLAG="" + local FEATURES_STR="" + fi + local CARGO_FLAGS="--example $EXAMPLE --target $TARGET $RELEASE_FLAG $FEATURES_FLAG" + + if [ $COMMAND = "run" ]; then + cargo $COMMAND $CARGO_FLAGS | diff -u ci/expected/$EXAMPLE.run - + else + cargo $COMMAND $CARGO_FLAGS + fi + arm-none-eabi-objcopy -O ihex target/$TARGET/$BUILD_MODE/examples/$EXAMPLE ${EXAMPLE}_${FEATURES_STR}${BUILD_MODE}_${BUILD_NUM}.hex +} + + main() { local T=$TARGET @@ -81,45 +112,31 @@ main() { continue fi - test_arm_example() { - local EXAMPLE=$1 - local TARGET=$2 - local BUILD_MODE=$3 - local FEATURES=$4 - - if [ $BUILD_MODE = "release" ]; then - local RELEASE_FLAG="--release" - else - local RELEASE_FLAG="" - fi - - if [ -n "$FEATURES" ]; then - local FEATURES_FLAG="--features $FEATURES" - else - local FEATURES_FLAG="" - fi - local CARGO_FLAGS="--example $EXAMPLE --target $TARGET $RELEASE_FLAG $FEATURES_FLAG" - - cargo run $CARGO_FLAGS | diff -u ci/expected/$EXAMPLE.run - - arm-none-eabi-objcopy -O ihex target/$TARGET/$BUILD_MODE/examples/$EXAMPLE ${EXAMPLE}_1.hex - - # build again to ensure that the build is reproducable - cargo clean - cargo build $CARGO_FLAGS - arm-none-eabi-objcopy -O ihex target/$TARGET/$BUILD_MODE/examples/$EXAMPLE ${EXAMPLE}_2.hex - - # compare results of both builds - cmp ${EXAMPLE}_1.hex ${EXAMPLE}_2.hex - } + if [ $ex != types ]; then + arm_example "run" $ex "debug" "" "1" + arm_example "run" $ex "release" "" "1" + fi + if [ $TARGET != thumbv6m-none-eabi ]; then + arm_example "run" $ex "debug" "timer-queue" "1" + arm_example "run" $ex "release" "timer-queue" "1" + fi + done + + cargo clean + for ex in ${exs[@]}; do if [ $ex != types ]; then - test_arm_example $ex $T "debug" "" - test_arm_example $ex $T "release" "" + arm_example "build" $ex "debug" "" "2" + cmp ${ex}_debug_1.hex ${ex}_debug_2.hex + arm_example "build" $ex "release" "" "2" + cmp ${ex}_release_1.hex ${ex}_release_2.hex fi if [ $TARGET != thumbv6m-none-eabi ]; then - test_arm_example $ex $T "debug" "timer-queue" - test_arm_example $ex $T "release" "timer-queue" + arm_example "build" $ex "debug" "timer-queue" "2" + cmp ${ex}_timer-queue_debug_1.hex ${ex}_timer-queue_debug_2.hex + arm_example "build" $ex "release" "timer-queue" "2" + cmp ${ex}_timer-queue_release_1.hex ${ex}_timer-queue_release_2.hex fi done esac -- cgit v1.2.3 From be8a5e89b8c5763dc691bb748ba1da73a56cb2cc Mon Sep 17 00:00:00 2001 From: Hugo van der Wijst Date: Wed, 16 Jan 2019 17:36:55 -0800 Subject: Make identifiers deterministic. --- ci/script.sh | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'ci/script.sh') diff --git a/ci/script.sh b/ci/script.sh index 6a15cc6..40b03a7 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -125,6 +125,12 @@ main() { cargo clean for ex in ${exs[@]}; do + if [ $ex = singleton ]; then + # singleton build is currently not reproducible due to + # https://github.com/japaric/owned-singleton/issues/2 + continue + fi + if [ $ex != types ]; then arm_example "build" $ex "debug" "" "2" cmp ${ex}_debug_1.hex ${ex}_debug_2.hex -- cgit v1.2.3 From 82c533cbf43c56da0960de7b48e7a6d1cc8defd0 Mon Sep 17 00:00:00 2001 From: Hugo van der Wijst Date: Wed, 16 Jan 2019 17:57:54 -0800 Subject: Fix thumbv6 build. --- ci/script.sh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ci/script.sh') diff --git a/ci/script.sh b/ci/script.sh index 40b03a7..1bb0ae2 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -125,6 +125,11 @@ main() { cargo clean for ex in ${exs[@]}; do + if [ $ex = ramfunc ] && [ $T = thumbv6m-none-eabi ]; then + # LLD doesn't support this at the moment + continue + fi + if [ $ex = singleton ]; then # singleton build is currently not reproducible due to # https://github.com/japaric/owned-singleton/issues/2 -- cgit v1.2.3 From 577d188f72398461650a4e76d81396bf0abea0f4 Mon Sep 17 00:00:00 2001 From: Hugo van der Wijst Date: Sun, 10 Feb 2019 15:25:33 -0800 Subject: Make generated names stable when sorting. --- ci/script.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'ci/script.sh') diff --git a/ci/script.sh b/ci/script.sh index 1bb0ae2..4b9cd22 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -27,13 +27,15 @@ arm_example() { else cargo $COMMAND $CARGO_FLAGS fi - arm-none-eabi-objcopy -O ihex target/$TARGET/$BUILD_MODE/examples/$EXAMPLE ${EXAMPLE}_${FEATURES_STR}${BUILD_MODE}_${BUILD_NUM}.hex + arm-none-eabi-objcopy -O ihex target/$TARGET/$BUILD_MODE/examples/$EXAMPLE ci/builds/${EXAMPLE}_${FEATURES_STR}${BUILD_MODE}_${BUILD_NUM}.hex } main() { local T=$TARGET + mkdir -p ci/builds + if [ $T = x86_64-unknown-linux-gnu ]; then # compile-fail and compile-pass tests case $TRAVIS_RUST_VERSION in @@ -138,16 +140,16 @@ main() { if [ $ex != types ]; then arm_example "build" $ex "debug" "" "2" - cmp ${ex}_debug_1.hex ${ex}_debug_2.hex + cmp ci/builds/${ex}_debug_1.hex ci/builds/${ex}_debug_2.hex arm_example "build" $ex "release" "" "2" - cmp ${ex}_release_1.hex ${ex}_release_2.hex + cmp ci/builds/${ex}_release_1.hex ci/builds/${ex}_release_2.hex fi if [ $TARGET != thumbv6m-none-eabi ]; then arm_example "build" $ex "debug" "timer-queue" "2" - cmp ${ex}_timer-queue_debug_1.hex ${ex}_timer-queue_debug_2.hex + cmp ci/builds/${ex}_timer-queue_debug_1.hex ci/builds/${ex}_timer-queue_debug_2.hex arm_example "build" $ex "release" "timer-queue" "2" - cmp ${ex}_timer-queue_release_1.hex ${ex}_timer-queue_release_2.hex + cmp ci/builds/${ex}_timer-queue_release_1.hex ci/builds/${ex}_timer-queue_release_2.hex fi done esac -- cgit v1.2.3 From cf05dc2c4b2bb702be4807867610dfedcc02d6f2 Mon Sep 17 00:00:00 2001 From: Hugo van der Wijst Date: Mon, 11 Feb 2019 11:54:55 -0800 Subject: Temporarily disable checking for reproducibility of debug builds. --- ci/script.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ci/script.sh') diff --git a/ci/script.sh b/ci/script.sh index 4b9cd22..7c14766 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -139,15 +139,15 @@ main() { fi if [ $ex != types ]; then - arm_example "build" $ex "debug" "" "2" - cmp ci/builds/${ex}_debug_1.hex ci/builds/${ex}_debug_2.hex + # arm_example "build" $ex "debug" "" "2" + # cmp ci/builds/${ex}_debug_1.hex ci/builds/${ex}_debug_2.hex arm_example "build" $ex "release" "" "2" cmp ci/builds/${ex}_release_1.hex ci/builds/${ex}_release_2.hex fi if [ $TARGET != thumbv6m-none-eabi ]; then - arm_example "build" $ex "debug" "timer-queue" "2" - cmp ci/builds/${ex}_timer-queue_debug_1.hex ci/builds/${ex}_timer-queue_debug_2.hex + # arm_example "build" $ex "debug" "timer-queue" "2" + # cmp ci/builds/${ex}_timer-queue_debug_1.hex ci/builds/${ex}_timer-queue_debug_2.hex arm_example "build" $ex "release" "timer-queue" "2" cmp ci/builds/${ex}_timer-queue_release_1.hex ci/builds/${ex}_timer-queue_release_2.hex fi -- cgit v1.2.3 From 2b8e743f35a69b9b09a4de4c346eb9015c6b45ea Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sat, 16 Feb 2019 00:22:00 +0100 Subject: make debug builds reproducible --- ci/script.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ci/script.sh') diff --git a/ci/script.sh b/ci/script.sh index 7c14766..4b9cd22 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -139,15 +139,15 @@ main() { fi if [ $ex != types ]; then - # arm_example "build" $ex "debug" "" "2" - # cmp ci/builds/${ex}_debug_1.hex ci/builds/${ex}_debug_2.hex + arm_example "build" $ex "debug" "" "2" + cmp ci/builds/${ex}_debug_1.hex ci/builds/${ex}_debug_2.hex arm_example "build" $ex "release" "" "2" cmp ci/builds/${ex}_release_1.hex ci/builds/${ex}_release_2.hex fi if [ $TARGET != thumbv6m-none-eabi ]; then - # arm_example "build" $ex "debug" "timer-queue" "2" - # cmp ci/builds/${ex}_timer-queue_debug_1.hex ci/builds/${ex}_timer-queue_debug_2.hex + arm_example "build" $ex "debug" "timer-queue" "2" + cmp ci/builds/${ex}_timer-queue_debug_1.hex ci/builds/${ex}_timer-queue_debug_2.hex arm_example "build" $ex "release" "timer-queue" "2" cmp ci/builds/${ex}_timer-queue_release_1.hex ci/builds/${ex}_timer-queue_release_2.hex fi -- cgit v1.2.3