Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

librsvg: prepend cairo.pc path to PKG_CONFIG_PATH #14489

Closed
wants to merge 1 commit into from

Conversation

2bits
Copy link
Contributor

@2bits 2bits commented Aug 27, 2012

librsvg depends on gtk, and when pkgconfig checks gtk-2.0.pc it
queries cairo.pc. The problem is that cairo.pc is prepended
to PKG_CONFIG_PATH on 10.7 because cairo is keg-only. On 10.8
cairo is not keg-only. So there is no prepend, causing compile
errors.

Add a prepend to PKG_CONFIG_PATH to the keg directory for cairo.pc.
Tested on 10.8.1 using XCode-4.4.1, XQuartz-2.7.2, and clang.

Fixes #14474

librsvg depends on gtk, and when pkgconfig checks gtk-2.0.pc it
queries cairo.pc.  The problem is that cairo.pc is prepended
to PKG_CONFIG_PATH on 10.7 because cairo is keg-only.  On 10.8
cairo is not keg-only. So there is no prepend, causing compile
errors.

Add a prepend to PKG_CONFIG_PATH to the keg directory for cairo.pc.
Tested on 10.8.1 using XCode-4.4.1, XQuartz-2.7.2, and clang.

Fixes Homebrew#14474
@Sharpie
Copy link
Contributor

Sharpie commented Aug 27, 2012

On 10.8 cairo is not keg-only. So there is no prepend, causing compile errors.

But if Cairo is not keg-only on 10.8, then its pkg-config file should be linked into /usr/local/lib/pkgconfig which is a place that is checked by a Homebrew-installed pkg-config.

@2bits
Copy link
Contributor Author

2bits commented Aug 27, 2012

Yea, it's the order of the items on the PATH:

Before

PKG_CONFIG_PATH=/usr/local/Cellar/libffi/3.0.11/lib/pkgconfig:/opt/X11/share/pkgconfig:/opt/X11/lib/pkgconfig:/usr/local/Library/Homebrew/pkgconfig

After cairo's directory is prepended:

PKG_CONFIG_PATH=/usr/local/Cellar/cairo/1.12.2/lib/pkgconfig:/usr/local/Cellar/libffi/3.0.11/lib/pkgconfig:/opt/X11/share/pkgconfig:/opt/X11/lib/pkgconfig:/usr/local/Library/Homebrew/pkgconfig

That guarantees that when we force gtk to use HB cairo on all OSX systems, we force librsvg to find cairo in the cellar before it finds cairo in /opt/x11. Does that make any sense? Jack might have explained it better in the issue.

@2bits
Copy link
Contributor Author

2bits commented Aug 27, 2012

I'm not even sure I have this right. So I'm glad you're asking btw.

@jacknagel
Copy link
Contributor

@Sharpie

But if Cairo is not keg-only on 10.8, then its pkg-config file should be linked into /usr/local/lib/pkgconfig which is a place that is checked by a Homebrew-installed pkg-config.

This is true, but because librsvg depends on XQuartz, the XQuartz pkgconfig directory is placed on PKG_CONFIG_PATH, and thus its libs are picked up before any brewed libs.

The goal is to ensure everything from the bottom up is using the same cairo, namely ours.

I've sent a message to the pkg-config mailing list asking for a PKG_CONFIG_FALLBACK_PATH, where we could place the X11 path instead and thus ensure that Homebrew's libs are always picked up first, so we'll see how receptive they are to that.

@Sharpie
Copy link
Contributor

Sharpie commented Aug 28, 2012

XQuartz pkgconfig directory is placed on PKG_CONFIG_PATH

Admittedly, I haven't installed XQuartz, but doesn't it install to /opt/x11? If so, why don't we build pkg-config with #{MacOS:X11.lib/pkgconfig} at the end of the default paths?

Hell, we could even stick /usr/lib/pkgconfig at the end as well.

@jacknagel
Copy link
Contributor

If so, why don't we build pkg-config with #{MacOS:X11.lib/pkgconfig} at the end of the default paths?

We stopped doing this in order to support both Apple's X11 or the upstream XQuartz distro. Since they can be installed after pkg-config is built, we can't guess which one is the right one.

Hell, we could even stick /usr/lib/pkgconfig at the end as well.

We already do this.

@Sharpie
Copy link
Contributor

Sharpie commented Aug 28, 2012

We stopped doing this in order to support both Apple's X11 or the upstream XQuartz distro.

Well, how about just:

<Homebrew pkgconfig>:<XQuartz pkgconfig>:<Apple X11 pkgconfig>:/usr/lib/pkgconfig

Following the assumption that if a user takes the time to install XQuartz, they prefer it to whatever Apple version may or may not be hanging around.

@jacknagel
Copy link
Contributor

I worry that if they are both installed, having both of them on the search path will cause even more problems; we're bound to end up with packages with linkages to both.

@Sharpie
Copy link
Contributor

Sharpie commented Aug 28, 2012

That may be true. But I think that adding code to this and every other formula that uses X11is the wrong way to solve a problem that is not specific to one formula.

@jacknagel
Copy link
Contributor

I'm not arguing in favor of that as a long term solution. As I stated earlier I am actively trying to pkg-config's functionality extended to support our circumstances.

@2bits
Copy link
Contributor Author

2bits commented Aug 28, 2012

brew deps librsvg shows cairo. So why couldn't the formula installer just prepend the path in the cellar to cairo.pc onto PKG_CONFIG_PATH when it knows that? If we always want HB cairo.pc to be found, it seems reasonable until the devs reply to Jack.

@jacknagel
Copy link
Contributor

We only do that for keg-only deps, because it shouldn't be necessary otherwise. I don't want to add any hacks like that to Homebrew-core. I'm OK with doing it in formulae as a stopgap measure, though, until a clean solution is arrived at.

But seriously, a patch to add a PKG_CONFIG_FALLBACK_PATH to pkg-config is like 4 LOC.

@2bits
Copy link
Contributor Author

2bits commented Aug 31, 2012

I'm closing this because librsvg works ok now with superenv.

@2bits 2bits closed this Aug 31, 2012
@Homebrew Homebrew locked and limited conversation to collaborators Feb 16, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

librsvg fails with wrong cairo
4 participants