Skip to content

Commit

Permalink
Issue #583: Enable ASAN builds for debug to help catch issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmpowell77 committed Jan 10, 2025
1 parent b36feda commit f2fea0f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ on:
- main
- calchart-3.6

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
name: ${{ matrix.config.name }}
Expand All @@ -45,6 +41,7 @@ jobs:
artifact_name: "CalChart-Windows",
os: windows-latest,
}
build_type: [Debug, Release]

steps:
- name: checkout
Expand Down Expand Up @@ -82,11 +79,11 @@ jobs:
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}}

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}}

# Codesigning for mac involves:
# 1. Creating a signing cert in p12 form (https://help.apple.com/xcode/mac/current/#/dev154b28f09)
Expand Down Expand Up @@ -134,6 +131,7 @@ jobs:
run: cmake -E tar cJfv ${{github.workspace}}/build/CalChart.tar.xz .

- name: Upload
if: matrix.build_type == 'Release'
uses: actions/upload-artifact@v4
with:
path: ${{github.workspace}}/build/${{ matrix.config.artifact }}
Expand Down
2 changes: 1 addition & 1 deletion LATEST_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ Bugs addressed in this release:

Other changes:

* [#583](../../issues/583) Enable ASAN builds for debug to help catch issue.
* [#584](../../issues/584) Why didn't the failures in ASAN cause sanity_test.py to fail?


7 changes: 7 additions & 0 deletions cmake/compiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,10 @@ macro(SetupCompilerForTarget arg)
set_target_properties(${arg} PROPERTIES CXX_STANDARD 23)
endmacro()

option(ENABLE_ASAN "Enable AddressSanitizer in Debug" ON)
if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND ENABLE_ASAN AND NOT MSVC)
set(SANITIZER_FLAGS "-fsanitize=address")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_FLAGS}")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} ${SANITIZER_FLAGS}")
endif()

0 comments on commit f2fea0f

Please sign in to comment.