summaryrefslogtreecommitdiff
path: root/ext/fiddle/extconf.rb
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2020-05-13 01:17:30 +0900
committerYusuke Endoh <mame@ruby-lang.org>2020-05-13 01:17:30 +0900
commite1855100e46040e73630b378974c17764e0cccee (patch)
tree298846e4039e6e528333933c8e6876418e78d49d /ext/fiddle/extconf.rb
parent1c4eb70654aa20dd7caf3ce31be944396c5d31b8 (diff)
ext/fiddle/extconf.rb: check if ffi_closure_alloc is available
to define HAVE_FFI_CLOSURE_ALLOC. The macro is used in closure.c, so have_func check is needed. If pkg-config is not installed, extconf.rb fails to detect the version of libffi, and does not add "-DUSE_FFI_CLOSURE_ALLOC=1" even when system libffi version is >= 3.2. If USE_FFI_CLOSURE_ALLOC is not defined, closure.c attempts to check if HAVE_FFI_CLOSURE_ALLOC is defined or not, but have_func was removed with 528a3a17977aa1843a26630c96635c3cb161e729, so the macro is always not defined. This resulted in this deprecation warning: https://rubyci.org/logs/rubyci.s3.amazonaws.com/ubuntu2004/ruby-master/log/20200512T123003Z.log.html.gz ``` compiling closure.c closure.c: In function 'initialize': closure.c:265:5: warning: 'ffi_prep_closure' is deprecated: use ffi_prep_closure_loc instead [-Wdeprecated-declarations] 265 | result = ffi_prep_closure(pcl, cif, callback, (void *)self); | ^~~~~~ In file included from ./fiddle.h:42, from closure.c:1: /usr/include/x86_64-linux-gnu/ffi.h:334:1: note: declared here 334 | ffi_prep_closure (ffi_closure*, | ^~~~~~~~~~~~~~~~ ```
Diffstat (limited to 'ext/fiddle/extconf.rb')
-rw-r--r--ext/fiddle/extconf.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/ext/fiddle/extconf.rb b/ext/fiddle/extconf.rb
index 0f06b7ff69..120c4ce7b4 100644
--- a/ext/fiddle/extconf.rb
+++ b/ext/fiddle/extconf.rb
@@ -122,6 +122,8 @@ end
case
when $mswin, $mingw, (ver && (ver <=> [3, 2]) >= 0)
$defs << "-DUSE_FFI_CLOSURE_ALLOC=1"
+else
+ have_func('ffi_closure_alloc', ffi_header)
end
have_header 'sys/mman.h'