Skip to content

Commit e080dd7

Browse files
committed
Add some Xtensa targets. ESP32, ESP8266 and a generic Xtensa target.
1 parent 07fe9cb commit e080dd7

File tree

4 files changed

+141
-0
lines changed

4 files changed

+141
-0
lines changed

compiler/rustc_target/src/spec/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,10 @@ supported_targets! {
668668

669669
("nvptx64-nvidia-cuda", nvptx64_nvidia_cuda),
670670

671+
("xtensa-esp32-none-elf", xtensa_esp32_none_elf),
672+
("xtensa-esp8266-none-elf", xtensa_esp8266_none_elf),
673+
("xtensa-none-elf", xtensa_none_elf),
674+
671675
("i686-wrs-vxworks", i686_wrs_vxworks),
672676
("x86_64-wrs-vxworks", x86_64_wrs_vxworks),
673677
("armv7-wrs-vxworks-eabihf", armv7_wrs_vxworks_eabihf),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
use crate::spec::{abi::Abi, LinkerFlavor, PanicStrategy, Target, TargetOptions, TargetResult, RelocModel};
2+
3+
pub fn target() -> TargetResult {
4+
Ok(Target {
5+
llvm_target: "xtensa-none-elf".to_string(),
6+
target_endian: "little".to_string(),
7+
target_pointer_width: "32".to_string(),
8+
target_c_int_width: "32".to_string(),
9+
data_layout: "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32".to_string(),
10+
arch: "xtensa".to_string(),
11+
target_os: "none".to_string(),
12+
target_env: String::new(),
13+
target_vendor: String::new(),
14+
linker_flavor: LinkerFlavor::Gcc,
15+
16+
options: TargetOptions {
17+
executables: true,
18+
cpu: "esp32".to_string(),
19+
linker: Some("xtensa-esp32-elf-gcc".to_string()),
20+
21+
max_atomic_width: Some(32),
22+
23+
// Because these devices have very little resources having an
24+
// unwinder is too onerous so we default to "abort" because the
25+
// "unwind" strategy is very rare.
26+
panic_strategy: PanicStrategy::Abort,
27+
28+
// Similarly, one almost always never wants to use relocatable
29+
// code because of the extra costs it involves.
30+
relocation_model: RelocModel::Static,
31+
32+
emit_debug_gdb_scripts: false,
33+
34+
unsupported_abis: vec![
35+
Abi::Stdcall,
36+
Abi::Fastcall,
37+
Abi::Vectorcall,
38+
Abi::Thiscall,
39+
Abi::Win64,
40+
Abi::SysV64,
41+
],
42+
43+
..Default::default()
44+
},
45+
})
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
use crate::spec::{abi::Abi, LinkerFlavor, PanicStrategy, Target, TargetOptions, TargetResult, RelocModel};
2+
3+
pub fn target() -> TargetResult {
4+
Ok(Target {
5+
llvm_target: "xtensa-none-elf".to_string(),
6+
target_endian: "little".to_string(),
7+
target_pointer_width: "32".to_string(),
8+
target_c_int_width: "32".to_string(),
9+
data_layout: "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32".to_string(),
10+
arch: "xtensa".to_string(),
11+
target_os: "none".to_string(),
12+
target_env: String::new(),
13+
target_vendor: String::new(),
14+
linker_flavor: LinkerFlavor::Gcc,
15+
16+
options: TargetOptions {
17+
executables: true,
18+
cpu: "esp8266".to_string(),
19+
linker: Some("xtensa-lx106-elf-gcc".to_string()),
20+
21+
max_atomic_width: Some(32),
22+
23+
// Because these devices have very little resources having an
24+
// unwinder is too onerous so we default to "abort" because the
25+
// "unwind" strategy is very rare.
26+
panic_strategy: PanicStrategy::Abort,
27+
28+
// Similarly, one almost always never wants to use relocatable
29+
// code because of the extra costs it involves.
30+
relocation_model: RelocModel::Static,
31+
32+
emit_debug_gdb_scripts: false,
33+
34+
unsupported_abis: vec![
35+
Abi::Stdcall,
36+
Abi::Fastcall,
37+
Abi::Vectorcall,
38+
Abi::Thiscall,
39+
Abi::Win64,
40+
Abi::SysV64,
41+
],
42+
43+
..Default::default()
44+
},
45+
})
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
use crate::spec::{abi::Abi, LinkerFlavor, PanicStrategy, Target, TargetOptions, TargetResult, RelocModel};
2+
3+
pub fn target() -> TargetResult {
4+
Ok(Target {
5+
llvm_target: "xtensa-none-elf".to_string(),
6+
target_endian: "little".to_string(),
7+
target_pointer_width: "32".to_string(),
8+
target_c_int_width: "32".to_string(),
9+
data_layout: "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32".to_string(),
10+
arch: "xtensa".to_string(),
11+
target_os: "none".to_string(),
12+
target_env: String::new(),
13+
target_vendor: String::new(),
14+
linker_flavor: LinkerFlavor::Gcc,
15+
16+
options: TargetOptions {
17+
executables: true,
18+
linker: Some("xtensa-esp32-elf-gcc".to_string()),
19+
20+
max_atomic_width: Some(32),
21+
22+
// Because these devices have very little resources having an
23+
// unwinder is too onerous so we default to "abort" because the
24+
// "unwind" strategy is very rare.
25+
panic_strategy: PanicStrategy::Abort,
26+
27+
// Similarly, one almost always never wants to use relocatable
28+
// code because of the extra costs it involves.
29+
relocation_model: RelocModel::Static,
30+
31+
emit_debug_gdb_scripts: false,
32+
33+
unsupported_abis: vec![
34+
Abi::Stdcall,
35+
Abi::Fastcall,
36+
Abi::Vectorcall,
37+
Abi::Thiscall,
38+
Abi::Win64,
39+
Abi::SysV64,
40+
],
41+
42+
..Default::default()
43+
},
44+
})
45+
}

0 commit comments

Comments
 (0)