-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update
cargo_build_script
to work without runfiles support. (#2887)
Partially addresses #1156 This pull-request implements an additional change to enable this behavior which aggregates all transitive `BuildInfo.compile_data` into `Rustc` 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](https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates) to a [path within the runfiles directory of the build script](https://github.com/bazelbuild/rules_rust/blame/d9ee6172d1dfc2801ba809441668e60e797f89de/cargo/private/cargo_build_script.bzl#L218). The combination of these two facts leads crates like [windows_x86_64_msvc](https://crates.io/crates/windows_x86_64_msvc), which assign a linker path using `CARGO_MANIFEST_DIR` ([@windows_x86_64_msvc//build.rs](https://github.com/microsoft/windows-rs/blob/0.59.0/crates/targets/x86_64_msvc/build.rs#L1-L8)) to introduce un-tracked dependencies into dependent `Rustc` actions. This then leads to build failures if the `windows_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 into `Rustc` actions.
- Loading branch information
1 parent
6e97b2f
commit 59464fe
Showing
236 changed files
with
616 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") | ||
load(":runfiles_enabled.bzl", "runfiles_enabled_build_setting") | ||
|
||
bzl_library( | ||
name = "bzl_lib", | ||
srcs = glob(["**/*.bzl"]), | ||
visibility = ["//:__subpackages__"], | ||
) | ||
|
||
runfiles_enabled_build_setting( | ||
name = "runfiles_enabled", | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.