From 4325d5b3d8f8d506fc22e454f49d9aa08534b034 Mon Sep 17 00:00:00 2001 From: rbehjati Date: Tue, 25 May 2021 15:36:20 +0100 Subject: [PATCH] Build Wasm modules (#5830) --- projects/oak/Dockerfile | 4 ++++ projects/oak/build.sh | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/projects/oak/Dockerfile b/projects/oak/Dockerfile index 13e83b953..a32788ba1 100644 --- a/projects/oak/Dockerfile +++ b/projects/oak/Dockerfile @@ -29,7 +29,11 @@ RUN curl --location https://github.com/protocolbuffers/protobuf/releases/downloa && chmod --recursive a+rwx ${protobuf_dir} \ && protoc --version +# Install WebAssembly target for Rust. +RUN rustup target add wasm32-unknown-unknown + RUN git clone --depth 1 https://github.com/project-oak/oak oak + WORKDIR oak COPY build.sh $SRC/ COPY rustc.py $SRC/ diff --git a/projects/oak/build.sh b/projects/oak/build.sh index 97e44f611..169a5492b 100755 --- a/projects/oak/build.sh +++ b/projects/oak/build.sh @@ -24,7 +24,16 @@ then export RUSTC="$SRC/rustc.py" fi -cargo fuzz build -O +cargo fuzz build --release + +# Clear RUSTFLAGS, and build the fuzzable example. The Wasm module is stored in `/out/bin`. +# Keep this in sync with `https://github.com/project-oak/oak/blob/main/oak_functions/loader/fuzz/fuzz_targets/wasm_invoke.rs`. +export RUSTFLAGS="" +cargo -Zunstable-options build \ + --target=wasm32-unknown-unknown \ + --target-dir=target/wasm32-unknown-unknown/wasm \ + --out-dir="$OUT/bin" \ + --manifest-path=../examples/fuzzable/module/Cargo.toml FUZZ_TARGET_OUTPUT_DIR=fuzz/target/x86_64-unknown-linux-gnu/release for f in fuzz/fuzz_targets/*.rs