Skip to content

Commit 38987c0

Browse files
committed
Remove +atomics-32 for armv4t-none-eabi and armv5te-none-eabi
Also rationalise the settings, and copy in the thumb base defaults, rather than just import them, because these aren't M-profile microcontrollers and may not want to always have the same settings.
1 parent 23f7081 commit 38987c0

File tree

2 files changed

+42
-32
lines changed

2 files changed

+42
-32
lines changed

compiler/rustc_target/src/spec/targets/armv4t_none_eabi.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@ pub(crate) fn target() -> Target {
2525
},
2626
pointer_width: 32,
2727
arch: Arch::Arm,
28-
/* Data layout args are '-' separated:
29-
* little endian
30-
* stack is 64-bit aligned (EABI)
31-
* pointers are 32-bit
32-
* i64 must be 64-bit aligned (EABI)
33-
* mangle names with ELF style
34-
* native integers are 32-bit
35-
* All other elements are default
36-
*/
3728
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
3829
options: TargetOptions {
3930
abi: Abi::Eabi,
@@ -43,15 +34,29 @@ pub(crate) fn target() -> Target {
4334
asm_args: cvs!["-mthumb-interwork", "-march=armv4t", "-mlittle-endian",],
4435
// Force-enable 32-bit atomics, which allows the use of atomic load/store only.
4536
// The resulting atomics are ABI incompatible with atomics backed by libatomic.
46-
features: "+soft-float,+strict-align,+atomics-32".into(),
47-
main_needs_argc_argv: false,
37+
features: "+soft-float,+strict-align".into(),
4838
atomic_cas: false,
4939
has_thumb_interworking: true,
50-
relocation_model: RelocModel::Static,
40+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
41+
linker: Some("rust-lld".into()),
42+
// Because these devices have very little resources having an unwinder is too onerous so we
43+
// default to "abort" because the "unwind" strategy is very rare.
5144
panic_strategy: PanicStrategy::Abort,
52-
// From thumb_base, rust-lang/rust#44993.
45+
// Similarly, one almost always never wants to use relocatable code because of the extra
46+
// costs it involves.
47+
relocation_model: RelocModel::Static,
48+
// When this section is added a volatile load to its start address is also generated. This
49+
// volatile load is a footgun as it can end up loading an invalid memory address, depending
50+
// on how the user set up their linker scripts. This section adds pretty printer for stuff
51+
// like std::Vec, which is not that used in no-std context, so it's best to left it out
52+
// until we figure a way to add the pretty printers without requiring a volatile load cf.
53+
// rust-lang/rust#44993.
5354
emit_debug_gdb_scripts: false,
54-
// From thumb_base, GCC gives enums a minimum of 8 bits on no-os targets.
55+
// LLVM is eager to trash the link register when calling `noreturn` functions, which
56+
// breaks debugging. Preserve LR by default to prevent that from happening.
57+
frame_pointer: FramePointer::Always,
58+
// ARM supports multiple ABIs for enums, the linux one matches the default of 32 here
59+
// but any arm-none or thumb-none target will be defaulted to 8 on GCC.
5560
c_enum_min_bits: Some(8),
5661
..Default::default()
5762
},

compiler/rustc_target/src/spec/targets/armv5te_none_eabi.rs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,7 @@ pub(crate) fn target() -> Target {
1515
},
1616
pointer_width: 32,
1717
arch: Arch::Arm,
18-
/* Data layout args are '-' separated:
19-
* little endian
20-
* stack is 64-bit aligned (EABI)
21-
* pointers are 32-bit
22-
* i64 must be 64-bit aligned (EABI)
23-
* mangle names with ELF style
24-
* native integers are 32-bit
25-
* All other elements are default
26-
*/
2718
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
28-
2919
options: TargetOptions {
3020
abi: Abi::Eabi,
3121
llvm_floatabi: Some(FloatAbi::Soft),
@@ -35,16 +25,31 @@ pub(crate) fn target() -> Target {
3525
// * use little-endian
3626
asm_args: cvs!["-mthumb-interwork", "-march=armv5te", "-mlittle-endian",],
3727
// minimum extra features, these cannot be disabled via -C
38-
// Also force-enable 32-bit atomics, which allows the use of atomic load/store only.
39-
// The resulting atomics are ABI incompatible with atomics backed by libatomic.
40-
features: "+soft-float,+strict-align,+atomics-32".into(),
41-
frame_pointer: FramePointer::MayOmit,
42-
main_needs_argc_argv: false,
43-
// don't have atomic compare-and-swap
28+
features: "+soft-float,+strict-align".into(),
4429
atomic_cas: false,
4530
has_thumb_interworking: true,
46-
47-
..base::thumb::opts()
31+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
32+
linker: Some("rust-lld".into()),
33+
// Because these devices have very little resources having an unwinder is too onerous so we
34+
// default to "abort" because the "unwind" strategy is very rare.
35+
panic_strategy: PanicStrategy::Abort,
36+
// Similarly, one almost always never wants to use relocatable code because of the extra
37+
// costs it involves.
38+
relocation_model: RelocModel::Static,
39+
// When this section is added a volatile load to its start address is also generated. This
40+
// volatile load is a footgun as it can end up loading an invalid memory address, depending
41+
// on how the user set up their linker scripts. This section adds pretty printer for stuff
42+
// like std::Vec, which is not that used in no-std context, so it's best to left it out
43+
// until we figure a way to add the pretty printers without requiring a volatile load cf.
44+
// rust-lang/rust#44993.
45+
emit_debug_gdb_scripts: false,
46+
// LLVM is eager to trash the link register when calling `noreturn` functions, which
47+
// breaks debugging. Preserve LR by default to prevent that from happening.
48+
frame_pointer: FramePointer::Always,
49+
// ARM supports multiple ABIs for enums, the linux one matches the default of 32 here
50+
// but any arm-none or thumb-none target will be defaulted to 8 on GCC.
51+
c_enum_min_bits: Some(8),
52+
..Default::default()
4853
},
4954
}
5055
}

0 commit comments

Comments
 (0)