Reapply patch from r62553, with a fix to avoid looking for an ffi.h that isn't