Closed lrettig closed 3 months ago
Ended up moving to a custom RV32E toolchain: https://github.com/athenavm/rustc-rv32e-toolchain/. Codegen support for RV32E was added recently to LLVM: https://github.com/llvm/llvm-project/commit/3ac9fe69f70a2b3541266daedbaaa7dc9c007a2a. We're still using patches but we should try switching to a newer Rust that depends on this version of LLVM, without the LLVM patches.
Done in linked issue
Right now we're using the SP1 toolchain: https://github.com/succinctlabs/rust. It should be possible to switch to
riscv32im-risc0-zkvm-elf
which has at least partial mainline Rust support, see https://github.com/rust-lang/rust/commit/75d7d7091a6c891bb98ff4158a09f4e1f2fb2be1. But I don't see this target listed for rustc 1.78.0 and I'm getting errors when trying to build using mainline rust rather than the custom toolchain (about missing std support).This works:
> RUSTC=/home/lane/.rustup/toolchains/risc0/bin/rustc CFLAGS_riscv32im_risc0_zkvm_elf="-march=rv32im -nostdlib" CC=/home/lane/.local/share/cargo-risczero/cpp/bin/riscv32-unknown-elf-gcc RUSTFLAGS="-Cpasses=loweratomic -Clink-arg=-Ttext=0x00200800 -Clink-arg=--fatal-warnings -Cpanic=abort" cargo build --target riscv32im-risc0-zkvm-elf
This also works:
> LD_LIBRARY_PATH=$HOME/opt/lib:$LD_LIBRARY_PATH RUSTUP_TOOLCHAIN=risc0 cargo build
This does not work: