Open swift-ci opened 4 years ago
Comment by Max Liberman (JIRA)
I'm running into this issue as well, in my case with the cairo
library. It looks like the problem in both cases is that the gobject-2.0
library's .pc
file has an absolute path in its Requires.private
field, which SPM does not currently support.
$ cat $(brew --prefix)/opt/glib/lib/pkgconfig/gobject-2.0.pc
prefix=/usr/local/Cellar/glib/2.64.3
libdir=${prefix}/lib
includedir=${prefix}/include
Name: GObject
Description: GLib Type, Object, Parameter and Signal Library
Version: 2.64.3
Requires: glib-2.0
Requires.private: /usr/local/opt/libffi/lib/pkgconfig/libffi.pc >= 3.0.0
Libs: -L${libdir} -lgobject-2.0
Libs.private: -lintl
Cflags:-I${includedir}
Comment by Serhii Mumriak (JIRA)
mliberman (JIRA User) oh my god, thank you so much! can i ask how did you find the underlying problem? I was thinking about debugging swiftpm itself, but it's not really possible which i tried to find help for here: https://forums.swift.org/t/is-there-a-way-to-debug-swift-package-manager-in-xcode/37185/5
Comment by Max Liberman (JIRA)
PALKOVNIK (JIRA User) I tracked down the warning message ("you may be able to install..."
) to here. I discovered that PkgConfig
is part of the SwiftToolsSupport
library (specifically, the TSCUtility
module), so I created a new executable Swift package that pulled in that dependency, and was able to debug the PkgConfig
constructor that way.
Comment by Max Liberman (JIRA)
PALKOVNIK (JIRA User) by the way, as a local workaround, you can just change the Requires.private
line in gobject-2.0.pc
to:
Requires.private: libffi >= 3.0.0
The file should be located at:
$(brew --prefix)/opt/glib/lib/pkgconfig/gobject-2.0.pc
Comment by Serhii Mumriak (JIRA)
mliberman (JIRA User) yea, I was also going thru `TSCUtility`, did not know about the `Requires.private` in pkg-config (I mean I don't know much about it at all). Also thanks for the workaround, I'll try it today 🙂
Comment by Serhii Mumriak (JIRA)
mliberman (JIRA User) I tried that workaround with changing the absolute path to just `libffi >= 3.0.0` and the issue is still there. I assume that's the one you've fixed is a different one.
UPD. oops, did not remove the file extension and it works correctly. Thanks for fix!
Comment by Tobias H (JIRA)
Hello, I think I've also encountered a similar, maybe the same problem. I think this issue has actually been fixed in the `main` branch of `apple/swift-tools-support-core`:
See my post here: https://forums.swift.org/t/possible-bug-regression-with-regards-to-pc-files/42306
Attachment: Download
Environment
OS: macOS 10.15.5 Xcode 11.4/11.5Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Package Manager | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 93258efbe2740a983119fe6423c1ea6fIssue Description:
Most of the dev libraries installed via homebrew provide pkg-config configuration files which swift package manager is able to locate and parse in order to get needed linking libraries and C flags to pass to compiler for "system library" targets.
Up till swift 5.1.x shipped with Xcode 11.3.x this worked perfectly fine. Starting from swift 5.2.x shipped with Xcode 11.4 and newer the parser fails to get the needed flags.
One example is the library called "pango".
It can be installed via homebrew (pango has hard dependency on glib):
```
brew install pango glib
```
After that you can inspect that pkg-config file located at `/usr/local/lib/pkgconfig/pango.pc`
I've added a sample project that adds the pango C module. Hit `swift build -v` and you can easily the the error on newer swift vesions:
a warning saying "warning: you may be able to install pango using your system-packager: brew install pango glib"
a compilation error saying "error: 'pango/pango.h' file not found".
None of this happens with swift 5.1.
Also this is a macOS specific issue - linux runs fine up to 5.2.4.