-
Notifications
You must be signed in to change notification settings - Fork 67
place debug option behind cmake switch buildtype=debug, instead of co… #758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
18751bd
e17fecd
eb562c0
5ea88cc
1e14e68
f7de284
1c14f83
0f9c730
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -317,18 +317,32 @@ if(${CMAKE_Fortran_COMPILER_ID} STREQUAL Intel OR ${CMAKE_Fortran_COMPILER_ID} | |
| target_compile_options(${PROJECT_NAME} PRIVATE -xHost) | ||
| endif() | ||
|
|
||
| # # debugging related compiler flags | ||
| # target_compile_options(${PROJECT_NAME} PRIVATE -qopenmp -g -traceback -check all,noarg_temp_created,bounds,uninit ) #-ftrapuv ) #-init=zero) | ||
| # target_compile_options(${PROJECT_NAME} PRIVATE -g -traceback -check all,noarg_temp_created,bounds,uninit ) #-ftrapuv ) #-init=zero) | ||
| # debugging related compiler flags (activated for Debug build type) | ||
| if(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
| if(ENABLE_OPENMP) | ||
| target_compile_options(${PROJECT_NAME} PRIVATE -qopenmp -g -traceback -check all,noarg_temp_created,bounds,uninit) #-ftrapuv ) #-init=zero) | ||
| else() | ||
| target_compile_options(${PROJECT_NAME} PRIVATE -g -traceback -check all,noarg_temp_created,bounds,uninit) #-ftrapuv ) #-init=zero) | ||
| endif() | ||
| endif() | ||
|
|
||
|
|
||
| elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL GNU ) | ||
| # target_compile_options(${PROJECT_NAME} PRIVATE -O3 -finit-local-zero -finline-functions -fimplicit-none -fdefault-real-8 -ffree-line-length-none) | ||
| if(${FESOM_PLATFORM_STRATEGY} STREQUAL ubuntu ) | ||
| message(STATUS "Allowing type mismatches on Ubuntu for CI Testing" ) # NOTE(PG): Would be nicer to grab the CI=True from the env variable | ||
| target_compile_options(${PROJECT_NAME} PRIVATE -O2 -g -fbacktrace -ffloat-store -finit-local-zero -finline-functions -fimplicit-none -fdefault-real-8 -fdefault-double-8 -ffree-line-length-none -fallow-argument-mismatch -cpp) | ||
| if(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
| target_compile_options(${PROJECT_NAME} PRIVATE -O0 -g -fbacktrace -ffloat-store -finit-local-zero -fimplicit-none -fdefault-real-8 -fdefault-double-8 -ffree-line-length-none -fallow-argument-mismatch -cpp) | ||
| else() | ||
| target_compile_options(${PROJECT_NAME} PRIVATE -O2 -g -fbacktrace -ffloat-store -finit-local-zero -finline-functions -fimplicit-none -fdefault-real-8 -fdefault-double-8 -ffree-line-length-none -fallow-argument-mismatch -cpp) | ||
| endif() | ||
| else() | ||
| target_compile_options(${PROJECT_NAME} PRIVATE -O3 -ffloat-store -finit-local-zero -finline-functions -fimplicit-none -fdefault-real-8 -fdefault-double-8 -ffree-line-length-none -cpp) | ||
| if(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
| target_compile_options(${PROJECT_NAME} PRIVATE -O0 -ffloat-store -finit-local-zero -fimplicit-none -fdefault-real-8 -fdefault-double-8 -ffree-line-length-none -cpp) | ||
| else() | ||
| target_compile_options(${PROJECT_NAME} PRIVATE -O3 -ffloat-store -finit-local-zero -finline-functions -fimplicit-none -fdefault-real-8 -fdefault-double-8 -ffree-line-length-none -cpp) | ||
| endif() | ||
|
|
||
| endif() | ||
| if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 10 ) | ||
| target_compile_options(${PROJECT_NAME} PRIVATE -fallow-argument-mismatch) # gfortran v10 is strict about erroneous API calls: "Rank mismatch between actual argument at (1) and actual argument at (2) (scalar and rank-1)" | ||
|
|
@@ -362,29 +376,34 @@ elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL GNU ) | |
| # | | -mno-fma4 -mavx2 -mfma | | | ||
| # | GCC/openMPI | -O3 -march=znver3 -mtune=znver3 -ftree-vectorize -flto | 280s | chatgpt recomendation | ||
| # | | -mcpu=znver3 | | | ||
| target_compile_options(${PROJECT_NAME} PRIVATE -march=znver3 -mtune=znver3 -ftree-vectorize -flto) | ||
| if(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
| target_compile_options(${PROJECT_NAME} PRIVATE -march=znver3 -mtune=znver3) | ||
| else() | ||
| target_compile_options(${PROJECT_NAME} PRIVATE -march=znver3 -mtune=znver3 -ftree-vectorize -flto) | ||
| endif() | ||
| else() | ||
| #[[if(NOT (${FESOM_PLATFORM_STRATEGY} STREQUAL ubuntu)) | ||
| target_compile_options(${PROJECT_NAME} PRIVATE -native) | ||
| endif() ]] | ||
| endif() | ||
|
|
||
| # # debugging related compiler flags | ||
| #target_compile_options(${PROJECT_NAME} PRIVATE | ||
| #-fallow-argument-mismatch | ||
| #-fno-fast-math -fno-signed-zeros | ||
| #-freciprocal-math | ||
| #-mveclibabi=svml | ||
| #-flto | ||
| #-pg | ||
| #-fbacktrace | ||
| #-fcheck=all,bounds | ||
| #-finit-real=snan | ||
| #-finit-integer=-9999 | ||
| #-fsanitize=undefined,address | ||
| #) | ||
| ## if use -fsanitize=undefined,address you also need ... PRIVATE -lubsan) | ||
| #target_link_libraries(${PROJECT_NAME} PRIVATE -lubsan) | ||
| # debugging related compiler flags (activated for Debug build type) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should use address sanitizer definitely for testing new code to check if we are allocating badly and creating leaks but I will skip -fsanitize for now as it need libasan to also be installed and present, this possibly need a cmake module to check this. so would skip this for now just, and ubsan seems to be a typo? should be -lasan or -static-libasan to compile options. More over any use of asan also need a env variable or someting to trace specific issue like ASAN_OPTIONS=detect_leaks=1 for detecting leaks. so this should be possibly done differently for it to be useful. |
||
| if(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
| target_compile_options(${PROJECT_NAME} PRIVATE | ||
| -fallow-argument-mismatch | ||
| -fno-fast-math -fno-signed-zeros | ||
| -freciprocal-math | ||
| -mveclibabi=svml | ||
| -flto | ||
| -pg | ||
| -fbacktrace | ||
| -fcheck=all,bounds | ||
| -finit-real=snan | ||
| -finit-integer=-9999 | ||
| -fsanitize=undefined,address | ||
| ) | ||
| target_link_libraries(${PROJECT_NAME} PRIVATE -lubsan) | ||
| endif() | ||
|
|
||
|
|
||
| elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL Cray ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wonder if we should just remove -DCMAKE_BUILD_TYPE=.... from ./configure.sh because 1. ./configure.sh also takes cmake args so gives flexibility for user to use ./configure.sh blahblah -DCMAKE_BUILD_TYPE=Debug if they want to. 2. in CMakeLists.txt build type is set to be Release in case the variable is not set.