• 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 develop 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
25# evmone v0.8.2 fixes: https://github.com/ethereum/evmone/issues/373
26RUN git clone --branch="v0.8.2" --recurse-submodules \
27    https://github.com/ethereum/evmone.git
28
29# Install statically built dependencies in "/usr" directory
30# Install boost
31RUN cd $SRC; \
32    wget -q 'https://boostorg.jfrog.io/artifactory/main/release/1.73.0/source/boost_1_73_0.tar.bz2' -O boost.tar.bz2; \
33    test "$(sha256sum boost.tar.bz2)" = "4eb3b8d442b426dc35346235c8733b5ae35ba431690e38c6a8263dce9fcbb402  boost.tar.bz2"; \
34    tar -xf boost.tar.bz2; \
35    rm boost.tar.bz2; \
36    cd boost_1_73_0; \
37    CXXFLAGS="-stdlib=libc++ -pthread" LDFLAGS="-stdlib=libc++" ./bootstrap.sh --with-toolset=clang --prefix=/usr; \
38    ./b2 toolset=clang cxxflags="-stdlib=libc++ -pthread" linkflags="-stdlib=libc++ -pthread" headers; \
39    ./b2 toolset=clang cxxflags="-stdlib=libc++ -pthread" linkflags="-stdlib=libc++ -pthread" \
40        link=static variant=release runtime-link=static \
41        system filesystem unit_test_framework program_options \
42        install -j $(($(nproc)/2)); \
43    rm -rf $SRC/boost_1_73_0
44
45# Install libprotobuf-mutator
46RUN mkdir $SRC/LPM; \
47    cd $SRC/LPM; \
48    cmake $SRC/libprotobuf-mutator -GNinja \
49    -DLIB_PROTO_MUTATOR_DOWNLOAD_PROTOBUF=ON -DLIB_PROTO_MUTATOR_TESTING=OFF \
50    -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/usr"; \
51    ninja; \
52    ninja install; \
53    cd external.protobuf; \
54    cp -Rf bin lib include /usr;
55
56# Install evmone
57RUN cd $SRC/evmone; \
58    mkdir -p build; \
59    cd build; \
60    cmake .. -G Ninja -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="/usr"; \
61    ninja; \
62    ninja install;
63
64# gmp
65RUN cd $SRC; \
66    # Replace system installed libgmp static library
67    # with sanitized version
68    rm -f /usr/lib/x86_64-linux-gnu/libgmp.a; \
69    wget -q 'https://gmplib.org/download/gmp/gmp-6.2.1.tar.xz' -O gmp.tar.xz; \
70    test "$(sha256sum gmp.tar.xz)" = "fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2  gmp.tar.xz"; \
71    tar -xf gmp.tar.xz; \
72    cd gmp-6.2.1; \
73    ./configure --prefix=/usr --enable-shared=no --enable-static=yes; \
74    make -j; \
75    make install; \
76    rm -rf $SRC/gmp-6.2.1; \
77    rm -f $SRC/gmp.tar.xz
78
79# libabicoder
80RUN set -ex; \
81    cd /usr/src; \
82    git clone https://github.com/ekpyron/Yul-Isabelle; \
83    cd Yul-Isabelle; \
84    cd libabicoder; \
85    CXX=clang++ CXXFLAGS="-stdlib=libc++ -pthread" make; \
86    cp libabicoder.a /usr/lib; \
87    cp abicoder.hpp /usr/include; \
88    rm -rf /usr/src/Yul-Isabelle
89
90COPY build.sh $SRC/
91