bazelbuild / rules_foreign_cc

Build rules for interfacing with "foreign" (non-Bazel) build systems (CMake, configure-make, GNU Make, boost, ninja, Meson)
https://bazelbuild.github.io/rules_foreign_cc
Apache License 2.0
650 stars 232 forks source link

pkg-config build broken on clang 15+ and gcc 14+ #1200

Open fuhry opened 2 months ago

fuhry commented 2 months ago

Background (what is pkg-config?)

pkg-config 0.29.2 (the latest release as of this writing) bundles an ancient version of glib 2.36 (released in August 2013) to workaround the pkg-config/glib circular dependency. It should be noted that pkg-config itself is not well-maintained, with the last major release having been in 2015 and the last point release in 2017, however it remains an important dependency of virtually all build systems as a standardized way to transform dependency names into CFLAGS, LDFLAGS, etc.

Note that glib is not to be confused with GNU libc, often abbreviated to glibc.

The issue

glib 2.36 performed implicit integer conversion for its atomic pointer arithmetic functions, using g(s)size (which is aliased to (u)long) instead of (u)intptr. This was a warning in most compilers for many years but was upgraded to an error with clang 15 and gcc 14. This was addressed in upstream glib in Dec 2022.

Patch and next steps

I've published a patch to the upstream pkg-config mailing list. (GitHub unfortunately is refusing to allow me to attach the .patch file here, despite claiming that .patch is a permitted file extension.) Depending on how quickly the maintainers process it, it may be advisable to bring this patch into rules_foreign_cc in advance of the upstream pkg-config release to unblock builds with newer clang and gcc.

Direct link to the patch (original filename: pkg-config-builtin-glib-int-conversion.patch)

Supply chain integrity / who am I

(In light of the xz thing)

My keybase provides positive proof linking my GitHub account, the domain of my email address, and the PGP key used to sign the patch, the latter of which is also the PGP key I use on GitHub. I am on the same team as @ravenblackx at @dropbox; they are an envoy maintainer and can vouch for me if necessary.

jez commented 1 month ago

Related: #1186

achernya commented 1 month ago

See also #1065

jsharpe commented 1 month ago

If someone wants to put together a PR to patch the pkg-config build with the provided patch then this is something I'd happily merge.

fuhry commented 3 weeks ago

@jsharpe I added such a patch to my envoyproxy AUR package last month. I don't have the free time to turn this into a rules_foreign_cc PR right this moment, but this patch should be able to be integrated with minimal effort.