rustc_target/spec/targets/xtensa_esp32s2_espidf.rs
1use rustc_abi::Endian;
2
3use crate::spec::base::xtensa;
4use crate::spec::{Target, TargetMetadata, TargetOptions, cvs};
5
6pub(crate) fn target() -> Target {
7 Target {
8 llvm_target: "xtensa-none-elf".into(),
9 pointer_width: 32,
10 data_layout: "e-m:e-p:32:32-v1:8:8-i64:64-i128:128-n32".into(),
11 arch: "xtensa".into(),
12 metadata: TargetMetadata { description: None, tier: None, host_tools: None, std: None },
13
14 options: TargetOptions {
15 endian: Endian::Little,
16 c_int_width: "32".into(),
17 families: cvs!["unix"],
18 os: "espidf".into(),
19 env: "newlib".into(),
20 vendor: "espressif".into(),
21
22 executables: true,
23 cpu: "esp32s2".into(),
24 linker: Some("xtensa-esp32s2-elf-gcc".into()),
25
26 // See https://github.com/espressif/rust-esp32-example/issues/3#issuecomment-861054477
27 //
28 // While the ESP32-S2 chip does not natively support atomics, ESP-IDF does support
29 // the __atomic* and __sync* compiler builtins. Setting `max_atomic_width` and `atomic_cas`
30 // and `atomic_cas: true` will cause the compiler to emit libcalls to these builtins. On the
31 // ESP32-S2, these are guaranteed to be lock-free.
32 //
33 // Support for atomics is necessary for the Rust STD library, which is supported by ESP-IDF.
34 max_atomic_width: Some(32),
35 atomic_cas: true,
36
37 ..xtensa::opts()
38 },
39 }
40}