From 9b391364fab2f485c0dfbab1f13ceaa240ad8300 Mon Sep 17 00:00:00 2001 From: Matthew Masarik Date: Fri, 2 Feb 2024 17:47:33 +0000 Subject: [PATCH] src/CMakeLists.txt: add "address sanitizing" compile options to debug options --- model/src/CMakeLists.txt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/model/src/CMakeLists.txt b/model/src/CMakeLists.txt index 7dd7d82a2..2ea6c635a 100644 --- a/model/src/CMakeLists.txt +++ b/model/src/CMakeLists.txt @@ -56,7 +56,13 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") set(compile_flags_release -O3) # SHELL: prefix fixes CMake attempting to de-duplicate the repeated uses of 'all' in -warn, -debug, -check # See https://cmake.org/cmake/help/latest/command/target_compile_options.html#option-de-duplication - set(compile_flags_debug -O0 "SHELL:-debug all" "SHELL:-warn all" "SHELL:-check all" -check noarg_temp_created -fp-stack-check -heap-arrays -traceback -fpe0) + # + # ##MTM set(compile_flags_debug -O0 "SHELL:-debug all" "SHELL:-warn all" "SHELL:-check all" -check noarg_temp_created -fp-stack-check -heap-arrays -traceback -fpe0) + # + # + set(compile_flags_debug -O0 "SHELL:-debug all" "SHELL:-warn all" "SHELL:-check all" -check noarg_temp_created -fp-stack-check -heap-arrays -traceback -fpe0 -fno-omit-frame-pointer -fsanitize=address) + # + # ##MTM if(APPLE) # The linker on macOS does not include `common symbols` (usually module variables without a default value) by default @@ -70,7 +76,7 @@ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") set(compile_flags -g -fno-second-underscore -ffree-line-length-none) set(compile_flags_release -O3) set(compile_flags_debug -Wall -fcheck=all -ffpe-trap=invalid,zero,overflow -frecursive -fbacktrace) - + if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10) target_compile_options(ww3_lib PUBLIC -fallow-argument-mismatch) endif() @@ -79,7 +85,7 @@ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "PGI") set(compile_flags -g -i4 -r4 -Kieee) set(compile_flags_release -O3) set(compile_flags_debug -O0 -Mbounds -Mchkfpstk -Mchkstk -Mdalign -Mdclchk -Mdepchk -Miomutex -Ktrap=fp -Mrecursive -traceback) - + if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10) target_compile_options(ww3_lib PUBLIC -fallow-argument-mismatch -fallow-invalid-boz) endif() @@ -131,13 +137,13 @@ if(MULTI_ESMF) if (NOT TARGET esmf) find_package(ESMF MODULE REQUIRED) endif() - + target_sources(ww3_lib PRIVATE wmesmfmd.F90) target_link_libraries(ww3_lib PUBLIC esmf) set_target_properties(ww3_lib PROPERTIES OUTPUT_NAME "ww3_multi_esmf") # Don't build executables when building WW3 ESMF library set(programs "") -endif() +endif() set_property(SOURCE w3initmd.F90 APPEND @@ -211,7 +217,7 @@ install( install(FILES ${CMAKE_BINARY_DIR}/switch DESTINATION ${CMAKE_INSTALL_PREFIX}) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod DESTINATION ${CMAKE_INSTALL_PREFIX}) - + export(EXPORT WW3Exports NAMESPACE WW3::