lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Note that the below is not relevant to any systems more embedded than a router; they won't care because they won't use ELF SVR4-style shared libraries.

IMO, the most compelling argument for the odd way upstream prefers to build modules is that the main program does not have to be position-independent. On some architectures, there is a large penalty for PIC, especially on i386 implementations. (For starters, you lose a very scarce register.) Using /usr/bin/lua as liblua.so as well helped get Lua to the top of the programming language shootout.

We're just about at the end of the i386 architecture. All the other platforms which could use shared libraries are not so register-starved. In the "PC" space, almost everything is amd64, and amd64 is much better for position-independent code. 

In addition, the preferred way to build liblua.so these days is to only export the public Lua API. This allows the linker to optimize internal references to private symbols. 

I would run benchmarks for you in my museum, but I would need some benchmarks to run. Any pointers or volunteers?

Jay

(Overhead could be reduced more if external symbols did not affect how liblua.so refers to the liblua.so symbols. This breaks LD_PRELOAD among other things, but it's about morally equivalent to exporting symbols from the main program.)


On Thu, Jun 22, 2017, 00:32 Deepak Jois <deepak.jois@gmail.com> wrote:
Thanks for the suggestions.

On Wed, Jun 21, 2017 at 1:26 PM, Deepak Jois <deepak.jois@gmail.com> wrote:
> Is there a specific way to link the Lua code inside of Rust
> so that the symbols are available to the C module?

FWIW, I managed to solve this by linking the Rust program with the
right flags. I had to pass a flag -rdynamic.

I just found the answer by doing a lot of trial and error, and
research. I can’t claim I understand all the mysteries of linking. I
wonder if this sort of info is already there on some Lua wiki. If not,
I would add it to an appropriate place if somebody can point it out to
me.

Some helpful links for anybody who might end up in the archives
searching for the exact same problem:

* https://stackoverflow.com/questions/21279036/what-is-clangs-equivalent-to-rdynamic-gcc-flag

* http://keitaito.com/blog/2017/01/02/exploring-compiler-options.html