[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: shared library RTTI with gcc
- From: Ronan Collobert <collober@...>
- Date: Thu, 04 Oct 2007 11:58:09 -0400
Hi,
I am using Lua since quite a while with (amongst other things)
hand-made packages written in C++. Some of these C++ packages are
dependent on other C++ packages. And these packages use RTTI.
There is a disputed bug in Lua and C++ packages. dlopen() is using the
flag RTLD_NOW only and *should*, for C++ libraries, use RTLD_NOW *and*
RTLD_GLOBAL. I have seen several emails on the mailing list about this
issue, but for some very obscure reasons, it seems the problem has been
abandoned each time, which is a shame, I believe.
Quote from gcc FAQ: http://gcc.gnu.org/faq.html#dso ...
"If you use dlopen to explicitly load code from a shared library, you
must do several things. First, export global symbols from the executable
by linking it with the "-E" flag (you will have to specify this as
"-Wl,-E" if you are invoking the linker in the usual manner from the
compiler driver, g++). You must also make the external symbols in the
loaded library available for subsequent libraries by providing the
RTLD_GLOBAL flag to dlopen. The symbol resolution can be immediate or lazy."
Note the "*must* [...] providing the RTLD_GLOBAL flag".
So, at least with gcc (but think about how common gcc is!) C++ libraries
support is broken under Lua.
Some people argue they do not like the RTLD_GLOBAL, but then it should
be at least possible to pass the right flags to Lua at run time to fix
this! (e.g. as supplied in Python). Right now people have to re-compile
their own Lua to use any C++ libraries dependent on RTTI.
Thanks for your understanding,
Ronan.