Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precompiled header broken on Mac #1549

Open
slipher opened this issue Feb 11, 2025 · 8 comments
Open

Precompiled header broken on Mac #1549

slipher opened this issue Feb 11, 2025 · 8 comments

Comments

@slipher
Copy link
Member

slipher commented Feb 11, 2025

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='
@illwieckz
Copy link
Member

illwieckz commented Feb 14, 2025

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.

@DolceTriade
Copy link
Contributor

❯ 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

@DolceTriade
Copy link
Contributor

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

@slipher
Copy link
Member Author

slipher commented Feb 25, 2025

I wouldn't jump to the conclusion that it's the host architecture that matters. Could be just different versions of the toolchain.

@DolceTriade
Copy link
Contributor

I think this flag needs to be set correctly for M1 Macs?

try_c_cxx_flag_werror(MARCH "-march=${GCC_GENERIC_ARCH}")

@DolceTriade
Copy link
Contributor

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.

@slipher
Copy link
Member Author

slipher commented Feb 25, 2025

The Mac build targets x86 by default. Arm is buildable but it won't be used unless you override CMAKE_OSX_ARCHITECTURES.

@DolceTriade
Copy link
Contributor

Sure, but that does mean that Arm M1 Mac isn't being handled correctly, or it needs some special settings that are undocumented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants