Skip to content

Commit 5be0f06

Browse files
committed
fix(fuzz): switch to static linking for ClusterFuzzLite compatibility
1 parent 1250024 commit 5be0f06

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

.clusterfuzzlite/build.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ mkdir -p "$OUT"
2525
if [[ -f ffi/zig/build.zig ]]; then
2626
pushd ffi/zig >/dev/null
2727
mkdir -p zig-out/lib
28-
zig build-lib -dynamic -O ReleaseSafe -fPIC --name proven \
29-
-femit-bin=zig-out/lib/libproven.so src/main.zig -lc || {
28+
zig build-lib -static -O ReleaseSafe -fPIC --name proven \
29+
-femit-bin=zig-out/lib/libproven.a src/main.zig -lc || {
3030
echo "WARN: standalone Zig FFI build failed; fuzz targets will not link." >&2
3131
exit 1
3232
}
@@ -53,10 +53,9 @@ for fuzzer in safe_path_has_traversal; do
5353
fi
5454
done
5555

56-
# Bundle libproven.so so the runner can find it at exec time.
57-
if [[ -f "$PROVEN_LIB_DIR/libproven.so" ]]; then
58-
cp "$PROVEN_LIB_DIR/libproven.so" "$OUT/"
59-
fi
56+
# Bundle libproven.a so the fuzzer build can find it (for static linking).
57+
# Note: ClusterFuzzLite binaries should be self-contained; static linking
58+
# is preferred to avoid runtime library loading issues.
6059
popd >/dev/null
6160

6261
echo "=== Build complete. Staged to $OUT. ==="

bindings/rust/build.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,14 @@ fn main() {
1919
println!("cargo:rustc-link-search=native={}", lib_dir);
2020
}
2121

22-
// Link against libproven (the compiled Zig/Idris2 shared library)
23-
println!("cargo:rustc-link-lib=dylib=proven");
22+
// Link against libproven (the compiled Zig/Idris2 library).
23+
// Prefer static linking if libproven.a is found (required for ClusterFuzzLite).
24+
let is_static = std::path::Path::new(&lib_dir_path).join("libproven.a").exists();
25+
if is_static {
26+
println!("cargo:rustc-link-lib=static=proven");
27+
} else {
28+
println!("cargo:rustc-link-lib=dylib=proven");
29+
}
2430

2531
// Add RPATH so binaries can find libproven.so relative to themselves (e.g. in ./lib/ or ./)
2632
// This is required for ClusterFuzzLite and standalone distributions.

0 commit comments

Comments
 (0)