From cef545eebbde5586e169bb670bb1cea0f8947fe8 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 17 Nov 2025 09:39:11 -0800 Subject: [PATCH 1/2] dependencies/mpi: Correctly handle Intel oneAPI MPI with Intel Compilers There are new programs that need to be checked for the new compilers, as ifort -> ifx, icc -> icx, etc. Fixes: #15259 --- mesonbuild/dependencies/mpi.py | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/mesonbuild/dependencies/mpi.py b/mesonbuild/dependencies/mpi.py index 3f61d0730c83..d4d691b7de23 100644 --- a/mesonbuild/dependencies/mpi.py +++ b/mesonbuild/dependencies/mpi.py @@ -36,7 +36,7 @@ def mpi_factory(env: 'Environment', compiler = detect_compiler('mpi', env, for_machine, language) if not compiler: return [] - compiler_is_intel = compiler.get_id() in {'intel', 'intel-cl'} + compiler_is_intel = compiler.get_id().startswith('intel') if DependencyMethods.CONFIG_TOOL in methods and not env.machines[for_machine].is_windows(): nwargs = kwargs.copy() @@ -55,15 +55,26 @@ def mpi_factory(env: 'Environment', tool_names = [t for t in tool_names if t] # remove empty environment variables if compiler_is_intel: + # The oneAPI compilers have different wrappers + is_llvm_based = 'llvm' in compiler.id if env.machines[for_machine].is_windows(): nwargs['returncode_value'] = 3 if language == 'c': - tool_names.append('mpiicc') + if is_llvm_based: + tool_names.append('mpiicx') + else: + tool_names.append('mpiicc') elif language == 'cpp': - tool_names.append('mpiicpc') + if is_llvm_based: + tool_names.append('mpiicpx') + else: + tool_names.append('mpiicpc') elif language == 'fortran': - tool_names.append('mpiifort') + if is_llvm_based: + tool_names.append('mpiifx') + else: + tool_names.append('mpiifort') # even with intel compilers, mpicc has to be considered if language == 'c': @@ -109,8 +120,16 @@ def __init__(self, name: str, env: 'Environment', kwargs: DependencyObjectKWs): if not self.is_found: return - # --showme for OpenMPI, -compile_info/-link_info for MPICH and IntelMPI - for comp, link in [('--showme:compile', '--showme:link'), ('-compile_info', '-link_info'), ('-show', None)]: + # --showme for OpenMPI + # -compile_info/-link_info for MPICH and IntelMPI + # -show for Intel + commands: T.List[T.Tuple[str, T.Optional[str]]] = [ + ('--showme:compile', '--showme:link'), + ('-compile_info', '-link_info'), + ('-show', None) + ] + + for comp, link in commands: try: c_args = self.get_config_value([comp], 'compile_args') l_args = self.get_config_value([link], 'link_args') if link is not None else c_args From 50e7a5bf90c2c84edf4df225e91cf1c23c131547 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Fri, 6 Feb 2026 11:49:55 -0800 Subject: [PATCH 2/2] dependencies/mpi: Correctly handle non-required MPI This expects that if the command fails that the next set of options will be tried. Of course, that doesn't happen if the dependency isn't required instead you get an empty list. Add an option to force the exception to be raised if the command fails, even for non-required dependencies. This fixes using Intel MPI (from oneAPI) with gcc/clang. --- mesonbuild/dependencies/configtool.py | 4 ++-- mesonbuild/dependencies/mpi.py | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/mesonbuild/dependencies/configtool.py b/mesonbuild/dependencies/configtool.py index 3d018943c7aa..ef18c14173d4 100644 --- a/mesonbuild/dependencies/configtool.py +++ b/mesonbuild/dependencies/configtool.py @@ -139,10 +139,10 @@ def report_config(self, version: T.Optional[str], req_version: T.List[str]) -> b return self.config is not None - def get_config_value(self, args: T.List[str], stage: str) -> T.List[str]: + def get_config_value(self, args: T.List[str], stage: str, required: bool = False) -> T.List[str]: p, out, err = Popen_safe_logged(self.config + args) if p.returncode != 0: - if self.required: + if self.required or required: raise DependencyException(f'Could not generate {stage} for {self.name}.\n{err}') return [] return split_args(out) diff --git a/mesonbuild/dependencies/mpi.py b/mesonbuild/dependencies/mpi.py index d4d691b7de23..1271c2f54496 100644 --- a/mesonbuild/dependencies/mpi.py +++ b/mesonbuild/dependencies/mpi.py @@ -131,8 +131,11 @@ def __init__(self, name: str, env: 'Environment', kwargs: DependencyObjectKWs): for comp, link in commands: try: - c_args = self.get_config_value([comp], 'compile_args') - l_args = self.get_config_value([link], 'link_args') if link is not None else c_args + # Set required=True to ensure that the next set of options is + # tried when the current ones fail, even if the dependency is + # not required + c_args = self.get_config_value([comp], 'compile_args', required=True) + l_args = self.get_config_value([link], 'link_args', required=True) if link is not None else c_args except DependencyException: continue else: