From 687774864a8292abf1a79275acd390b952f9117a Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Tue, 20 Oct 2026 23:40:36 +0200 Subject: [PATCH] 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. --- project.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/project.cpp b/project.cpp index 87fb040..c295d30 100644 --- a/project.cpp +++ b/project.cpp @@ -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=): 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/-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; }