mascarenhas / alien

A C FFI for Lua
http://mascarenhas.github.com/alien/
143 stars 45 forks source link

alien.lua: on darwin modules have file extension .so too. #17

Closed gvvaughan closed 12 years ago

gvvaughan commented 12 years ago

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 :)

gvvaughan commented 12 years ago

Added a patch to use APPLE instead of DARWIN.

Also, the SIGSEGV appears to be a Lion XCode bug with Apple's llvm build... using the previous apple gcc-4.2, everything appears to be working. (Debugging compiler errors is beyond my skills, so now that I have a working build, I don't plan to take it any further).