1# 2# This Dockerfile for AFLplusplus uses Ubuntu 22.04 jammy and 3# installs LLVM 14 for afl-clang-lto support. 4# 5# GCC 11 is used instead of 12 because genhtml for afl-cov doesn't like it. 6# 7 8FROM ubuntu:22.04 AS aflplusplus 9LABEL "maintainer"="AFL++ team <[email protected]>" 10LABEL "about"="AFLplusplus container image" 11 12### Comment out to enable these features 13# Only available on specific ARM64 boards 14ENV NO_CORESIGHT=1 15# Possible but unlikely in a docker container 16ENV NO_NYX=1 17 18### Only change these if you know what you are doing: 19# Current recommended LLVM version is 16 20ENV LLVM_VERSION=16 21# GCC 12 is producing compile errors for some targets so we stay at GCC 11 22ENV GCC_VERSION=11 23 24### No changes beyond the point unless you know what you are doing :) 25 26ARG DEBIAN_FRONTEND=noninteractive 27 28ENV NO_ARCH_OPT=1 29ENV IS_DOCKER=1 30 31RUN apt-get update && apt-get full-upgrade -y && \ 32 apt-get install -y --no-install-recommends wget ca-certificates apt-utils && \ 33 rm -rf /var/lib/apt/lists/* 34 35RUN echo "deb [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg.key] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-${LLVM_VERSION} main" > /etc/apt/sources.list.d/llvm.list && \ 36 wget -qO /etc/apt/keyrings/llvm-snapshot.gpg.key https://apt.llvm.org/llvm-snapshot.gpg.key 37 38RUN apt-get update && \ 39 apt-get -y install --no-install-recommends \ 40 make cmake automake meson ninja-build bison flex \ 41 git xz-utils bzip2 wget jupp nano bash-completion less vim joe ssh psmisc \ 42 python3 python3-dev python3-pip python-is-python3 \ 43 libtool libtool-bin libglib2.0-dev \ 44 apt-transport-https gnupg dialog \ 45 gnuplot-nox libpixman-1-dev bc \ 46 gcc-${GCC_VERSION} g++-${GCC_VERSION} gcc-${GCC_VERSION}-plugin-dev gdb lcov \ 47 clang-${LLVM_VERSION} clang-tools-${LLVM_VERSION} libc++1-${LLVM_VERSION} \ 48 libc++-${LLVM_VERSION}-dev libc++abi1-${LLVM_VERSION} libc++abi-${LLVM_VERSION}-dev \ 49 libclang1-${LLVM_VERSION} libclang-${LLVM_VERSION}-dev \ 50 libclang-common-${LLVM_VERSION}-dev libclang-rt-${LLVM_VERSION}-dev libclang-cpp${LLVM_VERSION} \ 51 libclang-cpp${LLVM_VERSION}-dev liblld-${LLVM_VERSION} \ 52 liblld-${LLVM_VERSION}-dev liblldb-${LLVM_VERSION} liblldb-${LLVM_VERSION}-dev \ 53 libllvm${LLVM_VERSION} libomp-${LLVM_VERSION}-dev libomp5-${LLVM_VERSION} \ 54 lld-${LLVM_VERSION} lldb-${LLVM_VERSION} llvm-${LLVM_VERSION} \ 55 llvm-${LLVM_VERSION}-dev llvm-${LLVM_VERSION}-runtime llvm-${LLVM_VERSION}-tools \ 56 $([ "$(dpkg --print-architecture)" = "amd64" ] && echo gcc-${GCC_VERSION}-multilib gcc-multilib) \ 57 $([ "$(dpkg --print-architecture)" = "arm64" ] && echo libcapstone-dev) && \ 58 rm -rf /var/lib/apt/lists/* 59 # gcc-multilib is only used for -m32 support on x86 60 # libcapstone-dev is used for coresight_mode on arm64 61 62RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_VERSION} 0 && \ 63 update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${GCC_VERSION} 0 && \ 64 update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${LLVM_VERSION} 0 && \ 65 update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${LLVM_VERSION} 0 66 67RUN wget -qO- https://sh.rustup.rs | CARGO_HOME=/etc/cargo sh -s -- -y -q --no-modify-path 68ENV PATH=$PATH:/etc/cargo/bin 69 70RUN apt clean -y 71 72ENV LLVM_CONFIG=llvm-config-${LLVM_VERSION} 73ENV AFL_SKIP_CPUFREQ=1 74ENV AFL_TRY_AFFINITY=1 75ENV AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 76 77RUN git clone --depth=1 https://github.com/vanhauser-thc/afl-cov && \ 78 (cd afl-cov && make install) && rm -rf afl-cov 79 80WORKDIR /AFLplusplus 81COPY . . 82 83ARG CC=gcc-$GCC_VERSION 84ARG CXX=g++-$GCC_VERSION 85 86# Used in CI to prevent a 'make clean' which would remove the binaries to be tested 87ARG TEST_BUILD 88 89RUN sed -i.bak 's/^ -/ /g' GNUmakefile && \ 90 make clean && make distrib && \ 91 ([ "${TEST_BUILD}" ] || (make install)) && \ 92 mv GNUmakefile.bak GNUmakefile 93 94RUN echo "set encoding=utf-8" > /root/.vimrc && \ 95 echo ". /etc/bash_completion" >> ~/.bashrc && \ 96 echo 'alias joe="joe --wordwrap --joe_state -nobackup"' >> ~/.bashrc && \ 97 echo "export PS1='"'[AFL++ \h] \w \$ '"'" >> ~/.bashrc 98