@@ -23,10 +23,15 @@ fn main() -> Result<(), Box<dyn Error>> {
23
23
println ! ( "cargo:rustc-cfg=armv7a" ) ;
24
24
}
25
25
26
+ let is_avr = env:: var ( "CARGO_CFG_TARGET_ARCH" ) == Ok ( "avr" . to_string ( ) ) ;
27
+
26
28
// built-in targets with no atomic / CAS support as of nightly-2022-01-13
27
29
// AND not supported by the atomic-polyfill crate
28
30
// see the `no-atomics.sh` / `no-cas.sh` script sitting next to this file
29
- match & target[ ..] {
31
+ if is_avr {
32
+ // lacks cas
33
+ } else {
34
+ match & target[ ..] {
30
35
"avr-unknown-gnu-atmega328"
31
36
| "bpfeb-unknown-none"
32
37
| "bpfel-unknown-none"
@@ -40,35 +45,41 @@ fn main() -> Result<(), Box<dyn Error>> {
40
45
_ => {
41
46
println ! ( "cargo:rustc-cfg=has_cas" ) ;
42
47
}
48
+ }
43
49
} ;
44
50
45
- match & target[ ..] {
46
- "avr-unknown-gnu-atmega328"
47
- | "msp430-none-elf"
51
+ if is_avr {
52
+ // lacks atomics
53
+ } else {
54
+ match & target[ ..] {
55
+ "msp430-none-elf"
48
56
// | "riscv32i-unknown-none-elf" // supported by atomic-polyfill
49
57
// | "riscv32imc-unknown-none-elf" // supported by atomic-polyfill
50
58
=> { }
51
59
52
60
_ => {
53
61
println ! ( "cargo:rustc-cfg=has_atomics" ) ;
54
62
}
63
+ }
55
64
} ;
56
65
57
66
// Let the code know if it should use atomic-polyfill or not, and what aspects
58
67
// of polyfill it requires
59
- match & target[ ..] {
60
- "riscv32i-unknown-none-elf"
61
- | "riscv32imc-unknown-none-elf"
62
- | "avr-atmega328p"
63
- | "avr-atmega2560" => {
64
- println ! ( "cargo:rustc-cfg=full_atomic_polyfill" ) ;
65
- println ! ( "cargo:rustc-cfg=cas_atomic_polyfill" ) ;
66
- }
68
+ if is_avr {
69
+ println ! ( "cargo:rustc-cfg=full_atomic_polyfill" ) ;
70
+ println ! ( "cargo:rustc-cfg=cas_atomic_polyfill" ) ;
71
+ } else {
72
+ match & target[ ..] {
73
+ "riscv32i-unknown-none-elf" | "riscv32imc-unknown-none-elf" => {
74
+ println ! ( "cargo:rustc-cfg=full_atomic_polyfill" ) ;
75
+ println ! ( "cargo:rustc-cfg=cas_atomic_polyfill" ) ;
76
+ }
67
77
68
- "thumbv6m-none-eabi" => {
69
- println ! ( "cargo:rustc-cfg=cas_atomic_polyfill" ) ;
78
+ "thumbv6m-none-eabi" => {
79
+ println ! ( "cargo:rustc-cfg=cas_atomic_polyfill" ) ;
80
+ }
81
+ _ => { }
70
82
}
71
- _ => { }
72
83
}
73
84
74
85
if !matches ! (
0 commit comments