-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Please considering removing non-determinism from bon's macros #218
Comments
Hi, thank you for creating the issue! I suspected, this non-determinism could cause some trouble, although I didn't know how exactly, so I was waiting for an issue like this to convince myself that removing randomness would be important. Given your explanation, I'm okay with changing the private fields to use static identifiers. It was my experimental way to ensure "hygiene" as you mentioned, which I thought would be very important given that the generated code internally uses Anyway, I guess this precaution isn't worth the headache of non-determinism that you found. I think it's enough for the fields to be marked with Just a followup question. How did you discover this problem? Did you stumble on repeated cache misses when building with Buck or did you pre-audit the code before upgrading to 3.1? |
Removed non-determinism. If users ever try to access the private fields of the builder, they'll get this warning:
(also added |
Thanks so much for the prompt reply and fix!
Yeah, that makes sense—soundness is a pretty reasonable motivation.
Nope! Nothing that clever; just monorepo-wide CI! Some crates failed to build with E0460:
I'm skipping past a few details, but this error shouldn't be possible to hit with Buck because of how the build graph is constructed and executed. While that error is a tell-tale sign of non-determinism in a crate (at least, under Buck/Bazel), some folks found the non-determinism inside Bon, and well, here we are. |
Thank you for the pointer to the error. I'll keep that in mind in the future. Hopefuly, this problem wasn't too much of a headache to debug. Sorry, for breaking your CI 😳 I've released a patch |
I honestly don't know how generalizable the E0460 trick actually is. I've mostly pattern matched on previous examples of non-determinism in Buck and this error was the common detail. I assume Bazel would also run into this error, but I don't know if, for example, Nix would report this error or if it'd just have suspiciously longer build times. (It'd be cool if rustc could tell if a proc macro was non-deterministic or if there was a cargo tool that did this, but ah well.)
Don't worry about it! This took us about 5 minutes to debug, if that. I spent more time writing up this issue 😀. Besides, this broke the tests before the Phabricator diff/PR landed. Even if CI was broken after landing, CI is meant to be broken and it would've been automatically bisected and reverted by a bot. There is no need to apologize at all. I'm just really thankful over how quickly you fixed this problem and how much you communicated about the why behind the original decision!
Thank you so much for the quick fix! We'll get on it right away. |
Hello! Would you be willing to remove the non-determinism in the proc macros? Part of my job is supporting Rust at Facebook, which builds the code using Buck. Buck strongly depends on deterministic builds in order to cache intermediate artifacts and produce correct binaries, but this non-determinism blocks my colleagues and I from upgrading to bon 3.1.
(As a previous example where non-determinism is problematic for Buck—and I assume Bazel—see: yaahc/displaydoc#52.)
As an alternative, I think a
#[doc_hidden]
could be supplant rust's lacking macro hygiene—rust-analyzer will not complete#[doc_hidden]
items, which should prevent most accidental usage of bon's internals.A note for the community from the maintainers
Please vote on this issue by adding a 👍 reaction to help the maintainers with prioritizing it. You may add a comment describing your real use case related to this issue for us to better understand the problem domain.
The text was updated successfully, but these errors were encountered: