Why is "cargo clean" required to get my inline asm to work?

Wow, seems like I stumbled on a high priority soundness bug in the compiler that is not actually anything to do with any asm. Nice I could contribute a little something to the Rust project.

15 Likes

Yay, this problem is now fixed in the latest nightly.

cargo --version --verbose
cargo 1.88.0-nightly (0e93c5bf6 2025-04-05)
release: 1.88.0-nightly
commit-hash: 0e93c5bf6a1d5ee7bc2af63d1afb16cd28793601
commit-date: 2025-04-05
host: aarch64-apple-darwin
libgit2: 1.9.0 (sys:0.20.0 vendored)
libcurl: 8.7.1 (sys:0.4.80+curl-8.12.1 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 3.4.1 11 Feb 2025
os: Mac OS 15.4.0 [64-bit]
8 Likes

That's actually big difference between C culture and Rust culture.

In a C world (especially in embedded) I saw some really horrible hacks designed to work around some exotic bugs in a compiler – yet people rarely report them.

Because there are no point in doing that: vendors give you some compiler based on decade old GCC (today they have switched to five years old clang… big progress!) and even if you report a bug… it may take 10 or 20 years before you may remove your kludge.

With Rust's “living at the ToT” way of doing things “reporting and fixing bug” activity is actually useful for the reporter.

P.S. This being said, you still have to keep in mind that for 100 times when you think… “no, that's not possible, there are something wrong with the compiler…” 99 times it's your fault, 1 time it's the compiler bug. Verify your “compiler bugs” carefully before reporting them, there are no need to clog the bug-reporting pipes with bugs that are not bugs.

5 Likes

Oh my God, so true. Back in the day it was mandated that our project will use WindRiver's VxWorks operating system. Because, you know, "safety critical", certifications, standards, "they use it on Mars" and all that. Well the GCC shipped with VxWorks crashed while compiling my code, which gave me little confidence in what it might generate. After suffering that and numerous other problems I managed to get permission to switch to Linux. Life was good and that system is still running all over Scandinavia fifteen years later.

Indeed, finding a compiler bug is amazingly rare. It's almost always my fault. So it was very helpful to have the discussion about it here first.

2 Likes