rustc_target/spec/targets/
riscv32im_risc0_zkvm_elf.rs

1use crate::spec::{
2    Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions,
3};
4
5pub(crate) fn target() -> Target {
6    Target {
7        data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(),
8        llvm_target: "riscv32".into(),
9        metadata: TargetMetadata {
10            description: Some("RISC Zero's zero-knowledge Virtual Machine (RV32IM ISA)".into()),
11            tier: Some(3),
12            host_tools: Some(false),
13            std: None, // ?
14        },
15        pointer_width: 32,
16        arch: "riscv32".into(),
17
18        options: TargetOptions {
19            os: "zkvm".into(),
20            vendor: "risc0".into(),
21            linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
22            linker: Some("rust-lld".into()),
23            cpu: "generic-rv32".into(),
24
25            // Some crates (*cough* crossbeam) assume you have 64 bit
26            // atomics if the target name is not in a hardcoded list.
27            // Since zkvm is singlethreaded and all operations are
28            // atomic, I guess we can just say we support 64-bit
29            // atomics.
30            max_atomic_width: Some(64),
31            atomic_cas: true,
32
33            features: "+m".into(),
34            llvm_abiname: "ilp32".into(),
35            executables: true,
36            panic_strategy: PanicStrategy::Abort,
37            relocation_model: RelocModel::Static,
38            emit_debug_gdb_scripts: false,
39            eh_frame_header: false,
40            singlethread: true,
41            ..Default::default()
42        },
43    }
44}