lua-users home
lua-l archive

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


-Wl,-E doesn't seem to prevent the linker from stripping them out as
unused functions, I'm afraid.  And turning off code stripping in the
linker globally isn't really be ideal.  I want the linker to strip out
unused code.  I just want to note that specific functions will be
referenced externally (in a dll, that's what the visibility attribute
does).  You don't have this problem with normal C functions you call
from lua, since you explicitly pass them to lua_open (and the linker
can't remove them since they have been referenced).  That's why I feel
like a ffi_register solution would be nice - and it would also cleanly
solve the namespacing issue in a simple, familiar fashion.  Ideally,
it would also allow you to avoid doing a ffi.cdef in lua for those
functions:

static const struct ffi_reg blockLib [] = {
  {"block_t* copy(block_t* src, block_t* dest)", blockCopy},

...

ffi_openlib(L, "block", blockLib, 0);	

-- in lua, no ffi.cdef necessary
ffi.block.copy(src, dest)




On Mon, Jun 13, 2011 at 5:10 PM, Mike Pall <mikelu-1106@mike.de> wrote:
> Scott Shumaker wrote:
>> > If you export them, then they don't get stripped.
>>
>> I've tried both: __attribute__((__visibility__("default"))), #pragma
>> GCC visibility push(default) - and neither one seems to do the trick.
>> Is there some other trick I need to get this to work (gcc version
>> 4.4.3 (GCC), cross-compiling for android).
>
> No, that's not how it works on Linux/Android and most ELF systems.
> Executables do not export any symbols by default. You need to use
> the -Wl,-E option when linking your executable.
>
> Conversely, this means you need to hide the non-static symbols you
> don't want exported (e.g. with visibility "hidden").
>
> --Mike
>
>