Skip to content

Commit 1ac1f5b

Browse files
committed
Add some no_std Xtensa targets
ESP32, ESP32S2, ESP32S3 & ESP8266.
1 parent 2f84f1d commit 1ac1f5b

File tree

7 files changed

+94
-0
lines changed

7 files changed

+94
-0
lines changed

compiler/rustc_target/src/spec/base/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ pub(crate) mod windows_gnullvm;
3535
pub(crate) mod windows_msvc;
3636
pub(crate) mod windows_uwp_gnu;
3737
pub(crate) mod windows_uwp_msvc;
38+
pub(crate) mod xtensa;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use crate::spec::{LinkerFlavor, Cc, PanicStrategy, RelocModel, TargetOptions, Lld};
2+
use crate::abi::Endian;
3+
4+
pub fn opts() -> TargetOptions {
5+
TargetOptions {
6+
os: "none".into(),
7+
endian: Endian::Little,
8+
c_int_width: "32".into(),
9+
linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No),
10+
executables: true,
11+
panic_strategy: PanicStrategy::Abort,
12+
relocation_model: RelocModel::Static,
13+
emit_debug_gdb_scripts: false,
14+
atomic_cas: false,
15+
..Default::default()
16+
}
17+
}

compiler/rustc_target/src/spec/mod.rs

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

16661666
("nvptx64-nvidia-cuda", nvptx64_nvidia_cuda),
16671667

1668+
("xtensa-esp32-none-elf", xtensa_esp32_none_elf),
1669+
("xtensa-esp32s2-none-elf", xtensa_esp32s2_none_elf),
1670+
("xtensa-esp8266-none-elf", xtensa_esp8266_none_elf),
1671+
("xtensa-esp32s3-none-elf", xtensa_esp32s3_none_elf),
1672+
16681673
("i686-wrs-vxworks", i686_wrs_vxworks),
16691674
("x86_64-wrs-vxworks", x86_64_wrs_vxworks),
16701675
("armv7-wrs-vxworks-eabihf", armv7_wrs_vxworks_eabihf),
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use crate::spec::{Target, TargetOptions, base::xtensa};
2+
3+
4+
pub fn target() -> Target {
5+
Target {
6+
llvm_target: "xtensa-none-elf".into(),
7+
pointer_width: 32,
8+
data_layout: "e-m:e-p:32:32-i64:64-i128:128-n32".into(),
9+
arch: "xtensa".into(),
10+
11+
options: TargetOptions {
12+
cpu: "esp32".into(),
13+
linker: Some("xtensa-esp32-elf-gcc".into()),
14+
max_atomic_width: Some(32),
15+
atomic_cas: true,
16+
..xtensa::opts()
17+
},
18+
}
19+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use crate::spec::{Target, TargetOptions, base::xtensa};
2+
3+
pub fn target() -> Target {
4+
Target {
5+
llvm_target: "xtensa-none-elf".into(),
6+
pointer_width: 32,
7+
data_layout: "e-m:e-p:32:32-i64:64-i128:128-n32".into(),
8+
arch: "xtensa".into(),
9+
10+
options: TargetOptions {
11+
cpu: "esp32-s2".into(),
12+
linker: Some("xtensa-esp32s2-elf-gcc".into()),
13+
max_atomic_width: Some(32),
14+
..xtensa::opts()
15+
},
16+
}
17+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use crate::spec::{Target, TargetOptions, base::xtensa};
2+
3+
pub fn target() -> Target {
4+
Target {
5+
llvm_target: "xtensa-none-elf".into(),
6+
pointer_width: 32,
7+
data_layout: "e-m:e-p:32:32-i64:64-i128:128-n32".into(),
8+
arch: "xtensa".into(),
9+
10+
options: TargetOptions {
11+
cpu: "esp32-s3".into(),
12+
linker: Some("xtensa-esp32s3-elf-gcc".into()),
13+
max_atomic_width: Some(32),
14+
atomic_cas: true,
15+
..xtensa::opts()
16+
},
17+
}
18+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use crate::spec::{Target, TargetOptions, base::xtensa};
2+
3+
pub fn target() -> Target {
4+
Target {
5+
llvm_target: "xtensa-none-elf".into(),
6+
pointer_width: 32,
7+
data_layout: "e-m:e-p:32:32-i64:64-i128:128-n32".into(),
8+
arch: "xtensa".into(),
9+
10+
options: TargetOptions {
11+
cpu: "esp8266".into(),
12+
linker: Some("xtensa-lx106-elf-gcc".into()),
13+
max_atomic_width: Some(32),
14+
..xtensa::opts()
15+
},
16+
}
17+
}

0 commit comments

Comments
 (0)