-
Notifications
You must be signed in to change notification settings - Fork 53
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
Provide C interface #13
Comments
For further context, bloaty is a elf/mach file size analyzer, which I think would be useful for the wider Rust community if it were able to demangle Rust symbols. |
I'd be totally down for supporting this! I think this library would make a great candidate for a C interface :) If you want to send a PR I'd be more than willing to help take a look and see how we can land it |
I hit bit of a snag while implementing this in the same package; rustc-demangle is no_std (which is nice), but crate-types cdylib/staticlib require eh_personality/panic_fmt implementations. While I could add dummy implementations, that would not be appropriate for lib/rlib crate types. Not sure if this could be resolved with some conditional compilation or feature flag trickery, rust-lang/rust#20267 is bit ambiguous. Overall this leads me to think that it might be better to have the C library part in its separate crate/package. Is there some general best practice on how this sort of thing is organized? Can the C lib still live in this same source tree as some sort of sub-crate(??) that Cargo then builds separately? Anyways, my WIP branch is at https://github.com/zokier/rustc-demangle/tree/c_library if you want to take a look. The wrapper function code itself is ready, but I am not able to build a cdylib/staticlib from it. |
Aha yes indeed! I was thinking though that the C API would be a separate crate that just links to |
A good example to go off I think is perhaps the |
@zokier & @alexcrichton Is there anything blocking this PR? What would be needed to push it over the finish line? EDIT: I meant to post this on #14. |
Nah nothing blocking, just never got around to finishing it I think! |
Bloaty has a use for Rust name demangling (see bloaty#110). Bloaty being C++ application we'd need to have a C interface to be able use rustc-demangle for that purpose.
I made quick wrapper (zokier/rustc-demangle-clib) but I think it is something that would make sense to have in-tree here.
The exact form of the interface can be discussed further, that wrapper has been made solely for the needs of bloaty.
If agreed, I can polish the the code (add tests and docs) and submit it as PR here.
The text was updated successfully, but these errors were encountered: