Subject:
[ruby-ffi] extconf.rb and libffi on OSX
From:
Simon Chiang
Date:
1/12/10 12:38 PM
To:
ruby-ffi

I'm trying to use the unreleased 0.6 version of FFI and I'm having an
issue that I ultimately tracked back to this part of extconf.rb:

  unless Config::CONFIG['host_os'] =~ /mswin32|mingw32/
    if pkg_config("libffi") || find_header("ffi.h", "/usr/local/
include")

      # We need at least ffi_call and ffi_prep_closure
      libffi_ok = have_library("ffi", "ffi_call", [ "ffi.h" ]) &&
have_func("ffi_prep_closure")

      # Check if the raw api is available.
      $defs << "-DHAVE_RAW_API" if have_func("ffi_raw_call") &&
have_func("ffi_prep_raw_closure")
    end
  end

Apparently I need to access the raw api and so I think I need -
DHAVE_RAW_API to be set. When I modify extconf.rb to enable that flag,
everything works on OSX 10.5.8 but it still doesn't work on OSX
10.6.2.

By looking at the commits where this code was introduced, I gather
this code is about detecting a functional libffi. So is libffi broke
on OSX or does it vary between 10.5.8 and 10.6.2 in some way that
causes FFI problems? Do I need to update libffi?

Thanks.

Relevant commits:

http://github.com/ffi/ffi/commit/8cbc3f54a875a61e1fb67ac88a25b71940a3ed91
http://github.com/ffi/ffi/commit/31e65abbf7e57b9776557227a41e4cd45886c986