-
Notifications
You must be signed in to change notification settings - Fork 442
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
Hermetic build.rs
#490
Comments
(For reference, that line was introduced by #447) I have no objections to making this off by default if necessary, though I don't think it will completely solve the issues of hermeticity - build scripts can still access arbitrary paths on the filesystem, call programs in the standard PATH, and make network requests for example. |
I'll try to do some investigating myself but it'd be a huge help if someone could enumerate all the things required to make In my experience, 80% of the |
Actually, the snippet I had questioned earlier doesn't seem problematic. @dfreese is there something else I'm missing? |
@UebelAndre some I don't think |
I came to the same conclusion about |
The reason for not changing Hence my suggestion to maintain a list of select well-known / trusted crates that would have |
How would it result in non hermetic builds? Won't that. Crate simply fail to build because |
Maybe bazelbuild/bazel#7026 is why? |
Will it, though? |
The outputs would go into This is quite the tricky situation. Maybe the output directory is something that should be explicitly requested when defining targets? |
Maybe not, that would probably lead to obscure build errors downstream. And work would be wasted since it wouldn't stop |
The thing I'm wondering now is, is there way to identify whether or not a |
I think naive way would be looking at We could be either permissive and allow crates with |
Is there an example of something that enumerates imports? Like a built in |
I have no idea, sorry. You'd probably need to use something like rust-analyzer. |
That might not actually work. Given https://github.com/dtolnay/syn/blob/master/build.rs Is there a way to restrict what binaries an action is allowed to use? |
Ops, you're right, libc's build.rs does the same, not sure how I've missed that. |
I believe that rules_rust/cargo/cargo_build_script.bzl Lines 135 to 143 in f33e3b3
and rustc : rules_rust/cargo/cargo_build_script.bzl Line 109 in f33e3b3
into relevant env vars so that these things work hermetically by default. We even go as far as to try to redact absolute paths in the outputs that build scripts propagate to their dependees (see the callers of rules_rust/cargo/cargo_build_script_runner/lib.rs Lines 176 to 178 in f33e3b3
Just like any action, you can do things like try to enumerate FWIW I would be strongly in favour of defaulting |
@dfreese do you concur with what @illicitonion is saying? |
Also curious to hear from @damienmg on this. |
default_shell_env can be forced with --action_env and was the scheduled way to run those rule in an hermetic fashion while still allowing for the ease of use of using the default environment. I don't think this should be removed. |
@damienmg Yeah, I think the conversation has moved away from suggesting that be removed. Given #490 (comment) I think it'd be reasonable to default |
I also think that default_gen_buildrs to true is sensible default. |
The next release of |
The Rust Bazel rules should have a way to handle
build.rs
in a hermetic way. My current hypothesis is that this could be handled by removing the following:and by adding a way for users to optionally enable
default_shell_env
.The text was updated successfully, but these errors were encountered: