Commit b6542b0
authored
CMake set release flags properly (#2138)
TYPE: bug fix
KEYWORDS: cmake, flags, optimization
SOURCE: internal
DESCRIPTION OF CHANGES:
Problem:
To feed initial flags into the cmake build, a toolchain file is used.
However, for particular build configurations, namely release and debug,
despite the configuration being "Release" and "Debug", respectively, the
corresponding `CMAKE_<LANG>_FLAGS_<CONFIG>_INIT` has the configuration
name capitalized.
Additionally, these initial flags supplement the starting flags and do
not override any inherited flags that CMake automatically appends. This
can cause issues with certain compilers where subsequent flags that
normally should supersede previously listed options are ignored. As an
example, using nvfortran/pgi the following will cause forced
optimization, which is not viable for some files within WRF :
https://forums.developer.nvidia.com/t/nvfortran-reducing-optimation-level-by-multiple-on-does-not-work/191825
https://forums.developer.nvidia.com/t/how-to-override-pgccs-optimization-flag/136275
Finally, certain files do not have optimization overridden even if it
were to work correctly
Solution:
Ensure correct variable name in toolchain file to provide initial
starting flags, and wipe CMake-injected release flags to avoid
significant deviation from provided optimization flags. Add proper
directory scope to files that need these reduced optimizations.
TESTS CONDUCTED:
1. Tested with CMake build on Derecho selecting nvhpc/pgi compiler
stanzas
RELEASE NOTE: Override CMake-injected optimization flags in favor of the
flags set by the build system and provided stanza information.1 parent 4889c3c commit b6542b0
File tree
3 files changed
+11
-4
lines changed- cmake/template
- frame
3 files changed
+11
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| 159 | + | |
| 160 | + | |
159 | 161 | | |
160 | 162 | | |
161 | 163 | | |
| |||
0 commit comments