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