From 57a778ed25264686e2da821b3d5caa249f079657 Mon Sep 17 00:00:00 2001 From: fanquake Date: Wed, 28 Jan 2026 13:33:44 +0000 Subject: [PATCH] depends: use -Xclang -fno-cxx-modules in macOS cross build Newer versions of the macOS SDK, have introduced code like: ```cpp if defined(__has_feature) && __has_feature(modules) define USE_CLANG_TYPES 1 else define USE_CLANG_TYPES 0 endif if USE_CLANG_TYPES include include include include endif ``` which is currently causing compile failures due to undeclared types, which manifest when C++ modules are enabled. Note that the usage of "modules" in LLVM is can be a bit ambiguous, see: https://github.com/llvm/llvm-project/issues/55891. For now, explcitly disable cxx modules using `-fno-cxx-modules`. This resolves the include/compilation issues. Related discussion: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116827 https://github.com/llvm/llvm-project/pull/150349 https://github.com/llvm/llvm-project/issues/57432 --- depends/hosts/darwin.mk | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/depends/hosts/darwin.mk b/depends/hosts/darwin.mk index d33b681babf..6f38a15b5d1 100644 --- a/depends/hosts/darwin.mk +++ b/depends/hosts/darwin.mk @@ -50,6 +50,12 @@ darwin_STRIP=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-strip") # # Disable adhoc codesigning (for now) when using LLVM tooling, to avoid # non-determinism issues with the Identifier field. +# +# -Xclang -fno-cxx-modules +# +# Disable C++ modules. We don't use these, and modules cause definition issues +# in the SDK, where __has_feature(modules) is used to define USE_CLANG_TYPES, +# which is in turn used as an include guard. darwin_CC=$(clang_prog) --target=$(host) \ -isysroot$(OSX_SDK) -nostdlibinc \ @@ -61,7 +67,7 @@ darwin_CXX=$(clangxx_prog) --target=$(host) \ -iwithsysroot/usr/include -iframeworkwithsysroot/System/Library/Frameworks darwin_CFLAGS=-mmacos-version-min=$(OSX_MIN_VERSION) -darwin_CXXFLAGS=-mmacos-version-min=$(OSX_MIN_VERSION) +darwin_CXXFLAGS=-mmacos-version-min=$(OSX_MIN_VERSION) -Xclang -fno-cxx-modules darwin_LDFLAGS=-Wl,-platform_version,macos,$(OSX_MIN_VERSION),$(OSX_SDK_VERSION) ifneq ($(build_os),darwin)