-
Notifications
You must be signed in to change notification settings - Fork 174
Description
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_idecargo-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.