Skip to content

cargo xtask fuzz fails on aarch64 — LSE target feature dropped by cargo-fuzz RUSTFLAGS #3003

@mattkur

Description

@mattkur

cargo xtask fuzz run fails to compile on aarch64 (e.g. aarch64 WSL) because cargo-fuzz overrides .cargo/config.toml target features via its own RUSTFLAGS env var.

Symptoms

error: instruction requires: lse
 --> <inline asm>:2:1
  |
2 | casalb w21, w8, [x10]
  | ^

Root cause

.cargo/config.toml sets -Ctarget-feature=+lse,+neon for aarch64 targets. trycopy's inline asm depends on this — it uses casalb (an ARMv8.1 LSE atomic) for fault-recovering compare-and-swap.

cargo-fuzz constructs its own RUSTFLAGS (ASAN, coverage instrumentation) and sets it as an env var. Per Cargo's precedence rules, the env var completely overrides [target.*.rustflags] from config, silently dropping +lse. LLVM then rejects the LSE instructions.

Workaround

RUSTFLAGS="-Ctarget-feature=+lse,+neon" cargo xtask fuzz run fuzz_ide

cargo-fuzz prepends the user's RUSTFLAGS to its own, so the features are preserved.

Proposed fix

Detect aarch64 in xtask/src/tasks/fuzz/cargo_fuzz.rs and inject -Ctarget-feature=+lse,+neon into the environment before invoking cargo fuzz. This makes it automatic for all fuzz targets.

An alternative: make trycopy's LSE asm conditional on cfg!(target_feature = "lse") with an LL/SC fallback — but that's significantly more work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions