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 3f61d0730c83..1271c2f54496 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,11 +120,22 @@ 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 + # 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: