This cherry-picks a commit by hand to fix a libffi build failure with clang. In particular, I applied the following patch from the official libffi repository: https://github.com/atgreen/libffi/blob/master/patches/x86_pcrel_test References: http://bugs.python.org/issue12812 https://bugzilla.mozilla.org/show_bug.cgi?id=631928 http://sourceware.org/ml/libffi-discuss/2011/msg00024.html
Work around build issues on mac instroduced this commmit: e2e7b25 Use union instead of struct for cmsghdr Reference: http://alas.matf.bg.ac.rs/manuals/lspe/snode=153.html
Use of struct with cmsghdr and pad is a GNU extension. When built with Clang, warnings are issued as such. So take the union approach instead. To fix this, I used an example at: http://www.rootr.net/man/man/CMSG_SPACE This is a second try to fix clang warnings in io.cpp. The reverted first try was: a9648cf Ignore all GNU-extension warnings As an alternative approach to it, I fixed the code itself.
This commit suppresses following warnings from Clang: vm/builtin/io.cpp:1101:22: error: field 'hdr' with variable sized type 'struct cmsghdr' not at the end of a struct or class is a GNU extension [-Werror,-Wgnu] struct cmsghdr hdr; ^ vm/builtin/io.cpp:1146:22: error: field 'hdr' with variable sized type 'struct cmsghdr' not at the end of a struct or class is a GNU extension [-Werror,-Wgnu] struct cmsghdr hdr; ^ 2 errors generated.
This suppresses a following warning by running specs with Rubinius built by clang: spec/ruby/optional/capi/ext/class_spec.c:108:2: warning: implicit declaration of function 'rb_cvar_set_internal' is invalid in C99 [-Wimplicit-function-declaration] rb_cvar_set(klass, rb_intern(StringValuePtr(name)), val); ^ vm/capi/19/include/ruby/ruby.h:1096:23: note: expanded from: #define rb_cvar_set rb_cvar_set_internal ^ 1 warning generated.
These methods where called directly by #flush_next_in and #flush_next_out and are not in MRI so let's remove them for the sake of consistency.