bazel-contrib / bazel-contrib/rules_foreign_cc

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

Open
#1,200 5 comments 5 reactions 0 assignees View on GitHub
good first issue help wanted
Dominant language
Starlark
Stars
737
Forks
270
PR merge metrics
No merged PRs in 30d

Description

# 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](https://download.gnome.org/sources/glib/2.36/)) 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](https://docs.gtk.org/glib/) is not to be confused with [GNU libc](https://www.gnu.org/software/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](https://releases.llvm.org/15.0.0/tools/clang/docs/ReleaseNotes.html#:~:text=The%20%2DWint%2Dconversion%20warning%20diagnostic%20for%20implicit%20int%20%3C%2D%3E%20pointer%20conversions%20now%20defaults%20to%20an%20error%20in%20all%20C%20language%20modes.%20It%20may%20be%20downgraded%20to%20a%20warning%20with%20%2DWno%2Derror%3Dint%2Dconversion%2C%20or%20disabled%20entirely%20with%20%2DWno%2Dint%2Dconversion.) and [gcc 14](https://gcc.gnu.org/gcc-14/porting_to.html#int-conversion). This was [addressed in upstream glib](https://gitlab.gnome.org/GNOME/glib/-/commit/c762d511346d3cb84cea3557a246ccf8873b4a1c) in Dec 2022.

# Patch and next steps

I've [published a patch to the upstream pkg-config mailing list](https://lists.freedesktop.org/archives/pkg-config/2024-May/001122.html). (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](https://lists.freedesktop.org/archives/pkg-config/attachments/20240503/7e621a18/attachment.bin) (original filename: `pkg-config-builtin-glib-int-conversion.patch`)

# Supply chain integrity / who am I

(In light of the [xz thing](https://en.wikipedia.org/wiki/XZ_Utils_backdoor))

My [keybase](https://keybase.io/fuhry) 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](https://github.com/fuhry.gpg). I am on the same team as @ravenblackx at @dropbox; they are an [envoy](https://github.com/envoyproxy/envoy) maintainer and can vouch for me if necessary.

Contributor guide

Open the contributing guide

Research direction

Review the linked pkg-config-builtin-glib-int-conversion.patch and locate how rules_foreign_cc vendors or builds pkg-config; the issue names no repository files or tests. Verify the patch can be integrated and that pkg-config builds with clang 15+ and gcc 14+ without the reported conversion errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.