Add header (#1777)

* add

* rdm

* CHATGPT

* CHATDUMB

* different action

* no

* fix

* ci

* ci

* ci

* fuck

* dir

* checkout?

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* ci

* don't use shit

* ci

* ci

* ci
This commit is contained in:
Dongjia "toka" Zhang 2024-01-05 19:35:36 +01:00 committed by GitHub
parent 207e7dbdff
commit 0a72d8abbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 79 additions and 56 deletions

View File

@ -57,6 +57,29 @@ jobs:
- name: Test libafl_targets no_std - name: Test libafl_targets no_std
run: cd libafl_targets && cargo test --no-default-features run: cd libafl_targets && cargo test --no-default-features
llvm-tester:
runs-on: ubuntu-22.04
continue-on-error: true
strategy:
matrix:
llvm-version: ["11", "12", "13", "14", "16", "17"]
steps:
- name: Remove Dotnet & Haskell
run: rm -rf /usr/share/dotnet && rm -rf /opt/ghc
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
version: "${{matrix.llvm-version}}"
- name: Build and test with llvm-${{ matrix.llvm-version }}
run: pwd && ls & cd libafl_cc && cargo build --release
ubuntu: ubuntu:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
@ -67,20 +90,20 @@ jobs:
profile: minimal profile: minimal
toolchain: stable toolchain: stable
- name: Remove existing clang and LLVM - name: Remove existing clang and LLVM
run: sudo apt purge llvm* clang* run: sudo apt purge llvm* clang* lld* lldb* opt*
- name: Install and cache deps - name: Install and cache deps
uses: awalsh128/cache-apt-pkgs-action@v1.1.0 run: sudo apt install ninja-build clang-format-13 shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev
with:
packages: llvm-15 llvm-15-dev clang-15 ninja-build clang-format-13 shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev
- name: get clang version
run: command -v llvm-config-15 && clang-15 -v
- name: Add nightly rustfmt and clippy - name: Add nightly rustfmt and clippy
run: rustup toolchain install nightly --component rustfmt --component clippy --component miri --allow-downgrade run: rustup toolchain install nightly --component rustfmt --component clippy --component miri --allow-downgrade
- name: Install ucd-generate - name: Install ucd-generate
run: cargo install -f ucd-generate run: cargo install -f ucd-generate
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
directory: ${{ runner.temp }}/llvm
version: 16
# ---- format check ---- # ---- format check ----
# pcguard edges and pcguard hitcounts are not compatible and we need to build them seperately # pcguard edges and pcguard hitcounts are not compatible and we need to build them seperately
- name: Check pcguard edges - name: Check pcguard edges
@ -118,16 +141,18 @@ jobs:
with: with:
profile: minimal profile: minimal
toolchain: stable toolchain: stable
- name: Install and cache deps - name: Install and cache deps
uses: awalsh128/cache-apt-pkgs-action@v1.1.0 run: sudo apt install ninja-build clang-format-13 shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev
with:
packages: llvm-15 clang-15 llvm-15-dev ninja-build clang-format-13 shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev
- name: get clang version
run: command -v llvm-config-15 && clang-15 -v
- name: Add nightly rustfmt and clippy - name: Add nightly rustfmt and clippy
run: rustup toolchain install nightly --component clippy --allow-downgrade && rustup default nightly run: rustup toolchain install nightly --component clippy --allow-downgrade && rustup default nightly
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
directory: ${{ runner.temp }}/llvm
version: 16
- name: Run clippy - name: Run clippy
run: ./scripts/clippy.sh run: ./scripts/clippy.sh
@ -153,11 +178,7 @@ jobs:
- name: Remove existing clang and LLVM - name: Remove existing clang and LLVM
run: sudo apt purge llvm* clang* run: sudo apt purge llvm* clang*
- name: Install and cache deps - name: Install and cache deps
uses: awalsh128/cache-apt-pkgs-action@v1.1.0 run: sudo apt install ninja-build clang-format-13 shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev
with:
packages: llvm-15 llvm-15-dev clang-15 ninja-build clang-format-13 shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev
- name: get clang version
run: command -v llvm-config-15 && clang-15 -v
- name: Install cargo-hack - name: Install cargo-hack
run: curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin run: curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin
- name: Install ucd-generate - name: Install ucd-generate
@ -166,14 +187,18 @@ jobs:
run: rustup toolchain install nightly --allow-downgrade run: rustup toolchain install nightly --allow-downgrade
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
directory: ${{ runner.temp }}/llvm
version: 16
# ---- build and feature check ---- # ---- build and feature check ----
# cargo-hack's --feature-powerset would be nice here but libafl has a too many knobs # cargo-hack's --feature-powerset would be nice here but libafl has a too many knobs
- name: Check each feature - name: Check each feature
# Skipping `python` as it has to be built with the `maturin` tool # Skipping `python` as it has to be built with the `maturin` tool
# `agpl`, `nautilus` require nightly # `agpl`, `nautilus` require nightly
# `sancov_pcguard_edges` is tested seperately # `sancov_pcguard_edges` is tested seperatelyc
run: LLVM_CONFIG=llvm-config-15 cargo hack check --workspace --each-feature --clean-per-run --exclude-features=prelude,agpl,nautilus,python,sancov_pcguard_edges,arm,aarch64,i386,be,systemmode,whole_archive --no-dev-deps --exclude libafl_libfuzzer run: LLVM_CONFIG=llvm-config cargo hack check --workspace --each-feature --clean-per-run --exclude-features=prelude,agpl,nautilus,python,sancov_pcguard_edges,arm,aarch64,i386,be,systemmode,whole_archive --no-dev-deps --exclude libafl_libfuzzer
- name: Check nightly features - name: Check nightly features
run: cargo +nightly check --features=agpl && cargo +nightly check --features=nautilus run: cargo +nightly check --features=agpl && cargo +nightly check --features=nautilus
@ -200,14 +225,19 @@ jobs:
toolchain: stable toolchain: stable
- name: Remove existing clang and LLVM - name: Remove existing clang and LLVM
run: sudo apt purge llvm* clang* run: sudo apt purge llvm* clang*
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
directory: ${{ runner.temp }}/llvm
version: 16
- name: Install deps - name: Install deps
run: sudo apt-get install -y llvm-15 llvm-15-dev clang-15 ninja-build python3-dev python3-pip python3-venv libz3-dev run: sudo apt-get install -y ninja-build python3-dev python3-pip python3-venv libz3-dev
- name: Install maturin - name: Install maturin
run: python3 -m pip install maturin run: python3 -m pip install maturin
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: Run a maturin build - name: Run a maturin build
run: export LLVM_CONFIG=llvm-config-15 && cd ./bindings/pylibafl && python3 -m venv .env && . .env/bin/activate && pip install --upgrade --force-reinstall . && ./test.sh run: export LLVM_CONFIG=llvm-config-16 && cd ./bindings/pylibafl && python3 -m venv .env && . .env/bin/activate && pip install --upgrade --force-reinstall . && ./test.sh
- name: Run python test - name: Run python test
run: . ./bindings/pylibafl/.env/bin/activate && cd ./fuzzers/baby_fuzzer && python3 baby_fuzzer.py 2>&1 | grep "Bye" run: . ./bindings/pylibafl/.env/bin/activate && cd ./fuzzers/baby_fuzzer && python3 baby_fuzzer.py 2>&1 | grep "Bye"
@ -246,13 +276,13 @@ jobs:
run: cargo install -f ucd-generate run: cargo install -f ucd-generate
- name: Remove obsolete llvm (Linux) - name: Remove obsolete llvm (Linux)
run: sudo apt purge llvm* clang* run: sudo apt purge llvm* clang*
- uses: lyricwulf/abc@v1 - name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with: with:
linux: llvm-15 llvm-15-dev clang-15 nasm ninja-build gcc-arm-linux-gnueabi g++-arm-linux-gnueabi gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-mipsel-linux-gnu g++-mipsel-linux-gnu gcc-powerpc-linux-gnu g++-powerpc-linux-gnu libc6-dev-i386-cross libc6-dev libc6-dev-i386 lib32gcc-11-dev lib32stdc++-11-dev libgtk-3-dev pax-utils libz3-dev directory: ${{ runner.temp }}/llvm
- name: Set clang version version: 16
run: sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 100 - name: Install deps
- name: Set clang++ version run: sudo apt install nasm ninja-build gcc-arm-linux-gnueabi g++-arm-linux-gnueabi gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-mipsel-linux-gnu g++-mipsel-linux-gnu gcc-powerpc-linux-gnu g++-powerpc-linux-gnu libc6-dev-i386-cross libc6-dev libc6-dev-i386 lib32gcc-11-dev lib32stdc++-11-dev libgtk-3-dev pax-utils libz3-dev
run: sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-15 100
- name: pip install - name: pip install
run: python3 -m pip install msgpack jinja2 find_libpython run: python3 -m pip install msgpack jinja2 find_libpython
# Note that nproc needs to have coreutils installed on macOS, so the order of CI commands matters. # Note that nproc needs to have coreutils installed on macOS, so the order of CI commands matters.
@ -281,7 +311,7 @@ jobs:
run: sudo ln -s /usr/include/asm-generic /usr/include/asm run: sudo ln -s /usr/include/asm-generic /usr/include/asm
- name: Build and run example fuzzers (Linux) - name: Build and run example fuzzers (Linux)
if: runner.os == 'Linux' if: runner.os == 'Linux'
run: RUN_ON_CI=1 LLVM_CONFIG=llvm-config-15 ./scripts/test_all_fuzzers.sh run: RUN_ON_CI=1 LLVM_CONFIG=llvm-config ./scripts/test_all_fuzzers.sh
qemu_fuzzers: qemu_fuzzers:
strategy: strategy:
@ -320,17 +350,13 @@ jobs:
- name: Remove obsolete llvm (Linux) - name: Remove obsolete llvm (Linux)
if: runner.os == 'Linux' if: runner.os == 'Linux'
run: sudo apt purge llvm* clang* run: sudo apt purge llvm* clang*
- uses: lyricwulf/abc@v1 - name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with: with:
linux: llvm-15 llvm-15-dev clang-15 nasm ninja-build gcc-arm-linux-gnueabi g++-arm-linux-gnueabi gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-mipsel-linux-gnu g++-mipsel-linux-gnu gcc-powerpc-linux-gnu g++-powerpc-linux-gnu libc6-dev-i386-cross libc6-dev libc6-dev-i386 lib32gcc-11-dev lib32stdc++-11-dev libgtk-3-dev pax-utils libz3-dev directory: ${{ runner.temp }}/llvm
# update bash for macos to support `declare -A` command` version: 16
macos: llvm@15 libpng nasm coreutils z3 bash wget - name: Install deps
- name: Set clang version run: sudo apt install nasm ninja-build gcc-arm-linux-gnueabi g++-arm-linux-gnueabi gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-mipsel-linux-gnu g++-mipsel-linux-gnu gcc-powerpc-linux-gnu g++-powerpc-linux-gnu libc6-dev-i386-cross libc6-dev libc6-dev-i386 lib32gcc-11-dev lib32stdc++-11-dev libgtk-3-dev pax-utils libz3-dev
if: runner.os == 'Linux'
run: sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 100
- name: Set clang++ version
if: runner.os == 'Linux'
run: sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-15 100
- name: pip install - name: pip install
run: python3 -m pip install msgpack jinja2 find_libpython run: python3 -m pip install msgpack jinja2 find_libpython
# Note that nproc needs to have coreutils installed on macOS, so the order of CI commands matters. # Note that nproc needs to have coreutils installed on macOS, so the order of CI commands matters.
@ -359,7 +385,7 @@ jobs:
run: sudo ln -s /usr/include/asm-generic /usr/include/asm run: sudo ln -s /usr/include/asm-generic /usr/include/asm
- name: Build and run example fuzzers (Linux) - name: Build and run example fuzzers (Linux)
if: runner.os == 'Linux' if: runner.os == 'Linux'
run: RUN_ON_CI=1 RUN_QEMU_FUZZER=1 LLVM_CONFIG=llvm-config-15 ./scripts/test_all_fuzzers.sh run: RUN_ON_CI=1 RUN_QEMU_FUZZER=1 LLVM_CONFIG=llvm-config ./scripts/test_all_fuzzers.sh
nostd-build: nostd-build:

View File

@ -21,7 +21,7 @@ RUN rustup default nightly
# Install clang 11, common build tools # Install clang 11, common build tools
RUN apt update && apt install -y build-essential gdb git wget python3-venv ninja-build lsb-release software-properties-common gnupg RUN apt update && apt install -y build-essential gdb git wget python3-venv ninja-build lsb-release software-properties-common gnupg
RUN wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 16 RUN wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 15
# Copy a dummy.rs and Cargo.toml first, so that dependencies are cached # Copy a dummy.rs and Cargo.toml first, so that dependencies are cached
WORKDIR /libafl WORKDIR /libafl

View File

@ -4,7 +4,7 @@ LibAFL CC provides the functionalities to write compiler wrappers for LibAFL, by
The online documentation for this crate is available [here](https://docs.rs/crate/libafl_cc/latest). The online documentation for this crate is available [here](https://docs.rs/crate/libafl_cc/latest).
Currently, we support LLVM version 11 up to 18, but other versions may work. Currently, we support LLVM version 11 up to 17, but other versions may work.
To install LLVM, use the official [download page](https://releases.llvm.org/download.html). To install LLVM, use the official [download page](https://releases.llvm.org/download.html).
The LLVM tools (including clang, clang++) are needed (newer than LLVM 11.0.0 up to LLVM 17.0.0) The LLVM tools (including clang, clang++) are needed (newer than LLVM 11.0.0 up to LLVM 17.0.0)

View File

@ -33,6 +33,8 @@ constexpr std::nullopt_t None = std::nullopt;
#include "llvm/Transforms/IPO/PassManagerBuilder.h" #include "llvm/Transforms/IPO/PassManagerBuilder.h"
#endif #endif
#include "llvm/IR/Function.h"
#define FATAL(...) \ #define FATAL(...) \
do { \ do { \
fprintf(stderr, "FATAL: " __VA_ARGS__); \ fprintf(stderr, "FATAL: " __VA_ARGS__); \

View File

@ -15,17 +15,12 @@ else
export PROFILE_DIR=debug export PROFILE_DIR=debug
fi fi
if [[ -z "${RUN_ON_CI}" ]]; then
:
else
if [[ -z "${RUN_QEMU_FUZZER}" ]]; then if [[ -z "${RUN_QEMU_FUZZER}" ]]; then
fuzzers=$(echo "$fuzzers" | tr ' ' '\n' | grep -v "qemu") fuzzers=$(echo "$fuzzers" | tr ' ' '\n' | grep -v "qemu")
backtrace_fuzzers=$(echo "$backtrace_fuzzers" | tr ' ' '\n' | grep "qemu") backtrace_fuzzers=$(echo "$backtrace_fuzzers" | tr ' ' '\n' | grep -v "qemu")
else else
fuzzers=$(echo "$fuzzers" | tr ' ' '\n' | grep "qemu") fuzzers=$(echo "$fuzzers" | tr ' ' '\n' | grep "qemu")
backtrace_fuzzers=$(echo "$backtrace_fuzzers" | tr ' ' '\n' | grep -v "qemu") backtrace_fuzzers=$(echo "$backtrace_fuzzers" | tr ' ' '\n' | grep "qemu")
fi
fi fi
libafl=$(pwd) libafl=$(pwd)