[osquery] Use platform toolchain and fix coverage builds (#3182)

This commit is contained in:
Teddy Reed 2020-01-05 02:32:42 -05:00 committed by Abhishek Arya
parent c8a528f2cf
commit 55b7ded4c8
2 changed files with 12 additions and 12 deletions

View File

@ -17,7 +17,7 @@
FROM gcr.io/oss-fuzz-base/base-builder
MAINTAINER theopolis@osquery.io
RUN apt-get update
RUN apt-get install -y --no-install-recommends python python3 bison flex make wget xz-utils
RUN apt-get install -y --no-install-recommends python python3 bison flex make wget xz-utils libunwind-dev
# Install specific git version.
RUN export GIT_VER=2.21.0 \
@ -36,11 +36,6 @@ RUN wget -q https://github.com/Kitware/CMake/releases/download/v3.14.6/cmake-3.1
&& tar xf cmake-3.14.6-Linux-x86_64.tar.gz -C /usr/local --strip 1 \
&& rm cmake-3.14.6-Linux-x86_64.tar.gz
# Install build toolchain
RUN wget https://github.com/osquery/osquery-toolchain/releases/download/1.0.0/osquery-toolchain-1.0.0.tar.xz \
&& tar xf osquery-toolchain-1.0.0.tar.xz -C /usr/local \
&& rm osquery-toolchain-1.0.0.tar.xz
RUN git clone --depth 1 https://github.com/osquery/osquery osquery
WORKDIR osquery

View File

@ -24,19 +24,20 @@ PROJECT=osquery
mv "${SRC}/${PROJECT}-dev" "${SRC}/${PROJECT}" )
pushd "${SRC}/${PROJECT}"
mkdir build && pushd build
export CXXFLAGS="${CXXFLAGS} -Wl,-lunwind -Wl,-lc++abi"
export CFLAGS="${CFLAGS} -Wl,-lunwind"
# Prefer shared libs
sed -i 's/CMAKE_LINK_SEARCH_START_STATIC ON/CMAKE_LINK_SEARCH_START_STATIC OFF/g' cmake/flags.cmake
sed -i 's/CMAKE_LINK_SEARCH_END_STATIC ON/CMAKE_LINK_SEARCH_END_STATIC OFF/g' cmake/flags.cmake
mkdir build && pushd build
cmake \
-DOSQUERY_VERSION:string=0.0.0-fuzz \
-DOSQUERY_ENABLE_ADDRESS_SANITIZER:BOOL=ON \
-DOSQUERY_ENABLE_FUZZER_SANITIZERS:BOOL=ON \
-DOSQUERY_TOOLCHAIN_SYSROOT=/usr/local/osquery-toolchain \
..
cmake \
-DCMAKE_EXE_LINKER_FLAGS=${LIB_FUZZING_ENGINE} \
"-DCMAKE_EXE_LINKER_FLAGS=${LIB_FUZZING_ENGINE} -Wl,-rpath,'\$ORIGIN/lib'" \
..
# Build harnesses
@ -48,6 +49,10 @@ find . -type f -name '*.o' -delete
rm -rf "${SRC}/${PROJECT}/libraries/cmake/source/libudev/src/test"
rm -rf libs/src/patched-source/libudev/src/test
# Move libunwind to output path
mkdir -p "${OUT}/lib"
cp /usr/lib/x86_64-linux-gnu/libunwind.so.8 "${OUT}/lib"
# Move harnesses to output path
cp osquery/main/harnesses/osqueryfuzz-config "${OUT}/osqueryfuzz-config"
cp osquery/main/harnesses/osqueryfuzz-sqlquery "${OUT}/osqueryfuzz-sqlquery"