From b000f4025cc7385fa7981e28c351d172afe4e1e9 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Thu, 14 Nov 2024 23:49:50 -0500 Subject: [PATCH] give up using toolchain --- .github/workflows/ci_tests.yml | 4 +-- CMakeLists.txt | 4 +++ CMakePresets.json | 2 -- cmake/toolchain.cmake | 47 ---------------------------------- 4 files changed, 6 insertions(+), 51 deletions(-) delete mode 100644 cmake/toolchain.cmake diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 5452e6a..320d5f5 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -51,10 +51,10 @@ jobs: args: "" - description: "TSan" config: "Debug" - args: "-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain.cmake -DBEMAN_BUILDSYS_SANITIZER=TSan" + args: "-DBEMAN_BUILDSYS_SANITIZER=TSan" - description: "ASan" config: "Debug" - args: "-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain.cmake -DBEMAN_BUILDSYS_SANITIZER=ASan" + args: "-DBEMAN_BUILDSYS_SANITIZER=ASan" include: - platform: ubuntu-latest compiler: diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e73ca3..ca77dd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,10 @@ option( ${PROJECT_IS_TOP_LEVEL} ) +if(DEFINED BEMAN_BUILDSYS_SANITIZER) + include(cmake/apply_santizers.cmake) +endif() + include(CTest) include(FetchContent) include(GNUInstallDirs) diff --git a/CMakePresets.json b/CMakePresets.json index 00f29f7..3d37d09 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -15,7 +15,6 @@ "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_TOOLCHAIN_FILE": "cmake/toolchain.cmake", "BEMAN_BUILDSYS_SANITIZER": "ASan" } }, @@ -24,7 +23,6 @@ "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "RelWithDebInfo", - "CMAKE_TOOLCHAIN_FILE": "cmake/toolchain.cmake", "BEMAN_BUILDSYS_SANITIZER": "OFF" } }, diff --git a/cmake/toolchain.cmake b/cmake/toolchain.cmake deleted file mode 100644 index b3cd128..0000000 --- a/cmake/toolchain.cmake +++ /dev/null @@ -1,47 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -set(CMAKE_C_FLAGS_RELEASE_INIT "-O3") -set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O3") - -set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O3") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O3") - -# BEMAN_BUILDSYS_SANITIZER is not a general use option -# It is used by preset and CI system. -# There's three possible values: -# TSan: Thread sanitizer -# ASan: All sanitizer (majorly Address sanitizer) that doesn't conflict with TSan -# OFF: No sanitizer - -if(DEFINED BEMAN_BUILDSYS_SANITIZER) - if(BEMAN_BUILDSYS_SANITIZER STREQUAL "ASan") - # Basic ASan flags - set(SANITIZER_FLAGS - "-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined" - ) - - # Exclude -fsanitize=leak on Apple Clang (gcc on macos) as it is not supported. - if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") - message(STATUS "Using GCC on macOS; excluding -fsanitize=leak") - else() - set(SANITIZER_FLAGS "${SANITIZER_FLAGS} -fsanitize=leak") - endif() - elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "TSan") - # Basic ASan flags - set(SANITIZER_FLAGS "-fsanitize=thread") - elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "OFF") - set(SANITIZER_FLAGS "") - else() - message( - FATAL_ERROR - "Invalid BEMAN_BUILDSYS_SANITIZER option: ${BEMAN_BUILDSYS_SANITIZER}" - ) - endif() - - set(CMAKE_C_FLAGS_DEBUG_INIT - "${CMAKE_C_FLAGS_DEBUG_INIT} ${SANITIZER_FLAGS}" - ) - set(CMAKE_CXX_FLAGS_DEBUG_INIT - "${CMAKE_C_FLAGS_DEBUG_INIT} ${SANITIZER_FLAGS}" - ) -endif()