Skip to content

Commit

Permalink
Add SDK paths on macOS
Browse files Browse the repository at this point in the history
MacOS removed `/usr/include` in recent versions of macOS.
That forced the usage of the internal libffi although macOS has a usable one itself.

This commit adds typical paths of the SDK which contain libffi.
Since it's possible to use non default SDK paths, there is another fallback to determine the path per "xcrun" command.

Fixes ffi#757
Closes ffi#765
Closes ffi#758
  • Loading branch information
larskanis committed Apr 15, 2020
1 parent 0e4e97f commit 77e575d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ext/ffi_c/extconf.rb
Expand Up @@ -8,7 +8,10 @@ def system_libffi_usable?
# We need pkg_config or ffi.h
libffi_ok = pkg_config("libffi") ||
have_header("ffi.h") ||
find_header("ffi.h", "/usr/local/include", "/usr/include/ffi")
find_header("ffi.h", "/usr/local/include", "/usr/include/ffi",
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ffi",
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ffi") ||
(find_header("ffi.h", `xcrun --sdk macosx --show-sdk-path`.strip + "/usr/include/ffi") rescue false)

# Ensure we can link to ffi_call
libffi_ok &&= have_library("ffi", "ffi_call", [ "ffi.h" ]) ||
Expand Down

0 comments on commit 77e575d

Please sign in to comment.