1*7330f729Sjoerg#===- llvm/tools/clang/tools/clang-fuzzer ---------------------------------===// 2*7330f729Sjoerg# 3*7330f729Sjoerg# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*7330f729Sjoerg# See https://llvm.org/LICENSE.txt for license information. 5*7330f729Sjoerg# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*7330f729Sjoerg# 7*7330f729Sjoerg#===----------------------------------------------------------------------===// 8*7330f729Sjoerg# Produces an image that builds clang-proto-fuzzer 9*7330f729SjoergFROM ubuntu:16.04 10*7330f729SjoergRUN apt-get update -y 11*7330f729SjoergRUN apt-get install -y autoconf automake libtool curl make g++ unzip wget git \ 12*7330f729Sjoerg binutils liblzma-dev libz-dev python-all cmake ninja-build subversion \ 13*7330f729Sjoerg pkg-config docbook2x 14*7330f729Sjoerg 15*7330f729SjoergWORKDIR /root 16*7330f729Sjoerg 17*7330f729Sjoerg# Get protobuf 18*7330f729SjoergRUN wget -qO- https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz | tar zxf - 19*7330f729SjoergRUN cd protobuf-3.3.0 && ./autogen.sh && ./configure && make -j $(nproc) && make check -j $(nproc) && make install && ldconfig 20*7330f729Sjoerg# Get LLVM 21*7330f729SjoergRUN svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm 22*7330f729SjoergRUN cd llvm/tools && svn co http://llvm.org/svn/llvm-project/cfe/trunk clang -r $(cd ../ && svn info | grep Revision | awk '{print $2}') 23*7330f729SjoergRUN cd llvm/projects && svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt -r $(cd ../ && svn info | grep Revision | awk '{print $2}') 24*7330f729Sjoerg# Build plain LLVM (stage 0) 25*7330f729SjoergRUN mkdir build0 && cd build0 && cmake -GNinja -DCMAKE_BUILD_TYPE=Release ../llvm && ninja 26*7330f729Sjoerg# Configure instrumented LLVM (stage 1) 27*7330f729SjoergRUN mkdir build1 && cd build1 && cmake -GNinja -DCMAKE_BUILD_TYPE=Release ../llvm \ 28*7330f729Sjoerg -DLLVM_ENABLE_ASSERTIONS=ON \ 29*7330f729Sjoerg -DCMAKE_C_COMPILER=`pwd`/../build0/bin/clang \ 30*7330f729Sjoerg -DCMAKE_CXX_COMPILER=`pwd`/../build0/bin/clang++ \ 31*7330f729Sjoerg -DLLVM_USE_SANITIZE_COVERAGE=YES \ 32*7330f729Sjoerg -DLLVM_USE_SANITIZER=Address -DCLANG_ENABLE_PROTO_FUZZER=ON 33*7330f729Sjoerg# Build the fuzzers 34*7330f729SjoergRUN cd build1 && ninja clang-fuzzer 35*7330f729SjoergRUN cd build1 && ninja clang-objc-fuzzer 36*7330f729SjoergRUN cd build1 && ninja clang-proto-fuzzer 37*7330f729SjoergRUN cd build1 && ninja clang-proto-to-cxx 38*7330f729SjoergRUN cd build1 && ninja clang-loop-proto-to-cxx 39*7330f729SjoergRUN cd build1 && ninja clang-loop-proto-to-llvm 40*7330f729SjoergRUN cd build1 && ninja clang-loop-proto-fuzzer 41*7330f729SjoergRUN cd build1 && ninja clang-llvm-proto-fuzzer 42