Generate bindgen files on build#236
Conversation
Import a minimized version of bootparam.h, elf.h and start_info.h to be used by bindgen to generate the respective Rust files. Signed-off-by: Sergio Lopez <slp@redhat.com>
Carrying pre-generated bindgen files is problematic because different targets may require different translation of types. Drop bootparam.rs, elf.rs and start_info.rs, and have them generated on build using the Linux headers imported on the previous commit. Signed-off-by: Sergio Lopez <slp@redhat.com>
Since we now run bindgen on build, add a build requirements section indicating that clang is required to build this crate. Signed-off-by: Sergio Lopez <slp@redhat.com>
rbradford
left a comment
There was a problem hiding this comment.
I really don't think we should do this. I think it breaks cross compilation and makes big assumptions about the environment the build is run in.
|
I'm also confused about your comment about different translation of types - these are x86-64 specific files - with the C ABI there is only one way that these types can be defined on that platform. Can you share the real world problem you're trying to fix with this? |
Much on the contrary, this doesn't break cross compilation, but fixes it. In fact, this is the recommended way of using bindgen: https://rust-lang.github.io/rust-bindgen/library-usage.html. The only assumption about the build environment is that clang-devel is installed, as the required Linux headers are vendored.
The prime example of this is the discrepancy between the size of Running |
I think if you changed the size values then the kernel wouldn't boot as Linux guest assumes those fixed sizes |
Indeed, that's why we need The alternative to this PR would be manually fixing the files generated by bindgen to address every cross-os/cross-arch issue we find. |
|
IIRC in vm-virtio we did something similar but then reverted it with rust-vmm/vm-virtio#348 Not sure if those scripts can help here too. |
|
What about just making them "native rust" (i know we would still need the |
Kind of funny this one: "because users have found the requirement to have an up to date libclang at build time to be onerous". xD
Yeah, that would work (and I guess it'd be less onerous ;-P). Let me redo this PR. |
Summary of the PR
Carrying pre-generated bindgen files is problematic because different targets may require different translation of types.
Drop bootparam.rs, elf.rs and start_info.rs, and have them generated on build using the minimized Linux headers imported on the previous commit.
Requirements
Before submitting your PR, please make sure you addressed the following
requirements:
git commit -s), and the commit message has max 60 characters for thesummary and max 75 characters for each description line.
test.
Release" section of CHANGELOG.md (if no such section exists, please create one).
unsafecode is properly documented.