-
Notifications
You must be signed in to change notification settings - Fork 424
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
Fix bzlmod examples on windows #2454
Conversation
602f9ad
to
9108a96
Compare
It seems that we can't build |
This runs the build on multiple platforms, uploads the artifacts for the release process to subsequently download. This only builds for x86 on osx and linux. Windows currently does not work due to bazelbuild/rules_rust#2454. For arm64 cross-compiling will need to be set up.
So the issue is that you can't run cargo build scripts when using bzlmod when rules_rust is an external repository. When trying to launch the build script, it fails with
Maybe it has something to do with weird characters in the path name. Here's the difference between the paths of the executables when running from rules_rust vs an external repository:
The first example is from rules_rust, the second is when running from the bzlmod example. Possibly its the tilde that's causing issues? |
Okay I know what is happening here. The issue is actually with the current_dir argument here. This goes beyond the 260 char file name limit on windows when running from an external repository. For example:
This still exceeds this limit when using a really short output base, for example Not sure what the best solution to this is. Can we just expect people to enable long paths, and do so on the CI machines too? |
9108a96
to
31ecb63
Compare
31ecb63
to
b082e96
Compare
Now there's a failure when linking. This directory is too long:
Any ideas on how to cut this down? Does the build script name actually need to be |
That comment is from abrisco/cargo-bazel#37. |
I believe we already enable long paths on the CI machines, however this is not sufficient because a lot of the Windows tools do not work with them (MSVC's |
@scentini It looks like the crate name is read from the executable name to set the rules_rust/cargo/private/cargo_build_script.bzl Lines 409 to 420 in 53daac7
I think changing this suffix to something shorter should work though. |
@cameron-martin I'm in favor of doing both if possible. For For the prefix - you're right; I believe that we could still make it work, by adding a |
Changing the suffix seems to work. Running EDIT: From reading some of the docs, I believe so. I've made windows just build |
b422285
to
9546771
Compare
On windows (and some other platforms), the file extension of cargo, rustc, etc have an extension. The module extension for loading crates did not take this into account, causing it to error on windows. Additionally, when using bzlmod to build vendored crates, the runfiles tree would exceed the 260 char windows path limit. To mitigate this, I have shortened the internal_deps module extension to just i and changed the build script suffix to `_bs`, from `_build_script`. This makes the path names below the 260 char limit. This makes the bzlmod CI run on windows, to avoid regressing this. Currently gen_rust_project does not run on windows for other reasons, although we do build this.
a408043
to
43662a9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@scentini Looks like the merge queue failed due to a network error when downloading a tar. |
When using rules_rust in another project (but not when running the rules_rust examples themselves) it's still trying to link paths longer than 260 chars when building the process wrapper, e.g:
Not sure why this only manifests itself when using it outside this repo. |
On windows (and some other platforms), the file extension of cargo, rustc, etc have an extension. The module extension for loading crates did not take this into account, causing it to error on windows. Additionally, when using bzlmod to build vendored crates, the runfiles tree would exceed the 260 char windows path limit. To mitigate this, I have shortened the internal_deps module extension to just `i` and changed the build script suffix to `_bs` from `_build_script`. This makes the path names below the 260 char limit. This makes the bzlmod CI run on windows, to avoid regressing this. Currently gen_rust_project does not run on windows for other reasons, although we do build this.
On windows (and some other platforms), the file extension of cargo, rustc, etc have an extension. The module extension for loading crates did not take this into account, causing it to error on windows.
Additionally, when using bzlmod to build vendored crates, the runfiles tree would exceed the 260 char windows path limit. To mitigate this, I have shortened the internal_deps module extension to just
i
and changed the build script suffix to_bs
from_build_script
. This makes the path names below the 260 char limit.This makes the bzlmod CI run on windows, to avoid regressing this. Currently gen_rust_project does not run on windows for other reasons, although we do build this.