Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
RELEASE NOTE: Override CMake-injected optimization flags in favor of the flags set by the build system and provided stanza information.