Homebrew-core: libffi: libffi.pc link not installed in /usr/local

Created on 22 May 2019  路  13Comments  路  Source: Homebrew/homebrew-core

Please note we will close your issue without comment if you delete, do not read or do not fill out the issue checklist below and provide ALL the requested information. If you repeatedly fail to use the issue template, we will block you from ever submitting issues to Homebrew again.

  • [x] are reporting a bug others will be able to reproduce and not asking a question or requesting software. If you're not sure or want to ask a question do so on our Discourse: https://discourse.brew.sh. To get software added or changed in Homebrew please file a Pull Request
  • [x] have a problem with brew install (or upgrade, reinstall) a single, Homebrew/homebrew-core formula (not cask) on macOS? If it's a general brew problem please file this issue at Homebrew/brew: https://github.com/Homebrew/brew/issues/new/choose. If it's a Linux problem please file this issue at https://github.com/Homebrew/linuxbrew-core/issues/new/choose. If it's a brew cask problem please file this issue at https://github.com/Homebrew/homebrew-cask/issues/new/choose. If it's a tap (e.g. Homebrew/homebrew-php) problem please file this issue at the tap.
  • [x] ran brew update and can still reproduce the problem?
  • [x] ran brew doctor, fixed all issues and can still reproduce the problem?
  • [x] ran brew gist-logs <formula> (where <formula> is the name of the formula that failed) and included the output link?
  • [x] if brew gist-logs didn't work: ran brew config and brew doctor and included their output with your issue?

To help us debug your issue please explain:

  • What you were trying to do (and why)

I tried to build a GTK+ application on macOS. This didn't work because pkg-config couldn't find libffi.pc. Upon inspection, I noticed this file was in the Cellar, but not linked in /usr/include/lib/pkgconfig. After creating a symlink myself, the issue was resolved.

Should this link be created upon installation, as is the case for other libraries I have installed?

Brew config:

HOMEBREW_VERSION: 2.1.3
ORIGIN: https://github.com/Homebrew/brew
HEAD: 099b047349d4ec67519206f15401d0e1cf90e953
Last commit: 2 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: e47f3e2682fa3d8a6ee58ded40718a1326e08a6d
Core tap last commit: 3 hours ago
HOMEBREW_PREFIX: /usr/local
CPU: octa-core 64-bit skylake
Homebrew Ruby: 2.3.7 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Clang: 10.0 build 1001
Git: 2.20.1 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.54.0 => /usr/bin/curl
Java: 10.0.2
macOS: 10.14.5-x86_64
CLT: 10.2.1.0.1.1554506761
Xcode: 10.2.1
CLT headers: 10.2.1.0.1.1554506761
outdated

Most helpful comment

@jonchang You are misunderstanding the problem. Homebrew installs pkg-config files from non-keg-only crates that just cannot work because they themselves refer to files from libffi that just cannot be found. Homebrew is basically installing things that just can't work. Saying that we should export env variables every time is way worse than just a caveat for people wishing to use libffi directly.

Why aren't the pkg-config files from the crates that depend on libffi not using paths to the libffi keg as suggested in this comment?

All 13 comments

This is by design. libffi formula has keg_only :provided_by_macos, which means it's installed but not linked into /usr/local/{include,lib} because it might conflict with the macOS-provided version.

I don't think libffi should be keg only anymore (at least since macOS Mojave), as I can't find any header files or .pc files.

See https://github.com/lovell/sharp/issues/1603

Also if libffi is keg-only, then every other library that depends on libffi must be keg-only too as their pkg-config files will reference libffi, for example. This is including glib and gtk.

Alternatively, the pkg-config file should be available in the default path and should point to the keg-only library and headers, or there should be a way to tell Homebrew to do just that (and not link in the library and headers too).

Alternatively, the pkg-config file should be available in the default path and should point to the keg-only library and headers, or there should be a way to tell Homebrew to do just that (and not link in the library and headers too).

This sounds to me (naively) like a good compromise. Is there any reason this would cause problems?
cc @fxcoudert

You'd end up with a state where all your tools think they can use your keg-only software while the user might not know about it because it's keg-only

I'm not sure I understand the problem with that. Isn't that the intended outcome? Anything that looks for the glib-2.0.pc will pick up libffi.pc correctly and transparently, will also link to the correct (Homebrew) libffi, and will load the correct (Homebrew) libffi at runtime too.

Any chance to do this change? As @nirbheek explains anything that depends on glib can't be used with pkgconfig right now.

One month on, is there any progress on this?

I don't think we'll be making this change, as libffi is marked as keg_only :provided_by_macos. If you want to use the brewed version of libffi with pkg-config for software that you build, the caveats section tells you how to do this:

For pkg-config to find libffi you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"

@jonchang You are misunderstanding the problem. Homebrew installs pkg-config files from non-keg-only crates that just cannot work because they themselves refer to files from libffi that just cannot be found. Homebrew is basically installing things that just can't work. Saying that we should export env variables every time is way worse than just a caveat for people wishing to use libffi directly.

Why aren't the pkg-config files from the crates that depend on libffi not using paths to the libffi keg as suggested in this comment?

Literally anything that depends on glib cannot be built right now, without that env variable.

See #44446 for a fix that should satisfy everyone.

Was this page helpful?
0 / 5 - 0 ratings