-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Generating libc from C headers #423
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
Comments
I don't think there's necessarily a large amount of motivation for this in the sense that this entire library is already verified as correct and header -> Rust generators I've seen tend to have lots of things that need to be fixed by hand. It's certainly plausible to generate headers and then commit them, but I don't think there's any particular reason to rewrite the crate to use generation now. |
It doesn't support newlib currently (or more obscure C libraries), which makes porting |
Trying to clean-up issues: is this still an issue @Zoxc ? |
@kristate It is. |
Platforms break ABI compatibility all the time due to changes in the values of constants, enums, sizes and alignment of structs, even signature of functions. As long as libc does not use a binding generation, every single libc version targets a specific version of an API, and has undefined behavior on all others. |
@Zoxc This is not a bad idea. The main problems are that generating libc from headers requires:
If one needs to re-compile libstd anyways, one can I think it would be better to create such a "libc-bindgen" first, add minimal support to Once we are there, we could start considering whether it is worth integrating such a thing with libc somehow. But I think that right now it would be too soon to discuss such a thing because we lack information about the problems / issues that will need to be solved for that to happen. Another approach that such a different As @alexcrichton mentions, I doubt that this is a process that can be fully automated. Bindgen has made huge leaps in the last couple of years, but even for tiny well-behaved C libraries I've needed to perform significant manual modifications when attempting to do similar things. Platform headers are anything but well-behaved and use a lot of platform specific C compiler features, that might cause clang and/or bindgen significant trouble. |
I'd be glad to help anybody wanting to pursue such an endeavor, but I think that it might be best to close this issue for now, because until somebody puts in the effort to come up with a proof-of-concept of this, we just know too little about which problems need to be solved for us to have a fruitful discussion about this. |
It would be nice if there was a way to generate
libc
using just a standard C library. That would make porting to less common targets way easier and also ensures that the headers are correct.The text was updated successfully, but these errors were encountered: