Update cargo_build_script
to work without runfiles support.
#2887
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Partially addresses #1156
This pull-request implements an additional change to enable this behavior which aggregates all transitive
BuildInfo.compile_data
intoRustc
actions. While this seems to bloat these actions with unnecessary data, it addresses a catastrophic flaw in how Windows works at all.As of Bazel 7.3.1, Windows does not run any actions in a sandbox (bazelbuild/bazel#18401), this means that references to the current working directory will be consistent since they always refer to the execroot. On top of this fact,
cargo_build_script
will assign CARGO_MANIFEST_DIR to a path within the runfiles directory of the build script. The combination of these two facts leads crates like windows_x86_64_msvc, which assign a linker path usingCARGO_MANIFEST_DIR
(@windows_x86_64_msvc//build.rs) to introduce un-tracked dependencies into dependentRustc
actions. This then leads to build failures if thewindows_x86_64_msvc
crate is ever a remote cache hit for the dependents as runfiles (or.cargo_runfiles
in the case of this PR) are not fetched and will not exist on the host at link time.This change addresses this issue of untracked dependencies by ensuring the runfiles of
cargo_build_script.script
targets are aggregated intoRustc
actions.