[erlang-patches] OS X fixes (HiPE, ddll unload)

Geoff Cant <>
Wed Sep 10 13:45:24 CEST 2008


Hi all, I wrote a couple of patches last night that improves Erlang OS X
support.

* http://github.com/mfoemmel/erlang-otp/commit/cf55be9b6dfcdbe8600decfee02d233e91cd88c2

This first patch is to replace the custom NSLinkModule machinery used for
loading libraries at runtime. While the old Apple TechNote TN2701
recommends you use NSLinkModule when porting unix applications, it was mainly
intended for OS X 10.2. Since OS X 10.3, the
dlopen/dlsym/dlclose/dlerror/dladdr functions are supported and
preferred. 

In the patch I've simply removed the HAVE_MACH_O_DYLD_H ifdefs and
special cases. The OS X code is now the same as other platforms with
HAVE_DLOPEN support.

* http://github.com/mfoemmel/erlang-otp/commit/8eb2f8c0b19bec023b8d1e8446b58c30b53c3c44

Since OS X 10.5.3 it hasn't been possible to compile Erlang/OTP with
hipe enabled due to problems with hipe_signal_init dumping core with a
SIGBUS while trying to patch sigaction
(http://www.erlang.org/pipermail/erlang-bugs/2008-May/000813.html). The
cause of this appears to be mach_override causing a SIGBUS for reasons I
don't understand.

In the patch I've altered the hipe_signal_init code to use the same
_sigaction wrapping mechanism as linux and solaris (saving the old
_sigaction via dlsym(RTLD_NEXT, "sigaction") and then overwriting that
address with a pointer to hipe's my_sigaction wrapper). As far as I can
tell, this should work the same way as other platforms and removes the
dependency on mach_override.

As this is my first foray into the guts of the emulator, I don't know
how reliable these patches are. From my own testing, crypto (and
crypto_drv) seemed to work fine so I think the erl_ddll patch works, and
with the HiPE patch I could actually build erlang (a big improvement),
start a node, hipe compile and use the lists module in a simple test -
so I think that roughly works too.

Are there some test suites I could run to verify that these patches do
the right thing? If the patches are OK, what do I need to do to get them
included in a future OTP release?

Cheers,
-- 
Geoff




More information about the erlang-patches mailing list