-
Notifications
You must be signed in to change notification settings - Fork 431
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
MacOS host paths being written into binaries #1530
Comments
I wonder if #1563 would help with this. |
I don't believe so - the issue is that However, I believe including tinyjson directly into the process_wrapper crate would work around this issue. |
I've run into something that might be related. When I run a build on my Ubuntu, but still do it remotely on RBE, it succeeds. On my pipeline machine, I'd expect to see it reusing actions pre-built just like it happens in all the other programming languages rules for Bazel I use. But what I'm seeing instead is my target trying to build again even when running against the same RBE. It complains I don't have clang in the RBE worker which surprised me to see it was able to build on my Ubuntu providing the same Adding clang to my worker fixed the error but I still don't fully understand why RBE isn't working as expected in rules_rust, causing my target to rebuild when it shouldn't. It is trying to rebuild Did someone find a workaround for that?
|
@bazaglia I successfully have rules_rust working with an Ubuntu remote execution environment without clang pre-installed. My guess is you're missing some toolchain for your exec platform. Some things I'd look at for debugging:
|
I attempted this solution. First I tried retaining the
An alternative could be to vendor tinyjson sources (i.e. check them into the repository) rather than trying to obtain them via a |
By the way, does anything prevent process_wrapper itself from being susceptible to the same issue? |
Yes, that's what I was thinking of anyway.
…On Fri, Dec 23, 2022, 15:20 John Firebaugh ***@***.***> wrote:
However, I believe including tinyjson directly into the process_wrapper
crate would work around this issue.
I attempted this solution. First I tried retaining the
@rules_rust_tinyjson repository but using copy_file from skylib to copy
individual source files at build time. This fails when building
process_wrapper in an external repository:
ERROR: /private/var/tmp/_bazel_john/c71b6d936ea520e6edb21b88752a38eb/external/rules_rust/util/process_wrapper/BUILD.bazel:25:36: in rust_binary_without_process_wrapper rule @rules_rust//util/process_wrapper:process_wrapper:
Traceback (most recent call last):
File "/private/var/tmp/_bazel_john/c71b6d936ea520e6edb21b88752a38eb/external/rules_rust/rust/private/rust.bzl", line 332, column 42, in _rust_binary_impl
srcs, crate_root = _transform_sources(ctx, ctx.files.srcs, getattr(ctx.file, "crate_root", None))
File "/private/var/tmp/_bazel_john/c71b6d936ea520e6edb21b88752a38eb/external/rules_rust/rust/private/rust.bzl", line 172, column 68, in _transform_sources
src_symlink = ctx.actions.declare_file(paths.relativize(src.short_path, package_root))
File "/private/var/tmp/_bazel_john/c71b6d936ea520e6edb21b88752a38eb/external/bazel_skylib/lib/paths.bzl", line 186, column 17, in _relativize
fail("Path '%s' is not beneath '%s'" % (path, start))
Error in fail: Path '../rules_rust/util/process_wrapper/flags.rs' is not beneath 'util/process_wrapper'
An alternative could be to vendor tinyjson sources (i.e. check them into
the repository) rather than trying to obtain them via a
@rules_rust_tinyjson repository. Is that what you had in mind?
—
Reply to this email directly, view it on GitHub
<#1530 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJO2TXUESS65DQFCD6ZBETWOYCSTANCNFSM57XZ5Y6Q>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
AFAIK rustc only inserts full file paths when instantiating cross-crate dependencies. It otherwise uses the exact paths provided on the command line, which are workspace-relative paths in our case. This could change in the future though. |
I have #1728 which should address the issue. It's hard to write a test for it, but does someone volunteer to do two |
I think I've found this to be a larger issue than than the process wrapper. As of v0.23.0 I'm able to consistently reproduce binaries within the same checkout but I cannot across different checkouts. When testing I get the following:
As well as (showing a binary built using the process wrapper)
This to me communicates incremental builds are able to produce the same outputs. However, if I were to clone
If I do an xxd dump of each file, I find that the Bazel output is embedded in each binary! 34379,34381c34379,34381
< 000864a0: 7269 7363 6f2f 3736 3238 3263 3636 6230 !!!!!/76282c66b0
< 000864b0: 6466 6533 6335 6362 3961 3233 3062 6463 dfe3c5cb9a230bdc
< 000864c0: 3931 3361 3532 2f65 7874 6572 6e61 6c2f 913a52/external/
---
> 000864a0: 7269 7363 6f2f 3262 6435 6633 3038 3038 !!!!!/2bd5f30808
> 000864b0: 6234 3531 3263 3830 3963 3561 6435 6130 b4512c809c5ad5a0
> 000864c0: 3539 3032 6532 2f65 7874 6572 6e61 6c2f 5902e2/external/
37589,37591c37589,37591
< 00092d40: 6973 636f 2f37 3632 3832 6336 3662 3064 !!!!/76282c66b0d
< 00092d50: 6665 3363 3563 6239 6132 3330 6264 6339 fe3c5cb9a230bdc9
< 00092d60: 3133 6135 322f 6578 7465 726e 616c 2f72 13a52/external/r
---
> 00092d40: 6973 636f 2f32 6264 3566 3330 3830 3862 !!!!/2bd5f30808b
> 00092d50: 3435 3132 6338 3039 6335 6164 3561 3035 4512c809c5ad5a05
> 00092d60: 3930 3265 322f 6578 7465 726e 616c 2f72 902e2/external/r
37651,37653c37651,37653
< 00093120: 6272 6973 636f 2f37 3632 3832 6336 3662 !!!!!!/76282c66b
< 00093130: 3064 6665 3363 3563 6239 6132 3330 6264 0dfe3c5cb9a230bd
< 00093140: 6339 3133 6135 322f 6578 7465 726e 616c c913a52/external
---
> 00093120: 6272 6973 636f 2f32 6264 3566 3330 3830 !!!!!!/2bd5f3080
> 00093130: 3862 3435 3132 6338 3039 6335 6164 3561 8b4512c809c5ad5a
> 00093140: 3035 3930 3265 322f 6578 7465 726e 616c 05902e2/external
37699,37701c37699,37701
< 00093420: 6562 7269 7363 6f2f 3736 3238 3263 3636 !!!!!!!/76282c66
< 00093430: 6230 6466 6533 6335 6362 3961 3233 3062 b0dfe3c5cb9a230b
< 00093440: 6463 3931 3361 3532 2f65 7874 6572 6e61 dc913a52/externa
---
> 00093420: 6562 7269 7363 6f2f 3262 6435 6633 3038 !!!!!!!/2bd5f308
> 00093430: 3038 6234 3531 3263 3830 3963 3561 6435 08b4512c809c5ad5
> 00093440: 6130 3539 3032 6532 2f65 7874 6572 6e61 a05902e2/externa
38121,38123c38121,38123
< 00094e80: 6472 6562 7269 7363 6f2f 3736 3238 3263 !!!!!!!!!/76282c
< 00094e90: 3636 6230 6466 6533 6335 6362 3961 3233 66b0dfe3c5cb9a23
< 00094ea0: 3062 6463 3931 3361 3532 2f65 7874 6572 0bdc913a52/exter
---
> 00094e80: 6472 6562 7269 7363 6f2f 3262 6435 6633 !!!!!!!!!/2bd5f3
> 00094e90: 3038 3038 6234 3531 3263 3830 3963 3561 0808b4512c809c5a
> 00094ea0: 6435 6130 3539 3032 6532 2f65 7874 6572 d5a05902e2/exter
38148,38150c38148,38150
< 00095030: 656c 5f61 6e64 7265 6272 6973 636f 2f37 !!!!!!!!!!!!!!/7
< 00095040: 3632 3832 6336 3662 3064 6665 3363 3563 6282c66b0dfe3c5c
< 00095050: 6239 6132 3330 6264 6339 3133 6135 322f b9a230bdc913a52/
---
> 00095030: 656c 5f61 6e64 7265 6272 6973 636f 2f32 !!!!!!!!!!!!!!/2
> 00095040: 6264 3566 3330 3830 3862 3435 3132 6338 bd5f30808b4512c8
> 00095050: 3039 6335 6164 3561 3035 3930 3265 322f 09c5ad5a05902e2/
38284,38286c38284,38286
< 000958b0: 7265 6272 6973 636f 2f37 3632 3832 6336 !!!!!!!!/76282c6
< 000958c0: 3662 3064 6665 3363 3563 6239 6132 3330 6b0dfe3c5cb9a230
< 000958d0: 6264 6339 3133 6135 322f 6578 7465 726e bdc913a52/extern
---
> 000958b0: 7265 6272 6973 636f 2f32 6264 3566 3330 !!!!!!!!/2bd5f30
> 000958c0: 3830 3862 3435 3132 6338 3039 6335 6164 808b4512c809c5ad
> 000958d0: 3561 3035 3930 3265 322f 6578 7465 726e 5a05902e2/extern
39091,39093c39091,39093
< 00098b20: 0ae3 64fc e432 f3b0 9ed1 5a6b 42b8 ccf8 ..d..2....ZkB...
< 00098b30: 83cb bcc1 c04e 4e67 3bb3 65ed ba54 0f43 .....NNg;.e..T.C
< 00098b40: 5fd7 f326 c5dc 3897 46b2 3e3f 744e 16f5 _..&..8.F.>?tN..
---
> 00098b20: 0ae3 64fc e432 f3d4 b6a5 17ad c586 10c4 ..d..2..........
> 00098b30: b515 7daa 1e76 bbff e44c b040 ba77 f877 ..}..v...L.@.w.w
> 00098b40: 8051 856f 34b8 0097 46b2 3e3f 744e 16f5 .Q.o4...F.>?tN..
39115,39123c39115,39123
< 00098ca0: 0b02 b312 4c9b 48d0 90a8 8d9d 88c1 f969 ....L.H........i
< 00098cb0: 3b0f 5259 1e1e 0e7d 869b cccc cadf 750a ;.RY...}......u.
< 00098cc0: aada 93f5 af8f b37b be77 7b91 f87d ba48 .......{.w{..}.H
< 00098cd0: 924d c755 9158 06fa 669e b80a 70f7 f389 .M.U.X..f...p...
< 00098ce0: a680 77e8 362a 20a1 61dc fc50 4f40 71e7 ..w.6* .a..PO@q.
< 00098cf0: 50e3 2ca4 7221 e2ee b700 98a3 1dfa dbf0 P.,.r!..........
< 00098d00: aec0 2032 e1cd 32a3 e3ef 4566 b18d b830 .. 2..2...Ef...0
< 00098d10: f463 36cc 6c9f d6a3 60c9 2207 ac9f 4c67 .c6.l...`."...Lg
< 00098d20: 0d4b e857 a9e7 7119 4e9a c4c8 1ecb 32ef .K.W..q.N.....2.
---
> 00098ca0: 0b02 b312 4c9b 48e0 403f 4d34 b3c7 7b18 ....L.H.@?M4..{.
> 00098cb0: 3fa4 8933 6468 9d58 1979 0632 e1fa 96a8 ?..3dh.X.y.2....
> 00098cc0: 88b7 1f65 cd72 ddd8 c3d0 9cb1 6648 b4d6 ...e.r......fH..
> 00098cd0: 6f20 67da e3c5 5a6f 3785 fb9a 6c7a b339 o g...Zo7...lz.9
> 00098ce0: dbfc 1694 9707 139e e2ea a74a 4ddd bb90 ...........JM...
> 00098cf0: c878 09f5 c42f 17aa 12a3 94ce 092e db31 .x.../.........1
> 00098d00: e11b b94e 5790 d5ec 0059 445c c246 e3b2 ...NW....YD\.F..
> 00098d10: 5e5b 20c0 febe 14d2 d9fe 4899 1fc3 641e ^[ .......H...d.
> 00098d20: cb45 3d84 5f0b 5b19 4e9a c4c8 1ecb 32ef .E=._.[.N.....2. These match the output bases of each workspace.
It's worth noting that the sandbox doesn't ever appear in the binary though (e.g.
The subcommand that produced this binary looks like:
I'm not sure where this embedded data is coming from or if rust is somehow escaping the sandbox but this to me is a major issue as it's virtually guaranteed that two developers will not be sharing the same output_base which means Rust targets are going to be cache missing and largely unreproducible depending on the CI solution. Any insight here would be hugely appreicated |
My experience with caching Rust builds in CI is that it actually works ok @UebelAndre, because It does mean that if the action is ever re-run and produces a result which should be identical, it instead invalidates all the other cached results though. Also if you ever build without the cache, which seems like a possibility for developers, then things won't work. |
I don't think the process wrapper is really the core issue anymore. It's an issue of general determinism in the rules. There's for sure band-aids that have helped mask this but I think this is a pretty major violation of one of the core principles of Bazel. For some of the projects I work on where we care immensely about determinism this would be considered a major issue. If anyone knows why those values are being written I'd love to know and want to work toward a fix. |
This may be resolved by rust-lang/rust#112586 |
This seems to only impact windows. |
I dug into this on linux as well and found that linux is actually reproducible. I'm only seeing this issue on MacOS (since I don't have a windows machine to test on). @illicitonion any suggestions on how to dig into MacOS binaries? I tried to see what section the host paths were being written to but I think I'm just failing to use |
My debugging so far:
However, it looks like the absolute path is one which isn't stripped by our My build appears to be happening in |
Where do you see this output? I think the thing I'm looking for is a path to bazel-out. All I see in I've also tried hacking in an explicit diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl
index 9f3b0c26..245d870c 100644
--- a/rust/private/rustc.bzl
+++ b/rust/private/rustc.bzl
@@ -934,6 +934,7 @@ def construct_arguments(
# For determinism to help with build distribution and such
if remap_path_prefix != None:
rustc_flags.add("--remap-path-prefix=${{pwd}}={}".format(remap_path_prefix))
+ rustc_flags.add("--remap-path-prefix=/private/var/tmp/_bazel_user/76282c66b0dfe3c5cb9a230bdc913a52={}".format(remap_path_prefix))
if emit:
rustc_flags.add("--emit=" + ",".join(emit_with_paths)) This still results in that path being found in my |
rust-lang/rust#116948 has some very useful info |
While experimenting with rules_rust build reproducibility, I found that the
process_wrapper
binary build is not deterministic.How I reproduced the problem:
I created 2 identical directories on my macOS machine with the following content:
Running
bazel build :panic
produced slightly different binaries.An inspection of
bazel-build-log.json
file showed thatprocess_wrapper
had different hashes in the two workspaces:The source of non-determinism is likely the
libtinyjson.rlib
file that has different file paths embedded into it:The first workspace had path "/tmp/sandbox/darwin-sandbox/1/execroot/main/...", the second workspace had path "/private/var/tmp/_bazel_lifted/dba7...561c/sandbox/darwin-sandbox/1/execroot/main/...".
Comment from Rosica Dejanovska:
The text was updated successfully, but these errors were encountered: