zenoh icon indicating copy to clipboard operation
zenoh copied to clipboard

Is [no_mangle] required for plugins?

Open milyin opened this issue 2 years ago • 3 comments

Describe the bug

In the plugins the #[cfg(feature = "no_mangle")] before zenoh_plugin_trait::declare_plugin!(... is used to avoid export of unmangled get_plugin_loader_version, get_compatibility, and load_plugin functions when they are not needed, i.e. when plugin is linked as static. Though it seems that everything works without them.

https://github.com/eclipse-zenoh/zenoh-plugin-mqtt/pull/32#discussion_r1471001574

Need to understand is this no_mangle feature really necessary

To reproduce

System info

milyin avatar Feb 22 '24 12:02 milyin

I had symbol clashes in the past when statically linking more plugins, to be checked if it is still the case.

gabrik avatar Feb 22 '24 13:02 gabrik

I had symbol clashes in the past when statically linking more plugins, to be checked if it is still the case.

This is why the feature exists: when statically linking more than one plugin, the linker will fail because multiple definitions for the same symbols exist.

p-avital avatar Feb 22 '24 13:02 p-avital

I had symbol clashes in the past when statically linking more plugins, to be checked if it is still the case.

This is why the feature exists: when statically linking more than one plugin, the linker will fail because multiple definitions for the same symbols exist.

And that's the question now: how to reproduce this name clash again to justify usage of "no_mangle" ?

milyin avatar Feb 22 '24 13:02 milyin