risc0 / risc0

RISC Zero is a zero-knowledge verifiable general computing platform based on zk-STARKs and the RISC-V microarchitecture.
https://risczero.com
Apache License 2.0
1.56k stars 375 forks source link

[BUG] `blst` does not build using `cargo risczero test` #1761

Open SchmErik opened 2 months ago

SchmErik commented 2 months ago

Bug Report

Running cargo risczero test in the blst crate's bindings/rust directory does not work.

Steps to Reproduce

  1. install cargo risczero with the experimental feature by running cargo install --force --path risc0/cargo-risczero -F experimental
  2. clone BLST by running https://github.com/supranational/blst.git
  3. add this change to patch getrandom

    diff --git a/bindings/rust/Cargo.toml b/bindings/rust/Cargo.toml
    index ce6ba53..d6ecfbe 100644
    --- a/bindings/rust/Cargo.toml
    +++ b/bindings/rust/Cargo.toml
    @@ -50,6 +50,9 @@ serde = { version = "1.0.152", optional = true }
    
    [target.'cfg(not(any(target_arch="wasm32", target_os="none", target_os="unknown", target_os="uefi")))'.dependencies]
    threadpool = "^1.8.1"
    +[target.'cfg(all(target_os = "zkvm", target_arch = "riscv32"))'.dependencies]
    +getrandom = { version = "0.2", features = ["custom"] }
    +
    
    [dev-dependencies]
    rand = "0.8"
  4. run cargo risczero test from the directory bindings/rust in the blst directory.
  5. The following warning appears in the terminal output:
    warning: blst@0.3.11: warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: archive library: /Users/erik/blst/bindings/rust/target/riscv32im-risc0-zkvm-elf/debug/build/blst-66bf3377eb4d0726/out/libblst.a the table of contents is empty (no object file members in the library define global symbols)

    followed by linker errors like these:

    = note: rust-lld: error: /Users/erik/blst/bindings/rust/target/riscv32im-risc0-zkvm-elf/debug/build/blst-66bf3377eb4d0726/out/libblst.a(9cfc24e6b3ae334c-server.o):(.debug_rnglists+0x11): unknown relocation (60) against symbol .LFE0
          rust-lld: error: /Users/erik/blst/bindings/rust/target/riscv32im-risc0-zkvm-elf/debug/build/blst-66bf3377eb4d0726/out/libblst.a(9cfc24e6b3ae334c-server.o):(.debug_rnglists+0x11): unknown relocation (61) against symbol .LFB0
          rust-lld: error: /Users/erik/blst/bindings/rust/target/riscv32im-risc0-zkvm-elf/debug/build/blst-66bf3377eb4d0726/out/libblst.a(9cfc24e6b3ae334c-server.o):(.debug_rnglists+0x17): unknown relocation (60) against symbol .LFE1

Expected behavior

I would expect cargo risczero test compile and link successfully and start running tests

Your Environment

Additional context

Without the change to the Cargo.toml the compilation will fail with an error that originates from the getrandom crate. I'll file a separate issue for this.

linear[bot] commented 2 months ago

ZKVM-422 [BUG] `blst` does not build using `cargo risczero test`