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

Added bzlmod support to core rules_rust #3034

Merged
merged 2 commits into from
Dec 4, 2024

Conversation

UebelAndre
Copy link
Collaborator

@UebelAndre UebelAndre commented Dec 2, 2024

@UebelAndre UebelAndre force-pushed the bzlmod branch 20 times, most recently from 1bab266 to f10686a Compare December 3, 2024 12:46
@UebelAndre UebelAndre marked this pull request as ready for review December 3, 2024 12:58
@@ -7,15 +7,15 @@ SETLOCAL ENABLEDELAYEDEXPANSION

@REM When cargo is detecting the host configuration, the host target needs to be
@REM injected into the command.
echo %*| FINDSTR /C:"rustc.exe - --crate-name ___ " | FINDSTR /V /C:"--target" >NUL
echo %*| FINDSTR /R /C:".*rustc[\.exe\"\"]* - --crate-name ___ " | FINDSTR /V /C:"--target" >NUL
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

bzlmod introduced the need for quotes in the command line which broke the rustc wrapper on windows.

@UebelAndre UebelAndre added this pull request to the merge queue Dec 4, 2024
Merged via the queue into bazelbuild:main with commit 69ddb09 Dec 4, 2024
4 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Dec 5, 2024
hauserx added a commit to hauserx/rules_rust that referenced this pull request Dec 15, 2024
The cargo_tree_resolver discovers dependencies by executing `cargo tree`
for different host and target triples. This procedure breaks when cargo
successfully but incorrectly caches rustc info. Incorrect cache hit may
happen because cache key does not take into account HOST_TRIPLE env
variable used by `rules_rust` to force rustc to report it's built for
different host.

The caching may happen if one has target/ directory in repo, or it was
created through running some commands outside of bazel.

Details:

After recent fixes to support properly bzlmod
(bazelbuild#3034) noticed issues
under windows when building bazel-lsp: cameron-martin/bazel-lsp#92

Cargo may cache rustc info in target/.rustc_info.json :
https://github.com/rust-lang/cargo/blob/769f622e12db0001431d8ae36d1093fb8727c5d9/src/cargo/util/rustc.rs#L163

The rules_rust hacks rustc by setting HOST_TRIPLE:
https://github.com/bazelbuild/rules_rust/blob/3aecdbedba0c001d0660ff631aeccb35d94ff3a7/crate_universe/src/metadata/cargo_tree_resolver.rs#L152

The HOST_TRIPLE env variable is not taken into account by cargo when
checking whether cached rustc info is valid:
https://github.com/rust-lang/cargo/blob/769f622e12db0001431d8ae36d1093fb8727c5d9/src/cargo/util/rustc.rs#L320
hauserx added a commit to hauserx/rules_rust that referenced this pull request Dec 15, 2024
The cargo_tree_resolver discovers dependencies by executing `cargo tree`
for different host and target triples. This procedure breaks when cargo
successfully but incorrectly caches rustc info. Incorrect cache hit may
happen because cache key does not take into account HOST_TRIPLE env
variable used by `rules_rust` to force rustc to report it's built for
different host.

The caching may happen if one has target/ directory in repo, or it was
created through running some commands outside of bazel.

Details:

After recent fixes to support properly bzlmod
(bazelbuild#3034) noticed issues
under windows when building bazel-lsp: cameron-martin/bazel-lsp#92

Cargo may cache rustc info in target/.rustc_info.json :
https://github.com/rust-lang/cargo/blob/769f622e12db0001431d8ae36d1093fb8727c5d9/src/cargo/util/rustc.rs#L163

The rules_rust hacks rustc by setting HOST_TRIPLE:
https://github.com/bazelbuild/rules_rust/blob/3aecdbedba0c001d0660ff631aeccb35d94ff3a7/crate_universe/src/metadata/cargo_tree_resolver.rs#L152

The HOST_TRIPLE env variable is not taken into account by cargo when
checking whether cached rustc info is valid:
https://github.com/rust-lang/cargo/blob/769f622e12db0001431d8ae36d1093fb8727c5d9/src/cargo/util/rustc.rs#L320
hauserx added a commit to hauserx/rules_rust that referenced this pull request Dec 16, 2024
The cargo_tree_resolver discovers dependencies by executing `cargo tree`
for different host and target triples. This procedure breaks when cargo
successfully but incorrectly caches rustc info. Incorrect cache hit may
happen because cache key does not take into account HOST_TRIPLE env
variable used by `rules_rust` to force rustc to report it's built for
different host.

The caching may happen if one has target/ directory in repo, or it was
created through running some commands outside of bazel.

Details:

After recent fixes to support properly bzlmod
(bazelbuild#3034) noticed issues
under windows when building bazel-lsp: cameron-martin/bazel-lsp#92

Cargo may cache rustc info in target/.rustc_info.json :
https://github.com/rust-lang/cargo/blob/769f622e12db0001431d8ae36d1093fb8727c5d9/src/cargo/util/rustc.rs#L163

The rules_rust hacks rustc by setting HOST_TRIPLE:
https://github.com/bazelbuild/rules_rust/blob/3aecdbedba0c001d0660ff631aeccb35d94ff3a7/crate_universe/src/metadata/cargo_tree_resolver.rs#L152

The HOST_TRIPLE env variable is not taken into account by cargo when
checking whether cached rustc info is valid:
https://github.com/rust-lang/cargo/blob/769f622e12db0001431d8ae36d1093fb8727c5d9/src/cargo/util/rustc.rs#L320
github-merge-queue bot pushed a commit that referenced this pull request Dec 16, 2024
The cargo_tree_resolver discovers dependencies by executing `cargo tree`
for different host and target triples. This procedure breaks when cargo
successfully but incorrectly caches rustc info. Incorrect cache hit may
happen because cache key does not take into account HOST_TRIPLE env
variable used by `rules_rust` to force rustc to report it's built for
different host.

The caching may happen if one has target/ directory in repo, or it was
created through running some commands outside of bazel.

# Details

- After recent fixes to support properly bzlmod
(#3034) noticed issues
under windows when building bazel-lsp:
cameron-martin/bazel-lsp#92

- Cargo may cache rustc info in target/.rustc_info.json :
https://github.com/rust-lang/cargo/blob/769f622e12db0001431d8ae36d1093fb8727c5d9/src/cargo/util/rustc.rs#L163

- The rules_rust hacks rustc by setting HOST_TRIPLE:
https://github.com/bazelbuild/rules_rust/blob/3aecdbedba0c001d0660ff631aeccb35d94ff3a7/crate_universe/src/metadata/cargo_tree_resolver.rs#L152

- The HOST_TRIPLE env variable is not taken into account by cargo when
checking whether cached rustc info is valid:

https://github.com/rust-lang/cargo/blob/769f622e12db0001431d8ae36d1093fb8727c5d9/src/cargo/util/rustc.rs#L320
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants