• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2019 Google Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15################################################################################
16
17FROM gcr.io/oss-fuzz-base/base-builder
18
19# Install packages we need to build dependencies
20RUN apt-get update && \
21    apt-get install -y \
22    make \
23    autoconf \
24    automake \
25    libtool \
26    sudo \
27    wget \
28    gcc \
29    g++ \
30    python \
31    python-dev
32
33# Install and build boost from source so we can have it use libc++
34RUN wget https://sourceforge.net/projects/boost/files/boost/1.70.0/boost_1_70_0.tar.gz && \
35    tar xzf boost_1_70_0.tar.gz && \
36    cd boost_1_70_0 && \
37    ./bootstrap.sh --with-toolset=clang && \
38    ./b2 clean && \
39    ./b2 toolset=clang cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++" -j$(nproc) install && \
40    cd .. && \
41    rm -rf boost_1_70_0
42
43# Build gflags/glog/gtest from source so we use libc++ and avoid incompatibilities with the std::string ABI breaking changes
44RUN sudo apt-get purge libgflags-dev
45
46RUN wget https://github.com/gflags/gflags/archive/v2.2.2.tar.gz && \
47    tar xzf v2.2.2.tar.gz && \
48    cd gflags-2.2.2 && \
49    mkdir build && \
50    cd build && \
51    export CC=clang && \
52    export CXX=clang++ && \
53    export CXXFLAGS="-stdlib=libc++" && \
54    cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON .. && \
55    make -j$(nproc) && \
56    sudo make install && \
57    cd ../../ && \
58    rm -rf gflags-2.2.2
59
60RUN wget https://github.com/google/glog/archive/v0.4.0.tar.gz && \
61    tar xzf v0.4.0.tar.gz && \
62    cd glog-0.4.0 && \
63    export CC=clang && \
64    export CXX=clang++ && \
65    export CXXFLAGS="-stdlib=libc++" && \
66    mkdir build && \
67    cd build && \
68    cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_VERBOSE_MAKEFILE=ON .. && \
69    make -j$(nproc) && \
70    sudo make install && \
71    cd ../.. && \
72    rm -rf glog-0.4.0
73
74RUN wget https://github.com/google/googletest/archive/release-1.8.1.tar.gz && \
75    tar xzf release-1.8.1.tar.gz && \
76    cd googletest-release-1.8.1 && \
77    export CC=clang && \
78    export CXX=clang++ && \
79    export CXXFLAGS="-stdlib=libc++" && \
80    mkdir build && \
81    cd build && \
82    cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_VERBOSE_MAKEFILE=ON .. && \
83    make -j$(nproc) && \
84    sudo make install && \
85    cd ../.. && \
86    rm -rf googletest-release-1.8.1
87
88# Build and install zstd from source so we have it available for proxygen
89RUN wget https://github.com/facebook/zstd/releases/download/v1.4.2/zstd-1.4.2.tar.gz && \
90    tar xzf zstd-1.4.2.tar.gz && \
91    cd zstd-1.4.2 && \
92    export CC=clang && \
93    export CXX=clang++ && \
94    export CXXFLAGS="-stdlib=libc++" && \
95    sudo make -j$(nproc) install && \
96    cd .. && \
97    rm -rf zstd-1.4.2
98
99# Build and install `fmt` needed by folly
100RUN wget https://github.com/fmtlib/fmt/archive/6.0.0.tar.gz && \
101    tar xzf 6.0.0.tar.gz && \
102    cd fmt-6.0.0 && \
103    export CC=clang && \
104    export CXX=clang++ && \
105    export CXXFLAGS="-stdlib=libc++" && \
106    mkdir build && \
107    cd build && \
108    cmake .. && \
109    make -j$(nproc) && \
110    sudo make install && \
111    cd ../.. && \
112    rm -rf fmt-6.0.0
113
114# Build and install `gperf` (>= 3.1)
115RUN wget http://ftp.gnu.org/pub/gnu/gperf/gperf-3.1.tar.gz && \
116    rm -rf gperf-3.1 | true && \
117    tar xzvf gperf-3.1.tar.gz && \
118    cd gperf-3.1 && \
119    export CC=gcc && \
120    export CXX=g++ && \
121    export CXXFLAGS="" && \
122    export CFLAGS_TMP="$CFLAGS" && \
123    unset CFLAGS && \
124    ./configure && \
125    make -j1 V=s && \
126    sudo make install && \
127    export CFLAGS="$CFLAGS_TMP" && \
128    unset CFLAGS_TMP && \
129    cd .. && \
130    rm -rf gperf-3.1
131
132# Replicate `install-dependencies` from the proxygen `build.sh` script
133RUN apt-get install -y \
134    git \
135    flex \
136    bison \
137    libkrb5-dev \
138    libsasl2-dev \
139    libnuma-dev \
140    pkg-config \
141    libssl-dev \
142    libcap-dev \
143    libevent-dev \
144    libtool \
145    libjemalloc-dev \
146    unzip \
147    libiberty-dev \
148    liblzma-dev \
149    zlib1g-dev \
150    binutils-dev \
151    libsodium-dev \
152    libdouble-conversion-dev \
153    libunwind8-dev
154
155# Install patchelf so we can fix path to libunwind
156RUN apt-get install patchelf
157
158# Fetch source and copy over files
159RUN git clone --depth 1 https://github.com/facebook/proxygen.git proxygen
160WORKDIR proxygen
161COPY build.sh $SRC/
162