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:
parent
f07a3716b3
commit
687774864a
1 changed files with 10 additions and 6 deletions
16
project.cpp
16
project.cpp
|
|
@ -40,12 +40,16 @@ struct GioFlags {
|
||||||
static GioFlags ComputeGioFlags(const Configuration& cfg) {
|
static GioFlags ComputeGioFlags(const Configuration& cfg) {
|
||||||
GioFlags f;
|
GioFlags f;
|
||||||
if (!cfg.sysroot.empty()) {
|
if (!cfg.sysroot.empty()) {
|
||||||
// cross build (e.g. --target=aarch64-alpine-linux-musl
|
// cross build (--target=aarch64-unknown-linux-gnu against a
|
||||||
// --sysroot=<packaging/make-sysroot.sh output>): the host's
|
// Freedesktop Sdk, or --target=aarch64-alpine-linux-musl against
|
||||||
// pkg-config would answer for the wrong architecture. glib's
|
// an Alpine sysroot): the host's pkg-config would answer for the
|
||||||
// include layout is stable across distros; the `-I=` form makes
|
// wrong architecture. glib's headers are in
|
||||||
// clang resolve the paths inside the sysroot.
|
// include/glib-2.0, its glibconfig.h in lib/glib-2.0/include or, on
|
||||||
f.compile = { "-I=/usr/include/glib-2.0", "-I=/usr/lib/glib-2.0/include" };
|
// 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" };
|
f.link = { "-lgio-2.0", "-lgobject-2.0", "-lglib-2.0" };
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue