-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Paths emitted by build script are not corrected when cross-compiling #6177
Comments
@alexcrichton I was looking at fixing this. It's a little convoluted, so I just wanted to verify some assumptions: The fix renaming PR introduced the fix that should address it, but it does it in a weird way. It uses the I think there is one exception that should still use the host directory, and that is this line which does some funky stuff for linking the build script itself. |
@ehuss nah you're spot on, build scripts only have supported output to Definitely feel free to correct any mistakes there :) |
@alexcrichton sorry, two more questions for fixing this.
|
No worries! Changing the filename is fine by me, although I'd also be up for throwing in a schema-like version baked into Cargo into the hash to bust the cache (and we could increment it on changes like this to bust the cache) That's a good point that we don't handle the other items. I think it's probably ok to handle it as if the absolute path to the output shows up in the various lines I can't really imagine a case where you wouldn't want it remapped! |
Fix renaming directory project using build scripts with cross-compiling. The rename-protection introduced in #4818 checks for paths with a prefix of `/…/target/debug`, but this does not work for paths used during cross-compiling. This change checks for paths with the full `OUT_DIR` prefix, and the `build/PKG/root-output` file now includes that full `OUT_DIR` instead of `/…/target/debug`. This also includes a few other changes: - Support fixing KIND=PATH style paths. - Support fixing paths in metadata (like `cargo:root=…` or `cargo:include=…` which are common). - Adds a "version" value to the metadata hash to ensure that cargo doesn't get confused with the new `root-output` file format. Fixes #6177
Posted on behalf of @Phaiax: (originally rust-lang/rust#55072)
I (@ExpHP) tried it myself and can easily reproduce it on linux, so it is not just a Windows thing. The build scripts involved are also innocuous, making correct use of
std::env::var("OUT_DIR")
and emitting basic cargo linker flags.To reproduce:
rustup target add thumbv7m-none-eabi
cortex-m-quickstart
template (or clone it and fix up the Cargo.toml)Thoughts:
To my best understanding,
cargo
normally has no problem with the absolute paths that appear in build scriptcargo:
directives because it stores the current path at the time of build totarget/build/(unique-name)/root-output
; future builds use this to correct the paths that are in the cached stdout from the script.Looking at the build artefacts for clues, I notice that the build scripts' output is saved at
but the
root-output
files for the build scripts containwhich is not a prefix of that path.
The text was updated successfully, but these errors were encountered: