fix: remove the stub code

This commit is contained in:
Roman 2026-05-25 14:14:44 +08:00
parent a2033af30e
commit a89ba33f3b
No known key found for this signature in database
GPG Key ID: 583BDF43C238B83E
4 changed files with 0 additions and 58 deletions

1
fuzz/Cargo.lock generated
View File

@ -2009,7 +2009,6 @@ dependencies = [
"afl",
"arbitrary",
"borsh",
"cc",
"common",
"fuzz_props",
"libfuzzer-sys",

View File

@ -3,8 +3,6 @@ name = "fuzz"
version = "0.1.0"
edition = "2024"
publish = false
# Provides sys_alloc_aligned stub for non-RISC-V host builds (see build.rs)
build = "build.rs"
[package.metadata]
cargo-fuzz = true
@ -52,10 +50,6 @@ common = { path = "../../logos-execution-zone/common" }
fuzz_props = { path = "../fuzz_props" }
testnet_initial_state = { path = "../../logos-execution-zone/testnet_initial_state" }
[build-dependencies]
# Used by build.rs to compile the sys_alloc_aligned stub for non-RISC-V hosts
cc = "1"
[profile.release]
debug = true
opt-level = 3

View File

@ -1,25 +0,0 @@
// fuzz/build.rs
//
// Provides `sys_alloc_aligned` for non-RISC-V host targets.
//
// `risc0_zkvm_platform::syscall::sys_alloc_words` calls the bare-metal symbol
// `sys_alloc_aligned`, which is normally supplied by the RISC-V zkVM runtime.
// When compiling fuzz targets for a host target (x86_64-unknown-linux-gnu,
// aarch64-unknown-linux-gnu, …) that symbol is absent, causing a linker error.
// This build script compiles a small C stub via the `cc` crate so the symbol
// is always available in the final fuzz binary.
//
// On macOS host builds (used by `cargo fuzz` / libFuzzer) the `cc` crate
// compiles the same stub; it is harmlessly dead-stripped if the symbol is not
// referenced.
fn main() {
let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();
// RISC-V builds get the real symbol from the zkVM runtime — skip the stub.
if target_arch != "riscv32" && target_arch != "riscv64" {
cc::Build::new()
.file("build_stubs/sys_alloc_aligned.c")
.compile("sys_alloc_stub");
}
}

View File

@ -1,26 +0,0 @@
/*
* sys_alloc_aligned.c
*
* Provides `sys_alloc_aligned` for non-RISC-V host targets
* (e.g. aarch64-unknown-linux-gnu, x86_64-unknown-linux-gnu).
*
* On RISC-V the real symbol is supplied by the zkVM bare-metal runtime.
* On host targets, risc0_zkvm_platform may still reference this symbol via
* its `sys_alloc_words` helper; this stub satisfies that reference using
* POSIX `posix_memalign`.
*/
#ifndef __riscv
#include <stddef.h>
#include <stdlib.h>
void *sys_alloc_aligned(size_t bytes, size_t align) {
void *ptr = NULL;
/* posix_memalign requires alignment >= sizeof(void*) and a power of 2. */
size_t real_align = align < sizeof(void *) ? sizeof(void *) : align;
if (posix_memalign(&ptr, real_align, bytes) != 0)
return NULL;
return ptr;
}
#endif /* !__riscv */