• 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    cmake \
33    ninja-build
34
35# Install and build boost from source so we can have it use libc++
36RUN wget https://sourceforge.net/projects/boost/files/boost/1.70.0/boost_1_70_0.tar.gz && \
37    tar xzf boost_1_70_0.tar.gz && \
38    cd boost_1_70_0 && \
39    ./bootstrap.sh --with-toolset=clang && \
40    ./b2 clean && \
41    ./b2 toolset=clang cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++" -j$(nproc) install && \
42    cd .. && \
43    rm -rf boost_1_70_0
44
45# Build gflags/glog/gtest from source so we use libc++ and avoid incompatibilities with the std::string ABI breaking changes
46RUN sudo apt-get purge libgflags-dev
47
48RUN wget https://github.com/gflags/gflags/archive/v2.2.2.tar.gz && \
49    tar xzf v2.2.2.tar.gz && \
50    cd gflags-2.2.2 && \
51    mkdir build && \
52    cd build && \
53    export CC=clang && \
54    export CXX=clang++ && \
55    export CXXFLAGS="-stdlib=libc++" && \
56    cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON .. && \
57    make -j$(nproc) && \
58    sudo make install && \
59    cd ../../ && \
60    rm -rf gflags-2.2.2
61
62RUN wget https://github.com/google/glog/archive/v0.4.0.tar.gz && \
63    tar xzf v0.4.0.tar.gz && \
64    cd glog-0.4.0 && \
65    export CC=clang && \
66    export CXX=clang++ && \
67    export CXXFLAGS="-stdlib=libc++" && \
68    mkdir build && \
69    cd build && \
70    cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_VERBOSE_MAKEFILE=ON .. && \
71    make -j$(nproc) && \
72    sudo make install && \
73    cd ../.. && \
74    rm -rf glog-0.4.0
75
76RUN wget https://github.com/google/googletest/archive/release-1.8.1.tar.gz && \
77    tar xzf release-1.8.1.tar.gz && \
78    cd googletest-release-1.8.1 && \
79    export CC=clang && \
80    export CXX=clang++ && \
81    export CXXFLAGS="-stdlib=libc++" && \
82    mkdir build && \
83    cd build && \
84    cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_VERBOSE_MAKEFILE=ON .. && \
85    make -j$(nproc) && \
86    sudo make install && \
87    cd ../.. && \
88    rm -rf googletest-release-1.8.1
89
90# Build and install zstd from source so we have it available for proxygen
91RUN wget https://github.com/facebook/zstd/releases/download/v1.4.2/zstd-1.4.2.tar.gz && \
92    tar xzf zstd-1.4.2.tar.gz && \
93    cd zstd-1.4.2 && \
94    export CC=clang && \
95    export CXX=clang++ && \
96    export CXXFLAGS="-stdlib=libc++" && \
97    sudo make -j$(nproc) install && \
98    cd .. && \
99    rm -rf zstd-1.4.2
100
101# Get double conversion
102RUN git clone --single-branch https://github.com/google/double-conversion.git double-conversion && \
103    cd double-conversion/double-conversion && \
104    cmake -GNinja ../ && \
105    ninja && \
106    ninja install
107
108# Build and install `fmt` needed by folly
109RUN wget https://github.com/fmtlib/fmt/archive/6.0.0.tar.gz && \
110    tar xzf 6.0.0.tar.gz && \
111    cd fmt-6.0.0 && \
112    export CC=clang && \
113    export CXX=clang++ && \
114    export CXXFLAGS="-stdlib=libc++" && \
115    mkdir build && \
116    cd build && \
117    cmake .. && \
118    make -j$(nproc) && \
119    sudo make install && \
120    cd ../.. && \
121    rm -rf fmt-6.0.0
122
123# Build and install `gperf` (>= 3.1)
124RUN wget http://ftp.gnu.org/pub/gnu/gperf/gperf-3.1.tar.gz && \
125    rm -rf gperf-3.1 | true && \
126    tar xzvf gperf-3.1.tar.gz && \
127    cd gperf-3.1 && \
128    export CC=gcc && \
129    export CXX=g++ && \
130    export CXXFLAGS="" && \
131    export CFLAGS_TMP="$CFLAGS" && \
132    unset CFLAGS && \
133    ./configure && \
134    make -j1 V=s && \
135    sudo make install && \
136    export CFLAGS="$CFLAGS_TMP" && \
137    unset CFLAGS_TMP && \
138    cd .. && \
139    rm -rf gperf-3.1
140
141# Replicate `install-dependencies` from the proxygen `build.sh` script
142RUN apt-get install -y \
143    git \
144    flex \
145    bison \
146    libkrb5-dev \
147    libsasl2-dev \
148    libnuma-dev \
149    pkg-config \
150    libssl-dev \
151    libcap-dev \
152    libevent-dev \
153    libtool \
154    libjemalloc-dev \
155    unzip \
156    libiberty-dev \
157    liblzma-dev \
158    zlib1g-dev \
159    binutils-dev \
160    libsodium-dev \
161    libunwind8-dev
162
163# Install patchelf so we can fix path to libunwind
164RUN apt-get install patchelf
165
166# Fetch source and copy over files
167RUN git clone --depth 1 https://github.com/facebook/proxygen.git proxygen
168WORKDIR proxygen
169COPY build.sh $SRC/
170