rustc_target/spec/targets/
riscv32im_risc0_zkvm_elf.rs

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