Is there a way to get bindgen to emit #[link(name = ...)] attributes with a particular prefix? In particular, I have a crate (let's call it "krate") which packages a C dependency that might also be present on consumers' systems. In order to avoid conflicting with other Rust code also depending on this library, I mangle the symbols to add a RUST_KRATE_ prefix. E.g., the FOO_init function is provided using the symbol RUST_KRATE_FOO_init. Thus, I'd like to instruct bindgen to emit something like:
Presumably you also need to convince C to prefix its symbols. Mature libraries usually wrap all function definitions in a macro to allow such things. So if you manage to make the C header use prefixed symbols, then you should be able to feed it to bindgen and it will pick it up prefixed symbols the normal way.
That would work too, but then I'd need to figure out how to re-export using the old names (ideally not by hand, I guess it wouldn't be the end of the world). These symbols are going to be exported from my crate, and I don't want my users to have to see krate::RUST_KRATE_FOO_init; I'd rather they just see krate::FOO_init.