-
Notifications
You must be signed in to change notification settings - Fork 462
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
Add a build setting to disable the hash prefix on rust_test outputs.
#1600
Conversation
|
This is nice! Just to make sure @jmillikin : is this just for consistency with |
|
A little of column A, and a little of column B. I have a workflow for integration testing using cross-compiled test binaries running in QEMU. To support this without depending on the output file layout would require Migrating these tests to Rust has required me to patch my local version of rules_rust in a couple ways, one of which is the removal of the test binary's hash prefix. This PR, if merged, would let that patch be dropped in favor of a [0] That function has a |
|
could you refresh this PR so the buildkites get reran |
|
And could you add a test |
1a95907 to
7476c49
Compare
|
@krasimirgg OK, I rebased on current main HEAD and added a test. |
|
If |
The current behavior (introduced in PR #1434, which you reviewed) is for This PR adds the option to remove the hash from outputs, because (again, per PR description) it is unnecessary on platforms with sandboxing and interferes with incremental migration from codebases in other languages (C++). |
7476c49 to
3a70b90
Compare
|
Rebased to current @UebelAndre , it's been about six months since I sent this PR in. Would it be possible to get it reviewed? |
|
@scentini @krasimirgg do you know why we have this hash output? Why can't |
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.
Sorry for the delay! Been a busy year!
3a70b90 to
aed941e
Compare
There's a fairly comprehensive writeup in the PR I linked: #1434 |
157cffa to
1034632
Compare
Thanks! I'll take a look in a but but in the mean time, could you add some documentation to the new flag that contains a writeup? I think the most ergonomic way to document this would be to use a custom rule instead of the |
|
I'm not sure I'm the correct person to write those docs because I don't use Windows, don't have any need for the hash prefix added by @scentini in that PR, and all I want to do here is have an escape hatch to turn it off. I would be perfectly happy with a PR that removed the whole thing. Would copying chunks of the original PR into a docstring be sufficient? |
Yeah probably 😅. Anything we can do to communicate this clearly would be good. I know I've had folks ask me about this directly and it was definitely a challenge to remember and dig up. Having a breakdown in the repo would be awesome! |
20eb8c0 to
53aab35
Compare
|
@UebelAndre I've added a file |
The hash prefix for test outputs was originally added to work around potential filename conflicts between `rust_test` and `rust_binary` on platforms without sandboxed builds (Windows). However, on platforms that *do* have sandboxed builds, the prefix can be unwanted because it makes path of Rust test binaries different from what would be produced using other language rules such as `cc_test`. This commit adds a Bazel build setting so that the output prefix can be disabled in cases where it's unwanted.
53aab35 to
8d16d34
Compare
|
Rebased to current @UebelAndre gentle ping. Any remaining blockers? |
|
Hey! Thanks for the ping and sorry for the delay. I will take a look tonight and if you don’t see activity feel free to ping me again :) |
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.
Digging into this closer, I don't actually see a reason why rust_binary and rust_test need to have hashes in the outputs of their names. Why not just delete this behavior and have them always write consistent outputs? In the links below we see the output is based on ctx.label.name which should always produce unique outputs, right?
https://github.com/bazelbuild/rules_rust/blob/0.21.1/rust/private/rust.bzl#L329
https://github.com/bazelbuild/rules_rust/blob/0.21.1/rust/private/rust.bzl#L385-L392
https://github.com/bazelbuild/rules_rust/blob/0.21.1/rust/private/rust.bzl#L431-L438
|
I believe that @scentini provided detailed steps to reproduce the issue in the original PR, which I linked above, and which you reviewed. If you want to revert PR #1434 then that would solve my problem, but it would leave Windows users out in the cold, and you may want to consider carefully given that in #1427 (comment) you determined the inter-action file corruption to be a release blocker. I don't have a Windows dev machine available at the moment, but I can verify that on Linux, with the hashes disabled, build actions for rust_binary: rust_test: |
|
Instead of a feature that disables this, why not continue to build with hashes but for tests and binaries, use |
|
It seems like keeping a perma-fork of |
Sorry, It's definitely not my intention to string you or anyone else along in a PR. Coming into this I lacked both the time to properly review and history with the problem which makes the review stressful for me since I don't wanna have something merge that ends up causing more problems later, which unfortunately happens 😞. I've opened #1968 since I think it would be a good change to have predictable outputs. Does that work for your use case? |
|
A similar change was implemented in #2828 |
The hash prefix for test outputs was originally added to work around potential filename conflicts between
rust_testandrust_binaryon platforms without sandboxed builds (Windows).However, on platforms that do have sandboxed builds, the prefix can be unwanted because it makes path of Rust test binaries different from what would be produced using other language rules such as
cc_test.This commit adds a Bazel build setting so that the output prefix can be disabled in cases where it's unwanted.