Skip to content

Commit ad570c5

Browse files
committed
Add xtensa-esp32-none-elf, xtensa-esp8266-none-elf targets. Remove xtensa-none-elf
1 parent 29de921 commit ad570c5

File tree

3 files changed

+134
-1
lines changed

3 files changed

+134
-1
lines changed

src/librustc_target/spec/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,8 @@ supported_targets! {
448448
("thumbv8m.main-none-eabihf", thumbv8m_main_none_eabihf),
449449

450450
("msp430-none-elf", msp430_none_elf),
451-
("xtensa-none-elf", xtensa_none_elf),
451+
("xtensa-esp32-none-elf", xtensa_esp32_none_elf),
452+
("xtensa-esp8266-none-elf", xtensa_esp8266_none_elf),
452453

453454
("aarch64-unknown-cloudabi", aarch64_unknown_cloudabi),
454455
("armv7-unknown-cloudabi-eabihf", armv7_unknown_cloudabi_eabihf),
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
use crate::spec::{LinkerFlavor, PanicStrategy, Target, TargetOptions, TargetResult, abi::Abi};
2+
// use crate::spec::abi::Abi;
3+
4+
pub fn target() -> TargetResult {
5+
Ok(Target {
6+
llvm_target: "xtensa-none-elf".to_string(),
7+
target_endian: "little".to_string(),
8+
target_pointer_width: "32".to_string(),
9+
target_c_int_width: "32".to_string(),
10+
data_layout: "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:64-f64:64-a:0:32-n32".to_string(),
11+
arch: "xtensa".to_string(),
12+
target_os: "none".to_string(),
13+
target_env: String::new(),
14+
target_vendor: String::new(),
15+
linker_flavor: LinkerFlavor::Gcc,
16+
17+
options: TargetOptions {
18+
executables: true,
19+
cpu: "esp32".to_string(),
20+
// The LLVM backend currently can't generate object files. To
21+
// workaround this LLVM generates assembly files which then we feed
22+
// to gcc to get object files. For this reason we have a hard
23+
// dependency on this specific gcc.
24+
// asm_args: vec!["-mcpu=esp32".to_string()],
25+
linker: Some("xtensa-esp32-elf-gcc".to_string()),
26+
no_integrated_as: true,
27+
28+
max_atomic_width: Some(32),
29+
atomic_cas: true,
30+
31+
// Because these devices have very little resources having an
32+
// unwinder is too onerous so we default to "abort" because the
33+
// "unwind" strategy is very rare.
34+
panic_strategy: PanicStrategy::Abort,
35+
36+
// Similarly, one almost always never wants to use relocatable
37+
// code because of the extra costs it involves.
38+
relocation_model: "static".to_string(),
39+
40+
// Right now we invoke an external assembler and this isn't
41+
// compatible with multiple codegen units, and plus we probably
42+
// don't want to invoke that many gcc instances.
43+
default_codegen_units: Some(1),
44+
45+
// Since MSP430 doesn't meaningfully support faulting on illegal
46+
// instructions, LLVM generates a call to abort() function instead
47+
// of a trap instruction. Such calls are 4 bytes long, and that is
48+
// too much overhead for such small target.
49+
trap_unreachable: false,
50+
51+
// See the thumb_base.rs file for an explanation of this value
52+
emit_debug_gdb_scripts: false,
53+
54+
abi_blacklist: vec![
55+
Abi::Stdcall,
56+
Abi::Fastcall,
57+
Abi::Vectorcall,
58+
Abi::Thiscall,
59+
Abi::Win64,
60+
Abi::SysV64,
61+
],
62+
63+
.. Default::default( )
64+
}
65+
})
66+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
use crate::spec::{LinkerFlavor, PanicStrategy, Target, TargetOptions, TargetResult, abi::Abi};
2+
// use crate::spec::abi::Abi;
3+
4+
pub fn target() -> TargetResult {
5+
Ok(Target {
6+
llvm_target: "xtensa-none-elf".to_string(),
7+
target_endian: "little".to_string(),
8+
target_pointer_width: "32".to_string(),
9+
target_c_int_width: "32".to_string(),
10+
data_layout: "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:64-f64:64-a:0:32-n32".to_string(),
11+
arch: "xtensa".to_string(),
12+
target_os: "none".to_string(),
13+
target_env: String::new(),
14+
target_vendor: String::new(),
15+
linker_flavor: LinkerFlavor::Gcc,
16+
17+
options: TargetOptions {
18+
executables: true,
19+
cpu: "esp8266".to_string(),
20+
// The LLVM backend currently can't generate object files. To
21+
// workaround this LLVM generates assembly files which then we feed
22+
// to gcc to get object files. For this reason we have a hard
23+
// dependency on this specific gcc.
24+
// asm_args: vec!["-mcpu=esp8266".to_string()],
25+
linker: Some("xtensa-esp32-elf-gcc".to_string()),
26+
no_integrated_as: true,
27+
28+
max_atomic_width: Some(32),
29+
atomic_cas: true,
30+
31+
// Because these devices have very little resources having an
32+
// unwinder is too onerous so we default to "abort" because the
33+
// "unwind" strategy is very rare.
34+
panic_strategy: PanicStrategy::Abort,
35+
36+
// Similarly, one almost always never wants to use relocatable
37+
// code because of the extra costs it involves.
38+
relocation_model: "static".to_string(),
39+
40+
// Right now we invoke an external assembler and this isn't
41+
// compatible with multiple codegen units, and plus we probably
42+
// don't want to invoke that many gcc instances.
43+
default_codegen_units: Some(1),
44+
45+
// Since MSP430 doesn't meaningfully support faulting on illegal
46+
// instructions, LLVM generates a call to abort() function instead
47+
// of a trap instruction. Such calls are 4 bytes long, and that is
48+
// too much overhead for such small target.
49+
trap_unreachable: false,
50+
51+
// See the thumb_base.rs file for an explanation of this value
52+
emit_debug_gdb_scripts: false,
53+
54+
abi_blacklist: vec![
55+
Abi::Stdcall,
56+
Abi::Fastcall,
57+
Abi::Vectorcall,
58+
Abi::Thiscall,
59+
Abi::Win64,
60+
Abi::SysV64,
61+
],
62+
63+
.. Default::default( )
64+
}
65+
})
66+
}

0 commit comments

Comments
 (0)