aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@google.com>2022-07-18 20:25:40 -0400
committerGravatar Benjamin Barenblat <bbarenblat@gmail.com>2022-07-18 20:30:39 -0400
commitf67f237fecfbbe8e68f7050ac236412bd9c65592 (patch)
treee30ea558a466f3cf76e6726634cebd891fd0b48e
parent8af4ebe337bae204ffd9e0a54e45b4e640aa4937 (diff)
mosh: fix code coverageHEADmaster
Update Mosh’s build.sh to pass appropriate configure options when coverage is requested, as well as to pass CXXFLAGS through to the actual build. These fix ClusterFuzz code coverage reports. Along the way, enable verbose build rules, since they’re useful for debugging build failures.
-rw-r--r--projects/mosh/Dockerfile2
-rwxr-xr-xprojects/mosh/build.sh23
2 files changed, 21 insertions, 4 deletions
diff --git a/projects/mosh/Dockerfile b/projects/mosh/Dockerfile
index c3497e91..50fb55d0 100644
--- a/projects/mosh/Dockerfile
+++ b/projects/mosh/Dockerfile
@@ -16,7 +16,7 @@
FROM gcr.io/oss-fuzz-base/base-builder
RUN apt-get update && apt-get install -y autoconf automake protobuf-compiler \
- libprotobuf-dev pkg-config zlib1g-dev libncurses5-dev libssl-dev clang
+ libprotobuf-dev pkg-config zlib1g-dev libncurses5-dev libssl-dev clang lcov
RUN git clone --depth 1 https://github.com/mobile-shell/mosh.git
WORKDIR mosh
COPY build.sh $SRC/
diff --git a/projects/mosh/build.sh b/projects/mosh/build.sh
index 87526a18..cf6039c0 100755
--- a/projects/mosh/build.sh
+++ b/projects/mosh/build.sh
@@ -19,16 +19,33 @@ set -eu
./autogen.sh
+# Sniff $CXXFLAGS to figure out what to pass to ./configure.
+configure_flags=
+case $CXXFLAGS in
+ *-fsanitize=address*)
+ configure_flags="$configure_flags --enable-asan"
+ ;;
+esac
+case $CXXFLAGS in
+ *-fcoverage*)
+ configure_flags="$configure_flags --enable-code-coverage"
+ ;;
+esac
+
+# Use libstdc++, not libc++, since the base image's prebuild libraries require
+# libstdc++.
+export CXXFLAGS="$CXXFLAGS -stdlib=libstdc++"
+
# Clear CFLAGS and CXXFLAGS during configure tests so configure won't try to
# link with -fsanitize=fuzz.
-CFLAGS= CXXFLAGS= ./configure --enable-fuzzing --enable-asan --enable-static-libraries
+CFLAGS= CXXFLAGS= ./configure --disable-silent-rules --enable-fuzzing --enable-static-libraries $configure_flags
n=$(nproc)
-make -j$n
+make -j$n CFLAGS+="$CFLAGS" CXXFLAGS+="$CXXFLAGS"
cd src/fuzz
-make -j$n
+make -j$n CFLAGS+="$CFLAGS" CXXFLAGS+="$CXXFLAGS"
for fuzzer in *_fuzzer; do
cp $fuzzer $OUT