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
yajl: Fix CFLAGS in pkgconfig #74516
Conversation
Thanks for your PR, @roolebo I'm a bit confused about the build failure you're seeing since it didn't emerge in #74349. The That said, I do think the correct way to include headers from |
@carlocab thats simple is due to the Intel homebrew install location being By default Now the problem is if your using a none default searched system location it becomes very different, I’ll use the M1 install location. So now using |
@carlocab The build failure happens if you checkout libvirt sources from git for development and try to build it with I believe the upstream issue didn't hit Linux distributions because yajl headers reside in I agree with @Gcenx wrt M1. |
Still doesn't quite explain it, as |
@carlocab I don't know all details of buildenv used by homebrew but it might make intermediate symlinks for dependencies and that will be sufficient to build libvirt package. It's not sufficient for libvirt development though, because of the outlined issue with headers :) |
I guess I just have the following reservations:
|
If I’ve done this in wine for detecting SDL2. Alternatively it’s not difficult to append the headers search path locally. |
The superenv adds |
@carlocab I don't see how the change should break anything. Except all bottles older than Mojave will be discarded, that's definitely true :)
|
Would it not break my builds if I use |
Using #include <generic_yajl.h> would work with the current pkg-config output as it will be searching the correct directory for the header. |
Here’s what I did in wine to resolve the same problem https://source.winehq.org/git/wine.git/patch/e4fbae832c868e9fcf5a91c58255fe3f4ea1cb30 |
@carlocab Official documentation and all three users of yajl (libvirt, uwsgi, kafkacat) in homebrew use Consider you develop a new feature for uwsgi, you have some changes, without proper pkg-config you need to either:
Also, official build instructions of the package won't work, so new developers will struggle without any reason. |
The workaround is as simple as appending Suppose, on the other hand, I'm a user who doesn't even know what a pre-processor is: all I know is that I want to install some piece of software that depends on This patch has now broken the build for me. When I go ask upstream what happened, it'll take some time for them to figure out that Homebrew actually jumped the gun on Perhaps I could patch the source of the software I wanted to install, but that might be challenging since I don't really understand
This sounds like a shortcoming of the build instructions when they're designed for non-default builds of upstream projects without saying so. |
It's not onerous, it doesn't seem to be correct. And I'm not messing up with my environment wrong way. I obviously rebuild the package with my fix and I no longer have the issue on my laptop but I wanted to help with fixing wrong pkg-config for other people who might hit the issue (upstream PR is submitted as well, but I wouldn't hold my breath until it get merged, because no PRs are merged for libyajl since 2015). And I'm sorry for being stubborn but I deeply want homebrew to be the best package manager :)
I'm not sure a user (or, perhaps, a developer) who doesn't know what a preprocessor is will even try to use libyajl. It's a necessary knowledge for any C programmer.
It wouldn't be correct. pkg-config provides a contract, if you use CFLAGS/LDFLAGS provided by pkg-config you should be able to use an external dependency without any workarounds :) That's the whole point about pkg-config. It says what compile and link flags should be used for an external dependency. If you don't believe me please read: https://www.freedesktop.org/wiki/Software/pkg-config/, and this guide to pkg-config might be helpful: https://people.freedesktop.org/~dbn/pkg-config-guide.html
Package environment has to be reasonable and follow established programming conventions and practices. In this case incorrect pkg-config file breaks established practices so I doubt a fix to libvirt would ever be upstreamable. |
The problem with a large majority of projects like this is they expect the headers to be installed into As the upstream project has not accepted any merger requests nor commits since 2015 the projects that expect the headers in a fixed location should be altered to check Here are some examples;
As can be seen in the examples ether |
@Gcenx, you are missing the point here. The libpng manual tells you to include png.h directly:
So the pkg-config file reflects this demand by setting CFLAGS accordingly. yajl, on the other hand, uses <yajl/yajl_*.h> pattern (even internally). Look here for example:
Even if you can hack up something to use API headers like this:
you will still get the error, because So setting CFLAGS like this (/usr/local/foo/bar/include/yajl) breaks yajl. This is not a matter of taste and preferences, this directory is required to be present in one of the include directories that C preprocessor is aware of. |
@heroin-moose the listed projects previously gave directions to use use a sub directory. Most projects as I’ve said expect to be installed into a standard location, pkg-config files are provided but bugs are not lightly to be found outside of being installed into a none standard location. I believe modifying this to “fix” upstream issues due to ancient instructions that doesn’t even mention pkg-config is a mistake, the upstream projects that use that should instead correct how they’re using the headers location from pkg-config. |
@Gcenx, current pkg-config file is buggy. Using it alone without placing |
@heroin-moose if the projects are modified correctly it won't fail to compile I've literally done exactly this for wine see configure: Don't prepend folder name for SDL.h. |
@Gcenx, why are you keep referring to other projects? Please, read what I write. The API headers of yajl itself use |
@heroin-moose gottach, the easiest possible fix would be modifying the |
@heroin-moose yeah somehow I wasn’t getting the headers themselves where doing this ugh. |
This is correct. The yajl example from: https://lloyd.github.io/yajl/ works with my fix:
This one without yajl prefix doesn't work with existing pc file:
It produces the error mentioned by @heroin-moose:
As a side note I'm not sure how it would be possible to fix libvirt, because it uses pkg-config indirectly through meson: And meson expects proper flags from pkg-config. |
@roolebo so does |
@Gcenx, yes with my fix anyone on M1 can compile libvirt using provided instructions: https://libvirt.org/compiling.html |
Yes, that's why the hypothetical user in my example wasn't even a C programmer. They just wanted to install software that made use of If we want to patch diff --git a/src/yajl.pc.cmake b/src/yajl.pc.cmake
index 6eaca14..dd01a30 100644
--- a/src/yajl.pc.cmake
+++ b/src/yajl.pc.cmake
@@ -1,9 +1,10 @@
prefix=${CMAKE_INSTALL_PREFIX}
libdir=${dollar}{prefix}/lib${LIB_SUFFIX}
-includedir=${dollar}{prefix}/include/yajl
+includedir=${dollar}{prefix}/include
+extra_includedir=${dollar}{includedir}/yajl
Name: Yet Another JSON Library
Description: A Portable JSON parsing and serialization library in ANSI C
Version: ${YAJL_MAJOR}.${YAJL_MINOR}.${YAJL_MICRO}
-Cflags: -I${dollar}{includedir}
+Cflags: -I${dollar}{includedir} -I${dollar}{extra_includedir}
Libs: -L${dollar}{libdir} -lyajl |
@carlocab there's no point in backward compatibility for this particular case because you can't compile any code that depends on yajl with existing pkg-config file. Please take a look at the message: #74516 (comment) |
Yes, I read your comment. I'm also not convinced that no one using Is there a downside to using a backward-compatible change? |
Ok. So? Why is the expectation for a proper example is "one that works with absolutely no workarounds"? We're already in agreement that
Maybe, maybe not. Not sure you can say that with absolute certainty, though.
We have lots of broken formulae because upstream hasn't fixed problems with it. Carrying around fixes for them isn't really what we do. |
No it’s more nothing will work without a workaround.
It seems your apposed to a workaround due to it breaking some other slim possible workaround.
That would only be resolved by using your example pc modification, I’m guessing your more included to use that than any others.
This was more of a side question, as I was under the impression broken formulas would be removed, also would be removed if a project hasn’t been maintained/updated in over a year? |
@carlocab, so you're proposing not to fix a real broken package because of the imaginary broken package? |
No. Please see #74516 (comment). |
libvirt can't be built from source because yajl contains CFLAGS in pkgconfig not matching layout of installed headers: ../src/util/virjson.c:36:11: fatal error: 'yajl/yajl_gen.h' file not found # include <yajl/yajl_gen.h> ^~~~~~~~~~~~~~~~~ 1 error generated. Here's pkg-config output from meson logs: Called `/opt/homebrew/bin/pkg-config --cflags yajl` -> 0 -I/opt/homebrew/Cellar/yajl/2.1.0/include/yajl Here's actual layout of includedir: /opt/homebrew/Cellar/yajl/2.1.0/include/yajl/yajl_tree.h /opt/homebrew/Cellar/yajl/2.1.0/include/yajl/yajl_gen.h /opt/homebrew/Cellar/yajl/2.1.0/include/yajl/yajl_common.h /opt/homebrew/Cellar/yajl/2.1.0/include/yajl/yajl_version.h /opt/homebrew/Cellar/yajl/2.1.0/include/yajl/yajl_parse.h Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
@carlocab I've done an investigation and Fedora and FreeBSD have the fix like I proposed. And there's another much earlier PR to yajl (almost 7 years old) - lloyd/yajl#139 and another one (9 years old) - lloyd/yajl#77 |
020fa2d
to
9368db7
Compare
I did check what other distros were doing with this yesterday. Why doesn't Debian do this? |
This issue won’t affect most Distros as they install packages into /usr |
While GitHub is not the only place where code is hosted, it's widely used enough that it can serve as a statistically significant sample. Searching for Based on this data, I'd say it's fair to conclude that the chances a non-developer will see a regression caused by this change while attempting to install some random piece of software are vanishingly small.
libvirt could likely work around the broken I have provided upstream with a patch fixing It looks like Readline 8.1 has finally been released last December, and both FreeBSD ports and Homebrew have quickly picked it up! That means the libvirt kludge is no longer necessary, and in fact I have just posted a patch dropping it :) Incidentally, this means that Readline - a much more popular package than yajl - has been affected by a change in behavior much like the one that's been proposed here for about four months. Did you get reports of breakages introduced by it? I've skimmed the list of issues and I haven't been able to find any.
As others have pointed out, Linux will generally not be hit by this because headers are always installed under That said, |
GitHub Search tokenizes entire words, so you can't search for a partial word. Searching for |
I’m looking through the results and currently none of those would be broken by this change as they ship there own modified of yajl. |
Fair point. Note, however, that almost all of those hits are from projects that vendor their own copy of yajl, and thus would not be affected at all by this change. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Please don't let this go stale. It's a good change, and the sooner it hits the repo the better :) |
I agree that it's a good change for upstream to make. We're not upstream, though, and I'm not sure I like the idea of carrying around another patch that will never get merged. |
Guys, almost two months passed. Either commit the change or close the ticket and tell people that it would not be possible to build libvirt on OS X until libvirt moves to some other JSON library. |
|
FYI, libvirt's build system now contains a workaround specifically for this issue. See libvirt/libvirt@cd76a97.
Carrying downstream patches is always a maintenance burden, so I fully understand your reluctance. In the case of yajl, however, upstream development having stopped results in two consequences: the first one is that almost zero non-trivial maintenance has been necessary for years, and the second one is that, if you added a downstream-only patch to fix CFLAGS, you would not have to worry about rebasing it every single time a new upstream release comes out :) Notice how the yajl patch is a single line change, whereas the libvirt kludge is almost twenty lines of code; additionally, each and every consumer of yajl will need to implement and carry a similar workaround, whereas if things were patched in Homebrew nobody else would have to ever worry about it. Overall, I still think applying the patch to Homebrew would be the second-best solution - the actual best solution being, of course, a new upstream release that includes the fix, but we all know we can't really hope to ever get that :(
We would love to use a different JSON library, and in fact a few years ago we even managed to switch to jansson for a brief time; however, that change never made into a release because we immediately found it caused a number of regressions and had to revert it. Since QEMU emits JSON that's not entirely standards-compliant, most JSON library are unfortunately just not usable for our purposes :( |
I'm willing to reconsider my position if another project (other than libvirt) asks for this, as long as no other Homebrew/core maintainer objects. |
Here a few Edited; |
Do you represent any of these projects, @Gcenx? |
@carlocab no I’m not involved in those, those were just a couple of projects that would benefit from this proposed change. |
The workaround in libvirt no longer works. Is it possible to reconsider the PR? |
Fine with me, but I won't argue against anyone else objecting to it. Please open a new PR, though. Locking this now to avoid filling up the inboxes of anyone else still following this. Those still interested can look at the new PR. |
libvirt can't be built from source because yajl contains
CFLAGS
inpkgconfig not matching layout of installed headers:
Here's pkg-config output from meson logs:
Here's actual layout of includedir:
brew install --build-from-source <formula>
, where<formula>
is the name of the formula you're submitting?brew test <formula>
, where<formula>
is the name of the formula you're submitting?brew audit --strict <formula>
(after doingbrew install <formula>
)?