rust-fuzz / afl.rs

🐇 Fuzzing Rust code with American Fuzzy Lop

Home Page:https://rust-fuzz.github.io/book/afl.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Plugins feature breaks afl build?

a1akris opened this issue · comments

I wanted to try out this change(#392) but it didn't work for me.

The command cargo install cargo-afl@0.15.0 -F plugins --force yields the following error:

error: failed to run custom build command for `cargo-afl v0.15.0`

Caused by:
  process didn't exit successfully: `/tmp/cargo-installZeuf5T/release/build/cargo-afl-ccb8e67a73670b8e/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-afl-0.15.0/src/config.rs:180:29:
  could not run llvm-config-17 --version
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: failed to compile `cargo-afl v0.15.0`, intermediate artifacts can be found at `/tmp/cargo-installZeuf5T`.

Looks like llvm-config-17 is missing but llvm17 is not available even on Arch yet. Also, I believe that cargo-afl was handling llvm build deps automatically, I didn't bother with them while hoping from toolchain to toolchain before.

Rustc version is: rustc 1.76.0-nightly (21cce21d8 2023-12-11)

Without -F plugins the installation succeeds.

Hi, @a1akris. Thanks very much for your note.

Looks like llvm-config-17 is missing but llvm17 is not available even on Arch yet.

Do you have LLVM 16 installed on your system? If so, then you might try the following:

rustup install nightly-2023-06-28 # A version that I happen to know uses LLVM 16.
cargo +nightly-2023-06-28 afl config --build --plugins

If you're running a Debian-based system, you can find instructions for installing LLVM 17 here: https://apt.llvm.org/

I just tried those instructions, and they seemed to work.

Also, I believe that cargo-afl was handling llvm build deps automatically, I didn't bother with them while hoping from toolchain to toolchain before.

I'm not sure that's right. LLVM is is only needed under certain circumstances. Building the plugins is one of those circumstances. Maybe that's why you haven't noticed before(?).

Having said that, I am open to suggestions on how to make the process easier.

Thank you for the quick response.

You're right, I need to install LLVM on my own in order for the plugins feature to work.

Additionally, on Arch Linux the current officially supported LLVM version is 16.0.6 so llvm-config command comes without a version prefix but the build script fails because it invokes llvm-config-16 --version instead of llvm-config --version. I had to create a symbolic link in order to fix this but it would be better if the build script checked llvm-config --version first before invoking the command with a specific prefix.

Also, I'm currently working on the fuzzing automation framework that setups everything for you and this LLVM dependency issue looks like a total disaster. I have no idea how to automate it either :)

Additionally, on Arch Linux the current officially supported LLVM version is 16.0.6 so llvm-config command comes without a version prefix but the build script fails because it invokes llvm-config-16 --version instead of llvm-config --version. I had to create a symbolic link in order to fix this but it would be better if the build script checked llvm-config --version first before invoking the command with a specific prefix.

Good point. I just opened #435 to record this.

Is there anything else that you think needs to be addressed in this issue?

No, thank you for support, I'm closing the issue.