From 53fa9560586c579bafd7d109eb0f3777951510f4 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 21 Sep 2023 17:26:08 +0800 Subject: [PATCH 1/2] Fix crash in __cxx_global_var_init if using Xcode 15 and targeting <= iOS 14 --- native/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt index 3935dbbc443..fcb7f074eda 100644 --- a/native/CMakeLists.txt +++ b/native/CMakeLists.txt @@ -3292,6 +3292,13 @@ if(APPLE) CC_KEYBOARD_SUPPORT ) elseif(IOS) + + if("${XCODE_VERSION}" VERSION_GREATER_EQUAL "15.0") + # For Xcode 15 and newer, add extra link flags to fix crash in __cxx_global_var_init. + message(STATUS "Using Xcode 15 or newer, adding extra link flags: -Wl,-ld_classic.") + target_link_options(${ENGINE_NAME} PUBLIC -Wl,-ld_classic) + endif() + target_link_libraries(${ENGINE_NAME} PUBLIC "-framework QuartzCore" "-framework MetalPerformanceShaders" From a236bba70893e2ee43f989ed343d6ed5ed911be2 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 6 Sep 2023 14:59:03 +0800 Subject: [PATCH 2/2] fixed #16190: Compilation errors if using Clang 15 with c++17 since std::unary_function has been removed (#16191) * fixed #16190: Compilation errors if using Clang 15 with c++17 since std::unary_function has been removed * Windows doesn't need to define BOOST_NO_CXX98_FUNCTION_BASE since it has already been defined. --- native/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt index fcb7f074eda..0ef166479f2 100644 --- a/native/CMakeLists.txt +++ b/native/CMakeLists.txt @@ -82,6 +82,13 @@ if(USE_SERVER_MODE) add_definitions(-DCC_SERVER_MODE) endif() +# Fix the issue: https://github.com/cocos/cocos-engine/issues/16190 +# std::unary_function was removed since clang 15 +# The macro has already been defined in boost/config/stdlib/dinkumware.hpp(258,1), +# so no need to define it again to avoid 'macro redefinition' error. +if(NOT WINDOWS) + add_definitions(-DBOOST_NO_CXX98_FUNCTION_BASE) +endif() add_definitions(-DCC_NETMODE_CLIENT=0) add_definitions(-DCC_NETMODE_LISTEN_SERVER=1)