From 60c0bd5f79fb5669aad223dabc831561f21ec284 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:30:33 -0500 Subject: [PATCH 01/28] add toolchain --- CMakePresets.json | 4 ++-- cmake/toolchain.cmake | 49 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 cmake/toolchain.cmake diff --git a/CMakePresets.json b/CMakePresets.json index 0b645f2..4746e2f 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -15,7 +15,7 @@ "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_CXX_FLAGS": "-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=leak -fsanitize=undefined" + "CMAKE_TOOLCHAIN_FILE": "cmake/toolchain.cmake" } }, { @@ -23,7 +23,7 @@ "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "RelWithDebInfo", - "CMAKE_CXX_FLAGS": "-O3" + "CMAKE_TOOLCHAIN_FILE": "cmake/toolchain.cmake" } }, { diff --git a/cmake/toolchain.cmake b/cmake/toolchain.cmake new file mode 100644 index 0000000..60b4769 --- /dev/null +++ b/cmake/toolchain.cmake @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# Toolchain file +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 if using GCC on macOS + # TODO: Is there a way to detect Apple Clang??? + if( + CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + AND CMAKE_SYSTEM_NAME STREQUAL "Darwin" + ) + message(STATUS "Using GCC on macOS; excluding -fsanitize=leak") + else() + list(APPEND SANITIZER_FLAGS "-fsanitize=leak") + endif() + elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "TSan") + 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() + + # Apply flags to both C and C++ compilers, along with debug settings + 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() From 054c877deab8287fa74396078572d703db283be6 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:33:16 -0500 Subject: [PATCH 02/28] enable santizier --- CMakePresets.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 4746e2f..00f29f7 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -15,7 +15,8 @@ "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_TOOLCHAIN_FILE": "cmake/toolchain.cmake" + "CMAKE_TOOLCHAIN_FILE": "cmake/toolchain.cmake", + "BEMAN_BUILDSYS_SANITIZER": "ASan" } }, { @@ -23,7 +24,8 @@ "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "RelWithDebInfo", - "CMAKE_TOOLCHAIN_FILE": "cmake/toolchain.cmake" + "CMAKE_TOOLCHAIN_FILE": "cmake/toolchain.cmake", + "BEMAN_BUILDSYS_SANITIZER": "OFF" } }, { From 8a59d2e9ae705ecbed5287ac9ea546b803c9ec43 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:41:58 -0500 Subject: [PATCH 03/28] fix toolchain --- cmake/toolchain.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/toolchain.cmake b/cmake/toolchain.cmake index 60b4769..77d6b54 100644 --- a/cmake/toolchain.cmake +++ b/cmake/toolchain.cmake @@ -26,9 +26,10 @@ if(DEFINED BEMAN_BUILDSYS_SANITIZER) ) message(STATUS "Using GCC on macOS; excluding -fsanitize=leak") else() - list(APPEND SANITIZER_FLAGS "-fsanitize=leak") + 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 "") @@ -39,7 +40,6 @@ if(DEFINED BEMAN_BUILDSYS_SANITIZER) ) endif() - # Apply flags to both C and C++ compilers, along with debug settings set(CMAKE_C_FLAGS_DEBUG_INIT "${CMAKE_C_FLAGS_DEBUG_INIT} ${SANITIZER_FLAGS}" ) From d65aeaf0ad0a8e8b6ef033d0e6f41d6c097844a5 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Thu, 14 Nov 2024 15:18:54 -0500 Subject: [PATCH 04/28] update action script --- .github/workflows/ci_tests.yml | 27 ++++++++++++--------------- cmake/toolchain.cmake | 4 +++- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 7c62dd5..bab5309 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -39,11 +39,14 @@ jobs: c: clang cpp_version: [17, 20, 23, 26] cmake_args: - - description: "Default" + - description: "Release Default" + config: "Release" args: "" - description: "TSan" + config: "Debug" args: "-DCMAKE_CXX_FLAGS=-fsanitize=thread" - description: "ASan" + config: "Debug" args: "-DCMAKE_CXX_FLAGS='-fsanitize=address -fsanitize=undefined'" include: - platform: ubuntu-latest @@ -53,6 +56,7 @@ jobs: cpp_version: 17 cmake_args: description: "Werror" + config: "Release" args: "-DCMAKE_CXX_FLAGS='-Werror=all -Werror=extra'" - platform: ubuntu-latest compiler: @@ -61,6 +65,7 @@ jobs: cpp_version: 17 cmake_args: description: "Dynamic" + config: "Release" args: "-DBUILD_SHARED_LIBS=on" name: "Unit: ${{ matrix.compiler.c }} ${{ matrix.cpp_version }} ${{ matrix.cmake_args.description }}" @@ -85,22 +90,14 @@ jobs: CC: ${{ matrix.compiler.c }} CXX: ${{ matrix.compiler.cpp }} CMAKE_GENERATOR: "Ninja Multi-Config" - - name: Build Release - run: | - cmake --build build --config Release --verbose - cmake --build build --config Release --target all_verify_interface_header_sets - cmake --install build --config Release --prefix /opt/beman.exemplar - find /opt/beman.exemplar -type f - - name: Test Release - run: ctest --test-dir build --build-config Release - - name: Build Debug + - name: Build run: | - cmake --build build --config Debug --verbose - cmake --build build --config Debug --target all_verify_interface_header_sets - cmake --install build --config Debug --prefix /opt/beman.exemplar + cmake --build build --config ${{ matrix.cmake_args.config }} --verbose + cmake --build build --config ${{ matrix.cmake_args.config }} --target all_verify_interface_header_sets + cmake --install build --config ${{ matrix.cmake_args.config }} --prefix /opt/beman.exemplar find /opt/beman.exemplar -type f - - name: Test Debug - run: ctest --test-dir build --build-config Debug + - name: Test + run: ctest --test-dir build --build-config ${{ matrix.cmake_args.config }} configuration-test: runs-on: ubuntu-latest diff --git a/cmake/toolchain.cmake b/cmake/toolchain.cmake index 77d6b54..8d01d9e 100644 --- a/cmake/toolchain.cmake +++ b/cmake/toolchain.cmake @@ -1,6 +1,8 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# Toolchain file +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") From aba478902d4e0e34b6591923c6a62d8146a65c2a Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Thu, 14 Nov 2024 15:21:26 -0500 Subject: [PATCH 05/28] use toolchain in CI --- .github/workflows/ci_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index bab5309..8fc09b8 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -44,10 +44,10 @@ jobs: args: "" - description: "TSan" config: "Debug" - args: "-DCMAKE_CXX_FLAGS=-fsanitize=thread" + args: "-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain.cmake -DBEMAN_BUILDSYS_SANITIZER=TSan" - description: "ASan" config: "Debug" - args: "-DCMAKE_CXX_FLAGS='-fsanitize=address -fsanitize=undefined'" + args: "-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain.cmake -DBEMAN_BUILDSYS_SANITIZER=ASan" include: - platform: ubuntu-latest compiler: From 730028a7e670a12b77b34133ee04d044644c15f1 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Thu, 14 Nov 2024 17:36:14 -0500 Subject: [PATCH 06/28] Update toolchain.cmake --- cmake/toolchain.cmake | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cmake/toolchain.cmake b/cmake/toolchain.cmake index 8d01d9e..b3cd128 100644 --- a/cmake/toolchain.cmake +++ b/cmake/toolchain.cmake @@ -20,12 +20,8 @@ if(DEFINED BEMAN_BUILDSYS_SANITIZER) "-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined" ) - # Exclude -fsanitize=leak if using GCC on macOS - # TODO: Is there a way to detect Apple Clang??? - if( - CMAKE_CXX_COMPILER_ID STREQUAL "GNU" - AND CMAKE_SYSTEM_NAME STREQUAL "Darwin" - ) + # 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") From f4932e93adee2ceb2dadf05e1220328e027e84fa Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Thu, 14 Nov 2024 23:30:48 -0500 Subject: [PATCH 07/28] run gcc-debug on macos --- .github/workflows/ci_tests.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 8fc09b8..5452e6a 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -12,11 +12,18 @@ on: jobs: preset-test: - runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - preset: ["gcc-debug", "gcc-release"] - name: "Preset: ${{ matrix.preset }}" + mtx: + - preset: "gcc-release" + os: ubuntu-latest + - preset: "gcc-debug" + os: ubuntu-latest + - preset: "gcc-debug" + os: macos-latest + runs-on: ${{ matrix.mtx.os }} + name: "Preset: ${{ matrix.mtx.preset }} on ${{ matrix.mtx.os }}" steps: - uses: actions/checkout@v4 - name: Setup build environment @@ -25,7 +32,7 @@ jobs: cmakeVersion: "~3.25.0" ninjaVersion: "^1.11.1" - name: Run preset - run: cmake --workflow --preset ${{ matrix.preset }} + run: cmake --workflow --preset ${{ matrix.mtx.preset }} gtest-test: strategy: From cc37b1a458ce3da3d26c39fe1b96913085d6338e Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Thu, 14 Nov 2024 23:51:49 -0500 Subject: [PATCH 08/28] give up using toolchain --- .github/workflows/ci_tests.yml | 4 +-- CMakeLists.txt | 4 +++ CMakePresets.json | 2 -- cmake/apply_santizers.cmake | 37 ++++++++++++++++++++++++++ cmake/toolchain.cmake | 47 ---------------------------------- 5 files changed, 43 insertions(+), 51 deletions(-) create mode 100644 cmake/apply_santizers.cmake 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/apply_santizers.cmake b/cmake/apply_santizers.cmake new file mode 100644 index 0000000..30e2d3f --- /dev/null +++ b/cmake/apply_santizers.cmake @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# 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 + +message("Applying sanitizers for ${CMAKE_CXX_COMPILER_ID}") + +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 "${CMAKE_C_FLAGS} ${SANITIZER_FLAGS}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_FLAGS}") 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() From 78e0a40a5030cac234fe2271085f8535cfbdf84a Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Fri, 15 Nov 2024 00:44:08 -0500 Subject: [PATCH 09/28] revert previous changes that are no longer needed --- .github/workflows/ci_tests.yml | 42 ++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 7ca2bec..0d005c2 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -15,15 +15,14 @@ jobs: strategy: fail-fast: false matrix: - mtx: + preset: ["gcc-debug"] + os: [ubuntu-latest, macos-latest] + include: + # Release don't have variants among platforms - preset: "gcc-release" os: ubuntu-latest - - preset: "gcc-debug" - os: ubuntu-latest - - preset: "gcc-debug" - os: macos-latest - runs-on: ${{ matrix.mtx.os }} - name: "Preset: ${{ matrix.mtx.preset }} on ${{ matrix.mtx.os }}" + runs-on: ${{ matrix.os }} + name: "Preset: ${{ matrix.preset }} on ${{ matrix.os }}" steps: - uses: actions/checkout@v4 - name: Setup build environment @@ -32,7 +31,7 @@ jobs: cmakeVersion: "~3.25.0" ninjaVersion: "^1.11.1" - name: Run preset - run: cmake --workflow --preset ${{ matrix.mtx.preset }} + run: cmake --workflow --preset ${{ matrix.preset }} gtest-test: strategy: @@ -46,14 +45,11 @@ jobs: c: clang cpp_version: [17, 20, 23, 26] cmake_args: - - description: "Release Default" - config: "Release" + - description: "Default" args: "" - description: "TSan" - config: "Debug" args: "-DBEMAN_BUILDSYS_SANITIZER=TSan" - description: "ASan" - config: "Debug" args: "-DBEMAN_BUILDSYS_SANITIZER=ASan" include: - platform: ubuntu-latest @@ -63,7 +59,6 @@ jobs: cpp_version: 17 cmake_args: description: "Werror" - config: "Release" args: "-DCMAKE_CXX_FLAGS='-Werror=all -Werror=extra'" - platform: ubuntu-latest compiler: @@ -72,7 +67,6 @@ jobs: cpp_version: 17 cmake_args: description: "Dynamic" - config: "Release" args: "-DBUILD_SHARED_LIBS=on" name: "Unit: ${{ matrix.compiler.c }} ${{ matrix.cpp_version }} ${{ matrix.cmake_args.description }}" @@ -97,14 +91,22 @@ jobs: CC: ${{ matrix.compiler.c }} CXX: ${{ matrix.compiler.cpp }} CMAKE_GENERATOR: "Ninja Multi-Config" - - name: Build + - name: Build Release + run: | + cmake --build build --config Release --verbose + cmake --build build --config Release --target all_verify_interface_header_sets + cmake --install build --config Release --prefix /opt/beman.exemplar + find /opt/beman.exemplar -type f + - name: Test Release + run: ctest --test-dir build --build-config Release + - name: Build Debug run: | - cmake --build build --config ${{ matrix.cmake_args.config }} --verbose - cmake --build build --config ${{ matrix.cmake_args.config }} --target all_verify_interface_header_sets - cmake --install build --config ${{ matrix.cmake_args.config }} --prefix /opt/beman.exemplar + cmake --build build --config Debug --verbose + cmake --build build --config Debug --target all_verify_interface_header_sets + cmake --install build --config Debug --prefix /opt/beman.exemplar find /opt/beman.exemplar -type f - - name: Test - run: ctest --test-dir build --build-config ${{ matrix.cmake_args.config }} + - name: Test Debug + run: ctest --test-dir build --build-config Debug configuration-test: runs-on: ubuntu-latest From 62874032e5d0261582f8760d60c2660b346114cf Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Fri, 15 Nov 2024 00:45:12 -0500 Subject: [PATCH 10/28] readd -O3 flag to release build --- CMakePresets.json | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakePresets.json b/CMakePresets.json index 3d37d09..4361f60 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -23,6 +23,7 @@ "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "CMAKE_CXX_FLAGS": "-O3", "BEMAN_BUILDSYS_SANITIZER": "OFF" } }, From 18f2be122522780bb31341dcfcf345889f32d38e Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Fri, 15 Nov 2024 00:48:07 -0500 Subject: [PATCH 11/28] move sanitizer entry --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae8f314..79f44dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,13 +23,13 @@ option( ${PROJECT_IS_TOP_LEVEL} ) +include(FetchContent) +include(GNUInstallDirs) + if(DEFINED BEMAN_BUILDSYS_SANITIZER) include(cmake/apply_santizers.cmake) endif() -include(FetchContent) -include(GNUInstallDirs) - if(BEMAN_EXEMPLAR_BUILD_TESTS) enable_testing() From 4f892cf6e3912f356538b5306d0e9b1fc5be2a72 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Fri, 15 Nov 2024 01:03:41 -0500 Subject: [PATCH 12/28] refactor apply_santizers --- cmake/apply_santizers.cmake | 39 ++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/cmake/apply_santizers.cmake b/cmake/apply_santizers.cmake index 30e2d3f..fa8da82 100644 --- a/cmake/apply_santizers.cmake +++ b/cmake/apply_santizers.cmake @@ -10,20 +10,45 @@ message("Applying sanitizers for ${CMAKE_CXX_COMPILER_ID}") if(BEMAN_BUILDSYS_SANITIZER STREQUAL "ASan") - # Basic ASan flags - set(SANITIZER_FLAGS + set(_ASAN_ADDR "-fsanitize=address") + set(_ASAN_LEAK "-fsanitize=leak") + set(_ASAN_MISC "-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined" ) - # Exclude -fsanitize=leak on Apple Clang (gcc on macos) as it is not supported. + # Exclude -fsanitize=leak on Apple Clang as it is not supported. if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") - message(STATUS "Using GCC on macOS; excluding -fsanitize=leak") + message(STATUS "Using AppleClang; excluding -fsanitize=leak") + set(SANITIZER_FLAGS "${_ASAN_ADDR} ${_ASAN_MISC}") + # Only include Address sanitizer on MSVC + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + message(STATUS "Using MSVC; only Address sanitizer is set") + set(SANITIZER_FLAGS _ASAN_ADDR) + # We are able to enable all sanitizers on Clang and GNU + elseif( + CMAKE_CXX_COMPILER_ID STREQUAL "Clang" + OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + ) + set(SANITIZER_FLAGS "${_ASAN_ADDR} ${_ASAN_LEAK} ${_ASAN_MISC}") else() - set(SANITIZER_FLAGS "${SANITIZER_FLAGS} -fsanitize=leak") + message( + STATUS + "Unknown compiler ${CMAKE_CXX_COMPILER_ID}, no sanitizer is set" + ) endif() elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "TSan") - # Basic ASan flags - set(SANITIZER_FLAGS "-fsanitize=thread") + # Basic TSan flags + if( + CMAKE_CXX_COMPILER_ID STREQUAL "Clang" + OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + ) + set(SANITIZER_FLAGS "-fsanitize=thread") + else() + message( + STATUS + "TSan not supported/ Unknown compiler: ${CMAKE_CXX_COMPILER_ID}, no sanitizer is set" + ) + endif() elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "OFF") set(SANITIZER_FLAGS "") else() From 87ac8ed200825e3578008a534b25c740997c1445 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Fri, 15 Nov 2024 01:13:34 -0500 Subject: [PATCH 13/28] run profile test on windows --- .github/workflows/ci_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 0d005c2..8dcd9fe 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: preset: ["gcc-debug"] - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, windows-latest] include: # Release don't have variants among platforms - preset: "gcc-release" From 219978e64e630c825b4f165c4e6d1bb5a46a04f0 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Fri, 15 Nov 2024 01:23:05 -0500 Subject: [PATCH 14/28] Revert "run profile test on windows" This reverts commit 87ac8ed200825e3578008a534b25c740997c1445. --- .github/workflows/ci_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 8dcd9fe..0d005c2 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: preset: ["gcc-debug"] - os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest, macos-latest] include: # Release don't have variants among platforms - preset: "gcc-release" From 93c06413402db0502a9c6a7b122b2f6d6e485c4f Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Wed, 20 Nov 2024 11:29:01 -0500 Subject: [PATCH 15/28] revert preset changes --- .github/workflows/ci_tests.yml | 12 +++--------- CMakePresets.json | 5 ++--- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 0d005c2..9b9db76 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -12,17 +12,11 @@ on: jobs: preset-test: + runs-on: ubuntu-latest strategy: - fail-fast: false matrix: - preset: ["gcc-debug"] - os: [ubuntu-latest, macos-latest] - include: - # Release don't have variants among platforms - - preset: "gcc-release" - os: ubuntu-latest - runs-on: ${{ matrix.os }} - name: "Preset: ${{ matrix.preset }} on ${{ matrix.os }}" + preset: ["gcc-debug", "gcc-release"] + name: "Preset: ${{ matrix.preset }}" steps: - uses: actions/checkout@v4 - name: Setup build environment diff --git a/CMakePresets.json b/CMakePresets.json index 4361f60..0b645f2 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -15,7 +15,7 @@ "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug", - "BEMAN_BUILDSYS_SANITIZER": "ASan" + "CMAKE_CXX_FLAGS": "-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=leak -fsanitize=undefined" } }, { @@ -23,8 +23,7 @@ "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "RelWithDebInfo", - "CMAKE_CXX_FLAGS": "-O3", - "BEMAN_BUILDSYS_SANITIZER": "OFF" + "CMAKE_CXX_FLAGS": "-O3" } }, { From d648625013115900f60bc84a422fdff15eb7b0f0 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Tue, 26 Nov 2024 02:18:37 -0500 Subject: [PATCH 16/28] tweak for msvc --- cmake/apply_santizers.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/apply_santizers.cmake b/cmake/apply_santizers.cmake index fa8da82..6483596 100644 --- a/cmake/apply_santizers.cmake +++ b/cmake/apply_santizers.cmake @@ -20,10 +20,10 @@ if(BEMAN_BUILDSYS_SANITIZER STREQUAL "ASan") if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") message(STATUS "Using AppleClang; excluding -fsanitize=leak") set(SANITIZER_FLAGS "${_ASAN_ADDR} ${_ASAN_MISC}") - # Only include Address sanitizer on MSVC + # Only include Address sanitizer on MSVC, debug info must be included for MSVC to work elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") message(STATUS "Using MSVC; only Address sanitizer is set") - set(SANITIZER_FLAGS _ASAN_ADDR) + set(SANITIZER_FLAGS "/fsanitize=address /Zi") # We are able to enable all sanitizers on Clang and GNU elseif( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" From ff6a3d97e1c42998507de4f68df91f3e3e7b3dcd Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Tue, 26 Nov 2024 02:19:13 -0500 Subject: [PATCH 17/28] warp apply_santizers.cmake in ifdef --- cmake/apply_santizers.cmake | 92 +++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 45 deletions(-) diff --git a/cmake/apply_santizers.cmake b/cmake/apply_santizers.cmake index 6483596..e4693ba 100644 --- a/cmake/apply_santizers.cmake +++ b/cmake/apply_santizers.cmake @@ -7,56 +7,58 @@ # ASan: All sanitizer (majorly Address sanitizer) that doesn't conflict with TSan # OFF: No sanitizer -message("Applying sanitizers for ${CMAKE_CXX_COMPILER_ID}") +if(DEFINED BEMAN_BUILDSYS_SANITIZER) + message("Applying sanitizers for ${CMAKE_CXX_COMPILER_ID}") -if(BEMAN_BUILDSYS_SANITIZER STREQUAL "ASan") - set(_ASAN_ADDR "-fsanitize=address") - set(_ASAN_LEAK "-fsanitize=leak") - set(_ASAN_MISC - "-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined" - ) + if(BEMAN_BUILDSYS_SANITIZER STREQUAL "ASan") + set(_ASAN_ADDR "-fsanitize=address") + set(_ASAN_LEAK "-fsanitize=leak") + set(_ASAN_MISC + "-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined" + ) - # Exclude -fsanitize=leak on Apple Clang as it is not supported. - if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") - message(STATUS "Using AppleClang; excluding -fsanitize=leak") - set(SANITIZER_FLAGS "${_ASAN_ADDR} ${_ASAN_MISC}") - # Only include Address sanitizer on MSVC, debug info must be included for MSVC to work - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - message(STATUS "Using MSVC; only Address sanitizer is set") - set(SANITIZER_FLAGS "/fsanitize=address /Zi") - # We are able to enable all sanitizers on Clang and GNU - elseif( - CMAKE_CXX_COMPILER_ID STREQUAL "Clang" - OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" - ) - set(SANITIZER_FLAGS "${_ASAN_ADDR} ${_ASAN_LEAK} ${_ASAN_MISC}") - else() - message( - STATUS - "Unknown compiler ${CMAKE_CXX_COMPILER_ID}, no sanitizer is set" + # Exclude -fsanitize=leak on Apple Clang as it is not supported. + if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + message(STATUS "Using AppleClang; excluding -fsanitize=leak") + set(SANITIZER_FLAGS "${_ASAN_ADDR} ${_ASAN_MISC}") + # Only include Address sanitizer on MSVC, debug info must be included for MSVC to work + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + message(STATUS "Using MSVC; only Address sanitizer is set") + set(SANITIZER_FLAGS "/fsanitize=address /Zi") + # We are able to enable all sanitizers on Clang and GNU + elseif( + CMAKE_CXX_COMPILER_ID STREQUAL "Clang" + OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" ) - endif() -elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "TSan") - # Basic TSan flags - if( - CMAKE_CXX_COMPILER_ID STREQUAL "Clang" - OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" - ) - set(SANITIZER_FLAGS "-fsanitize=thread") + set(SANITIZER_FLAGS "${_ASAN_ADDR} ${_ASAN_LEAK} ${_ASAN_MISC}") + else() + message( + STATUS + "Unknown compiler ${CMAKE_CXX_COMPILER_ID}, no sanitizer is set" + ) + endif() + elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "TSan") + # Basic TSan flags + if( + CMAKE_CXX_COMPILER_ID STREQUAL "Clang" + OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + ) + set(SANITIZER_FLAGS "-fsanitize=thread") + else() + message( + STATUS + "TSan not supported/ Unknown compiler: ${CMAKE_CXX_COMPILER_ID}, no sanitizer is set" + ) + endif() + elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "OFF") + set(SANITIZER_FLAGS "") else() message( - STATUS - "TSan not supported/ Unknown compiler: ${CMAKE_CXX_COMPILER_ID}, no sanitizer is set" + FATAL_ERROR + "Invalid BEMAN_BUILDSYS_SANITIZER option: ${BEMAN_BUILDSYS_SANITIZER}" ) endif() -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 "${CMAKE_C_FLAGS} ${SANITIZER_FLAGS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_FLAGS}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_FLAGS}") +endif() From 03a0ea03e49d48103d939a89fd16179c3adaa790 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Tue, 26 Nov 2024 13:43:43 -0500 Subject: [PATCH 18/28] extract sanitizer generation as function --- CMakeLists.txt | 11 +++++++- cmake/apply_santizers.cmake | 50 ++++++++++++++----------------------- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 79f44dc..d1ac098 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,8 +26,17 @@ option( include(FetchContent) include(GNUInstallDirs) +include(cmake/apply_santizers.cmake) + if(DEFINED BEMAN_BUILDSYS_SANITIZER) - include(cmake/apply_santizers.cmake) + message( + "Applying sanitizer set ${BEMAN_BUILDSYS_SANITIZER} for ${CMAKE_CXX_COMPILER_ID}" + ) + + generate_sanitizer_param(${BEMAN_BUILDSYS_SANITIZER} ${CMAKE_CXX_COMPILER_ID} SANITIZER_FLAGS) + + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_FLAGS}") endif() if(BEMAN_EXEMPLAR_BUILD_TESTS) diff --git a/cmake/apply_santizers.cmake b/cmake/apply_santizers.cmake index e4693ba..391fb5a 100644 --- a/cmake/apply_santizers.cmake +++ b/cmake/apply_santizers.cmake @@ -7,58 +7,46 @@ # ASan: All sanitizer (majorly Address sanitizer) that doesn't conflict with TSan # OFF: No sanitizer -if(DEFINED BEMAN_BUILDSYS_SANITIZER) - message("Applying sanitizers for ${CMAKE_CXX_COMPILER_ID}") - - if(BEMAN_BUILDSYS_SANITIZER STREQUAL "ASan") +function(GENERATE_SANITIZER_PARAM KIND COMPILER_ID SANITIZER_FLAGS) + if(${KIND} STREQUAL "ASan") set(_ASAN_ADDR "-fsanitize=address") set(_ASAN_LEAK "-fsanitize=leak") set(_ASAN_MISC "-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined" ) - # Exclude -fsanitize=leak on Apple Clang as it is not supported. - if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + if(${COMPILER_ID} STREQUAL "AppleClang") + # Exclude -fsanitize=leak on Apple Clang as it is not supported. message(STATUS "Using AppleClang; excluding -fsanitize=leak") - set(SANITIZER_FLAGS "${_ASAN_ADDR} ${_ASAN_MISC}") + set(RES "${_ASAN_ADDR} ${_ASAN_MISC}") + elseif(${COMPILER_ID} STREQUAL "MSVC") # Only include Address sanitizer on MSVC, debug info must be included for MSVC to work - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") message(STATUS "Using MSVC; only Address sanitizer is set") - set(SANITIZER_FLAGS "/fsanitize=address /Zi") + set(RES "/fsanitize=address /Zi") + elseif(${COMPILER_ID} STREQUAL "Clang" OR ${COMPILER_ID} STREQUAL "GNU") # We are able to enable all sanitizers on Clang and GNU - elseif( - CMAKE_CXX_COMPILER_ID STREQUAL "Clang" - OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" - ) - set(SANITIZER_FLAGS "${_ASAN_ADDR} ${_ASAN_LEAK} ${_ASAN_MISC}") + set(RES "${_ASAN_ADDR} ${_ASAN_LEAK} ${_ASAN_MISC}") else() message( STATUS - "Unknown compiler ${CMAKE_CXX_COMPILER_ID}, no sanitizer is set" + "Unknown compiler ${${COMPILER_ID}}, no sanitizer is set" ) endif() - elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "TSan") + elseif(KIND STREQUAL "TSan") # Basic TSan flags - if( - CMAKE_CXX_COMPILER_ID STREQUAL "Clang" - OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" - ) - set(SANITIZER_FLAGS "-fsanitize=thread") + if(${COMPILER_ID} STREQUAL "Clang" OR ${COMPILER_ID} STREQUAL "GNU") + set(RES "-fsanitize=thread") else() message( STATUS - "TSan not supported/ Unknown compiler: ${CMAKE_CXX_COMPILER_ID}, no sanitizer is set" + "TSan not supported/ Unknown compiler: ${${COMPILER_ID}}, no sanitizer is set" ) endif() - elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "OFF") - set(SANITIZER_FLAGS "") + elseif(KIND STREQUAL "OFF") + set(RES "") else() - message( - FATAL_ERROR - "Invalid BEMAN_BUILDSYS_SANITIZER option: ${BEMAN_BUILDSYS_SANITIZER}" - ) + message(FATAL_ERROR "Invalid Sanitizer class kind option: ${KIND}") endif() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_FLAGS}") -endif() + set(${SANITIZER_FLAGS} ${RES} PARENT_SCOPE) +endfunction() From 55c966c13234f972d2892f2de85f49997717d04f Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Tue, 26 Nov 2024 13:45:27 -0500 Subject: [PATCH 19/28] update comment --- CMakeLists.txt | 2 ++ cmake/apply_santizers.cmake | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d1ac098..dedcd7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,8 @@ include(GNUInstallDirs) include(cmake/apply_santizers.cmake) if(DEFINED BEMAN_BUILDSYS_SANITIZER) + # BEMAN_BUILDSYS_SANITIZER is not a general use option + # It is used by preset and CI system. message( "Applying sanitizer set ${BEMAN_BUILDSYS_SANITIZER} for ${CMAKE_CXX_COMPILER_ID}" ) diff --git a/cmake/apply_santizers.cmake b/cmake/apply_santizers.cmake index 391fb5a..dfbdf37 100644 --- a/cmake/apply_santizers.cmake +++ b/cmake/apply_santizers.cmake @@ -1,12 +1,9 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# 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 - function(GENERATE_SANITIZER_PARAM KIND COMPILER_ID SANITIZER_FLAGS) if(${KIND} STREQUAL "ASan") set(_ASAN_ADDR "-fsanitize=address") From 8057e45fc4a704d29f1615621f01706971e7ac62 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:25:25 -0500 Subject: [PATCH 20/28] use toolchain --- .github/workflows/ci_tests.yml | 71 +++++++++++++--------------------- CMakePresets.json | 9 ++--- cmake/gnu-toolchain.cmake | 18 +++++++++ cmake/llvm-toolchain.cmake | 18 +++++++++ 4 files changed, 67 insertions(+), 49 deletions(-) create mode 100644 cmake/gnu-toolchain.cmake create mode 100644 cmake/llvm-toolchain.cmake diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 25cb49a..91e2f78 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -33,13 +33,11 @@ jobs: matrix: platform: - description: "Ubuntu GCC" - cpp: g++ - c: gcc os: ubuntu-latest + toolchain: "cmake/gnu-toolchain.cmake" - description: "Ubuntu Clang" - cpp: clang++ - c: clang os: ubuntu-latest + toolchain: "cmake/llvm-toolchain.cmake" cpp_version: [17, 20, 23, 26] cmake_args: - description: "Default" @@ -51,42 +49,40 @@ jobs: include: - platform: description: "Ubuntu GCC" - cpp: g++ - c: gcc os: ubuntu-latest + toolchain: "cmake/gnu-toolchain.cmake" cpp_version: 17 cmake_args: description: "Werror" args: "-DCMAKE_CXX_FLAGS='-Werror=all -Werror=extra'" - platform: description: "Ubuntu GCC" - cpp: g++ - c: gcc os: ubuntu-latest + toolchain: "cmake/gnu-toolchain.cmake" cpp_version: 17 cmake_args: description: "Dynamic" args: "-DBUILD_SHARED_LIBS=on" - - platform: - description: "Windows MSVC" - cpp: cl - c: cl - os: windows-latest - cpp_version: 17 - cmake_args: - description: "Default" - args: "" - - platform: - description: "Windows MSVC" - cpp: cl - c: cl - os: windows-latest - cpp_version: 17 - cmake_args: - description: "ASan" - # Debug infomation needed to avoid cl: C5072 - # https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-c5072?view=msvc-170 - args: "-DCMAKE_CXX_FLAGS='/fsanitize=address /Zi'" + # - platform: + # description: "Windows MSVC" + # cpp: cl + # c: cl + # os: windows-latest + # cpp_version: 17 + # cmake_args: + # description: "Default" + # args: "" + # - platform: + # description: "Windows MSVC" + # cpp: cl + # c: cl + # os: windows-latest + # cpp_version: 17 + # cmake_args: + # description: "ASan" + # # Debug infomation needed to avoid cl: C5072 + # # https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-c5072?view=msvc-170 + # args: "-DCMAKE_CXX_FLAGS='/fsanitize=address /Zi'" name: "Unit: ${{ matrix.platform.description }} ${{ matrix.cpp_version }} ${{ matrix.cmake_args.description }}" @@ -106,27 +102,14 @@ jobs: - name: Print installed softwares shell: bash run: | - echo "Compiler:" - - # cl does not have a --version option - if [ "${{ matrix.platform.cpp }}" != "cl" ]; then - ${{ matrix.platform.cpp }} --version - ${{ matrix.platform.c }} --version - else - ${{ matrix.platform.cpp }} - ${{ matrix.platform.c }} - fi - echo "Build system:" cmake --version ninja --version - name: Configure CMake run: | - cmake -B build -S . -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }} ${{ matrix.cmake_args.args }} - env: - CC: ${{ matrix.platform.c }} - CXX: ${{ matrix.platform.cpp }} - CMAKE_GENERATOR: "Ninja Multi-Config" + cmake -B build -S . -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }} \ + -DCMAKE_TOOLCHAIN_FILE=${{ matrix.platform.toolchain }} \ + ${{ matrix.cmake_args.args }} - name: Build Release run: | # Portable commands only diff --git a/CMakePresets.json b/CMakePresets.json index 0b645f2..402261a 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -15,15 +15,14 @@ "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_CXX_FLAGS": "-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=leak -fsanitize=undefined" + "BEMAN_BUILDSYS_SANITIZER": "ASan" } }, { "name": "_release-base", "hidden": true, "cacheVariables": { - "CMAKE_BUILD_TYPE": "RelWithDebInfo", - "CMAKE_CXX_FLAGS": "-O3" + "CMAKE_BUILD_TYPE": "RelWithDebInfo" } }, { @@ -34,7 +33,7 @@ "_debug-base" ], "cacheVariables": { - "CMAKE_CXX_COMPILER": "g++" + "CMAKE_TOOLCHAIN_FILE": "cmake/gnu-toolchain.cmake" } }, { @@ -45,7 +44,7 @@ "_release-base" ], "cacheVariables": { - "CMAKE_CXX_COMPILER": "g++" + "CMAKE_TOOLCHAIN_FILE": "cmake/gnu-toolchain.cmake" } } ], diff --git a/cmake/gnu-toolchain.cmake b/cmake/gnu-toolchain.cmake new file mode 100644 index 0000000..4f3a3a2 --- /dev/null +++ b/cmake/gnu-toolchain.cmake @@ -0,0 +1,18 @@ +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_COMPILER g++) +set(CMAKE_GENERATOR "Ninja Multi-Config") + +if(BEMAN_BUILDSYS_SANITIZER STREQUAL "ASan") + set(CMAKE_CXX_FLAGS_DEBUG_INIT + "-fsanitize=address -fsanitize=leak -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined" + ) + set(CMAKE_C_FLAGS_DEBUG_INIT + "-fsanitize=address -fsanitize=leak -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined" + ) +elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "TSan") + set(CMAKE_CXX_FLAGS_DEBUG_INIT "-fsanitize=thread") + set(CMAKE_C_FLAGS_DEBUG_INIT "-fsanitize=thread") +endif() + +set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O3") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O3") diff --git a/cmake/llvm-toolchain.cmake b/cmake/llvm-toolchain.cmake new file mode 100644 index 0000000..5cc375c --- /dev/null +++ b/cmake/llvm-toolchain.cmake @@ -0,0 +1,18 @@ +set(CMAKE_C_COMPILER clang) +set(CMAKE_CXX_COMPILER clang++) +set(CMAKE_GENERATOR "Ninja Multi-Config") + +if(BEMAN_BUILDSYS_SANITIZER STREQUAL "ASan") + set(CMAKE_CXX_FLAGS_DEBUG_INIT + "-fsanitize=address -fsanitize=leak -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined" + ) + set(CMAKE_C_FLAGS_DEBUG_INIT + "-fsanitize=address -fsanitize=leak -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined" + ) +elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "TSan") + set(CMAKE_CXX_FLAGS_DEBUG_INIT "-fsanitize=thread") + set(CMAKE_C_FLAGS_DEBUG_INIT "-fsanitize=thread") +endif() + +set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O3") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O3") From 68224937bdf070b3538a014a562352a7f8d0cc5c Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:31:10 -0500 Subject: [PATCH 21/28] move generator out --- .github/workflows/ci_tests.yml | 2 ++ CMakePresets.json | 3 ++- cmake/gnu-toolchain.cmake | 1 - cmake/llvm-toolchain.cmake | 1 - 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 91e2f78..fc727e0 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -110,6 +110,8 @@ jobs: cmake -B build -S . -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }} \ -DCMAKE_TOOLCHAIN_FILE=${{ matrix.platform.toolchain }} \ ${{ matrix.cmake_args.args }} + env: + CMAKE_GENERATOR: "Ninja Multi-Config" - name: Build Release run: | # Portable commands only diff --git a/CMakePresets.json b/CMakePresets.json index 402261a..4919cce 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -7,7 +7,8 @@ "generator": "Ninja", "binaryDir": "${sourceDir}/build/${presetName}", "cacheVariables": { - "CMAKE_CXX_STANDARD": "20" + "CMAKE_CXX_STANDARD": "20", + "CMAKE_GENERATOR": "Ninja Multi-Config" } }, { diff --git a/cmake/gnu-toolchain.cmake b/cmake/gnu-toolchain.cmake index 4f3a3a2..b17ddef 100644 --- a/cmake/gnu-toolchain.cmake +++ b/cmake/gnu-toolchain.cmake @@ -1,6 +1,5 @@ set(CMAKE_C_COMPILER gcc) set(CMAKE_CXX_COMPILER g++) -set(CMAKE_GENERATOR "Ninja Multi-Config") if(BEMAN_BUILDSYS_SANITIZER STREQUAL "ASan") set(CMAKE_CXX_FLAGS_DEBUG_INIT diff --git a/cmake/llvm-toolchain.cmake b/cmake/llvm-toolchain.cmake index 5cc375c..afcfe3f 100644 --- a/cmake/llvm-toolchain.cmake +++ b/cmake/llvm-toolchain.cmake @@ -1,6 +1,5 @@ set(CMAKE_C_COMPILER clang) set(CMAKE_CXX_COMPILER clang++) -set(CMAKE_GENERATOR "Ninja Multi-Config") if(BEMAN_BUILDSYS_SANITIZER STREQUAL "ASan") set(CMAKE_CXX_FLAGS_DEBUG_INIT From b99f9adefc8adc09ec58ebe73e753ac8d677e5c6 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:33:07 -0500 Subject: [PATCH 22/28] remove generator at preset --- CMakePresets.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 4919cce..402261a 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -7,8 +7,7 @@ "generator": "Ninja", "binaryDir": "${sourceDir}/build/${presetName}", "cacheVariables": { - "CMAKE_CXX_STANDARD": "20", - "CMAKE_GENERATOR": "Ninja Multi-Config" + "CMAKE_CXX_STANDARD": "20" } }, { From f309be8e5f03d3db4f683a4ae6cfbc12cf607765 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:40:41 -0500 Subject: [PATCH 23/28] remove cmake/apply_santizers.cmake --- CMakeLists.txt | 15 ------------ cmake/apply_santizers.cmake | 49 ------------------------------------- 2 files changed, 64 deletions(-) delete mode 100644 cmake/apply_santizers.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 63ddf1a..45a240a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,21 +26,6 @@ option( include(FetchContent) include(GNUInstallDirs) -include(cmake/apply_santizers.cmake) - -if(DEFINED BEMAN_BUILDSYS_SANITIZER) - # BEMAN_BUILDSYS_SANITIZER is not a general use option - # It is used by preset and CI system. - message( - "Applying sanitizer set ${BEMAN_BUILDSYS_SANITIZER} for ${CMAKE_CXX_COMPILER_ID}" - ) - - generate_sanitizer_param(${BEMAN_BUILDSYS_SANITIZER} ${CMAKE_CXX_COMPILER_ID} SANITIZER_FLAGS) - - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_FLAGS}") -endif() - if(BEMAN_EXEMPLAR_BUILD_TESTS) enable_testing() diff --git a/cmake/apply_santizers.cmake b/cmake/apply_santizers.cmake deleted file mode 100644 index dfbdf37..0000000 --- a/cmake/apply_santizers.cmake +++ /dev/null @@ -1,49 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# There's three possible values: -# TSan: Thread sanitizer -# ASan: All sanitizer (majorly Address sanitizer) that doesn't conflict with TSan -# OFF: No sanitizer -function(GENERATE_SANITIZER_PARAM KIND COMPILER_ID SANITIZER_FLAGS) - if(${KIND} STREQUAL "ASan") - set(_ASAN_ADDR "-fsanitize=address") - set(_ASAN_LEAK "-fsanitize=leak") - set(_ASAN_MISC - "-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined" - ) - - if(${COMPILER_ID} STREQUAL "AppleClang") - # Exclude -fsanitize=leak on Apple Clang as it is not supported. - message(STATUS "Using AppleClang; excluding -fsanitize=leak") - set(RES "${_ASAN_ADDR} ${_ASAN_MISC}") - elseif(${COMPILER_ID} STREQUAL "MSVC") - # Only include Address sanitizer on MSVC, debug info must be included for MSVC to work - message(STATUS "Using MSVC; only Address sanitizer is set") - set(RES "/fsanitize=address /Zi") - elseif(${COMPILER_ID} STREQUAL "Clang" OR ${COMPILER_ID} STREQUAL "GNU") - # We are able to enable all sanitizers on Clang and GNU - set(RES "${_ASAN_ADDR} ${_ASAN_LEAK} ${_ASAN_MISC}") - else() - message( - STATUS - "Unknown compiler ${${COMPILER_ID}}, no sanitizer is set" - ) - endif() - elseif(KIND STREQUAL "TSan") - # Basic TSan flags - if(${COMPILER_ID} STREQUAL "Clang" OR ${COMPILER_ID} STREQUAL "GNU") - set(RES "-fsanitize=thread") - else() - message( - STATUS - "TSan not supported/ Unknown compiler: ${${COMPILER_ID}}, no sanitizer is set" - ) - endif() - elseif(KIND STREQUAL "OFF") - set(RES "") - else() - message(FATAL_ERROR "Invalid Sanitizer class kind option: ${KIND}") - endif() - - set(${SANITIZER_FLAGS} ${RES} PARENT_SCOPE) -endfunction() From b93b070212489fd92a39539bb7c3e49cacd9447c Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:45:47 -0500 Subject: [PATCH 24/28] add msvc toolchain --- .github/workflows/ci_tests.yml | 24 +++--------------------- cmake/msvc-toolchain.cmake | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 21 deletions(-) create mode 100644 cmake/msvc-toolchain.cmake diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index fc727e0..b9fc37d 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -38,6 +38,9 @@ jobs: - description: "Ubuntu Clang" os: ubuntu-latest toolchain: "cmake/llvm-toolchain.cmake" + - description: "Windows MSVC" + os: windows-latest + toolchain: "cmake/msvc-toolchain.cmake" cpp_version: [17, 20, 23, 26] cmake_args: - description: "Default" @@ -63,27 +66,6 @@ jobs: cmake_args: description: "Dynamic" args: "-DBUILD_SHARED_LIBS=on" - # - platform: - # description: "Windows MSVC" - # cpp: cl - # c: cl - # os: windows-latest - # cpp_version: 17 - # cmake_args: - # description: "Default" - # args: "" - # - platform: - # description: "Windows MSVC" - # cpp: cl - # c: cl - # os: windows-latest - # cpp_version: 17 - # cmake_args: - # description: "ASan" - # # Debug infomation needed to avoid cl: C5072 - # # https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-c5072?view=msvc-170 - # args: "-DCMAKE_CXX_FLAGS='/fsanitize=address /Zi'" - name: "Unit: ${{ matrix.platform.description }} ${{ matrix.cpp_version }} ${{ matrix.cmake_args.description }}" runs-on: ${{ matrix.platform.os }} diff --git a/cmake/msvc-toolchain.cmake b/cmake/msvc-toolchain.cmake new file mode 100644 index 0000000..3d9e3d9 --- /dev/null +++ b/cmake/msvc-toolchain.cmake @@ -0,0 +1,15 @@ +set(CMAKE_C_COMPILER cl) +set(CMAKE_CXX_COMPILER cl) + +if(BEMAN_BUILDSYS_SANITIZER STREQUAL "ASan") + set(CMAKE_CXX_FLAGS_DEBUG_INIT "/fsanitize=address /Zi") + set(CMAKE_C_FLAGS_DEBUG_INIT "/fsanitize=address /Zi") +endif() + +set(CMAKE_CXX_FLAGS_DEBUG_INIT + "${CMAKE_CXX_FLAGS_DEBUG_INIT} /EHsc /permissive-" +) +set(CMAKE_C_FLAGS_DEBUG_INIT "${CMAKE_C_FLAGS_DEBUG_INIT} /EHsc /permissive-") + +set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/EHsc /permissive- /O2") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/EHsc /permissive- /O2") From 0c6f92bd44bbf4be24b7637b449dc4520c55ba04 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:49:48 -0500 Subject: [PATCH 25/28] ensure portable --- .github/workflows/ci_tests.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index b9fc37d..6f6a9b8 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -89,9 +89,7 @@ jobs: ninja --version - name: Configure CMake run: | - cmake -B build -S . -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }} \ - -DCMAKE_TOOLCHAIN_FILE=${{ matrix.platform.toolchain }} \ - ${{ matrix.cmake_args.args }} + cmake -B build -S . -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }} -DCMAKE_TOOLCHAIN_FILE="${{ matrix.platform.toolchain }}" ${{ matrix.cmake_args.args }} env: CMAKE_GENERATOR: "Ninja Multi-Config" - name: Build Release From 9127cc266128c6def3a3fe85c13aa5edcc4969f3 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Wed, 11 Dec 2024 19:17:03 -0500 Subject: [PATCH 26/28] msvc does not support TSan --- .github/workflows/ci_tests.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 6f6a9b8..c5bf092 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -32,10 +32,10 @@ jobs: fail-fast: false matrix: platform: - - description: "Ubuntu GCC" + - description: "Ubuntu GNU" os: ubuntu-latest toolchain: "cmake/gnu-toolchain.cmake" - - description: "Ubuntu Clang" + - description: "Ubuntu LLVM" os: ubuntu-latest toolchain: "cmake/llvm-toolchain.cmake" - description: "Windows MSVC" @@ -44,7 +44,6 @@ jobs: cpp_version: [17, 20, 23, 26] cmake_args: - description: "Default" - args: "" - description: "TSan" args: "-DBEMAN_BUILDSYS_SANITIZER=TSan" - description: "ASan" @@ -66,6 +65,12 @@ jobs: cmake_args: description: "Dynamic" args: "-DBUILD_SHARED_LIBS=on" + exclude: + # MSVC does not support thread sanitizer + - platform: + description: "Windows MSVC" + cmake_args: + description: "TSan" name: "Unit: ${{ matrix.platform.description }} ${{ matrix.cpp_version }} ${{ matrix.cmake_args.description }}" runs-on: ${{ matrix.platform.os }} From 3bba8f1d43ee48afb72cafe524dd4511abc9e321 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Sat, 14 Dec 2024 19:07:44 -0500 Subject: [PATCH 27/28] apply license --- cmake/gnu-toolchain.cmake | 2 ++ cmake/llvm-toolchain.cmake | 2 ++ cmake/msvc-toolchain.cmake | 2 ++ 3 files changed, 6 insertions(+) diff --git a/cmake/gnu-toolchain.cmake b/cmake/gnu-toolchain.cmake index b17ddef..b4dc0f6 100644 --- a/cmake/gnu-toolchain.cmake +++ b/cmake/gnu-toolchain.cmake @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + set(CMAKE_C_COMPILER gcc) set(CMAKE_CXX_COMPILER g++) diff --git a/cmake/llvm-toolchain.cmake b/cmake/llvm-toolchain.cmake index afcfe3f..db30515 100644 --- a/cmake/llvm-toolchain.cmake +++ b/cmake/llvm-toolchain.cmake @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + set(CMAKE_C_COMPILER clang) set(CMAKE_CXX_COMPILER clang++) diff --git a/cmake/msvc-toolchain.cmake b/cmake/msvc-toolchain.cmake index 3d9e3d9..cb6f889 100644 --- a/cmake/msvc-toolchain.cmake +++ b/cmake/msvc-toolchain.cmake @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + set(CMAKE_C_COMPILER cl) set(CMAKE_CXX_COMPILER cl) From a0f8cd2b613c14663e44ad41e0df427e4c9ba1b5 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Mon, 16 Dec 2024 13:09:57 -0500 Subject: [PATCH 28/28] adopt include guard --- cmake/gnu-toolchain.cmake | 2 ++ cmake/llvm-toolchain.cmake | 2 ++ cmake/msvc-toolchain.cmake | 2 ++ 3 files changed, 6 insertions(+) diff --git a/cmake/gnu-toolchain.cmake b/cmake/gnu-toolchain.cmake index b4dc0f6..2b74d5c 100644 --- a/cmake/gnu-toolchain.cmake +++ b/cmake/gnu-toolchain.cmake @@ -1,5 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +include_guard(GLOBAL) + set(CMAKE_C_COMPILER gcc) set(CMAKE_CXX_COMPILER g++) diff --git a/cmake/llvm-toolchain.cmake b/cmake/llvm-toolchain.cmake index db30515..debacef 100644 --- a/cmake/llvm-toolchain.cmake +++ b/cmake/llvm-toolchain.cmake @@ -1,5 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +include_guard(GLOBAL) + set(CMAKE_C_COMPILER clang) set(CMAKE_CXX_COMPILER clang++) diff --git a/cmake/msvc-toolchain.cmake b/cmake/msvc-toolchain.cmake index cb6f889..0f40ba7 100644 --- a/cmake/msvc-toolchain.cmake +++ b/cmake/msvc-toolchain.cmake @@ -1,5 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +include_guard(GLOBAL) + set(CMAKE_C_COMPILER cl) set(CMAKE_CXX_COMPILER cl)