Skip to content

Commit e185510

Browse files
committed
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 528a3a1, 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*, | ^~~~~~~~~~~~~~~~ ```
1 parent 1c4eb70 commit e185510

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

ext/fiddle/extconf.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@
122122
case
123123
when $mswin, $mingw, (ver && (ver <=> [3, 2]) >= 0)
124124
$defs << "-DUSE_FFI_CLOSURE_ALLOC=1"
125+
else
126+
have_func('ffi_closure_alloc', ffi_header)
125127
end
126128

127129
have_header 'sys/mman.h'

0 commit comments

Comments
 (0)