Define __GI_SCANNER__ in generated umbrella headers
Avoids Clang module conflicts when a NEON/SIMD-gated system header (e.g. Graphene's graphene_simd4f_t backend) is reachable from two different .systemLibrary modules on aarch64 Linux: one pulls in the real _Builtin_intrinsics.arm.acle module, the other re-parses the same header textually, and Clang rejects the resulting conflicting uint32_t/__fsid_t redeclarations. __GI_SCANNER__ is the escape hatch these libraries already ship for exactly this class of consumer (a declaration-only binding generator, same as gobject-introspection's own scanner).
This commit is contained in:
parent
5866ed57e9
commit
917cd29646
1 changed files with 16 additions and 1 deletions
|
|
@ -149,6 +149,21 @@ extension CodeGenerator {
|
|||
umbrellaHeader += "\n#include <gtk/gtkunixprint.h>"
|
||||
}
|
||||
|
||||
// Every umbrella header defines `__GI_SCANNER__` before pulling in
|
||||
// the system header. GLib, GTK, and Graphene all gate architecture-
|
||||
// specific `static inline` fast paths (most notably Graphene's
|
||||
// SSE/ARM-NEON `graphene_simd4f_t` backend) behind `#ifndef
|
||||
// __GI_SCANNER__`, falling back to a portable scalar/definition-only
|
||||
// path when it is set - the same escape hatch upstream ships for
|
||||
// gobject-introspection's scanner, which (like Clang's ClangImporter
|
||||
// here) only needs declarations, never compiled SIMD bodies. Without
|
||||
// it, a NEON-using header reachable from two different `.systemLibrary`
|
||||
// modules (e.g. both CGraphene and CGsk textually include
|
||||
// <graphene-simd4f.h>) is compiled with the real Clang builtin
|
||||
// `_Builtin_intrinsics.arm.acle` module in one and not the other,
|
||||
// and Clang's module visibility rules reject the resulting
|
||||
// conflicting `uint32_t`/`__fsid_t` redeclarations on aarch64 -
|
||||
// reproducible on every aarch64 Linux target, not distro-specific.
|
||||
// No `link` directives: the `.systemLibrary` target carries
|
||||
// `pkgConfig:`, so pkg-config `--libs` supplies the exact linker
|
||||
// flags. Emitting `link "glib-2"` here both duplicates that and
|
||||
|
|
@ -160,7 +175,7 @@ extension CodeGenerator {
|
|||
}
|
||||
"""
|
||||
files["Sources/\(cName)/module.modulemap"] = moduleMap
|
||||
files["Sources/\(cName)/\(cName).h"] = umbrellaHeader + "\n"
|
||||
files["Sources/\(cName)/\(cName).h"] = "#define __GI_SCANNER__ 1\n" + umbrellaHeader + "\n"
|
||||
}
|
||||
|
||||
// Monorepo Package.swift
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue