You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.4 KiB

2 months ago
  1. name: sanitizer
  2. on:
  3. push: {}
  4. pull_request: {}
  5. env:
  6. UBSAN_OPTIONS: "print_stacktrace=1"
  7. jobs:
  8. job:
  9. name: ${{ matrix.sanitizer }}.${{ matrix.build_type }}.${{ matrix.compiler }}
  10. runs-on: ubuntu-latest
  11. strategy:
  12. fail-fast: false
  13. matrix:
  14. build_type: ['Debug', 'RelWithDebInfo']
  15. sanitizer: ['asan', 'ubsan', 'tsan']
  16. compiler: ['clang', 'gcc']
  17. # TODO: add 'msan' above. currently failing and needs investigation.
  18. steps:
  19. - uses: actions/checkout@v3
  20. - name: configure msan env
  21. if: matrix.sanitizer == 'msan'
  22. run: |
  23. echo "EXTRA_FLAGS=-g -O2 -fno-omit-frame-pointer -fsanitize=memory -fsanitize-memory-track-origins" >> $GITHUB_ENV
  24. echo "LIBCXX_SANITIZER=MemoryWithOrigins" >> $GITHUB_ENV
  25. - name: configure ubsan env
  26. if: matrix.sanitizer == 'ubsan'
  27. run: |
  28. echo "EXTRA_FLAGS=-g -O2 -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=all" >> $GITHUB_ENV
  29. echo "LIBCXX_SANITIZER=Undefined" >> $GITHUB_ENV
  30. - name: configure asan env
  31. if: matrix.sanitizer == 'asan'
  32. run: |
  33. echo "EXTRA_FLAGS=-g -O2 -fno-omit-frame-pointer -fsanitize=address -fno-sanitize-recover=all" >> $GITHUB_ENV
  34. echo "LIBCXX_SANITIZER=Address" >> $GITHUB_ENV
  35. - name: configure tsan env
  36. if: matrix.sanitizer == 'tsan'
  37. run: |
  38. echo "EXTRA_FLAGS=-g -O2 -fno-omit-frame-pointer -fsanitize=thread -fno-sanitize-recover=all" >> $GITHUB_ENV
  39. echo "LIBCXX_SANITIZER=Thread" >> $GITHUB_ENV
  40. - name: fine-tune asan options
  41. # in clang+asan we get an error from std::regex. ignore it.
  42. if: matrix.sanitizer == 'asan' && matrix.compiler == 'clang'
  43. run: |
  44. echo "ASAN_OPTIONS=alloc_dealloc_mismatch=0" >> $GITHUB_ENV
  45. - name: setup clang
  46. if: matrix.compiler == 'clang'
  47. uses: egor-tensin/setup-clang@v1
  48. with:
  49. version: latest
  50. platform: x64
  51. - name: configure clang
  52. if: matrix.compiler == 'clang'
  53. run: |
  54. echo "CC=cc" >> $GITHUB_ENV
  55. echo "CXX=c++" >> $GITHUB_ENV
  56. - name: configure gcc
  57. if: matrix.compiler == 'gcc'
  58. run: |
  59. sudo apt update && sudo apt -y install gcc-10 g++-10
  60. echo "CC=gcc-10" >> $GITHUB_ENV
  61. echo "CXX=g++-10" >> $GITHUB_ENV
  62. - name: install llvm stuff
  63. if: matrix.compiler == 'clang'
  64. run: |
  65. "${GITHUB_WORKSPACE}/.github/libcxx-setup.sh"
  66. echo "EXTRA_CXX_FLAGS=\"-stdlib=libc++\"" >> $GITHUB_ENV
  67. - name: create build environment
  68. run: cmake -E make_directory ${{ runner.workspace }}/_build
  69. - name: configure cmake
  70. shell: bash
  71. working-directory: ${{ runner.workspace }}/_build
  72. run: >
  73. VERBOSE=1
  74. cmake $GITHUB_WORKSPACE
  75. -DBENCHMARK_ENABLE_ASSEMBLY_TESTS=OFF
  76. -DBENCHMARK_ENABLE_LIBPFM=OFF
  77. -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON
  78. -DCMAKE_C_COMPILER=${{ env.CC }}
  79. -DCMAKE_CXX_COMPILER=${{ env.CXX }}
  80. -DCMAKE_C_FLAGS="${{ env.EXTRA_FLAGS }}"
  81. -DCMAKE_CXX_FLAGS="${{ env.EXTRA_FLAGS }} ${{ env.EXTRA_CXX_FLAGS }}"
  82. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
  83. - name: build
  84. shell: bash
  85. working-directory: ${{ runner.workspace }}/_build
  86. run: cmake --build . --config ${{ matrix.build_type }}
  87. - name: test
  88. shell: bash
  89. working-directory: ${{ runner.workspace }}/_build
  90. run: ctest -C ${{ matrix.build_type }} -VV