13e78c4bdSKostya Serebryany#===- llvm/tools/clang/tools/clang-fuzzer ---------------------------------===// 23e78c4bdSKostya Serebryany# 32946cd70SChandler Carruth# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 42946cd70SChandler Carruth# See https://llvm.org/LICENSE.txt for license information. 52946cd70SChandler Carruth# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 63e78c4bdSKostya Serebryany# 73e78c4bdSKostya Serebryany#===----------------------------------------------------------------------===// 83e78c4bdSKostya Serebryany# Produces an image that builds clang-proto-fuzzer 93e78c4bdSKostya SerebryanyFROM ubuntu:16.04 103e78c4bdSKostya SerebryanyRUN apt-get update -y 113e78c4bdSKostya SerebryanyRUN apt-get install -y autoconf automake libtool curl make g++ unzip wget git \ 123e78c4bdSKostya Serebryany binutils liblzma-dev libz-dev python-all cmake ninja-build subversion \ 133e78c4bdSKostya Serebryany pkg-config docbook2x 143e78c4bdSKostya Serebryany 153e78c4bdSKostya SerebryanyWORKDIR /root 163e78c4bdSKostya Serebryany 173e78c4bdSKostya Serebryany# Get protobuf 183e78c4bdSKostya SerebryanyRUN wget -qO- https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz | tar zxf - 193e78c4bdSKostya SerebryanyRUN cd protobuf-3.3.0 && ./autogen.sh && ./configure && make -j $(nproc) && make check -j $(nproc) && make install && ldconfig 203e78c4bdSKostya Serebryany# Get LLVM 213e78c4bdSKostya SerebryanyRUN svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm 223e78c4bdSKostya SerebryanyRUN cd llvm/tools && svn co http://llvm.org/svn/llvm-project/cfe/trunk clang -r $(cd ../ && svn info | grep Revision | awk '{print $2}') 233e78c4bdSKostya SerebryanyRUN 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}') 243e78c4bdSKostya Serebryany# Build plain LLVM (stage 0) 253e78c4bdSKostya SerebryanyRUN mkdir build0 && cd build0 && cmake -GNinja -DCMAKE_BUILD_TYPE=Release ../llvm && ninja 263e78c4bdSKostya Serebryany# Configure instrumented LLVM (stage 1) 273e78c4bdSKostya SerebryanyRUN mkdir build1 && cd build1 && cmake -GNinja -DCMAKE_BUILD_TYPE=Release ../llvm \ 283e78c4bdSKostya Serebryany -DLLVM_ENABLE_ASSERTIONS=ON \ 293e78c4bdSKostya Serebryany -DCMAKE_C_COMPILER=`pwd`/../build0/bin/clang \ 303e78c4bdSKostya Serebryany -DCMAKE_CXX_COMPILER=`pwd`/../build0/bin/clang++ \ 313e78c4bdSKostya Serebryany -DLLVM_USE_SANITIZE_COVERAGE=YES \ 323e78c4bdSKostya Serebryany -DLLVM_USE_SANITIZER=Address -DCLANG_ENABLE_PROTO_FUZZER=ON 333e78c4bdSKostya Serebryany# Build the fuzzers 343e78c4bdSKostya SerebryanyRUN cd build1 && ninja clang-fuzzer 35*e5ecba4fSDavid GoldmanRUN cd build1 && ninja clang-objc-fuzzer 363e78c4bdSKostya SerebryanyRUN cd build1 && ninja clang-proto-fuzzer 373e78c4bdSKostya SerebryanyRUN cd build1 && ninja clang-proto-to-cxx 3870657f65SEmmett NeymanRUN cd build1 && ninja clang-loop-proto-to-cxx 3970657f65SEmmett NeymanRUN cd build1 && ninja clang-loop-proto-to-llvm 4070657f65SEmmett NeymanRUN cd build1 && ninja clang-loop-proto-fuzzer 4170657f65SEmmett NeymanRUN cd build1 && ninja clang-llvm-proto-fuzzer 42