Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust: Rebuild targets when compiler got updated #12536

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

xclaesse
Copy link
Member

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

When the compiler has been updated we need to trigger a reconfigure
because any compiler checks result could have changed.

In the case the compiler is a wrapper script we cannot detect when the
real compiler changed, but this is better than nothing and we should
reconfigure when the wrapper itself changed as well anyway.
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: mesonbuild#10706
@xclaesse xclaesse force-pushed the rust-resolve-realpath branch from ac75f92 to 73257b0 Compare November 22, 2023 13:20
@xclaesse
Copy link
Member Author

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
Copy link
Member Author

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.

@sdroege
Copy link
Contributor

sdroege commented Mar 25, 2024

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.

@eli-schwartz
Copy link
Member

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.

@@ -631,6 +631,9 @@ def get_exelist(self, ccache: bool = True) -> T.List[str]:
def get_linker_exelist(self) -> T.List[str]:
return self.linker.get_exelist() if self.linker else self.get_exelist()

def get_exe_file(self) -> str:
return os.path.realpath(self.exelist_no_ccache[0])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns a bad value when only the executable name is passed (so shouldn't shutil.which() be used here?)

@TheComputerGuy96
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants