meson icon indicating copy to clipboard operation
meson copied to clipboard

rust: Rebuild targets when compiler got updated

Open xclaesse opened this issue 1 year ago • 5 comments

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

xclaesse avatar Nov 22 '23 13:11 xclaesse

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?

xclaesse avatar Nov 22 '23 13:11 xclaesse

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.

xclaesse avatar Nov 22 '23 13:11 xclaesse

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.

sdroege avatar Mar 25 '24 12:03 sdroege

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.

eli-schwartz avatar Mar 25 '24 12:03 eli-schwartz

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)

TheComputerGuy96 avatar Apr 10 '24 08:04 TheComputerGuy96