Skip to content

Commit 03f0ac0

Browse files
committed
Remove warning by not calling have_library after pkg_config
pkg_config without the options arguments stores the result in the global values. Calling `pkg_config` and `have_library` causes -lffi to appear twice in the LIBS variable in the resulting Makefile, and causes ld on macOS to emit a warning: $ bundle exec rake compile 2>&1 | grep warning: ld: warning: ignoring duplicate libraries: '-lffi'
1 parent 6368ee0 commit 03f0ac0

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

ext/fiddle/extconf.rb

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,21 @@ def enable_debug_build_flag(flags)
6464
dir_config 'libffi'
6565

6666
if pkg_config("libffi")
67+
have_libffi = true
6768
libffi_version = pkg_config("libffi", "modversion")
6869
end
6970

70-
have_ffi_header = false
71-
if have_header(ffi_header = 'ffi.h')
72-
have_ffi_header = true
73-
elsif have_header(ffi_header = 'ffi/ffi.h')
74-
$defs.push('-DUSE_HEADER_HACKS')
75-
have_ffi_header = true
76-
end
77-
if have_ffi_header && (have_library('ffi') || have_library('libffi'))
78-
have_libffi = true
71+
unless have_libffi
72+
have_ffi_header = false
73+
if have_header(ffi_header = 'ffi.h')
74+
have_ffi_header = true
75+
elsif have_header(ffi_header = 'ffi/ffi.h')
76+
$defs.push('-DUSE_HEADER_HACKS')
77+
have_ffi_header = true
78+
end
79+
if have_ffi_header && (have_library('ffi') || have_library('libffi'))
80+
have_libffi = true
81+
end
7982
end
8083
end
8184

0 commit comments

Comments
 (0)