From a60abc163d61af61b8b35c8d3ac397f5bdcc1c94 Mon Sep 17 00:00:00 2001 From: captainurist <73941350+captainurist@users.noreply.github.com> Date: Sun, 15 Oct 2023 20:48:52 +0100 Subject: [PATCH] Dropped the libcxx assertion workarounds --- CMakeLists.txt | 3 +- CMakeModules/AppleLibcxxAssertionTest.cpp | 7 --- .../AppleLibcxxAssertionWorkaround.cpp | 22 --------- CMakeModules/AppleLibcxxAssertions.cmake | 45 ------------------- src/Bin/CodeGen/CMakeLists.txt | 1 - src/Bin/LodTool/CMakeLists.txt | 1 - src/Bin/OpenEnroth/CMakeLists.txt | 1 - test/Bin/GameTest/CMakeLists.txt | 1 - test/Bin/UnitTest/CMakeLists.txt | 1 - 9 files changed, 1 insertion(+), 81 deletions(-) delete mode 100644 CMakeModules/AppleLibcxxAssertionTest.cpp delete mode 100644 CMakeModules/AppleLibcxxAssertionWorkaround.cpp delete mode 100644 CMakeModules/AppleLibcxxAssertions.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index c7cabf39ed66..5f065e937dc0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules) include(Git) include(Detection) -include(AppleLibcxxAssertions) include(ExternalProject) include(CppLint) include(Dependencies) @@ -120,7 +119,7 @@ elseif(BUILD_COMPILER STREQUAL "clang") add_compile_options(-Werror=inconsistent-missing-override) # 'override' only used on some of the overridden functions. add_compile_options(-Werror=invalid-noreturn) # function declared 'noreturn' should not return. add_compile_options(-Werror=uninitialized) # variable 'x' is used uninitialized. - enable_libcxx_assertions(FALSE) + add_compile_definitions($<$:_LIBCPP_ENABLE_ASSERTIONS=1>) # Enable assertions in libcxx. elseif(BUILD_COMPILER STREQUAL "msvc") # /Zi -> /Z7: Pack debug info into .obj files, this is needed for ccache to work. Note that pdb for the binary # itself is still generated. diff --git a/CMakeModules/AppleLibcxxAssertionTest.cpp b/CMakeModules/AppleLibcxxAssertionTest.cpp deleted file mode 100644 index 35b88c227144..000000000000 --- a/CMakeModules/AppleLibcxxAssertionTest.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -int main(int argc, char **argv) { - std::vector a; - a[0] = 0; - return 0; -} diff --git a/CMakeModules/AppleLibcxxAssertionWorkaround.cpp b/CMakeModules/AppleLibcxxAssertionWorkaround.cpp deleted file mode 100644 index 52a8e9cde92a..000000000000 --- a/CMakeModules/AppleLibcxxAssertionWorkaround.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -#ifdef _LIBCPP_DEBUG - -static void debug_handler(const std::__libcpp_debug_info &info) { - const size_t bufsize = 1024; - char buf[bufsize] = {}; - char *pos = buf; - char *end = buf + bufsize - 1; - - pos = stpncpy(pos, info.__pred_, end - pos); - pos = stpncpy(pos, " (", end - pos); - pos = stpncpy(pos, info.__msg_, end - pos); - pos = stpncpy(pos, ")", end - pos); - - __assert_rtn("", info.__file_, info.__line_, buf); -} - -std::__libcpp_debug_function_type std::__libcpp_debug_function = &debug_handler; - -#endif diff --git a/CMakeModules/AppleLibcxxAssertions.cmake b/CMakeModules/AppleLibcxxAssertions.cmake deleted file mode 100644 index 9328b89eb671..000000000000 --- a/CMakeModules/AppleLibcxxAssertions.cmake +++ /dev/null @@ -1,45 +0,0 @@ - -set(DEBUG_LIBCXX_COMPILES FALSE) -set(DEBUG_LIBCXX_WORKAROUND_WORKS FALSE) -set(DEBUG_LIBCXX_SOURCE_ROOT ${CMAKE_CURRENT_LIST_DIR}) - -if(BUILD_PLATFORM STREQUAL "darwin") - try_compile( - DEBUG_LIBCXX_COMPILES - ${CMAKE_BINARY_DIR}/apple_libcxx_assertion_test - ${DEBUG_LIBCXX_SOURCE_ROOT}/AppleLibcxxAssertionTest.cpp - COMPILE_DEFINITIONS -D_LIBCPP_DEBUG=0 - OUTPUT_VARIABLE DEBUG_LIBCXX_COMPILE_OUTPUT - ) - if(NOT DEBUG_LIBCXX_COMPILES) - string(FIND ${DEBUG_LIBCXX_COMPILE_OUTPUT} "__libcpp_debug_function" DEBUG_LIBCXX_STR_POS) - if(NOT ${DEBUG_LIBCXX_STR_POS} EQUAL -1) - set(DEBUG_LIBCXX_WORKAROUND_WORKS TRUE) - else() - message(STATUS "Haven't found a way to fix debug libcxx build, target_fix_libcxx_assertions() won't work.") - endif() - endif() -endif() - -function(enable_libcxx_assertions ENABLE_IN_RELEASE_TOO) - if(NOT BUILD_PLATFORM STREQUAL "darwin") - message(WARNING "enable_libcxx_assertions() only works on mac os builds.") - return() - endif() - - if(ENABLE_IN_RELEASE_TOO) - add_compile_definitions(_LIBCPP_DEBUG=0) - else() - add_compile_definitions($<$:_LIBCPP_DEBUG=0>) - endif() -endfunction() - -function(target_fix_libcxx_assertions TARGET) - if(NOT BUILD_PLATFORM STREQUAL "darwin" OR DEBUG_LIBCXX_COMPILES) - return() - endif() - - if(DEBUG_LIBCXX_WORKAROUND_WORKS) - target_sources(${TARGET} PRIVATE ${DEBUG_LIBCXX_SOURCE_ROOT}/AppleLibcxxAssertionWorkaround.cpp) - endif() -endfunction() diff --git a/src/Bin/CodeGen/CMakeLists.txt b/src/Bin/CodeGen/CMakeLists.txt index 9b107493a943..e1fb09353be7 100644 --- a/src/Bin/CodeGen/CMakeLists.txt +++ b/src/Bin/CodeGen/CMakeLists.txt @@ -13,7 +13,6 @@ set(BIN_CODEGEN_HEADERS if(NOT BUILD_PLATFORM STREQUAL "android") add_executable(CodeGen ${BIN_CODEGEN_SOURCES} ${BIN_CODEGEN_HEADERS}) - target_fix_libcxx_assertions(CodeGen) target_link_libraries(CodeGen PUBLIC platform_main application CLI11::CLI11) target_check_style(CodeGen) endif() diff --git a/src/Bin/LodTool/CMakeLists.txt b/src/Bin/LodTool/CMakeLists.txt index 1ff7fc10b6a0..f1282852a1c5 100644 --- a/src/Bin/LodTool/CMakeLists.txt +++ b/src/Bin/LodTool/CMakeLists.txt @@ -9,7 +9,6 @@ set(BIN_LODTOOL_HEADERS if(NOT BUILD_PLATFORM STREQUAL "android") add_executable(LodTool ${BIN_LODTOOL_SOURCES} ${BIN_LODTOOL_HEADERS}) - target_fix_libcxx_assertions(LodTool) target_link_libraries(LodTool PUBLIC library_lod library_lodformats CLI11::CLI11) target_check_style(LodTool) endif() diff --git a/src/Bin/OpenEnroth/CMakeLists.txt b/src/Bin/OpenEnroth/CMakeLists.txt index 80518d2c1a2b..a38f5316f65d 100644 --- a/src/Bin/OpenEnroth/CMakeLists.txt +++ b/src/Bin/OpenEnroth/CMakeLists.txt @@ -17,7 +17,6 @@ else() add_executable(OpenEnroth MACOSX_BUNDLE) target_sources(OpenEnroth PUBLIC ${BIN_OPENENROTH_HEADERS} ${BIN_OPENENROTH_SOURCES}) target_check_style(OpenEnroth) - target_fix_libcxx_assertions(OpenEnroth) target_link_libraries(OpenEnroth PUBLIC platform_main application CLI11::CLI11) set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT OpenEnroth) diff --git a/test/Bin/GameTest/CMakeLists.txt b/test/Bin/GameTest/CMakeLists.txt index 683afca4808c..aa65157b4ad8 100644 --- a/test/Bin/GameTest/CMakeLists.txt +++ b/test/Bin/GameTest/CMakeLists.txt @@ -9,7 +9,6 @@ if(OE_BUILD_TESTS) GameTestOptions.h) add_executable(OpenEnroth_GameTest ${GAME_TEST_MAIN_SOURCES} ${GAME_TEST_MAIN_HEADERS}) - target_fix_libcxx_assertions(OpenEnroth_GameTest) target_link_libraries(OpenEnroth_GameTest PUBLIC platform_main application testing_game GTest::gtest CLI11::CLI11) target_check_style(OpenEnroth_GameTest) diff --git a/test/Bin/UnitTest/CMakeLists.txt b/test/Bin/UnitTest/CMakeLists.txt index 0ee0703d0d7d..b7c040c12327 100644 --- a/test/Bin/UnitTest/CMakeLists.txt +++ b/test/Bin/UnitTest/CMakeLists.txt @@ -5,7 +5,6 @@ if(OE_BUILD_TESTS) UnitTestMain.cpp) add_executable(OpenEnroth_UnitTest ${UNIT_TEST_MAIN_SOURCES}) - target_fix_libcxx_assertions(OpenEnroth_UnitTest) target_link_libraries(OpenEnroth_UnitTest PUBLIC testing_unit CLI11::CLI11) add_custom_target(UnitTest OpenEnroth_UnitTest