Skip to content

Commit

Permalink
CMake: add ASAN build configuration
Browse files Browse the repository at this point in the history
Add ASAN build configuration, based on debug with ASAN
enabled. This might help finding crashes like in
#548

Signed-off-by: Lev Stipakov <lev@openvpn.net>
  • Loading branch information
lstipakov committed Sep 4, 2023
1 parent a34cb32 commit 6a70ad2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/msbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,23 @@ jobs:
strategy:
matrix:
arch: [x86, x64, arm64]
conf:
- name: ""
value: "release"
ovpn3:
- preset: ""
name: ""
upload_name: ""
- preset: -ovpn3
name: "- ovpn3"
upload_name: "_ovpn3"
include:
- conf:
name: " ASAN"
value: "asan"
arch: x64

name: 'msvc - ${{matrix.arch}} ${{ matrix.ovpn3.name }}'
name: 'msvc - ${{matrix.arch}} ${{ matrix.ovpn3.name }}${{ matrix.conf.name }}'
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -55,14 +63,14 @@ jobs:
uses: lukka/run-cmake@v10
with:
configurePreset: '${{ matrix.arch }}${{ matrix.ovpn3.preset }}'
buildPreset: '${{ matrix.arch }}-release${{ matrix.ovpn3.preset }}'
buildPreset: '${{ matrix.arch }}-${{ matrix.conf.value }}${{ matrix.ovpn3.preset }}'

- uses: actions/upload-artifact@v3
with:
name: openvpn-gui_${{ matrix.arch }}${{ matrix.ovpn3.upload_name }}
name: openvpn-gui_${{ matrix.arch }}_${{ matrix.conf }}${{ matrix.ovpn3.upload_name }}
path: |
out/build/${{ matrix.arch }}${{ matrix.ovpn3.preset }}/Release/*.dll
out/build/${{ matrix.arch }}${{ matrix.ovpn3.preset }}/Release/*.exe
out/build/${{ matrix.arch }}${{ matrix.ovpn3.preset }}/${{ matrix.conf.value }}/*.dll
out/build/${{ matrix.arch }}${{ matrix.ovpn3.preset }}/${{ matrix.conf.value }}/*.exe
mingw:
strategy:
Expand Down Expand Up @@ -107,4 +115,3 @@ jobs:
- name: make
run: make
working-directory: openvpn-gui

23 changes: 20 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,24 @@ add_executable(${PROJECT_NAME} WIN32
res/openvpn-gui-res.rc)

set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} /guard:cf /Qspectre")

if(MSVC)
list(APPEND CMAKE_CONFIGURATION_TYPES Asan)
endif(MSVC)

set(CMAKE_C_FLAGS_ASAN
"${CMAKE_C_FLAGS_DEBUG} /fsanitize=address" CACHE STRING
"Flags used by the C compiler during AddressSanitizer builds." FORCE)

set(CMAKE_EXE_LINKER_FLAGS_ASAN
"${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING
"Flags used by the linker during AddressSanitizer builds." FORCE)

set(CMAKE_SHARED_LINKER_FLAGS_ASAN
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING
"Flags used by the linker during AddressSanitizer builds." FORCE)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:cf /Qspectre")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /guard:cf /DYNAMICBASE")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996 /wd4267 /wd4244")
Expand Down Expand Up @@ -160,5 +176,6 @@ if(MSVC)
"$<$<CONFIG:Release>:/OPT:ICF>")
endif(MSVC)

set_target_properties(${TEST_PLAP_EXE} PROPERTIES
LINK_FLAGS " /MANIFEST:EMBED /MANIFESTINPUT:${CMAKE_SOURCE_DIR}/plap/test-plap.manifest ")
target_link_options(${TEST_PLAP_EXE} PRIVATE
"/MANIFEST:EMBED"
"/MANIFESTINPUT:${CMAKE_SOURCE_DIR}/plap/test-plap.manifest")
5 changes: 5 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@
"configurePreset": "x64",
"configuration": "Debug"
},
{
"name": "x64-asan",
"configurePreset": "x64",
"configuration": "Asan"
},
{
"name": "x86-debug",
"configurePreset": "x86",
Expand Down

0 comments on commit 6a70ad2

Please sign in to comment.