Skip to content

Commit

Permalink
add tsan ci
Browse files Browse the repository at this point in the history
  • Loading branch information
poor-circle committed Feb 5, 2025
1 parent d49be23 commit ebbf522
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 78 deletions.
24 changes: 0 additions & 24 deletions .github/workflows/bazel_gcc.yml

This file was deleted.

14 changes: 6 additions & 8 deletions .github/workflows/ubuntu_clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ jobs:
working-directory: ${{github.workspace}}/build
run: ctest -C ${{matrix.mode}} -j 1 -V

ubuntu_clang_pb:
ubuntu_clang_tsan:
strategy:
matrix:
mode: [ Release, Debug ]
libcxx: [ OFF ]
ssl: [ ON, OFF ]
ssl: [ ON ]

runs-on: ubuntu-22.04

Expand All @@ -72,7 +72,6 @@ jobs:
- name: Install Dependencies
run: |
sudo apt-get install openssl libssl-dev
sudo apt-get install libprotobuf-dev protobuf-compiler libprotoc-dev
- name: Install ninja-build tool
uses: seanmiddleditch/gha-setup-ninja@v3
Expand All @@ -85,9 +84,6 @@ jobs:
chmod +x ./llvm.sh
sudo ./llvm.sh 17
- name: Check protoc
run: protoc --version

- name: ccache
uses: hendrikmuhs/[email protected]
with:
Expand All @@ -98,13 +94,15 @@ jobs:
cmake -B ${{github.workspace}}/build -G Ninja \
-DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=${{matrix.libcxx}} -DYLT_ENABLE_SSL=${{matrix.ssl}} \
-DUSE_CCACHE=${{env.ccache}} -DCMAKE_C_COMPILER=clang-17 -DCMAKE_CXX_COMPILER=clang++-17\
-DBUILD_CORO_HTTP=OFF -DBUILD_CORO_IO=OFF -DBUILD_STRUCT_PB=ON -DBUILD_CORO_RPC=OFF -DBUILD_EASYLOG=OFF -DBUILD_STRUCT_JSON=OFF -DBUILD_STRUCT_XML=OFF -DBUILD_STRUCT_YAML=OFF -DBUILD_UTIL=OFF
-DENABLE_TSAN=ON
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{matrix.mode}}

- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -C ${{matrix.mode}} -j 1 -V
run: |
export TSAN_OPTIONS="halt_on_error=1"
ctest -C ${{matrix.mode}} -j 1 -V

ubuntu_clang_for_liburing:
strategy:
Expand Down
41 changes: 0 additions & 41 deletions .github/workflows/ubuntu_gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,47 +48,6 @@ jobs:
working-directory: ${{github.workspace}}/build
run: ctest -C ${{matrix.mode}} -j 1 -V

ubuntu_gcc_pb:
strategy:
matrix:
mode: [ Debug ] #[Release, Debug]
ssl: [ ON, OFF ]
runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Dependencies
run: |
sudo apt-get install openssl libssl-dev
sudo apt-get install libprotobuf-dev protobuf-compiler libprotoc-dev
- name: Check protoc
run: protoc --version

- name: Install ninja-build tool
uses: seanmiddleditch/gha-setup-ninja@v3

- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ github.job }}-${{ matrix.mode}}-ssl( ${{ matrix.ssl}} )

- name: Configure
run: |
CXX=g++ CC=gcc
cmake -B ${{github.workspace}}/build -G Ninja \
-DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=${{matrix.libcxx}} -DYLT_ENABLE_SSL=${{matrix.ssl}} \
-DUSE_CCACHE=${{env.ccache}} \
-DBUILD_CORO_HTTP=OFF -DBUILD_CORO_IO=OFF -DBUILD_STRUCT_PB=ON -DBUILD_CORO_RPC=OFF -DBUILD_EASYLOG=OFF -DBUILD_STRUCT_JSON=OFF -DBUILD_STRUCT_XML=OFF -DBUILD_STRUCT_YAML=OFF -DBUILD_UTIL=OFF
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{matrix.mode}}

- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -C ${{matrix.mode}} -j 1 -V

ubuntu_gcc_for_liburing:
strategy:
matrix:
Expand Down
23 changes: 18 additions & 5 deletions cmake/develop.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,26 @@ message(STATUS "CORO_RPC_USE_OTHER_RPC: ${CORO_RPC_USE_OTHER_RPC}")
# Enable address sanitizer
option(ENABLE_SANITIZER "Enable sanitizer(Debug+Gcc/Clang/AppleClang)" ON)

option(ENABLE_TSAN "Enable thread sanitizer" ON)

if(ENABLE_SANITIZER AND NOT MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
check_asan(HAS_ASAN)
if(HAS_ASAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
if (ENABLE_TSAN)
## thread sanitizer
check_tsan(HAS_TSAN)
if(HAS_TSAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
else()
message(WARNING "sanitizer is no supported with current tool-chains")
message(WARNING "thread sanitizer is no supported with current tool-chains")
endif()
else()
## address santizer
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
check_asan(HAS_ASAN)
if(HAS_ASAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
else()
message(WARNING "address sanitizer is no supported with current tool-chains")
endif()
endif()
endif()
endif()
Expand Down
15 changes: 15 additions & 0 deletions cmake/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ int main()
{
return 0;
}
]====]
${_RESULT}
)
unset(CMAKE_REQUIRED_FLAGS)
endmacro()

macro(check_tsan _RESULT)
include(CheckCXXSourceRuns)
set(CMAKE_REQUIRED_FLAGS "-fsanitize=thread")
check_cxx_source_runs(
[====[
int main()
{
return 0;
}
]====]
${_RESULT}
)
Expand Down

0 comments on commit ebbf522

Please sign in to comment.