@@ -32,80 +32,40 @@ main() {
3232 local fail_examples=(
3333 data_overflow
3434 )
35+ local linkers=(
36+ # Link with arm-none-eabi-ld
37+ " -C linker=arm-none-eabi-ld"
38+ # Link with arm-none-eabi-gcc, requires -nostartfiles
39+ " -C linker=arm-none-eabi-gcc -C link-arg=-nostartfiles"
40+ # Link with rust-lld (default)
41+ " "
42+ )
3543 if [ " $TARGET " != x86_64-unknown-linux-gnu ]; then
3644 RUSTDOCFLAGS=" -Cpanic=abort" cargo test --doc
3745
38- # linking with GNU LD
39- for ex in " ${examples[@]} " ; do
40- cargo rustc --target " $TARGET " --example " $ex " -- \
41- -C linker=arm-none-eabi-ld
42-
43- cargo rustc --target " $TARGET " --example " $ex " --release -- \
44- -C linker=arm-none-eabi-ld
45- done
46- for ex in " ${fail_examples[@]} " ; do
47- ! cargo rustc --target " $TARGET " --example " $ex " -- \
48- -C linker=arm-none-eabi-ld
49-
50- ! cargo rustc --target " $TARGET " --example " $ex " --release -- \
51- -C linker=arm-none-eabi-ld
52- done
53-
54- cargo rustc --target " $TARGET " --example device --features device -- \
55- -C linker=arm-none-eabi-ld
56-
57- cargo rustc --target " $TARGET " --example device --features device --release -- \
58- -C linker=arm-none-eabi-ld
59-
60- # linking with GNU GCC
61- for ex in " ${examples[@]} " ; do
62- cargo rustc --target " $TARGET " --example " $ex " -- \
63- -C linker=arm-none-eabi-gcc -C link-arg=-nostartfiles
64-
65- cargo rustc --target " $TARGET " --example " $ex " --release -- \
66- -C linker=arm-none-eabi-gcc -C link-arg=-nostartfiles
46+ for linker in " ${linkers[@]} " ; do
47+ for ex in " ${examples[@]} " ; do
48+ cargo rustc --target " $TARGET " --example " $ex " -- $linker
49+ cargo rustc --target " $TARGET " --example " $ex " --release -- $linker
50+ done
51+ for ex in " ${fail_examples[@]} " ; do
52+ ! cargo rustc --target " $TARGET " --example " $ex " -- $linker
53+ ! cargo rustc --target " $TARGET " --example " $ex " --release -- $linker
54+ done
55+ cargo rustc --target " $TARGET " --example device --features device -- $linker
56+ cargo rustc --target " $TARGET " --example device --features device --release -- $linker
6757 done
68- for ex in " ${fail_examples[@]} " ; do
69- ! cargo rustc --target " $TARGET " --example " $ex " -- \
70- -C linker=arm-none-eabi-gcc -C link-arg=-nostartfiles
71-
72- ! cargo rustc --target " $TARGET " --example " $ex " --release -- \
73- -C linker=arm-none-eabi-gcc -C link-arg=-nostartfiles
74- done
75-
76- cargo rustc --target " $TARGET " --example device --features device -- \
77- -C linker=arm-none-eabi-gcc -C link-arg=-nostartfiles
78-
79- cargo rustc --target " $TARGET " --example device --features device --release -- \
80- -C linker=arm-none-eabi-gcc -C link-arg=-nostartfiles
81-
82- # linking with rustc's LLD
83- for ex in " ${examples[@]} " ; do
84- cargo rustc --target " $TARGET " --example " $ex "
85- cargo rustc --target " $TARGET " --example " $ex " --release
86- done
87- for ex in " ${fail_examples[@]} " ; do
88- ! cargo rustc --target " $TARGET " --example " $ex "
89- ! cargo rustc --target " $TARGET " --example " $ex " --release
90- done
91-
92- cargo rustc --target " $TARGET " --example device --features device
93- cargo rustc --target " $TARGET " --example device --features device --release
9458 fi
9559
9660 case $TARGET in
9761 thumbv6m-none-eabi|thumbv7m-none-eabi)
98- # linking with GNU LD
99- env RUSTFLAGS=" -C linker=arm-none-eabi-ld -C link-arg=-Tlink.x" cargo run --target " $TARGET " --example qemu | grep " x = 42"
100- env RUSTFLAGS=" -C linker=arm-none-eabi-ld -C link-arg=-Tlink.x" cargo run --target " $TARGET " --example qemu --release | grep " x = 42"
101-
102- # linking with GNU GCC
103- 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"
104- 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"
62+ for linker in " ${linkers[@]} " ; do
63+ env RUSTFLAGS=" $linker -C link-arg=-Tlink.x" cargo run \
64+ --target " $TARGET " --example qemu | grep " x = 42"
65+ env RUSTFLAGS=" $linker -C link-arg=-Tlink.x" cargo run \
66+ --target " $TARGET " --example qemu --release | grep " x = 42"
67+ done
10568
106- # linking with rustc's LLD
107- cargo run --target " $TARGET " --example qemu | grep " x = 42"
108- cargo run --target " $TARGET " --example qemu --release | grep " x = 42"
10969 ;;
11070 esac
11171
0 commit comments