diff options
author | 2020-04-04 19:04:18 +0100 | |
---|---|---|
committer | 2020-04-04 19:04:18 +0100 | |
commit | cf11ef141e62048874bf1bcaebcf3bc4daf64df2 (patch) | |
tree | 4492df6a175a0a48865d09c8a67da5187ce7d4e9 /cortex-m-rt/ci/script.sh | |
parent | 107950df6d2e7e219c61a1694dfe9ccc9d3d2ddd (diff) | |
download | cortex-m-cf11ef141e62048874bf1bcaebcf3bc4daf64df2.tar.gz cortex-m-cf11ef141e62048874bf1bcaebcf3bc4daf64df2.tar.zst cortex-m-cf11ef141e62048874bf1bcaebcf3bc4daf64df2.zip |
Refactor ci/script.sh to factor our linker
Diffstat (limited to 'cortex-m-rt/ci/script.sh')
-rwxr-xr-x | cortex-m-rt/ci/script.sh | 90 |
1 files changed, 25 insertions, 65 deletions
diff --git a/cortex-m-rt/ci/script.sh b/cortex-m-rt/ci/script.sh index ee4cd2c..eea81b8 100755 --- a/cortex-m-rt/ci/script.sh +++ b/cortex-m-rt/ci/script.sh @@ -32,80 +32,40 @@ main() { local fail_examples=( data_overflow ) + local linkers=( + # Link with arm-none-eabi-ld + "-C linker=arm-none-eabi-ld" + # Link with arm-none-eabi-gcc, requires -nostartfiles + "-C linker=arm-none-eabi-gcc -C link-arg=-nostartfiles" + # Link with rust-lld (default) + "" + ) if [ "$TARGET" != x86_64-unknown-linux-gnu ]; then RUSTDOCFLAGS="-Cpanic=abort" cargo test --doc - # linking with GNU LD - for ex in "${examples[@]}"; do - cargo rustc --target "$TARGET" --example "$ex" -- \ - -C linker=arm-none-eabi-ld - - cargo rustc --target "$TARGET" --example "$ex" --release -- \ - -C linker=arm-none-eabi-ld - done - for ex in "${fail_examples[@]}"; do - ! cargo rustc --target "$TARGET" --example "$ex" -- \ - -C linker=arm-none-eabi-ld - - ! cargo rustc --target "$TARGET" --example "$ex" --release -- \ - -C linker=arm-none-eabi-ld - done - - cargo rustc --target "$TARGET" --example device --features device -- \ - -C linker=arm-none-eabi-ld - - cargo rustc --target "$TARGET" --example device --features device --release -- \ - -C linker=arm-none-eabi-ld - - # linking with GNU GCC - for ex in "${examples[@]}"; do - cargo rustc --target "$TARGET" --example "$ex" -- \ - -C linker=arm-none-eabi-gcc -C link-arg=-nostartfiles - - cargo rustc --target "$TARGET" --example "$ex" --release -- \ - -C linker=arm-none-eabi-gcc -C link-arg=-nostartfiles + for linker in "${linkers[@]}"; do + for ex in "${examples[@]}"; do + cargo rustc --target "$TARGET" --example "$ex" -- $linker + cargo rustc --target "$TARGET" --example "$ex" --release -- $linker + done + for ex in "${fail_examples[@]}"; do + ! cargo rustc --target "$TARGET" --example "$ex" -- $linker + ! cargo rustc --target "$TARGET" --example "$ex" --release -- $linker + done + cargo rustc --target "$TARGET" --example device --features device -- $linker + cargo rustc --target "$TARGET" --example device --features device --release -- $linker done - for ex in "${fail_examples[@]}"; do - ! cargo rustc --target "$TARGET" --example "$ex" -- \ - -C linker=arm-none-eabi-gcc -C link-arg=-nostartfiles - - ! cargo rustc --target "$TARGET" --example "$ex" --release -- \ - -C linker=arm-none-eabi-gcc -C link-arg=-nostartfiles - done - - cargo rustc --target "$TARGET" --example device --features device -- \ - -C linker=arm-none-eabi-gcc -C link-arg=-nostartfiles - - cargo rustc --target "$TARGET" --example device --features device --release -- \ - -C linker=arm-none-eabi-gcc -C link-arg=-nostartfiles - - # linking with rustc's LLD - for ex in "${examples[@]}"; do - cargo rustc --target "$TARGET" --example "$ex" - cargo rustc --target "$TARGET" --example "$ex" --release - done - for ex in "${fail_examples[@]}"; do - ! cargo rustc --target "$TARGET" --example "$ex" - ! cargo rustc --target "$TARGET" --example "$ex" --release - done - - cargo rustc --target "$TARGET" --example device --features device - cargo rustc --target "$TARGET" --example device --features device --release fi case $TARGET in thumbv6m-none-eabi|thumbv7m-none-eabi) - # linking with GNU LD - env RUSTFLAGS="-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x" cargo run --target "$TARGET" --example qemu | grep "x = 42" - env RUSTFLAGS="-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x" cargo run --target "$TARGET" --example qemu --release | grep "x = 42" - - # linking with GNU GCC - env RUSTFLAGS="-C linker=arm-none-eabi-gcc -C link-arg=-Tlink.x -Clink-arg=-nostartfiles" cargo run --target "$TARGET" --example qemu | grep "x = 42" - env RUSTFLAGS="-C linker=arm-none-eabi-gcc -C link-arg=-Tlink.x -Clink-arg=-nostartfiles" cargo run --target "$TARGET" --example qemu --release | grep "x = 42" + for linker in "${linkers[@]}"; do + env RUSTFLAGS="$linker -C link-arg=-Tlink.x" cargo run \ + --target "$TARGET" --example qemu | grep "x = 42" + env RUSTFLAGS="$linker -C link-arg=-Tlink.x" cargo run \ + --target "$TARGET" --example qemu --release | grep "x = 42" + done - # linking with rustc's LLD - cargo run --target "$TARGET" --example qemu | grep "x = 42" - cargo run --target "$TARGET" --example qemu --release | grep "x = 42" ;; esac |