Closed VarLad closed 1 year ago
Yeah, I think we should be able to do something like this. We actually already have this for compille_shlib
thanks to #79, which we could probably build on to add this for compile_executable
as well
@VarLad have you tried out compile_shlib
yet? It does what you're asking for here. I'm not sure it makes any sense to have multiple functions exposed from compile_executable
since that is just meant to produce a binary, not a library like you seem to want here.
Completed by #122
It'd be nice if
compile_executable
could take a Tuple of functions, with the first element being the main function, and use the other function's object files to make the final executable. The use case being, I'm trying to find an alternative of@cfunction
for using bindings to a Rust library with StaticCompiler. The discussion took place in JuliaLang Zulip's general > StaticTools Other than that, having similar functionality forcomiple_shlib
would make sense as well, since it'd make single shlibs exposing mulitple functions/symbols quite easier. (as they're usually used)For the Rust binding: This can be solved via making
shlibs
out of the said functions and getting a pointer to them via dlsym. But this, while it works, would make the user experience a pain, both while developing and distributing. Another solution is to usedlopen(NULL)
in the program itself, and get a pointer to the required function via dlsym. The issue with this approach being, the function name being called gets mangled for some reason. Here's an example of the latter (from Zulip):This gives segfault when executed because the symbol name in the final binary gets mangled to
julia_add_RandomNumberHere