Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust toolchain #3

Closed
lrettig opened this issue Jun 5, 2024 · 2 comments
Closed

Rust toolchain #3

lrettig opened this issue Jun 5, 2024 · 2 comments

Comments

@lrettig
Copy link
Contributor

lrettig commented Jun 5, 2024

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 rust-lang/rust@75d7d70. 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:

> RUSTFLAGS="-Cpasses=loweratomic -Clink-arg=-Ttext=0x00200800 -Clink-arg=--fatal-warnings -Cpanic=abort" cargo build --target riscv32im-risc0-zkvm-elf
   Compiling zeroize v1.8.1
   Compiling typenum v1.17.0
   Compiling cfg-if v1.0.0
   Compiling subtle v2.5.0
   Compiling const-oid v0.9.6
   Compiling tap v1.0.1
   Compiling funty v2.0.0
   Compiling base16ct v0.2.0
   Compiling ppv-lite86 v0.2.17
   Compiling generic-array v0.14.7
   Compiling num-traits v0.2.19
   Compiling radium v0.7.0
   Compiling proc-macro2 v1.0.84
   Compiling serde v1.0.203
   Compiling hex v0.4.3
   Compiling anyhow v1.0.86
error[E0463]: can't find crate for `core`
  |
  = note: the `riscv32im-risc0-zkvm-elf` target may not be installed
  = help: consider downloading the target with `rustup target add riscv32im-risc0-zkvm-elf`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

For more information about this error, try `rustc --explain E0463`.
   Compiling once_cell v1.19.0
error: could not compile `tap` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `const-oid` (lib) due to 1 previous error
error: could not compile `cfg-if` (lib) due to 1 previous error
error: could not compile `zeroize` (lib) due to 1 previous error
error: could not compile `base16ct` (lib) due to 1 previous error
error: could not compile `funty` (lib) due to 1 previous error
error: could not compile `subtle` (lib) due to 1 previous error
error: could not compile `ppv-lite86` (lib) due to 1 previous error
error: could not compile `radium` (lib) due to 1 previous error
error[E0463]: can't find crate for `std`
  |
  = note: the `riscv32im-risc0-zkvm-elf` target may not be installed
  = help: consider downloading the target with `rustup target add riscv32im-risc0-zkvm-elf`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

error: could not compile `once_cell` (lib) due to 1 previous error
error: could not compile `hex` (lib) due to 1 previous error
@lrettig
Copy link
Contributor Author

lrettig commented Jun 8, 2024

Ended up moving to a custom RV32E toolchain: https://github.com/athenavm/rustc-rv32e-toolchain/. Codegen support for RV32E was added recently to LLVM: llvm/llvm-project@3ac9fe6. 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.

@lrettig
Copy link
Contributor Author

lrettig commented Jun 14, 2024

Done in linked issue

@lrettig lrettig closed this as completed Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant