Skip to content

Commit b0e355c

Browse files
committed
Add some Xtensa targets
ESP32, ESP32s2, ESP8266 and a generic Xtensa target.
1 parent 2ed078f commit b0e355c

File tree

5 files changed

+204
-0
lines changed

5 files changed

+204
-0
lines changed

compiler/rustc_target/src/spec/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,11 @@ supported_targets! {
882882

883883
("nvptx64-nvidia-cuda", nvptx64_nvidia_cuda),
884884

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

0 commit comments

Comments
 (0)