Daemon
Daemon copied to clipboard
Precompiled header broken on Mac
Precompiled headers on Mac are still broken since #982. The problem of #1508 that USE_PRECOMPILED_HEADER is ignored was fixed: now it attempts to build a PCH. But the build does not succeed.
[ 53%] Generating CMakeFiles/engine-lib.h.gch
/Library/Developer/CommandLineTools/usr/bin/c++ -DBUILD_ENGINE -DDAEMON_ARCH_amd64 -DARCH_STRING=amd64 -DNACL_ARCH_STRING=amd64 -DDAEMON_USE_ARCH_INTRINSICS=1 -DDAEMON_USE_ARCH_INTRINSICS_amd64=1 -DDAEMON_USE_ARCH_INTRINSICS_i686=1 -DDAEMON_C_COMPILER_AppleClang=1 -DDAEMON_C_COMPILER_STRING=AppleClang_15.0.0/Clang_15.0.0:cc -DDAEMON_CXX_COMPILER_AppleClang=1 -DDAEMON_CXX_COMPILER_STRING=AppleClang_15.0.0/Clang_15.0.0:c++ -DDAEMON_BUILD_RelWithDebInfo -DDAEMON_USE_COMPILER_INTRINSICS=1 -DDAEMON_USE_COMPILER_CUSTOMIZATION=1 -DMACOS_X -DTHIS_IS_NOT_A_DEBUG_BUILD -DUSE_MUMBLE -DNACL_WINDOWS=0 -DNACL_LINUX=0 -DNACL_ANDROID=0 -DNACL_FREEBSD=0 -DNACL_OSX=1 -DNACL_BUILD_ARCH=x86 -DNACL_BUILD_SUBARCH=64 -DPDC_WIDE -DPDC_FORCE_UTF8 -DPDC_RGB -DUSE_CURSES -I/Users/slipher/Unvanquished/daemon/src -I/Users/slipher/Unvanquished/daemon/libs -I/Users/slipher/Unvanquished/daemon/libs/nacl -I/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/System/Library/Frameworks/OpenGL.framework -I/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include -I/Users/slipher/Unvanquished/daemon/libs/pdcursesmod -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include/opus -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include -I/Library/Frameworks/Mono.framework/Headers -I/Library/Frameworks/Mono.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include -I/Library/Frameworks/Mono.framework/Headers -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include/freetype2 -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include/AL -I/Users/slipher/Unvanquished/daemon/src -I/Users/slipher/Unvanquished/daemon/libs -I/Users/slipher/Unvanquished/daemon/libs/nacl -I/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/System/Library/Frameworks/OpenGL.framework -I/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include -I/Users/slipher/Unvanquished/daemon/libs/pdcursesmod -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include/opus -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include -I/Library/Frameworks/Mono.framework/Headers -I/Library/Frameworks/Mono.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include -I/Library/Frameworks/Mono.framework/Headers -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include/freetype2 -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include -I/Users/slipher/Unvanquished/daemon/external_deps/macos-amd64-default_10/include/AL -I/Users/slipher/Unvanquished/daemon/src/engine -I/Users/slipher/Unvanquished/daemon/src -I/Users/slipher/Unvanquished/daemon/libs -std=gnu++14 -ffast-math -fvisibility=hidden -fno-strict-aliasing -march=x86-64 -mtune=generic -mcx16 -Wall -Wextra -Wno-pragmas -Wno-unknown-pragmas -Wno-old-style-cast -Woverloaded-virtual -Wno-sign-compare -O2 -g -DNDEBUG -g3 -D_FORTIFY_SOURCE=2 -x c++-header /Users/slipher/Unvanquished/daemon/src/common/Common.h -o /Users/slipher/Unvanquished/daemon/build/CMakeFiles/engine-lib.h.gch
clang: error: unsupported argument 'x86-64' to option '-march='
I don't reproduce that bug on an amd64 macOS Sequoia. Is that reproduced on an arm64 mac? What is the macOS version and compiler version?
On my end I have:
$ uname -srm
Darwin 24.2.0 x86_64
$ sw_vers
ProductName: macOS
ProductVersion: 15.2
BuildVersion: 24C101
$ clang --version
Apple clang version 16.0.0 (clang-1600.0.26.6)
Target: x86_64-apple-darwin24.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ clang -print-targets
Registered Targets:
aarch64 - AArch64 (little endian)
aarch64_32 - AArch64 (little endian ILP32)
aarch64_be - AArch64 (big endian)
arm - ARM
arm64 - ARM64 (little endian)
arm64_32 - ARM64 (little endian ILP32)
armeb - ARM (big endian)
thumb - Thumb
thumbeb - Thumb (big endian)
x86 - 32-bit X86: Pentium-Pro and above
x86-64 - 64-bit X86: EM64T and AMD64
It may be a compiler bug if the bug happens on arm64 compiling amd64 but not on amd64 compiling amd64.
It may also be a compiler bug if the bug only happens with PCH as if the build succeeds without PCH it means the -march=x86-64 options isn't unsupported.
❯ make
[ 5%] Built target srclibs-rmlui
[ 5%] Built target src-sgame-entities.yaml
[ 6%] Built target srclibs-minizip
[ 7%] Built target srclibs-fastlz
[ 9%] Built target srclibs-detour
[ 11%] Built target srclibs-recast
[ 11%] Generating CMakeFiles/sgame-native-dll.h.gch
c++: error: unsupported argument 'x86-64' to option '-march='
make[2]: *** [CMakeFiles/sgame-native-dll.h.gch] Error 1
make[1]: *** [CMakeFiles/sgame-native-dll-pch.dir/all] Error 2
make: *** [all] Error 2
This is my error when compiling with PCH. Compiling on an arm macbook.
Yes, this is an ARM mac issue. We need to be more aware of the march flag
Further, if I set USE_GENERIC_ARCHITECTURE to false, I get:
❯ make
[ 5%] Built target srclibs-rmlui
[ 5%] Built target src-sgame-entities.yaml
[ 6%] Built target srclibs-minizip
[ 7%] Built target srclibs-fastlz
[ 9%] Built target srclibs-detour
[ 11%] Built target srclibs-recast
[ 11%] Generating CMakeFiles/sgame-native-dll.h.gch
c++: warning: argument unused during compilation: '-mcx16' [-Wunused-command-line-argument]
In file included from /Users/harshmodi/code/Unvanquished/daemon/src/common/Common.h:35:
/Users/harshmodi/code/Unvanquished/daemon/src/engine/qcommon/q_shared.h:69:10: fatal error: 'errno.h' file not found
69 | #include <errno.h>
| ^~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/sgame-native-dll.h.gch] Error 1
make[1]: *** [CMakeFiles/sgame-native-dll-pch.dir/all] Error 2
make: *** [all] Error 2
I wouldn't jump to the conclusion that it's the host architecture that matters. Could be just different versions of the toolchain.
I think this flag needs to be set correctly for M1 Macs? https://github.com/DaemonEngine/Daemon/blob/17ba767bf0b128368af1f8e7d6a75f36385a1702/cmake/DaemonFlags.cmake#L541
Detected architecture: amd64
Enabling amd64 architecture intrinsics
Enabling i686 architecture intrinsics
CMake generator: Unix Makefiles
Detected C compiler: AppleClang_16.0.0/Clang_16.0.0:cc
Detected C++ compiler: AppleClang_16.0.0/Clang_16.0.0:c++
Seems like its just not being handled correctly.
The Mac build targets x86 by default. Arm is buildable but it won't be used unless you override CMAKE_OSX_ARCHITECTURES.
Sure, but that does mean that Arm M1 Mac isn't being handled correctly, or it needs some special settings that are undocumented.
I don't reproduce that bug on an amd64 macOS Sequoia. Is that reproduced on an arm64 mac? What is the macOS version and compiler version?
I probably didn't reproduced the AppleClang bug at the time on Sequoia because of a bug in our CMake code disabling PCH in all cases:
- https://github.com/DaemonEngine/Daemon/pull/1500
I haven't retried on Sequoia though…