rust-lang / rust-lang/rust

Nightly rustc cannot load LLVM plugins on ARM64 platforms (impacts afl.rs crate)

Open
#127,573 6 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-LLVM C-bug T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

This issue prevents using the effective afl.rs (AFL++) plugins for fuzzing in Rust on ARM64 platforms.

The nightly rustc allows for loading LLVM plugins with -Z llvm-plugins=/path/to/plugin.

This works without problems on Linux x86_x64, however on ARM64 - both Linux and MacOS - this fails with symbols not being resolvable.

How to reproduce:

  • this requires LLVM in the same version that is used in nightly (currently llvm 18):
    Linux: wget http://apt.llvm.org/llvm.sh ; sudo bash ./llvm.sh 18
    Macos: brew install llvm + setting up the PATH to prefer clang/clang++ from brew and not xlang
# Install cargo-afl because this is where we need LLVM plugins from
cargo install cargo-afl
# Compile the AFL++ plugins for cargo-afl - this requires LLVM installed
cargo afl config --plugins --force
# Now get a simple test example
git clone --depth=1 https://github.com/rust-fuzz/afl.rs
# Build any example
cd afl.rs/afl
cargo afl build --example arbitrary

On Linux x86_x64 this works:

    Finished `dev` profile [unoptimized + debuginfo] target(s) in 8.05s

On ARM64 Ubuntu and MacOS this both fails:

error: failed to run LLVM passes: Could not load library '/Users/ssh_debug/.local/share/afl.rs/rustc-1.81.0-nightly-6be96e3/afl.rs-0.15.8/afl-llvm/cmplog-instructions-pass.so': dlopen(/Users/ssh_debug/.local/share/afl.rs/rustc-1.81.0-nightly-6be96e3/afl.rs-0.15.8/afl-llvm/cmplog-instructions-pass.so, 0x0009): symbol not found in flat namespace '__ZN4llvm17PreservedAnalyses14AllAnalysesKeyE'

After a lot of debugging, the reason seems to be that on Linux x86_x64 the following library is present:
libLLVM-18-rust-1.81.0-nightly.so
But on ARM64 rust nightly installation this is missing.
So this might be the reason for this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure using the listed LLVM 18 setup, cargo-afl plugin build, and afl.rs example on an ARM64 Linux or macOS system. Compare the nightly installation's LLVM libraries with the x86_64 installation, especially the reported libLLVM-18-rust-1.81.0-nightly.so. Done means the cargo afl example builds successfully with LLVM plugins on ARM64.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.