Skip to content

Commit b01f161

Browse files
committed
Add some no_std Xtensa targets
ESP32, ESP32S2, ESP32S3 & ESP8266.
1 parent f9ac75e commit b01f161

File tree

7 files changed

+117
-0
lines changed

7 files changed

+117
-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
@@ -1766,6 +1766,11 @@ supported_targets! {
17661766

17671767
("nvptx64-nvidia-cuda", nvptx64_nvidia_cuda),
17681768

1769+
("xtensa-esp32-none-elf", xtensa_esp32_none_elf),
1770+
("xtensa-esp32s2-none-elf", xtensa_esp32s2_none_elf),
1771+
("xtensa-esp8266-none-elf", xtensa_esp8266_none_elf),
1772+
("xtensa-esp32s3-none-elf", xtensa_esp32s3_none_elf),
1773+
17691774
("i686-wrs-vxworks", i686_wrs_vxworks),
17701775
("x86_64-wrs-vxworks", x86_64_wrs_vxworks),
17711776
("armv7-wrs-vxworks-eabihf", armv7_wrs_vxworks_eabihf),
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use crate::spec::{base::xtensa, Target, TargetOptions};
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-v1:8:8-i64:64-i128:128-n32".into(),
8+
arch: "xtensa".into(),
9+
metadata: crate::spec::TargetMetadata {
10+
description: None,
11+
tier: None,
12+
host_tools: None,
13+
std: None,
14+
},
15+
16+
options: TargetOptions {
17+
cpu: "esp32".into(),
18+
linker: Some("xtensa-esp32-elf-gcc".into()),
19+
max_atomic_width: Some(32),
20+
atomic_cas: true,
21+
..xtensa::opts()
22+
},
23+
}
24+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use crate::spec::{base::xtensa, Target, TargetOptions};
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-v1:8:8-i64:64-i128:128-n32".into(),
8+
arch: "xtensa".into(),
9+
metadata: crate::spec::TargetMetadata {
10+
description: None,
11+
tier: None,
12+
host_tools: None,
13+
std: None,
14+
},
15+
16+
options: TargetOptions {
17+
cpu: "esp32-s2".into(),
18+
linker: Some("xtensa-esp32s2-elf-gcc".into()),
19+
max_atomic_width: Some(32),
20+
..xtensa::opts()
21+
},
22+
}
23+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use crate::spec::{base::xtensa, Target, TargetOptions};
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-v1:8:8-i64:64-i128:128-n32".into(),
8+
arch: "xtensa".into(),
9+
metadata: crate::spec::TargetMetadata {
10+
description: None,
11+
tier: None,
12+
host_tools: None,
13+
std: None,
14+
},
15+
16+
options: TargetOptions {
17+
cpu: "esp32-s3".into(),
18+
linker: Some("xtensa-esp32s3-elf-gcc".into()),
19+
max_atomic_width: Some(32),
20+
atomic_cas: true,
21+
..xtensa::opts()
22+
},
23+
}
24+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use crate::spec::{base::xtensa, Target, TargetOptions};
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-v1:8:8-i64:64-i128:128-n32".into(),
8+
arch: "xtensa".into(),
9+
metadata: crate::spec::TargetMetadata {
10+
description: None,
11+
tier: None,
12+
host_tools: None,
13+
std: None,
14+
},
15+
16+
options: TargetOptions {
17+
cpu: "esp8266".into(),
18+
linker: Some("xtensa-lx106-elf-gcc".into()),
19+
max_atomic_width: Some(32),
20+
..xtensa::opts()
21+
},
22+
}
23+
}

0 commit comments

Comments
 (0)