project: glib's config header on a multiarch sysroot

A cross build passes glib's include paths itself, and named only
lib/glib-2.0/include for glibconfig.h, which is where Alpine has it. The
aarch64 Freedesktop Sdk keeps it under
lib/aarch64-linux-gnu/glib-2.0/include, so the path for the target's
architecture is passed as well; clang ignores it in a sysroot that has
no such directory.
This commit is contained in:
Jorijn van der Graaf 2026-10-20 23:40:36 +02:00
commit 687774864a
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB

View file

@ -40,12 +40,16 @@ struct GioFlags {
static GioFlags ComputeGioFlags(const Configuration& cfg) {
GioFlags f;
if (!cfg.sysroot.empty()) {
// cross build (e.g. --target=aarch64-alpine-linux-musl
// --sysroot=<packaging/make-sysroot.sh output>): the host's
// pkg-config would answer for the wrong architecture. glib's
// include layout is stable across distros; the `-I=` form makes
// clang resolve the paths inside the sysroot.
f.compile = { "-I=/usr/include/glib-2.0", "-I=/usr/lib/glib-2.0/include" };
// cross build (--target=aarch64-unknown-linux-gnu against a
// Freedesktop Sdk, or --target=aarch64-alpine-linux-musl against
// an Alpine sysroot): the host's pkg-config would answer for the
// wrong architecture. glib's headers are in
// include/glib-2.0, its glibconfig.h in lib/glib-2.0/include or, on
// a multiarch layout like the Freedesktop Sdk's, under
// lib/<arch>-linux-gnu; the `-I=` form makes clang resolve the
// paths inside the sysroot.
const std::string arch = cfg.target.substr(0, cfg.target.find('-'));
f.compile = { "-I=/usr/include/glib-2.0", "-I=/usr/lib/glib-2.0/include", std::format("-I=/usr/lib/{}-linux-gnu/glib-2.0/include", arch) };
f.link = { "-lgio-2.0", "-lgobject-2.0", "-lglib-2.0" };
return f;
}