meson
meson copied to clipboard
rust: Rebuild targets when compiler got updated
rustc updates are usually incompatible and requires recompiling of all
targets. This adds the compiler exe as dependency of every rust
ninja targets. Also try to resolve the real rustc exe being used when
the toolchain is wrapped by rustup.
Fixes: #10706
This is of course not foolproof by any mean. The compiler exe could be wrapper script and we won't detect changes for the real compiler. If the compiler is a symlink it won't detect if the symlink changed. It could cause spurious reconfigure if the toolchain got minor changes that does not require a reconfigure....
But I think it's better than nothing. It's not every day someone update their toolchain, and when they do it's safer to actually rebuild.
If that's controversial, I could limit this to only rustc?
If the compiler is a symlink it won't detect if the symlink changed.
Note that alternatively I could remove os.path.realpath()
, that probably would be more consistent with custom_target() that does not resolve symlinks AFAIK.
The compiler exe could be wrapper script and we won't detect changes for the real compiler.
This means that this won't work for rustup, or not? rustc is just a wrapper in that case, which would execute the correct rustc depending on configured toolchain etc.
It will indeed not work for rustup. it relies on adding the compiler binary as a meson --internal regenerate
dependency, forcing a reconfigure whenever the mtime of rustup changes and then triggering a rebuild if it was a symlink and the symlink destination changes.
I tested this patch and the Rust libraries don't get recompiled after only a Rust compiler update (I'm not sure if this is the intended behavior)