CMake Fix split command flags to be correctly populated #2108
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, mpi, compilation
SOURCE: internal
DESCRIPTION OF CHANGES:
Problem:
The
arch/configure_reader.py
does the job of parsing, organizing, and sanitizing input from configuration stanzas into a CMake toolchain file which can then be used to inform the build about which compilers, flags, and options to use.Occasionally, stanzas fields inject flags into a compiler or other command field (like
DM_FC
) so that the actual command is a command + flags. Part of thearch/configure_reader.py
organization is breaking these up into separable sections automatically. With the example ofDM_FC = mpif90 -f90=gfortran
($(SFC)
already expanded) this should be broken intoDM_FC = mpif90
andDM_FC_FLAGS = -f90=gfortran
. Currently, the*_FLAGS
field when split out for certain keys in a stanza is not populated due to using the wrong index from the Pythonstr.partition()
call.Secondly, when these fields are actually provided to CMake compilation breaks for MPI specifically. Since the MPI "compilers" are wrappers, they are then interrogated for the underlying flags and options meaning further adding the flags back into compilation results in things like
gfortran <all the other flags> -f90=gfortran
. This is incorrect, and instead the flags should be provided to the MPI flags used during wrapper interrogation on a per-language basis. Furthermore, for certain MPI implementations supplying any flags renders the query command (e.g.-show
,-showme
, or-compileinfo
) useless. For instance, OpenMPImpif90 -f90=gfortran -show
only outputsgfortran -f90=gfortran
which is also wrong.Solution:
MPI_<LANG>_COMPILER_FLAGS
if neededFindMPI
module already feeds in the underlying compiler specification for wrappers that support it so flags like-f90=$(SFC)
should be filtered out fromDM_*_FLAGS
before being written to thewrf_config.cmake
toolchain fileTESTS CONDUCTED:
wrf_config.cmake
file