-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add std Xtensa targets support
- Loading branch information
1 parent
f6b4b71
commit 3954b74
Showing
8 changed files
with
144 additions
and
1 deletion.
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
36 changes: 36 additions & 0 deletions
36
compiler/rustc_target/src/spec/targets/xtensa_esp32_espidf.rs
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,36 @@ | ||
use crate::abi::Endian; | ||
use crate::spec::{base::xtensa, cvs, Target, TargetOptions}; | ||
|
||
pub fn target() -> Target { | ||
Target { | ||
llvm_target: "xtensa-none-elf".into(), | ||
pointer_width: 32, | ||
data_layout: "e-m:e-p:32:32-v1:8:8-i64:64-i128:128-n32".into(), | ||
arch: "xtensa".into(), | ||
metadata: crate::spec::TargetMetadata { | ||
description: None, | ||
tier: None, | ||
host_tools: None, | ||
std: None, | ||
}, | ||
|
||
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. | ||
max_atomic_width: Some(32), | ||
atomic_cas: true, | ||
|
||
..xtensa::opts() | ||
}, | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
compiler/rustc_target/src/spec/targets/xtensa_esp32s2_espidf.rs
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,43 @@ | ||
use crate::abi::Endian; | ||
use crate::spec::{base::xtensa, cvs, Target, TargetOptions}; | ||
|
||
pub fn target() -> Target { | ||
Target { | ||
llvm_target: "xtensa-none-elf".into(), | ||
pointer_width: 32, | ||
data_layout: "e-m:e-p:32:32-v1:8:8-i64:64-i128:128-n32".into(), | ||
arch: "xtensa".into(), | ||
metadata: crate::spec::TargetMetadata { | ||
description: None, | ||
tier: None, | ||
host_tools: None, | ||
std: None, | ||
}, | ||
|
||
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 | ||
// | ||
// While the ESP32-S2 chip does not natively support atomics, ESP-IDF does support | ||
// the __atomic* and __sync* compiler builtins. Setting `max_atomic_width` and `atomic_cas` | ||
// and `atomic_cas: true` will cause the compiler to emit libcalls to these builtins. On the | ||
// ESP32-S2, these are guaranteed to be lock-free. | ||
// | ||
// Support for atomics is necessary for the Rust STD library, which is supported by ESP-IDF. | ||
max_atomic_width: Some(32), | ||
atomic_cas: true, | ||
|
||
..xtensa::opts() | ||
}, | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
compiler/rustc_target/src/spec/targets/xtensa_esp32s3_espidf.rs
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,36 @@ | ||
use crate::abi::Endian; | ||
use crate::spec::{base::xtensa, cvs, Target, TargetOptions}; | ||
|
||
pub fn target() -> Target { | ||
Target { | ||
llvm_target: "xtensa-none-elf".into(), | ||
pointer_width: 32, | ||
data_layout: "e-m:e-p:32:32-v1:8:8-i64:64-i128:128-n32".into(), | ||
arch: "xtensa".into(), | ||
metadata: crate::spec::TargetMetadata { | ||
description: None, | ||
tier: None, | ||
host_tools: None, | ||
std: None, | ||
}, | ||
|
||
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. | ||
max_atomic_width: Some(32), | ||
atomic_cas: true, | ||
|
||
..xtensa::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
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
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