-
Notifications
You must be signed in to change notification settings - Fork 286
Open
Description
The symcc-* fuzzers all fail to build yielding compilation faults like
148.4 /symcc/compiler/Symbolizer.h:209:11: error: no member named 'getInt8PtrTy' in 'llvm::IntegerType'; did you mean 'llvm::IRBuilderBase::getIntPtrTy'?
148.4 209 | llvm::IntegerType::getInt8PtrTy(V->getContext()));
148.4 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
148.4 | llvm::IRBuilderBase::getIntPtrTy
148.4 /usr/local/include/llvm/IR/IRBuilder.h:611:16: note: 'llvm::IRBuilderBase::getIntPtrTy' declared here
148.4 611 | IntegerType *getIntPtrTy(const DataLayout &DL, unsigned AddrSpace = 0) {
148.4 | ^
Then I figured out that gcr.io/fuzzbench/builders/symcc_*/$benchmark images inherit the local-built clang from the oss-fuzz/base-clang image. Since symcc requires llvm-8/9/10, the daily updated base image breaks the dependency.
The temporary solution is to install llvm-10-dev via apt, and specify the /usr/lib/llvm-10 and /usr/bin/llvm in successive build args, since the custom built /usr/local posses higher priority than system distribution.
--- a/fuzzers/symcc_afl/builder.Dockerfile
+++ b/fuzzers/symcc_afl/builder.Dockerfile
@@ -44,6 +44,13 @@ RUN wget -qO /tmp/z3x64.zip https://github.com/Z3Prover/z3/releases/download/z3-
ENV CFLAGS=""
ENV CXXFLAGS=""
+RUN apt install -y git cargo clang-10 cmake g++ git libz3-dev llvm-10-dev llvm-10-tools ninja-build python2 python3-pip zlib1g-dev && pip3 install lit
+# Get and install symcc.
+# 设置LLVM-10的路径环境变量
+ENV LLVM_CONFIG=/usr/bin/llvm-config-10
+ENV CC=/usr/bin/clang-10
+ENV CXX=/usr/bin/clang++-10
+
# Get and install symcc.
RUN cd / && \
git clone https://github.com/AdaLogics/adacc symcc && \
@@ -52,33 +59,54 @@ RUN cd / && \
cd ./runtime/qsym_backend && \
git clone https://github.com/adalogics/qsym && \
cd qsym && \
- git checkout adalogics && \
- cd /symcc && \
+ git checkout adalogics
+RUN cd /symcc && \
mkdir build && \
cd build && \
+ # 关键修改:显式指定LLVM路径
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DQSYM_BACKEND=ON \
- -DZ3_TRUST_SYSTEM_VERSION=ON ../ && \
+ -DZ3_TRUST_SYSTEM_VERSION=ON \
+ -DLLVM_DIR=/usr/lib/llvm-10/lib/cmake/llvm \
+ -DClang_DIR=/usr/lib/llvm-10/lib/cmake/clang \
+ -DCMAKE_PREFIX_PATH="/usr/lib/llvm-10;/usr/lib/llvm-10/lib/cmake" \
+ -DCMAKE_C_COMPILER=/usr/bin/clang-10 \
+ -DCMAKE_CXX_COMPILER=/usr/bin/clang++-10 \
+ -DCMAKE_CXX_FLAGS="-I/usr/lib/llvm-10/include -I/usr/include/llvm-10 -I/usr/include/llvm-c-10" \
+ -DCMAKE_EXE_LINKER_FLAGS="-L/usr/lib/llvm-10/lib -Wl,-rpath,/usr/lib/llvm-10/lib" .. && \
ninja -j 3 && \
cd ../examples && \
export SYMCC_PC=1 && \
../build/symcc -c ./libfuzz-harness-proxy.c -o /libfuzzer-harness.o && \
cd ../ && echo "[+] Installing cargo now 4" && \
- cargo install --path util/symcc_fuzzing_helper
+ /usr/bin/cargo install --path util/symcc_fuzzing_helper
# Build libcxx with the SymCC compiler so we can instrument
# C++ code.
-RUN git clone -b llvmorg-12.0.0 --depth 1 https://github.com/llvm/llvm-project.git /llvm_source && \
- mkdir /libcxx_native_install && mkdir /libcxx_native_build && \
- cd /libcxx_native_install \
- && export SYMCC_REGULAR_LIBCXX="" && \
- cmake /llvm_source/llvm \
- -G Ninja -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" \
- -DLLVM_DISTRIBUTION_COMPONENTS="cxx;cxxabi;cxx-headers" \
- -DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_BUILD_TYPE=Release \
- -DCMAKE_C_COMPILER=/symcc/build/symcc \
- -DCMAKE_CXX_COMPILER=/symcc/build/sym++ \
- -DHAVE_POSIX_REGEX=1 \
+RUN git clone -b llvmorg-12.0.0 --depth 1 https://github.com/llvm/llvm-project.git /llvm_source && \
+ mkdir /libcxx_native_install && mkdir /libcxx_native_build
+RUN sed -i 's/-Qunused-arguments/-Qunused-arguments -lLLVM-10/g' /symcc/build/symcc && \
+ sed -i 's/-Qunused-arguments/-Qunused-arguments -lLLVM-10/g' /symcc/build/sym++
+RUN cd /libcxx_native_install && \
+ export SYMCC_REGULAR_LIBCXX="" && \
+ # 设置LD_LIBRARY_PATH指向LLVM-10的库
+ LD_LIBRARY_PATH=/usr/lib/llvm-10/lib \
+ LIBRARY_PATH=/usr/lib/llvm-10/lib \
+ cmake /llvm_source/llvm \
+ -G Ninja -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" \
+ -DLLVM_DISTRIBUTION_COMPONENTS="cxx;cxxabi;cxx-headers" \
+ -DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_C_COMPILER=/symcc/build/symcc \
+ -DCMAKE_CXX_COMPILER=/symcc/build/sym++ \
+ -DHAVE_POSIX_REGEX=1 \
+ -DHAVE_STEADY_CLOCK=1 \
-DCMAKE_INSTALL_PREFIX="/libcxx_native_build" \
- -DHAVE_STEADY_CLOCK=1 && \
- ninja distribution && \
- ninja install-distribution
+ # RPATH问题
+ -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
+ -DCMAKE_INSTALL_RPATH="/usr/lib/llvm-10/lib;/symcc/build/SymRuntime-prefix/src/SymRuntime-build" \
+ -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE \
+ # 设置链接器标志,强制使用LLVM-10的库
+ -DCMAKE_EXE_LINKER_FLAGS="-Wl,-rpath,/usr/lib/llvm-10/lib -L/usr/lib/llvm-10/lib" \
+ -DCMAKE_SHARED_LINKER_FLAGS="-Wl,-rpath,/usr/lib/llvm-10/lib -L/usr/lib/llvm-10/lib" && \
+ # 构建时也设置库路径
+ LD_LIBRARY_PATH=/usr/lib/llvm-10/lib ninja distribution && \
+ LD_LIBRARY_PATH=/usr/lib/llvm-10/lib ninja install-distributionBesides, it seems that problems also exist about symcc_fuzzing_helper and rust toolchain (no /rust found)
Metadata
Metadata
Assignees
Labels
No labels