forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Xtensa targets for the ESP-IDF framework
- Loading branch information
Showing
4 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use crate::spec::{cvs, Target, TargetOptions}; | ||
use crate::abi::Endian; | ||
|
||
pub fn target() -> Target { | ||
Target { | ||
llvm_target: "xtensa-none-elf".into(), | ||
pointer_width: 32, | ||
data_layout: "e-m:e-p:32:32-i64:64-i128:128-n32".into(), | ||
arch: "xtensa".into(), | ||
|
||
options: TargetOptions { | ||
endian: Endian::Little, | ||
c_int_width: "32".into(), | ||
families: cvs!["unix"], | ||
os: "espidf".into(), | ||
env: "newlib".into(), | ||
vendor: "espressif".into(), | ||
|
||
executables: true, | ||
cpu: "esp32".into(), | ||
linker: Some("xtensa-esp32-elf-gcc".into()), | ||
|
||
// The esp32 only supports native 32bit atomics. However, esp-idf will emulate 64bit atomics | ||
// so we claim a max atomic width of 64 here. | ||
max_atomic_width: Some(64), | ||
atomic_cas: true, | ||
|
||
..super::xtensa_base::opts() | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use crate::spec::{cvs, Target, TargetOptions}; | ||
use crate::abi::Endian; | ||
|
||
pub fn target() -> Target { | ||
Target { | ||
llvm_target: "xtensa-none-elf".into(), | ||
pointer_width: 32, | ||
data_layout: "e-m:e-p:32:32-i64:64-i128:128-n32".into(), | ||
arch: "xtensa".into(), | ||
|
||
options: TargetOptions { | ||
endian: Endian::Little, | ||
c_int_width: "32".into(), | ||
families: cvs!["unix"], | ||
os: "espidf".into(), | ||
env: "newlib".into(), | ||
vendor: "espressif".into(), | ||
|
||
executables: true, | ||
cpu: "esp32-s2".into(), | ||
linker: Some("xtensa-esp32s2-elf-gcc".into()), | ||
|
||
// See https://github.com/espressif/rust-esp32-example/issues/3#issuecomment-861054477 | ||
// | ||
// Unlike the original ESP32 chip, ESP32-S2 does not really support atomics. | ||
// If the missing hardware instruction ends up being emulated in ESP-IDF, we might want to revert | ||
// this change and claim that atomics are supported "in hardware" (even though they would be emulated | ||
// by actually trapping the illegal instruction exception handler and calling into an ESP-IDF C emulation code). | ||
// | ||
// However, for now we simultaneously claim "max_atomic_width: Some(64)" **and** atomic_cas: true, | ||
// which should force the compiler to generate libcalls to functions that emulate atomics | ||
// and which are already implemented in the ESP-IDF main branch anyway. | ||
max_atomic_width: Some(64), | ||
atomic_cas: true, | ||
|
||
..super::xtensa_base::opts() | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use crate::spec::{cvs, Target, TargetOptions}; | ||
use crate::abi::Endian; | ||
|
||
pub fn target() -> Target { | ||
Target { | ||
llvm_target: "xtensa-none-elf".into(), | ||
pointer_width: 32, | ||
data_layout: "e-m:e-p:32:32-i64:64-i128:128-n32".into(), | ||
arch: "xtensa".into(), | ||
|
||
options: TargetOptions { | ||
endian: Endian::Little, | ||
c_int_width: "32".into(), | ||
families: cvs!["unix"], | ||
os: "espidf".into(), | ||
env: "newlib".into(), | ||
vendor: "espressif".into(), | ||
|
||
executables: true, | ||
cpu: "esp32-s3".into(), | ||
linker: Some("xtensa-esp32s3-elf-gcc".into()), | ||
|
||
// The esp32s3 only supports native 32bit atomics. However, esp-idf will emulate 64bit atomics | ||
// so we claim a max atomic width of 64 here. | ||
max_atomic_width: Some(64), | ||
atomic_cas: true, | ||
|
||
..super::xtensa_base::opts() | ||
}, | ||
} | ||
} |