-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Make --export-dynamic
the default option when linking executables.
#34131
Comments
We probably don't want to blanket pass |
Actually, I've just realised that maybe it doesn't need to be transitive at all, and maybe you don't even need new syntax. What about if just every public symbol in the main executable is converted to a dynamic symbol? Does Maybe I should change the issue to " |
Yeah in theory all reachable symbols ("pub to the root") should be exported from an executable. We don't do much with whether symbols are dynamic or not, we largely just configure their linkage visibility to LLVM currently. |
Unfortunately I don't know anything about how LLVM handles linkage, but the dynamic symbols are important and the result of compiling a Rust program seems inconsistent at the moment. There are quite a few dymanic symbols already coming out, but apart from I'm not sure what you mean by "pub to the root", is root |
The other dynamic symbols are likely coming from dependencies, which are compiled differently. By "pub to the root" I just mean reachable if the executable were actually a crate. |
#85673 will add a |
With
#[no_mangle] pub fn
Rust exports a dynamic symbol for the defined function in an executable, but this behaviour is somewhat magical and not transitive.If
--export-dynamic
is made the default then all symbols that are marked as visible in any dependency of the executable will also be exported as a dynamic symbol. This is important for libraries that support plugins where the plugin needs to be able to call back into a function defined in the library. The case I am dealing with is Lua plugins which must have access to the Lua runtime functions when loaded, but presumably the same issues exist for other pluggable libraries (for example SQLite loadable extensions).So long as Rust correctly manage its symbol visibility, and authors of static libraries correctly manage the symbol visibility of the C functions in their libraries, this change should have no down-sides.
I believe currently Rust does not quite manage symbol visibility correctly because it leaves every local absolute symbol visible. I'm not sure if there is a reason for this or it is just an oversight, but this would probably need to be resolved.
On the issue of the
#[no_mangle] pub fn
I'm not sure why this behaviour is not transitive, but I believe this issue should also be fixed. I may not be using it correctly, but I cannot seem to make a#[no_mangle] pub fn
from a dependency appear in the symbol table of an executable.I believe this is related to issue #27541.
The text was updated successfully, but these errors were encountered: