diff --git a/Sources/GObjectGeneratorCore/CodeGen+Scaffolding.swift b/Sources/GObjectGeneratorCore/CodeGen+Scaffolding.swift index 949fa6f..6ff97ad 100644 --- a/Sources/GObjectGeneratorCore/CodeGen+Scaffolding.swift +++ b/Sources/GObjectGeneratorCore/CodeGen+Scaffolding.swift @@ -149,6 +149,21 @@ extension CodeGenerator { umbrellaHeader += "\n#include " } + // 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 + // ) 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