Skip to content

Commit d825c5c

Browse files
committed
fix: improve san and debug symbols on windows
1 parent 791a450 commit d825c5c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE ${PY3LM_LINK_LIBRARIES})
7171

7272
if(MSVC)
7373
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX /Zc:preprocessor $<$<CONFIG:Release>:/Zi>)
74+
target_link_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:Release>:/DEBUG /OPT:REF /OPT:ICF>)
7475
else()
7576
target_compile_options(${PROJECT_NAME} PRIVATE -Wextra -Wconversion -Werror -Wshadow -Wpedantic $<$<CONFIG:Release>:-g1>)
7677
endif()
@@ -82,10 +83,15 @@ elseif(UNIX)
8283
target_link_options(${PROJECT_NAME} PRIVATE "-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/sym/version_script.lds")
8384
endif()
8485

85-
if(PLUGIFY_HAS_SANITIZER)
86+
if(PLUGIFY_USE_SANITIZER)
8687
# https://github.com/llvm/llvm-project/pull/121228
87-
target_compile_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:Debug>: -fsanitize=address -fno-omit-frame-pointer>) # -fsanitize=undefined
88-
target_link_libraries(${PROJECT_NAME} PRIVATE $<$<CONFIG:Debug>: -fsanitize=address -fno-omit-frame-pointer>) # -fsanitize=undefined
88+
if(MSVC)
89+
target_compile_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:Debug>: /fsanitize=address>)
90+
target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<CONFIG:Debug>: _DISABLE_VECTOR_ANNOTATION>)
91+
else()
92+
target_compile_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:Debug>: -fsanitize=address -fsanitize=leak>) # -fsanitize=undefined disabled
93+
target_link_libraries(${PROJECT_NAME} PRIVATE $<$<CONFIG:Debug>: -fsanitize=address -fsanitize=leak>) # -fsanitize=undefined disabled
94+
endif()
8995
endif()
9096

9197
include(GenerateExportHeader)

0 commit comments

Comments
 (0)