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