Skip to content

[Develop] Cannot compile source code using non-Apple clang, showing "could not build module QuartzCore and CoreVideo", on macOS #107199

@OzelotVanilla

Description

@OzelotVanilla

Tested versions

Current master branch (4.5 dev).

System information

macOS 15.5 (24F74)

Issue description

This issue is discussing the fail of compiling source code problem found in engine development. It does not related to the release of any version.
See PR #107200 for current fixing.

(Some part copied from #106820 (comment))

These two lines (L42 and L43; L42 is a comment) makes the compilation failing when not using clang at /usr/bin/clang.

env_metal.Append(CCFLAGS=["-fmodules", "-fcxx-modules"])

More specificly speaking, the -fmodules flag causes problem.

These lines are introduced in this commit by this PR #105628:
4572994#diff-1b97ad843ac03b1910b3b5b6888d75e1d0a5ea9a51919f28cd0b1ccb1b49fc8a

In this comment #105628 (comment), they explain the reason why the line mentioned above, is added. But as they had said, this is not widely supported by all compilers, so my compiler (clang v20.1.5, from homebrew) failed to build.

I have a pull-request #107200 which may fix this problem by checking if the clang is Apple-clang or not, but I still hope the root cause could be found.

This is a part of the log when the compiler fails. The whole log is too long, but expected function body after function declarator error could be seen a lot of times in these logs.

While building module 'QuartzCore' imported from drivers/metal/metal_objects.h:63:
While building module 'CoreVideo' imported from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CAOpenGLLayer.h:9:
While building module 'ApplicationServices' imported from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVImageBuffer.h:29:
While building module 'CUPS' imported from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/ApplicationServices.framework/Frameworks/PrintCore.framework/Headers/PDEPluginInterface.h:24:
In file included from <module-includes>:1:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/cups/cups.h:428:60: error: expected function body after function declarator
  428 | extern cups_file_t      *cupsTempFile2(char *filename, int len) _CUPS_API_1_2;
      |                                                                 ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/cups/versioning.h:112:27: note: expanded from macro '_CUPS_API_1_2'
  112 | #    define _CUPS_API_1_2 API_AVAILABLE(macos(10.5), ios(11.0)) _CUPS_PUBLIC
      |                           ^
While building module 'QuartzCore' imported from drivers/metal/metal_objects.h:63:
While building module 'CoreVideo' imported from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CAOpenGLLayer.h:9:
While building module 'ApplicationServices' imported from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVImageBuffer.h:29:
While building module 'CUPS' imported from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/ApplicationServices.framework/Frameworks/PrintCore.framework/Headers/PDEPluginInterface.h:24:
In file included from <module-includes>:1:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/cups/cups.h:433:20: error: expected function body after function declarator
  433 |                                          int outfile) _CUPS_API_1_3;
      |                                                       ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/cups/versioning.h:113:27: note: expanded from macro '_CUPS_API_1_3'
  113 | #    define _CUPS_API_1_3 API_AVAILABLE(macos(10.5), ios(11.0)) _CUPS_PUBLIC
      |                           ^
While building module 'QuartzCore' imported from drivers/metal/metal_objects.h:63:
While building module 'CoreVideo' imported from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CAOpenGLLayer.h:9:
While building module 'ApplicationServices' imported from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVImageBuffer.h:29:
While building module 'CUPS' imported from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/ApplicationServices.framework/Frameworks/PrintCore.framework/Headers/PDEPluginInterface.h:24:
In file included from <module-includes>:1:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/cups/cups.h:437:12: error: expected function body after function declarator
  437 |                                        _CUPS_API_1_3;
      |                                        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/cups/versioning.h:113:27: note: expanded from macro '_CUPS_API_1_3'
  113 | #    define _CUPS_API_1_3 API_AVAILABLE(macos(10.5), ios(11.0)) _CUPS_PUBLIC
      |                           ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
While building module 'QuartzCore' imported from drivers/metal/metal_objects.h:63:
While building module 'CoreVideo' imported from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CAOpenGLLayer.h:9:
While building module 'ApplicationServices' imported from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVImageBuffer.h:29:
In file included from <module-includes>:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:62:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/ApplicationServices.framework/Frameworks/PrintCore.framework/Headers/PrintCore.h:26:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/ApplicationServices.framework/Frameworks/PrintCore.framework/Headers/PDEPluginInterface.h:24:9: fatal error: could not build module 'CUPS'
   24 | #import <cups/ppd.h>
      |  ~~~~~~~^
While building module 'QuartzCore' imported from drivers/metal/metal_objects.h:63:
While building module 'CoreVideo' imported from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CAOpenGLLayer.h:9:
In file included from <module-includes>:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CoreVideo.h:29:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVPixelBuffer.h:23:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVImageBuffer.h:29:10: fatal error: could not build module 'ApplicationServices'
   29 | #include <ApplicationServices/ApplicationServices.h>
      |  ~~~~~~~~^
While building module 'QuartzCore' imported from drivers/metal/metal_objects.h:63:
In file included from <module-includes>:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.h:20:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CoreAnimation.h:34:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CAOpenGLLayer.h:9:9: fatal error: could not build module 'CoreVideo'
    9 | #import <CoreVideo/CVBase.h>
      |  ~~~~~~~^
In file included from drivers/metal/metal_objects.mm:51:
drivers/metal/metal_objects.h:63:9: fatal error: could not build module 'QuartzCore'
   63 | #import <QuartzCore/CAMetalLayer.h>
      |  ~~~~~~~^
24 errors generated.
scons: *** [bin/obj/drivers/metal/metal_objects.macos.editor.arm64.o] Error 1
scons: building terminated because of errors.
INFO: Time elapsed: 00:01:12.29

Steps to reproduce

  • Use brew install llvm to install Homebrew-clang.
  • Run PATH=/opt/homebrew/opt/llvm/bin:$PATH scons

Minimal reproduction project (MRP)

Use the code in master branch.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Not Critical

Relationships

None yet

Development

No branches or pull requests

Issue actions