Open deepakjois opened 7 years ago
@Parakleta, it seems you posted something similar here: https://users.rust-lang.org/t/exporting-dynamic-symbols-from-executable/6103/3
Do you have any idea what’s going on here?
What I posted there is probably exactly the issue you're having. Essentially the lfs.so
module needs the be able to see the Lua API functions in the executable, and a chain of compile options are required to keep them visible to the end. I haven't compiled this stuff in ages so I don't know exactly what is still relevant.
You'll need the use the nm
utility on the output of the various compile stages to work out where the symbols are being lost. Have you tried creating the dynsyms.txt
file and the custom build rule from the linked post? Also try setting the LUA_API
and LUALIB_API
to set default visibility in luaconf.h
I think.
On Linux, when I put this is my .cargo/config
file, things work fine and the Lua C module loads successfully:
[build]
rustflags = ["-C", "link-args=-Wl,-export-dynamic"]
On OS X, I have to tweak the linker flags slightly:
[build]
rustflags = ["-C", "link-args=-Wl,-export_dynamic"]
See the underscore instead of the dash, i.e. export_dynamic
instead of export-dynamic
.
After doing a little bit more research it appears that a more cross-platform solution is putting this in .cargo/config
[build]
rustflags = ["-C", "link-args=-rdynamic"]
Discovered this via a tip here: https://stackoverflow.com/questions/34082636/expose-symbols-to-dynamic-linker-when-linking-with-native-library-in-rust
This is a separate error from #84. This occurs on both OS X and Linux. In the code snippet below:
serpent
is a regular Lua module andlfs
(luafilesystem) is a C module.On Linux it gives the following error:
On OS X (after fixing #84), it gives the following error: