-
Notifications
You must be signed in to change notification settings - Fork 759
Closed
Labels
Description
I'm trying to integrate a C library which supports symbol renaming. I want to use this feature in order to allow consumers to depend on multiple versions of my crate without encountering symbol conflicts during build.
In order to do this, I'd like the C symbol FOO
to be exposed through Rust as FOO
- the name people expect. However, I will invoke the C library's build system in a way that causes the emitted object file to expose the name CUSTOM_PREFIX_FOO
. Thus, I need to also emit a #[link(name = "CUSTOM_PREFIX_FOO")]
attribute on the Rust-side FOO
declaration.
It would be great if bindgen supported this natively, e.g. via a --symbol-prefix
flag. This feature would instruct bindgen to emit link
attributes as described above. Concretely:
- Original C name -
FOO
- C name after prefixing (this is what's exported from the object files) -
CUSTOM_PREFIX_FOO
- Rust name (what consumers of the crate see) -
FOO
- Attribute on Rust-side declaration -
#[link(name = "CUSTOM_PREFIX_FOO")]