rustc_target/spec/targets/
xtensa_esp32s2_espidf.rs

1use rustc_abi::Endian;
2
3use crate::spec::base::xtensa;
4use crate::spec::{Target, 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: crate::spec::TargetMetadata {
13            description: None,
14            tier: None,
15            host_tools: None,
16            std: None,
17        },
18
19        options: TargetOptions {
20            endian: Endian::Little,
21            c_int_width: "32".into(),
22            families: cvs!["unix"],
23            os: "espidf".into(),
24            env: "newlib".into(),
25            vendor: "espressif".into(),
26
27            executables: true,
28            cpu: "esp32-s2".into(),
29            linker: Some("xtensa-esp32s2-elf-gcc".into()),
30
31            // See https://github.com/espressif/rust-esp32-example/issues/3#issuecomment-861054477
32            //
33            // While the ESP32-S2 chip does not natively support atomics, ESP-IDF does support
34            // the __atomic* and __sync* compiler builtins. Setting `max_atomic_width` and `atomic_cas`
35            // and `atomic_cas: true` will cause the compiler to emit libcalls to these builtins. On the
36            // ESP32-S2, these are guaranteed to be lock-free.
37            //
38            // Support for atomics is necessary for the Rust STD library, which is supported by ESP-IDF.
39            max_atomic_width: Some(32),
40            atomic_cas: true,
41
42            ..xtensa::opts()
43        },
44    }
45}