mirror of https://github.com/google/oss-fuzz.git
Simplify rust project setup. (#3830)
* Simplify rust project setup. - Add rust and cargo-fuzz in base builder. - Set RUSTC_BOOSTRAP to make ASan available. - Set RUSTFLAGS and C,CXXFLAGS properly.
This commit is contained in:
parent
261abce857
commit
4f7cf1b334
|
@ -15,14 +15,16 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
FROM gcr.io/oss-fuzz-base/base-clang
|
FROM gcr.io/oss-fuzz-base/base-clang
|
||||||
RUN apt-get install -y git \
|
RUN apt-get update && apt-get install -y \
|
||||||
subversion \
|
|
||||||
jq \
|
|
||||||
python3 \
|
|
||||||
zip \
|
|
||||||
make \
|
|
||||||
binutils-dev \
|
binutils-dev \
|
||||||
libc6-dev-i386
|
curl \
|
||||||
|
git \
|
||||||
|
jq \
|
||||||
|
libc6-dev-i386 \
|
||||||
|
make \
|
||||||
|
python3 \
|
||||||
|
subversion \
|
||||||
|
zip
|
||||||
|
|
||||||
# Download and install the latest stable Go.
|
# Download and install the latest stable Go.
|
||||||
ADD https://storage.googleapis.com/golang/getgo/installer_linux $SRC/
|
ADD https://storage.googleapis.com/golang/getgo/installer_linux $SRC/
|
||||||
|
@ -41,6 +43,13 @@ ENV PATH $PATH:/root/.go/bin:$GOPATH/bin
|
||||||
RUN go get -u github.com/mdempsky/go114-fuzz-build && \
|
RUN go get -u github.com/mdempsky/go114-fuzz-build && \
|
||||||
ln -s $GOPATH/bin/go114-fuzz-build $GOPATH/bin/go-fuzz
|
ln -s $GOPATH/bin/go114-fuzz-build $GOPATH/bin/go-fuzz
|
||||||
|
|
||||||
|
# Install Rust and cargo-fuzz for libFuzzer instrumentation.
|
||||||
|
ENV CARGO_HOME=/rust
|
||||||
|
ENV RUSTUP_HOME=/rust/rustup
|
||||||
|
ENV PATH=$PATH:/rust/bin
|
||||||
|
RUN curl https://sh.rustup.rs | sh -s -- -y --default-toolchain=nightly
|
||||||
|
RUN cargo install cargo-fuzz
|
||||||
|
|
||||||
# Default build flags for various sanitizers.
|
# Default build flags for various sanitizers.
|
||||||
ENV SANITIZER_FLAGS_address "-fsanitize=address -fsanitize-address-use-after-scope"
|
ENV SANITIZER_FLAGS_address "-fsanitize=address -fsanitize-address-use-after-scope"
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,24 @@ if [ $FUZZING_ENGINE = "none" ]; then
|
||||||
export COVERAGE_FLAGS=
|
export COVERAGE_FLAGS=
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export CFLAGS="$CFLAGS $SANITIZER_FLAGS $COVERAGE_FLAGS"
|
if [[ $FUZZING_LANGUAGE == "rust" ]]; then
|
||||||
export CXXFLAGS="$CFLAGS $CXXFLAGS_EXTRA"
|
# Rust does not support sanitizers and coverage flags via CFLAGS/CXXFLAGS.
|
||||||
|
# Instead, use RUSTFLAGS.
|
||||||
|
# FIXME: Support code coverage once support is in.
|
||||||
|
# See https://github.com/rust-lang/rust/issues/34701.
|
||||||
|
export RUSTFLAGS="--cfg fuzzing -Zsanitizer=${SANITIZER} -Cdebuginfo=1 -Cforce-frame-pointers"
|
||||||
|
|
||||||
|
# Add Rust libfuzzer flags.
|
||||||
|
# See https://github.com/rust-fuzz/libfuzzer/blob/master/build.rs#L12.
|
||||||
|
export CUSTOM_LIBFUZZER_PATH="$LIB_FUZZING_ENGINE_DEPRECATED"
|
||||||
|
export CUSTOM_LIBFUZZER_STD_CXX=c++
|
||||||
|
|
||||||
|
# Set RUSTC_BOOTSTRAP to get nightly features like sanitizers.
|
||||||
|
export RUSTC_BOOTSTRAP=1
|
||||||
|
else
|
||||||
|
export CFLAGS="$CFLAGS $SANITIZER_FLAGS $COVERAGE_FLAGS"
|
||||||
|
export CXXFLAGS="$CFLAGS $CXXFLAGS_EXTRA"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "CC=$CC"
|
echo "CC=$CC"
|
||||||
echo "CXX=$CXX"
|
echo "CXX=$CXX"
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
FROM gcr.io/oss-fuzz-base/base-builder
|
FROM gcr.io/oss-fuzz-base/base-builder
|
||||||
MAINTAINER p.antoine@catenacyber.fr
|
MAINTAINER p.antoine@catenacyber.fr
|
||||||
RUN apt-get update && apt-get install -y make cmake bzip2 autoconf automake gettext libtool python nodejs npm
|
RUN apt-get update && apt-get install -y make cmake bzip2 autoconf automake gettext libtool python nodejs npm
|
||||||
ENV CARGO_HOME=/rust RUSTUP_HOME=/rust/rustup PATH=$PATH:/rust/bin
|
|
||||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
||||||
RUN rustup target add i686-unknown-linux-gnu
|
RUN rustup target add i686-unknown-linux-gnu
|
||||||
RUN npm install -g browserify
|
RUN npm install -g browserify
|
||||||
RUN npm install elliptic
|
RUN npm install elliptic
|
||||||
|
|
|
@ -21,10 +21,6 @@ MAINTAINER davidwg@fb.com
|
||||||
# install other tools we might need
|
# install other tools we might need
|
||||||
RUN apt-get update && apt-get install -y cmake curl
|
RUN apt-get update && apt-get install -y cmake curl
|
||||||
|
|
||||||
# install rust and cargo-fuzz
|
|
||||||
ENV CARGO_HOME=/rust RUSTUP_HOME=/rust/rustup PATH=$PATH:/rust/bin
|
|
||||||
RUN curl https://sh.rustup.rs | sh -s -- -y
|
|
||||||
|
|
||||||
# get libra
|
# get libra
|
||||||
RUN git clone --depth 1 https://github.com/libra/libra $SRC/libra
|
RUN git clone --depth 1 https://github.com/libra/libra $SRC/libra
|
||||||
WORKDIR $SRC/libra
|
WORKDIR $SRC/libra
|
||||||
|
|
|
@ -56,9 +56,6 @@ export CUSTOM_LIBFUZZER_PATH="$LIB_FUZZING_ENGINE_DEPRECATED"
|
||||||
export CUSTOM_LIBFUZZER_STD_CXX=c++
|
export CUSTOM_LIBFUZZER_STD_CXX=c++
|
||||||
# export CUSTOM_LIBFUZZER_STD_CXX=none
|
# export CUSTOM_LIBFUZZER_STD_CXX=none
|
||||||
|
|
||||||
# RUSTC_BOOTSTRAP: to get some nightly features like ASAN
|
|
||||||
export RUSTC_BOOTSTRAP=1
|
|
||||||
|
|
||||||
# export fuzzing flags
|
# export fuzzing flags
|
||||||
RUSTFLAGS="$RUSTFLAGS --cfg fuzzing" # used to change code logic
|
RUSTFLAGS="$RUSTFLAGS --cfg fuzzing" # used to change code logic
|
||||||
RUSTFLAGS="$RUSTFLAGS -Cdebug-assertions" # to get debug_assert in rust
|
RUSTFLAGS="$RUSTFLAGS -Cdebug-assertions" # to get debug_assert in rust
|
||||||
|
|
|
@ -18,10 +18,6 @@ FROM gcr.io/oss-fuzz-base/base-builder
|
||||||
MAINTAINER mgregan@mozilla.com
|
MAINTAINER mgregan@mozilla.com
|
||||||
RUN apt-get update && apt-get install -y make autoconf automake libtool curl cmake python llvm-dev libclang-dev clang
|
RUN apt-get update && apt-get install -y make autoconf automake libtool curl cmake python llvm-dev libclang-dev clang
|
||||||
|
|
||||||
ENV CARGO_HOME=/rust RUSTUP_HOME=/rust/rustup PATH=$PATH:/rust/bin
|
|
||||||
RUN curl https://sh.rustup.rs | sh -s -- -y --default-toolchain=nightly
|
|
||||||
RUN cargo install cargo-fuzz
|
|
||||||
|
|
||||||
RUN git clone --depth 1 https://github.com/mozilla/mp4parse-rust mp4parse-rust
|
RUN git clone --depth 1 https://github.com/mozilla/mp4parse-rust mp4parse-rust
|
||||||
WORKDIR mp4parse-rust
|
WORKDIR mp4parse-rust
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,6 @@ FROM gcr.io/oss-fuzz-base/base-builder
|
||||||
MAINTAINER david@adalogics.com
|
MAINTAINER david@adalogics.com
|
||||||
RUN apt-get update && apt-get install -y make autoconf automake libtool curl cmake python llvm-dev libclang-dev clang
|
RUN apt-get update && apt-get install -y make autoconf automake libtool curl cmake python llvm-dev libclang-dev clang
|
||||||
|
|
||||||
ENV CARGO_HOME=/rust RUSTUP_HOME=/rust/rustup PATH=$PATH:/rust/bin
|
|
||||||
RUN curl https://sh.rustup.rs | sh -s -- -y --default-toolchain=nightly
|
|
||||||
RUN cargo install cargo-fuzz
|
|
||||||
|
|
||||||
RUN git clone --depth 1 https://github.com/serde-rs/json json
|
RUN git clone --depth 1 https://github.com/serde-rs/json json
|
||||||
WORKDIR $SRC
|
WORKDIR $SRC
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,6 @@ FROM gcr.io/oss-fuzz-base/base-builder
|
||||||
MAINTAINER foote@fastly.com
|
MAINTAINER foote@fastly.com
|
||||||
RUN apt-get update && apt-get install -y make autoconf automake libtool curl cmake python llvm-dev libclang-dev clang
|
RUN apt-get update && apt-get install -y make autoconf automake libtool curl cmake python llvm-dev libclang-dev clang
|
||||||
|
|
||||||
ENV CARGO_HOME=/rust RUSTUP_HOME=/rust/rustup PATH=$PATH:/rust/bin
|
|
||||||
RUN curl https://sh.rustup.rs | sh -s -- -y --default-toolchain=nightly
|
|
||||||
RUN cargo install cargo-fuzz
|
|
||||||
|
|
||||||
RUN git clone --depth 1 https://github.com/bytecodealliance/wasmtime wasmtime
|
RUN git clone --depth 1 https://github.com/bytecodealliance/wasmtime wasmtime
|
||||||
WORKDIR wasmtime
|
WORKDIR wasmtime
|
||||||
RUN git submodule update --init --recursive
|
RUN git submodule update --init --recursive
|
||||||
|
|
Loading…
Reference in New Issue