rustc_target/spec/targets/
riscv32imc_esp_espidf.rs

1use crate::spec::{PanicStrategy, RelocModel, Target, TargetOptions, cvs};
2
3pub(crate) fn target() -> Target {
4    Target {
5        data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(),
6        llvm_target: "riscv32".into(),
7        metadata: crate::spec::TargetMetadata {
8            description: Some("RISC-V ESP-IDF".into()),
9            tier: Some(3),
10            host_tools: Some(false),
11            std: Some(true),
12        },
13        pointer_width: 32,
14        arch: "riscv32".into(),
15
16        options: TargetOptions {
17            families: cvs!["unix"],
18            os: "espidf".into(),
19            env: "newlib".into(),
20            vendor: "espressif".into(),
21            linker: Some("riscv32-esp-elf-gcc".into()),
22            cpu: "generic-rv32".into(),
23
24            // While the RiscV32IMC architecture does not natively support atomics, ESP-IDF does support
25            // the __atomic* and __sync* GCC builtins, so setting `max_atomic_width` to `Some(32)`
26            // and `atomic_cas` to `true` will cause the compiler to emit libcalls to these builtins.
27            //
28            // Support for atomics is necessary for the Rust STD library, which is supported by the ESP-IDF framework.
29            max_atomic_width: Some(32),
30            atomic_cas: true,
31
32            features: "+m,+c".into(),
33            llvm_abiname: "ilp32".into(),
34            panic_strategy: PanicStrategy::Abort,
35            relocation_model: RelocModel::Static,
36            emit_debug_gdb_scripts: false,
37            eh_frame_header: false,
38            ..Default::default()
39        },
40    }
41}