Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information