Skip to content

Commit

Permalink
Add some Xtensa targets. ESP32, ESP8266 and a generic Xtensa target.
Browse files Browse the repository at this point in the history
  • Loading branch information
MabezDev committed Sep 13, 2020
1 parent 07fe9cb commit e080dd7
Show file tree
Hide file tree
Showing 4 changed files with 141 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 @@ -668,6 +668,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
46 changes: 46 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,46 @@
use crate::spec::{abi::Abi, LinkerFlavor, PanicStrategy, Target, TargetOptions, TargetResult, RelocModel};

pub fn target() -> TargetResult {
Ok(Target {
llvm_target: "xtensa-none-elf".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
data_layout: "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32".to_string(),
arch: "xtensa".to_string(),
target_os: "none".to_string(),
target_env: String::new(),
target_vendor: String::new(),
linker_flavor: LinkerFlavor::Gcc,

options: TargetOptions {
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()
},
})
}
46 changes: 46 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,46 @@
use crate::spec::{abi::Abi, LinkerFlavor, PanicStrategy, Target, TargetOptions, TargetResult, RelocModel};

pub fn target() -> TargetResult {
Ok(Target {
llvm_target: "xtensa-none-elf".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
data_layout: "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32".to_string(),
arch: "xtensa".to_string(),
target_os: "none".to_string(),
target_env: String::new(),
target_vendor: String::new(),
linker_flavor: LinkerFlavor::Gcc,

options: TargetOptions {
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()
},
})
}
45 changes: 45 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,45 @@
use crate::spec::{abi::Abi, LinkerFlavor, PanicStrategy, Target, TargetOptions, TargetResult, RelocModel};

pub fn target() -> TargetResult {
Ok(Target {
llvm_target: "xtensa-none-elf".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
data_layout: "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32".to_string(),
arch: "xtensa".to_string(),
target_os: "none".to_string(),
target_env: String::new(),
target_vendor: String::new(),
linker_flavor: LinkerFlavor::Gcc,

options: TargetOptions {
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 e080dd7

Please sign in to comment.