• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 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
18RUN apt-get update && apt-get install -y make autoconf automake libtool \
19    build-essential libbz2-dev ninja-build zlib1g-dev wget python python-dev \
20    liblzma-dev uuid-dev pkg-config openjdk-8-jdk unzip mlton
21
22RUN git clone --recursive -b breaking https://github.com/ethereum/solidity.git solidity
23RUN git clone --depth 1 https://github.com/ethereum/solidity-fuzzing-corpus.git
24RUN git clone --depth 1 https://github.com/google/libprotobuf-mutator.git
25RUN git clone --branch="v0.4.0" --recurse-submodules \
26    https://github.com/ethereum/evmone.git
27
28# Install statically built dependencies in "/usr" directory
29# Install boost
30RUN cd $SRC; \
31    wget -q 'https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.tar.bz2' -O boost.tar.bz2; \
32    test "$(sha256sum boost.tar.bz2)" = "4eb3b8d442b426dc35346235c8733b5ae35ba431690e38c6a8263dce9fcbb402  boost.tar.bz2"; \
33    tar -xf boost.tar.bz2; \
34    rm boost.tar.bz2; \
35    cd boost_1_73_0; \
36    CXXFLAGS="-stdlib=libc++ -pthread" LDFLAGS="-stdlib=libc++" ./bootstrap.sh --with-toolset=clang --prefix=/usr; \
37    ./b2 toolset=clang cxxflags="-stdlib=libc++ -pthread" linkflags="-stdlib=libc++ -pthread" headers; \
38    ./b2 toolset=clang cxxflags="-stdlib=libc++ -pthread" linkflags="-stdlib=libc++ -pthread" \
39        link=static variant=release runtime-link=static \
40        system filesystem unit_test_framework program_options \
41        install -j $(($(nproc)/2)); \
42    rm -rf $SRC/boost_1_73_0
43
44# Install libprotobuf-mutator
45RUN mkdir $SRC/LPM; \
46    cd $SRC/LPM; \
47    cmake $SRC/libprotobuf-mutator -GNinja \
48    -DLIB_PROTO_MUTATOR_DOWNLOAD_PROTOBUF=ON -DLIB_PROTO_MUTATOR_TESTING=OFF \
49    -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/usr"; \
50    ninja; \
51    ninja install; \
52    cd external.protobuf; \
53    cp -Rf bin lib include /usr;
54
55# Install evmone
56RUN cd $SRC/evmone; \
57    mkdir -p build; \
58    cd build; \
59    cmake .. -G Ninja -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="/usr"; \
60    ninja; \
61    ninja install;
62
63# gmp
64RUN cd $SRC; \
65    # Replace system installed libgmp static library
66    # with sanitized version
67    rm -f /usr/lib/x86_64-linux-gnu/libgmp.a; \
68    wget -q 'https://gmplib.org/download/gmp/gmp-6.2.1.tar.xz' -O gmp.tar.xz; \
69    test "$(sha256sum gmp.tar.xz)" = "fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2  gmp.tar.xz"; \
70    tar -xf gmp.tar.xz; \
71    cd gmp-6.2.1; \
72    ./configure --prefix=/usr --enable-shared=no --enable-static=yes; \
73    make -j; \
74    make install; \
75    rm -rf $SRC/gmp-6.2.1; \
76    rm -f $SRC/gmp.tar.xz
77
78# libabicoder
79RUN set -ex; \
80    cd /usr/src; \
81    git clone https://github.com/ekpyron/Yul-Isabelle; \
82    cd Yul-Isabelle; \
83    cd libabicoder; \
84    CXX=clang++ CXXFLAGS="-stdlib=libc++ -pthread" make; \
85    cp libabicoder.a /usr/lib; \
86    cp abicoder.hpp /usr/include; \
87    rm -rf /usr/src/Yul-Isabelle
88
89COPY build.sh $SRC/
90