mascarenhas/alien — pull request #17 by gvvaughan (2012-06-14 20:34:11+00:00)
Title: alien.lua: on darwin modules have file extension .so too.

* src/alien.lua (load_library_helper): Return the error message
on faliure rather than abort.
(load_library.linux): Adjust.
(load_library.darwin): If .dylib load fails, also try with .so
before aborting.

This isn't complete, but is a start at making darwin builds work out of the box.

I still need to pass CPPFLAGS=-DDARWIN manually at configure time, or else the dlopen code is not compiled in. Would you prefer to change the .c files to use #ifdef __APPLE__ instead of #ifdef DARWIN, or have DARWIN defined in config.h when configure/config.guess detect a darwin system at build time?

At this stage, the build completes without warnings, but make check SIGSEGVs before alientest.c:_testfunc_i_bhilfd returns. If I uncomment the printf, that displays correctly, so execution is reaching the called function through libffi. But even if I return an integer constant, alien segfaults before reaching the next test. I'm completely new to libffi, so any advice on where to look gratefully received :)