summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2021-05-09 16:11:52 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2021-05-09 16:11:52 +0000
commit5df653caaa1a666172d889760786cdf26952a1a7 (patch)
treeb2da18ca2e1d16140a740776e7628e78a948e9f1 /ext
parent1b59a4dc76caa061355f4289d2c54d4625671735 (diff)
downloadruby-5df653caaa1a666172d889760786cdf26952a1a7.tar.gz
fix macos build
note that this is not a security fix, but recognized as critical build problem. [Backport #17777] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/fiddle/closure.c5
-rw-r--r--ext/fiddle/extconf.rb13
2 files changed, 12 insertions, 6 deletions
diff --git a/ext/fiddle/closure.c b/ext/fiddle/closure.c
index 1a80b2b02a..2044c836ea 100644
--- a/ext/fiddle/closure.c
+++ b/ext/fiddle/closure.c
@@ -14,10 +14,7 @@ typedef struct {
} fiddle_closure;
#if defined(USE_FFI_CLOSURE_ALLOC)
-#elif defined(__OpenBSD__) || defined(__APPLE__) || defined(__linux__)
-# define USE_FFI_CLOSURE_ALLOC 0
-#elif defined(RUBY_LIBFFI_MODVERSION) && RUBY_LIBFFI_MODVERSION < 3000005 && \
- (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_AMD64))
+#elif !defined(HAVE_FFI_CLOSURE_ALLOC)
# define USE_FFI_CLOSURE_ALLOC 0
#else
# define USE_FFI_CLOSURE_ALLOC 1
diff --git a/ext/fiddle/extconf.rb b/ext/fiddle/extconf.rb
index fce0cb4079..dc53f22dfb 100644
--- a/ext/fiddle/extconf.rb
+++ b/ext/fiddle/extconf.rb
@@ -13,7 +13,7 @@ if ! bundle
if have_header(ffi_header = 'ffi.h')
true
elsif have_header(ffi_header = 'ffi/ffi.h')
- $defs.push(format('-DUSE_HEADER_HACKS'))
+ $defs.push('-DUSE_HEADER_HACKS')
true
end and (have_library('ffi') || have_library('libffi'))
end or
@@ -116,6 +116,15 @@ if ver
ver = ver.gsub(/-rc\d+/, '') # If ver contains rc version, just ignored.
ver = (ver.split('.') + [0,0])[0,3]
$defs.push(%{-DRUBY_LIBFFI_MODVERSION=#{ '%d%03d%03d' % ver }})
+ warn "libffi_version: #{ver.join('.')}"
+end
+
+case
+when $mswin, $mingw, (ver && (ver <=> [3, 2]) >= 0)
+ $defs << "-DUSE_FFI_CLOSURE_ALLOC=1"
+when (ver && (ver <=> [3, 2]) < 0)
+else
+ have_func('ffi_closure_alloc', ffi_header)
end
have_header 'sys/mman.h'
@@ -142,7 +151,7 @@ types.each do |type, signed|
if /^\#define\s+SIZEOF_#{type}\s+(SIZEOF_(.+)|\d+)/ =~ config
if size = $2 and size != 'VOIDP'
size = types.fetch(size) {size}
- $defs << format("-DTYPE_%s=TYPE_%s", signed||type, size)
+ $defs << "-DTYPE_#{signed||type}=TYPE_#{size}"
end
if signed
check_signedness(type.downcase, "stddef.h")