-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os/mac/pkgconfig: use ${homebrew_sdkroot}/usr/lib for libffi #10079
Conversation
We need to use ${homebrew_sdkroot}/usr/lib/libffi.tbd not /usr/lib/libffi.dylib to use libffi with ${homebrew_sdkroot}/usr/include/ffi/ffi.h. If we use /usr/lib/libffi.dylib directly, ${homebrew_sdkroot}/usr/include/ffi/ffi.h and -lffi are inconsistent. For example, ${homebrew_sdkroot}/usr/include/ffi/ffi.h for 10.14 doesn't provide ffi_prep_cif_var() but -lffi accept it. a.c: #include <ffi.h> int main(void) { ffi_prep_cif_var(NULL, 0, 0, 0, 0, NULL); return 0; } No declaration error is expected, OK: $ gcc $(PKG_CONFIG_PATH=$(brew --prefix)/Homebrew/Library/Homebrew/os/mac/pkgconfig/10.14 pkg-config --cflags --libs libffi) a.c a.c:6:3: error: implicit declaration of function 'ffi_prep_cif_var' is invalid in C99 [-Werror,-Wimplicit-function-declaration] ffi_prep_cif_var(NULL, 0, 0, 0, 0, NULL); ^ a.c:6:3: note: did you mean 'ffi_prep_cif'? /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/ffi/ffi.h:312:1: note: 'ffi_prep_cif' declared here ffi_prep_cif( ^ 1 error generated. Ignoring no declaration error. It must be a link error. NG: $ gcc -Wno-implicit-function-declaration $(PKG_CONFIG_PATH=$(brew --prefix)/Homebrew/Library/Homebrew/os/mac/pkgconfig/10.14 pkg-config --cflags --libs libffi) a.c (no error, unexpected) With this change: Ignoring no declaration error. It must be a link error. OK: $ gcc -Wno-implicit-function-declaration $(PKG_CONFIG_PATH=$(brew --prefix)/Homebrew/Library/Homebrew/os/mac/pkgconfig/10.14 pkg-config --cflags --libs libffi) a.c Undefined symbols for architecture x86_64: "_ffi_prep_cif_var", referenced from: _main in a-ae3840.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Context: ruby/fiddle#52
427f0c8
to
829c326
Compare
The change seems reasonable and technically more correct (if applied consistently across all libraries - not just libffi), but the real cause of the error you saw was because the wrong headers were being used for the system. 10.14 SDK headers should not be used on Catalina (10.15). That's why the mismatch between library and headers occur. I suspect the user is using an old build of pkg-config and the problem will go away with a |
@Bo98 yup, that'd be great, thanks ❤️ |
@kou could you try this? |
I'm sorry but I can't try it because I don't have an environment that reproduces this case. @escogido Could you try the following command lines? $ gem install fiddle:1.0.4 # This will be failed.
$ brew reinstall pkgconfig
$ gem install fiddle:1.0.4 # This will not be failed. |
Thanks for the PR @kou but passing on this until we find someone who is affected by this who can test reproduce steps. |
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?brew man
locally and committed any changes?We need to use ${homebrew_sdkroot}/usr/lib/libffi.tbd not
/usr/lib/libffi.dylib to use libffi with
${homebrew_sdkroot}/usr/include/ffi/ffi.h. If we use
/usr/lib/libffi.dylib directly,
${homebrew_sdkroot}/usr/include/ffi/ffi.h and -lffi are inconsistent.
For example, ${homebrew_sdkroot}/usr/include/ffi/ffi.h for 10.14
doesn't provide ffi_prep_cif_var() but -lffi accept it.
a.c:
No declaration error is expected, OK:
Ignoring no declaration error. It must be a link error. NG:
With this change: Ignoring no declaration error. It must be a link error. OK:
Context: ruby/fiddle#52