Skip to content

Commit 8a69d09

Browse files
rem1776rem1776
authored andcommitted
simplify build type options and compiler flags
1 parent 06d81cc commit 8a69d09

7 files changed

Lines changed: 19 additions & 45 deletions

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ project(FMS
3030

3131
include(GNUInstallDirs)
3232

33-
if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel|DebugUFS|ReleaseUFS|NoFlags|Repro)$")
33+
if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel|DebugUFS|ReleaseUFS)$")
3434
message(STATUS "Setting build type to 'Release' as none was specified.")
3535
set(CMAKE_BUILD_TYPE
3636
"Release"
3737
CACHE STRING "Choose the type of build." FORCE)
38-
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "DebugUFS" "ReleaseUFS" "NoFlags" "Repro")
38+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "DebugUFS" "ReleaseUFS")
3939
endif()
4040

4141
if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Intel|GNU|Clang|IntelLLVM)$")

cmake/compiler_flags_GNU_C.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# GNU C
22
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
33
set(CMAKE_C_FLAGS_RELEASE "-O2")
4-
set(CMAKE_C_FLAGS_REPRO "-O2")
54
set(CMAKE_C_FLAGS_DEBUG "-O0 -g")
65

76
set(CMAKE_C_LINK_FLAGS "")

cmake/compiler_flags_GNU_Fortran.cmake

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# Precision-based Fortran compiler flags
22
set(r8_flags "-fdefault-real-8 -fdefault-double-8") # Fortran flags for 64BIT precision
3+
set(r4_flags "-fdefault-real-4") # Fortran flags for 32BIT precision
34

45
# GNU Fortran
5-
set(CMAKE_Fortran_FLAGS "")
6+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fcray-pointer -fallow-argument-mismatch")
67

7-
set(base_flags "-fcray-pointer -fdefault-double-8 -Waliasing -ffree-line-length-none -fno-range-check -fallow-argument-mismatch")
8-
9-
set(CMAKE_Fortran_FLAGS_RELEASE "${base_flags} -O2 -fno-expensive-optimizations")
10-
set(CMAKE_Fortran_FLAGS_DEBUG "${base_flags} -O0 -g -W -fbounds-check -ffpe-trap=invalid,zero,overflow")
8+
set(CMAKE_Fortran_FLAGS_RELEASE "-O2")
9+
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -g")
1110

1211
set(CMAKE_Fortran_LINK_FLAGS "" )
1312

cmake/compiler_flags_IntelLLVM_C.cmake

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
# Intel LLVM based C
22

3-
# flags from mkmf intel oneapi template
4-
# Release is prod/opt flags, debug and repro are the same
5-
set( CMAKE_C_FLAGS_BASE "-sox -traceback -march=core-avx-i")
6-
7-
set( isa_flags "-march=core-avx-i")
8-
93
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
104

11-
set( CMAKE_C_FLAGS_RELEASE "-O2 -debug minimal ${CMAKE_C_FLAGS_BASE} ${isa_flags}")
12-
set( CMAKE_C_FLAGS_DEBUG "-O0 -g ${CMAKE_C_FLAGS_BASE}")
13-
set( CMAKE_C_FLAGS_REPRO "-O2 -debug minimal ${CMAKE_C_FLAGS_BASE} ${isa_flags}")
14-
set( CMAKE_C_FLAGS_NOFLAGS "")
5+
set( CMAKE_C_FLAGS_RELEASE "-O2")
6+
set( CMAKE_C_FLAGS_DEBUG "-O0 -g -traceback")
157

168
set( CMAKE_C_LINK_FLAGS "")
179

cmake/compiler_flags_IntelLLVM_Fortran.cmake

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,14 @@
22
set(r4_flags "-real-size 32") # Fortran flags for 32BIT precision
33
set(r8_flags "-real-size 64") # Fortran flags for 64BIT precision
44

5-
set(isa_flag "-march=core-avx-i")
5+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -safe-cray-ptr")
66

7-
# base flags from mkmf oneapi template
8-
set(CMAKE_Fortran_FLAGS_BASE "-fno-alias -auto -safe-cray-ptr -ftz -assume byterecl -i4 -nowarn -traceback")
9-
10-
# set the default as empty so we can add on to it
11-
set(CMAKE_Fortran_FLAGS "")
12-
13-
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -debug minimal -fp-model source ${isa_flag} ${CMAKE_Fortran_FLAGS_BASE}")
14-
set(CMAKE_Fortran_FLAGS_DEBUG "-g -O0 -check -check noarg_temp_created -check nopointer -check nouninit -warn -warn noerrors -fpe0 -ftrapuv ${isa_flag} ${CMAKE_Fortran_FLAGS_BASE}")
15-
set(CMAKE_Fortran_FLAGS_REPRO "-O2 -debug minimal -fp-model source ${isa_flag} ${CMAKE_Fortran_FLAGS_BASE}")
16-
set(CMAKE_Fortran_FLAGS_NOFLAGS "")
7+
set(CMAKE_Fortran_FLAGS_RELEASE "-O3")
8+
set(CMAKE_Fortran_FLAGS_DEBUG "-g -O0 -traceback")
179

1810
set(CMAKE_Fortran_LINK_FLAGS "-fuse-ld=lld")
1911

20-
# ufs flags
12+
# ufs flags to repoduce old behavior
2113
set(CMAKE_Fortran_SHARED_FLAGS "-fpp -fno-alias -auto -safe-cray-ptr -ftz -assume byterecl -align array64byte -nowarn -traceback")
2214
set(CMAKE_Fortran_FLAGS_RELEASEUFS "-O2 -debug minimal -nowarn -qoverride-limits -qno-opt-dynamic-align ${CMAKE_Fortran_SHARED_FLAGS}")
2315
set(CMAKE_Fortran_FLAGS_DEBUGUFS "-g -O0 -check -check noarg_temp_created -check nopointer -warn -warn noerrors -fpe0 -ftrapuv ${CMAKE_Fortran_SHARED_FLAGS}")

cmake/compiler_flags_Intel_C.cmake

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
# Intel C
22
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
33

4-
set( base_flags "-sox -traceback")
5-
6-
set( isa_flags "-march=core-avx-i -qno-opt-dynamic-align")
7-
8-
set( CMAKE_C_FLAGS_RELEASE "-O2 -debug minimal ${base_flags} ${isa_flags}")
9-
set( CMAKE_C_FLAGS_REPRO "-O2 -debug minimal ${base_flags} ${isa_flags}")
10-
set( CMAKE_C_FLAGS_DEBUG "-O0 -g -ftrapuv ${base_flags} ${isa_flags}")
4+
set( CMAKE_C_FLAGS_RELEASE "-O2")
5+
set( CMAKE_C_FLAGS_DEBUG "-O0 -g -traceback")
116

127
set( CMAKE_C_LINK_FLAGS "")
138

cmake/compiler_flags_Intel_Fortran.cmake

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
# Precision-based Fortran compiler flags
22
set(r4_flags "-real-size 32") # Fortran flags for 32BIT precision
33
set(r8_flags "-real-size 64") # Fortran flags for 64BIT precision
4-
set(r8_flags "${r8_flags} -no-prec-div -no-prec-sqrt")
54

6-
set(isa_flags "-march=core-avx-i -qno-opt-dynamic-align")
5+
# Minimal set of flags for stand release and debug build types
6+
set(CMAKE_Fortran_FLAGS "${RELEASE} -safe-cray-ptr")
7+
set(CMAKE_Fortran_FLAGS_RELEASE "-O3")
8+
set(CMAKE_Fortran_FLAGS_DEBUG "-g -O0")
79

8-
set(CMAKE_Fortran_FLAGS "")
9-
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -debug minimal -fp-model source ${isa_flags}")
10-
set(CMAKE_Fortran_FLAGS_REPRO "-O2 -debug minimal -fp-model source ${isa_flags}")
11-
set(CMAKE_Fortran_FLAGS_DEBUG "-g -O0 -check -check noarg_temp_created -check nopointer -warn -warn noerrors -fpe0 -ftrapuv ${isa_flags}")
12-
13-
# ufs flags
10+
# ufs flags to reproduce past behavior
1411
set(ufs_flags_base "${CMAKE_Fortran_FLAGS} -fpp -fno-alias -auto -safe-cray-ptr -ftz -assume byterecl -align array64byte -nowarn -sox -traceback")
1512

1613
set(CMAKE_Fortran_FLAGS_RELEASE "${ufs_flags_base} -O2 -debug minimal -fp-model source -nowarn -qoverride-limits -qno-opt-dynamic-align -qopt-prefetch=3")

0 commit comments

Comments
 (0)