<commit_before># Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ARG parent_image=gcr.io/fuzzbench/base-builder
FROM $parent_image

# Need Clang/LLVM 3.8.
RUN apt-get update -y && \
    apt-get -y install llvm-3.8 \
    clang-3.8 \
    libstdc++-5-dev \
    wget

# Download AFL and compile using default compiler.
# We need afl-2.26b
RUN wget https://lcamtuf.coredump.cx/afl/releases/afl-2.26b.tgz -O /afl-2.26b.tgz && \
    tar xvzf /afl-2.26b.tgz -C / && \
    mv /afl-2.26b /afl && \
    cd /afl && \
    AFL_NO_X86=1 make

# Set the env variables for LLVM passes and test units.
ENV CC=clang-3.8
ENV CXX=clang++-3.8
ENV LLVM_CONFIG=llvm-config-3.8

# Build the LLVM passes with the LAF-INTEL patches, using Clang 3.8.
# We force linking by setting maybe_linking = 1, see https://github.com/google/AFL/commit/3ef34c16697715d64fecfaed46c0e31e86fa9f01#diff-49b21a9ca7039117ef774ba1adfa2962
RUN cd /afl/llvm_mode && \
    wget https://gitlab.com/laf-intel/laf-llvm-pass/raw/master/src/afl.patch && \
    patch -p0 < afl.patch && \
    sed -i 's/maybe_linking = 0/maybe_linking = 1/g' afl-clang-fast.c && \
    wget https://gitlab.com/laf-intel/laf-llvm-pass/raw/master/src/compare-transform-pass.so.cc && \
    wget https://gitlab.com/laf-intel/laf-llvm-pass/raw/master/src/split-compares-pass.so.cc && \
    wget https://gitlab.com/laf-intel/laf-llvm-pass/raw/master/src/split-switches-pass.so.cc && \
    sed -i 's/errs()/outs()/g' split-switches-pass.so.cc && \
    sed -i 's/errs()/outs()/g' split-compares-pass.so.cc && \
    sed -i 's/errs()/outs()/g' compare-transform-pass.so.cc && \
    CXXFLAGS= CFLAGS= make

# Use afl_driver.cpp from LLVM as our fuzzing library.
RUN wget https://raw.githubusercontent.com/llvm/llvm-project/master/compiler-rt/lib/fuzzer/afl/afl_driver.cpp -O /afl/afl_driver.cpp && \
    $CXX -I/usr/local/include/c++/v1/ -stdlib=libc++ -std=c++11 -O2 -c /afl/afl_driver.cpp && \
    ar r /libAFL.a *.o<commit_msg>use latest AFL code for lafintel (#208)<commit_after># Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ARG parent_image=gcr.io/fuzzbench/base-builder
FROM $parent_image

# Need Clang/LLVM 3.8.
RUN apt-get update -y && \
    apt-get -y install llvm-3.8 \
    clang-3.8 \
    libstdc++-5-dev \
    wget

# Download AFL and compile using default compiler.
# We need afl-2.26b
RUN wget https://lcamtuf.coredump.cx/afl/releases/afl-2.26b.tgz -O /afl-2.26b.tgz && \
    tar xvzf /afl-2.26b.tgz -C / && \
    mv /afl-2.26b /afl && \
    cd /afl && \
    git clone https://github.com/google/AFL.git /afl/recent_afl && \
    cd /afl/recent_afl && \ 
    git checkout 8da80951dd7eeeb3e3b5a3bcd36c485045f40274 && \
    cd /afl/ && \
    cp /afl/recent_afl/*.c /afl/ && \
    cp /afl/recent_afl/*.h /afl/ && \
    AFL_NO_X86=1 make

# Set the env variables for LLVM passes and test units.
ENV CC=clang-3.8
ENV CXX=clang++-3.8
ENV LLVM_CONFIG=llvm-config-3.8

# Build the LLVM passes with the LAF-INTEL patches, using Clang 3.8.
# We force linking by setting maybe_linking = 1, see https://github.com/google/AFL/commit/3ef34c16697715d64fecfaed46c0e31e86fa9f01#diff-49b21a9ca7039117ef774ba1adfa2962
RUN cd /afl/llvm_mode && \
    wget https://gitlab.com/laf-intel/laf-llvm-pass/raw/master/src/afl.patch && \
    patch -p0 < afl.patch && \
    sed -i 's/maybe_linking = 0/maybe_linking = 1/g' afl-clang-fast.c && \
    wget https://gitlab.com/laf-intel/laf-llvm-pass/raw/master/src/compare-transform-pass.so.cc && \
    wget https://gitlab.com/laf-intel/laf-llvm-pass/raw/master/src/split-compares-pass.so.cc && \
    wget https://gitlab.com/laf-intel/laf-llvm-pass/raw/master/src/split-switches-pass.so.cc && \
    sed -i 's/errs()/outs()/g' split-switches-pass.so.cc && \
    sed -i 's/errs()/outs()/g' split-compares-pass.so.cc && \
    sed -i 's/errs()/outs()/g' compare-transform-pass.so.cc && \
    CXXFLAGS= CFLAGS= make

# Use afl_driver.cpp from LLVM as our fuzzing library.
RUN wget https://raw.githubusercontent.com/llvm/llvm-project/master/compiler-rt/lib/fuzzer/afl/afl_driver.cpp -O /afl/afl_driver.cpp && \
    $CXX -I/usr/local/include/c++/v1/ -stdlib=libc++ -std=c++11 -O2 -c /afl/afl_driver.cpp && \
    ar r /libAFL.a *.o
{'fraction_non_alphanumeric': 0.14584532719247745, 'fraction_numerical': 0.04049126847054308, 'mean_word_length': 3.04344453064391, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 15, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3611092', 'n_tokens_mistral': 2145, 'n_tokens_neox': 2020, 'n_words': 466}