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

Fully support windows without --enable_runfiles #1156

Open
1 of 3 tasks
UebelAndre opened this issue Feb 27, 2022 · 0 comments
Open
1 of 3 tasks

Fully support windows without --enable_runfiles #1156

UebelAndre opened this issue Feb 27, 2022 · 0 comments

Comments

@UebelAndre
Copy link
Collaborator

UebelAndre commented Feb 27, 2022

rules_rust currently has some components that require --enable_runfiles and --windows_enable_symlinks to be set on windows. This should not be needed and all rules should work without requiring any flags.

Rules that require extra flags:

@UebelAndre UebelAndre changed the title Fully support windows without --enable_runfiles Fully support windows without --enable_runfiles Feb 27, 2022
github-merge-queue bot pushed a commit that referenced this issue Sep 19, 2024
UebelAndre added a commit to UebelAndre/rules_rust that referenced this issue Sep 19, 2024
github-merge-queue bot pushed a commit that referenced this issue Sep 19, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant