Skip to content

Commit

Permalink
Add some Xtensa targets
Browse files Browse the repository at this point in the history
ESP32, ESP8266 and a generic Xtensa target.
  • Loading branch information
MabezDev authored and kelnos committed Feb 13, 2021
1 parent 0c11a48 commit bc0e24c
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,10 @@ supported_targets! {

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

("xtensa-esp32-none-elf", xtensa_esp32_none_elf),
("xtensa-esp8266-none-elf", xtensa_esp8266_none_elf),
("xtensa-none-elf", xtensa_none_elf),

("i686-wrs-vxworks", i686_wrs_vxworks),
("x86_64-wrs-vxworks", x86_64_wrs_vxworks),
("armv7-wrs-vxworks-eabihf", armv7_wrs_vxworks_eabihf),
Expand Down
47 changes: 47 additions & 0 deletions compiler/rustc_target/src/spec/xtensa_esp32_none_elf.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
use crate::spec::{abi::Abi, LinkerFlavor, PanicStrategy, Target, TargetOptions, RelocModel};

pub fn target() -> Target {
Target {
llvm_target: "xtensa-none-elf".to_string(),
pointer_width: 32,
data_layout: "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32".to_string(),
arch: "xtensa".to_string(),

options: TargetOptions {
endian: "little".to_string(),
c_int_width: "32".to_string(),
os: "none".to_string(),
env: String::new(),
vendor: String::new(),
linker_flavor: LinkerFlavor::Gcc,

executables: true,
cpu: "esp32".to_string(),
linker: Some("xtensa-esp32-elf-gcc".to_string()),

max_atomic_width: Some(32),

// Because these devices have very little resources having an
// unwinder is too onerous so we default to "abort" because the
// "unwind" strategy is very rare.
panic_strategy: PanicStrategy::Abort,

// Similarly, one almost always never wants to use relocatable
// code because of the extra costs it involves.
relocation_model: RelocModel::Static,

emit_debug_gdb_scripts: false,

unsupported_abis: vec![
Abi::Stdcall,
Abi::Fastcall,
Abi::Vectorcall,
Abi::Thiscall,
Abi::Win64,
Abi::SysV64,
],

..Default::default()
},
}
}
47 changes: 47 additions & 0 deletions compiler/rustc_target/src/spec/xtensa_esp8266_none_elf.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
use crate::spec::{abi::Abi, LinkerFlavor, PanicStrategy, Target, TargetOptions, RelocModel};

pub fn target() -> Target {
Target {
llvm_target: "xtensa-none-elf".to_string(),
pointer_width: 32,
data_layout: "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32".to_string(),
arch: "xtensa".to_string(),

options: TargetOptions {
endian: "little".to_string(),
c_int_width: "32".to_string(),
os: "none".to_string(),
env: String::new(),
vendor: String::new(),
linker_flavor: LinkerFlavor::Gcc,

executables: true,
cpu: "esp8266".to_string(),
linker: Some("xtensa-lx106-elf-gcc".to_string()),

max_atomic_width: Some(32),

// Because these devices have very little resources having an
// unwinder is too onerous so we default to "abort" because the
// "unwind" strategy is very rare.
panic_strategy: PanicStrategy::Abort,

// Similarly, one almost always never wants to use relocatable
// code because of the extra costs it involves.
relocation_model: RelocModel::Static,

emit_debug_gdb_scripts: false,

unsupported_abis: vec![
Abi::Stdcall,
Abi::Fastcall,
Abi::Vectorcall,
Abi::Thiscall,
Abi::Win64,
Abi::SysV64,
],

..Default::default()
},
}
}
46 changes: 46 additions & 0 deletions compiler/rustc_target/src/spec/xtensa_none_elf.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
use crate::spec::{abi::Abi, LinkerFlavor, PanicStrategy, Target, TargetOptions, RelocModel};

pub fn target() -> Target {
Target {
llvm_target: "xtensa-none-elf".to_string(),
pointer_width: 32,
data_layout: "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32".to_string(),
arch: "xtensa".to_string(),

options: TargetOptions {
endian: "little".to_string(),
c_int_width: "32".to_string(),
os: "none".to_string(),
env: String::new(),
vendor: String::new(),
linker_flavor: LinkerFlavor::Gcc,

executables: true,
linker: Some("xtensa-esp32-elf-gcc".to_string()),

max_atomic_width: Some(32),

// Because these devices have very little resources having an
// unwinder is too onerous so we default to "abort" because the
// "unwind" strategy is very rare.
panic_strategy: PanicStrategy::Abort,

// Similarly, one almost always never wants to use relocatable
// code because of the extra costs it involves.
relocation_model: RelocModel::Static,

emit_debug_gdb_scripts: false,

unsupported_abis: vec![
Abi::Stdcall,
Abi::Fastcall,
Abi::Vectorcall,
Abi::Thiscall,
Abi::Win64,
Abi::SysV64,
],

..Default::default()
},
}
}

0 comments on commit bc0e24c

Please sign in to comment.