rust-lang / rust-bindgen

Automatically generates Rust FFI bindings to C (and some C++) libraries.
https://rust-lang.github.io/rust-bindgen/
BSD 3-Clause "New" or "Revised" License
4.4k stars 691 forks source link

Simplify Rust to Clang target conversion #2808

Closed jorolf closed 5 months ago

jorolf commented 5 months ago

This change simplifies/generalizes the rust to clang target conversion and allows more targets to work. (e.g. riscv32i-unknown-none-elf)

Let me know if I'm missing something!

pvdrz commented 5 months ago

I like the spirit of this PR as the current code has been pretty much a "oh damn, this other target doesn't work, let me get some tape" kind of situation,

It also makes me think that we should have some dedicated type for the target triples. So instead of doing target.starts_with("architecture") we were able to do things like target.architecture == "architecture" or something.

Maybe using https://docs.rs/target-lexicon would be a good idea. It is an extra dependency, but it doesn't have other dependencies and it is well maintained IMHO.