Support passing attributes on the command line
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start by reviewing bindgen's command-line options and the derived-type generation path; no repository file or test is named in the issue. Define how a flag should add zerocopy attributes to generated types, including the requested unconditional derives and on_error behavior, then add coverage showing the generated bindings compile.
Written by the indexing model from the issue text.
Description
Seems like this has been discussed in various places, but I'm not sure if there's a single issue that tracks this. Feel free to close in favor of one of those.
In https://github.com/google/zerocopy/pull/2982, we're adding a #[zerocopy(on_error = skip/fail)] attribute that would allow code to compile even if a type derives a trait which it can't implement, e.g.:
use zerocopy::*;
// Can't be `FromBytes` because `bool: !FromBytes`
#[derive(IntoBytes, FromBytes)]
#[zerocopy(on_error = skip)]
struct Foo(bool);
This is especially useful in conjunction with bindgen. Many zerocopy users add zerocopy derives to bindgen-generated types, but need to jump through significant hoops (such as the hoops that Fuchsia jumps through) in order to avoid adding #[derive(Xxx)] on a type that can't support the trait being derived.
Once this attribute is supported, they can unconditionally add all zerocopy traits and add #[zerocopy(on_error = skip)] to ensure everything compiles regardless of which traits are supported.
Currently, bindgen doesn't support a flag to automatically add attributes to derived types, so this would have to be done as a post-processing step. It'd be great if such a flag were supported. Note that this is a soft blocker for the Linux kernel to be able to use zerocopy.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 846
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 11
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rust-lang/rust-bindgen
-
--enable-cxx-namespaces panics on namespace [[deprecated]] { ("[" is not a valid Ident)Possibly taken @lwz23 claimed this 47 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
rust-lang/rust-bindgen#3485 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
rust-lang/rust-bindgen#3483 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
rust-lang/rust-bindgen#3370 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
rust-lang/rust-bindgen#3363 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
rust-lang/rust-bindgen#3540 ·
Maintainers usually reply within 1 day
All issues in rust-lang/rust-bindgen
Similar issues
-
yara-x fails to build with rsa 0.10.0: unresolved import rsa::Pkcs1v15SignPossibly taken @CfirTsabari claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 87/100
VirusTotal/yara-x#865 ·
Maintainers usually reply within 1 day
-
good first issue help wanted program
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
hffgzktbcc-blip/ounce-core#297 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
nautechsystems/nautilus_trader#5631 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
bytecodealliance/rustix#1736 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
longbridge/gpui-kit#3871 ·
Maintainers usually reply within 1 day