Skip to content

Commit 0a72d8a

Browse files
authored
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
1 parent 207e7db commit 0a72d8a

File tree

6 files changed

+79
-56
lines changed

6 files changed

+79
-56
lines changed

.github/workflows/build_and_test.yml

+69-43
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,30 @@ jobs:
5656
run: cd libafl_bolts && cargo test --no-default-features
5757
- name: Test libafl_targets no_std
5858
run: cd libafl_targets && cargo test --no-default-features
59-
59+
60+
llvm-tester:
61+
runs-on: ubuntu-22.04
62+
continue-on-error: true
63+
strategy:
64+
matrix:
65+
llvm-version: ["11", "12", "13", "14", "16", "17"]
66+
steps:
67+
- name: Remove Dotnet & Haskell
68+
run: rm -rf /usr/share/dotnet && rm -rf /opt/ghc
69+
- uses: actions-rs/toolchain@v1
70+
with:
71+
profile: minimal
72+
toolchain: stable
73+
- uses: actions/checkout@v3
74+
- uses: Swatinem/rust-cache@v2
75+
- name: Install LLVM and Clang
76+
uses: KyleMayes/install-llvm-action@v1
77+
with:
78+
version: "${{matrix.llvm-version}}"
79+
- name: Build and test with llvm-${{ matrix.llvm-version }}
80+
run: pwd && ls & cd libafl_cc && cargo build --release
81+
82+
6083
ubuntu:
6184
runs-on: ubuntu-22.04
6285
steps:
@@ -67,20 +90,20 @@ jobs:
6790
profile: minimal
6891
toolchain: stable
6992
- name: Remove existing clang and LLVM
70-
run: sudo apt purge llvm* clang*
93+
run: sudo apt purge llvm* clang* lld* lldb* opt*
7194
- name: Install and cache deps
72-
uses: awalsh128/[email protected]
73-
with:
74-
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
75-
- name: get clang version
76-
run: command -v llvm-config-15 && clang-15 -v
95+
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
7796
- name: Add nightly rustfmt and clippy
7897
run: rustup toolchain install nightly --component rustfmt --component clippy --component miri --allow-downgrade
7998
- name: Install ucd-generate
8099
run: cargo install -f ucd-generate
81100
- uses: actions/checkout@v3
82101
- uses: Swatinem/rust-cache@v2
83-
102+
- name: Install LLVM and Clang
103+
uses: KyleMayes/install-llvm-action@v1
104+
with:
105+
directory: ${{ runner.temp }}/llvm
106+
version: 16
84107
# ---- format check ----
85108
# pcguard edges and pcguard hitcounts are not compatible and we need to build them seperately
86109
- name: Check pcguard edges
@@ -118,16 +141,18 @@ jobs:
118141
with:
119142
profile: minimal
120143
toolchain: stable
144+
121145
- name: Install and cache deps
122-
uses: awalsh128/[email protected]
123-
with:
124-
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
125-
- name: get clang version
126-
run: command -v llvm-config-15 && clang-15 -v
146+
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
127147
- name: Add nightly rustfmt and clippy
128148
run: rustup toolchain install nightly --component clippy --allow-downgrade && rustup default nightly
129149
- uses: actions/checkout@v3
130150
- uses: Swatinem/rust-cache@v2
151+
- name: Install LLVM and Clang
152+
uses: KyleMayes/install-llvm-action@v1
153+
with:
154+
directory: ${{ runner.temp }}/llvm
155+
version: 16
131156
- name: Run clippy
132157
run: ./scripts/clippy.sh
133158

@@ -153,11 +178,7 @@ jobs:
153178
- name: Remove existing clang and LLVM
154179
run: sudo apt purge llvm* clang*
155180
- name: Install and cache deps
156-
uses: awalsh128/[email protected]
157-
with:
158-
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
159-
- name: get clang version
160-
run: command -v llvm-config-15 && clang-15 -v
181+
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
161182
- name: Install cargo-hack
162183
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
163184
- name: Install ucd-generate
@@ -166,14 +187,18 @@ jobs:
166187
run: rustup toolchain install nightly --allow-downgrade
167188
- uses: actions/checkout@v3
168189
- uses: Swatinem/rust-cache@v2
169-
190+
- name: Install LLVM and Clang
191+
uses: KyleMayes/install-llvm-action@v1
192+
with:
193+
directory: ${{ runner.temp }}/llvm
194+
version: 16
170195
# ---- build and feature check ----
171196
# cargo-hack's --feature-powerset would be nice here but libafl has a too many knobs
172197
- name: Check each feature
173198
# Skipping `python` as it has to be built with the `maturin` tool
174199
# `agpl`, `nautilus` require nightly
175-
# `sancov_pcguard_edges` is tested seperately
176-
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
200+
# `sancov_pcguard_edges` is tested seperatelyc
201+
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
177202
- name: Check nightly features
178203
run: cargo +nightly check --features=agpl && cargo +nightly check --features=nautilus
179204

@@ -200,14 +225,19 @@ jobs:
200225
toolchain: stable
201226
- name: Remove existing clang and LLVM
202227
run: sudo apt purge llvm* clang*
228+
- name: Install LLVM and Clang
229+
uses: KyleMayes/install-llvm-action@v1
230+
with:
231+
directory: ${{ runner.temp }}/llvm
232+
version: 16
203233
- name: Install deps
204-
run: sudo apt-get install -y llvm-15 llvm-15-dev clang-15 ninja-build python3-dev python3-pip python3-venv libz3-dev
234+
run: sudo apt-get install -y ninja-build python3-dev python3-pip python3-venv libz3-dev
205235
- name: Install maturin
206236
run: python3 -m pip install maturin
207237
- uses: actions/checkout@v3
208238
- uses: Swatinem/rust-cache@v2
209239
- name: Run a maturin build
210-
run: export LLVM_CONFIG=llvm-config-15 && cd ./bindings/pylibafl && python3 -m venv .env && . .env/bin/activate && pip install --upgrade --force-reinstall . && ./test.sh
240+
run: export LLVM_CONFIG=llvm-config-16 && cd ./bindings/pylibafl && python3 -m venv .env && . .env/bin/activate && pip install --upgrade --force-reinstall . && ./test.sh
211241
- name: Run python test
212242
run: . ./bindings/pylibafl/.env/bin/activate && cd ./fuzzers/baby_fuzzer && python3 baby_fuzzer.py 2>&1 | grep "Bye"
213243

@@ -246,13 +276,13 @@ jobs:
246276
run: cargo install -f ucd-generate
247277
- name: Remove obsolete llvm (Linux)
248278
run: sudo apt purge llvm* clang*
249-
- uses: lyricwulf/abc@v1
250-
with:
251-
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
252-
- name: Set clang version
253-
run: sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 100
254-
- name: Set clang++ version
255-
run: sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-15 100
279+
- name: Install LLVM and Clang
280+
uses: KyleMayes/install-llvm-action@v1
281+
with:
282+
directory: ${{ runner.temp }}/llvm
283+
version: 16
284+
- name: Install deps
285+
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
256286
- name: pip install
257287
run: python3 -m pip install msgpack jinja2 find_libpython
258288
# Note that nproc needs to have coreutils installed on macOS, so the order of CI commands matters.
@@ -281,7 +311,7 @@ jobs:
281311
run: sudo ln -s /usr/include/asm-generic /usr/include/asm
282312
- name: Build and run example fuzzers (Linux)
283313
if: runner.os == 'Linux'
284-
run: RUN_ON_CI=1 LLVM_CONFIG=llvm-config-15 ./scripts/test_all_fuzzers.sh
314+
run: RUN_ON_CI=1 LLVM_CONFIG=llvm-config ./scripts/test_all_fuzzers.sh
285315

286316
qemu_fuzzers:
287317
strategy:
@@ -320,17 +350,13 @@ jobs:
320350
- name: Remove obsolete llvm (Linux)
321351
if: runner.os == 'Linux'
322352
run: sudo apt purge llvm* clang*
323-
- uses: lyricwulf/abc@v1
324-
with:
325-
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
326-
# update bash for macos to support `declare -A` command`
327-
macos: llvm@15 libpng nasm coreutils z3 bash wget
328-
- name: Set clang version
329-
if: runner.os == 'Linux'
330-
run: sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 100
331-
- name: Set clang++ version
332-
if: runner.os == 'Linux'
333-
run: sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-15 100
353+
- name: Install LLVM and Clang
354+
uses: KyleMayes/install-llvm-action@v1
355+
with:
356+
directory: ${{ runner.temp }}/llvm
357+
version: 16
358+
- name: Install deps
359+
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
334360
- name: pip install
335361
run: python3 -m pip install msgpack jinja2 find_libpython
336362
# Note that nproc needs to have coreutils installed on macOS, so the order of CI commands matters.
@@ -359,7 +385,7 @@ jobs:
359385
run: sudo ln -s /usr/include/asm-generic /usr/include/asm
360386
- name: Build and run example fuzzers (Linux)
361387
if: runner.os == 'Linux'
362-
run: RUN_ON_CI=1 RUN_QEMU_FUZZER=1 LLVM_CONFIG=llvm-config-15 ./scripts/test_all_fuzzers.sh
388+
run: RUN_ON_CI=1 RUN_QEMU_FUZZER=1 LLVM_CONFIG=llvm-config ./scripts/test_all_fuzzers.sh
363389

364390

365391
nostd-build:

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ RUN rustup default nightly
2121

2222
# Install clang 11, common build tools
2323
RUN apt update && apt install -y build-essential gdb git wget python3-venv ninja-build lsb-release software-properties-common gnupg
24-
RUN wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 16
24+
RUN wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 15
2525

2626
# Copy a dummy.rs and Cargo.toml first, so that dependencies are cached
2727
WORKDIR /libafl

libafl_cc/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ LibAFL CC provides the functionalities to write compiler wrappers for LibAFL, by
44

55
The online documentation for this crate is available [here](https://docs.rs/crate/libafl_cc/latest).
66

7-
Currently, we support LLVM version 11 up to 18, but other versions may work.
7+
Currently, we support LLVM version 11 up to 17, but other versions may work.
88
To install LLVM, use the official [download page](https://releases.llvm.org/download.html).
99

1010
The LLVM tools (including clang, clang++) are needed (newer than LLVM 11.0.0 up to LLVM 17.0.0)

libafl_cc/src/common-llvm.h

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ constexpr std::nullopt_t None = std::nullopt;
3333
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
3434
#endif
3535

36+
#include "llvm/IR/Function.h"
37+
3638
#define FATAL(...) \
3739
do { \
3840
fprintf(stderr, "FATAL: " __VA_ARGS__); \

libafl_targets/src/coverage.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ uint8_t *__token_stop = &__stop_libafl_token;
3232

3333
#endif
3434

35-
//#if defined(__ANDROID__) || defined(__HAIKU__)
35+
// #if defined(__ANDROID__) || defined(__HAIKU__)
3636
MAYBE_THREAD_LOCAL prev_loc_t __afl_prev_loc[NGRAM_SIZE_MAX];
3737
MAYBE_THREAD_LOCAL prev_loc_t __afl_prev_caller[CTX_MAX_K];
3838
MAYBE_THREAD_LOCAL uint32_t __afl_prev_ctx;

scripts/test_all_fuzzers.sh

+5-10
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,12 @@ else
1515
export PROFILE_DIR=debug
1616
fi
1717

18-
19-
if [[ -z "${RUN_ON_CI}" ]]; then
20-
:
18+
if [[ -z "${RUN_QEMU_FUZZER}" ]]; then
19+
fuzzers=$(echo "$fuzzers" | tr ' ' '\n' | grep -v "qemu")
20+
backtrace_fuzzers=$(echo "$backtrace_fuzzers" | tr ' ' '\n' | grep -v "qemu")
2121
else
22-
if [[ -z "${RUN_QEMU_FUZZER}" ]]; then
23-
fuzzers=$(echo "$fuzzers" | tr ' ' '\n' | grep -v "qemu")
24-
backtrace_fuzzers=$(echo "$backtrace_fuzzers" | tr ' ' '\n' | grep "qemu")
25-
else
26-
fuzzers=$(echo "$fuzzers" | tr ' ' '\n' | grep "qemu")
27-
backtrace_fuzzers=$(echo "$backtrace_fuzzers" | tr ' ' '\n' | grep -v "qemu")
28-
fi
22+
fuzzers=$(echo "$fuzzers" | tr ' ' '\n' | grep "qemu")
23+
backtrace_fuzzers=$(echo "$backtrace_fuzzers" | tr ' ' '\n' | grep "qemu")
2924
fi
3025

3126
libafl=$(pwd)

0 commit comments

Comments
 (0)