@@ -32,80 +32,40 @@ main() {
32
32
local fail_examples=(
33
33
data_overflow
34
34
)
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
+ )
35
43
if [ " $TARGET " != x86_64-unknown-linux-gnu ]; then
36
44
RUSTDOCFLAGS=" -Cpanic=abort" cargo test --doc
37
45
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
67
57
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
94
58
fi
95
59
96
60
case $TARGET in
97
61
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
105
68
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"
109
69
;;
110
70
esac
111
71
0 commit comments