Skip to content

Commit

Permalink
Merge branch 'main' into flaub/native-machine
Browse files Browse the repository at this point in the history
  • Loading branch information
flaub committed Apr 29, 2024
2 parents 5594ed3 + 1a3fa2e commit c732ffa
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions risc0/build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,19 +318,27 @@ pub fn cargo_command(subcmd: &str, rust_flags: &[&str]) -> Command {
.concat()
.join("\x1f");

let cc_path = risc0_data()
.unwrap()
.join("cpp/bin/riscv32-unknown-elf-gcc");
let c_flags = "-march=rv32im -nostdlib";
if !cpp_toolchain_override() {
let cc_path = risc0_data()
.unwrap()
.join("cpp/bin/riscv32-unknown-elf-gcc");
cmd.env("CC", cc_path)
.env("CFLAGS_riscv32im_risc0_zkvm_elf", "-march=rv32im -nostdlib");
}

cmd.env("RUSTC", rustc)
.env("CARGO_ENCODED_RUSTFLAGS", rustflags_envvar)
.env("CC", cc_path)
.env("CFLAGS_riscv32im_risc0_zkvm_elf", c_flags)
.args(args);

cmd
}

fn cpp_toolchain_override() -> bool {
// detect if there's an attempt to override the Cpp toolchain.
// Overriding the toolchain useful for troubleshooting crates.
std::env::var("CC_riscv32im_risc0_zkvm_elf").is_ok()
|| std::env::var("CFLAGS_riscv32im_risc0_zkvm_elf").is_ok()
}

/// Builds a static library providing a rust runtime.
///
/// This can be used to build programs for the zkvm which don't depend on
Expand Down

0 comments on commit c732ffa

Please sign in to comment.