basic support for oneapi compilers

dirc2
Robert Cohn 2 years ago committed by Jussi Pakkanen
parent 942aea230f
commit 1939e567d6
  1. 2
      docs/markdown/Reference-tables.md
  2. 8
      docs/markdown/snippets/oneapi_compilers.md
  3. 10
      mesonbuild/compilers/c.py
  4. 12
      mesonbuild/compilers/cpp.py
  5. 38
      mesonbuild/compilers/detect.py
  6. 9
      mesonbuild/compilers/fortran.py
  7. 3
      run_project_tests.py

@ -20,6 +20,8 @@ These are return values of the `get_id` (Compiler family) and
| gcc | The GNU Compiler Collection | gcc |
| intel | Intel compiler (Linux and Mac) | gcc |
| intel-cl | Intel compiler (Windows) | msvc |
| intel-llvm | Intel oneAPI LLVM-based compiler | |
| intel-llvm-cl | Intel oneAPI LLVM-based compiler (Windows) | msvc |
| lcc | Elbrus C/C++/Fortran Compiler | |
| llvm | LLVM-based compiler (Swift, D) | |
| mono | Xamarin C# compiler | |

@ -0,0 +1,8 @@
## Basic support for oneAPI compilers on Linux and Windows
To use on Linux:
```
source /opt/intel/oneapi/setvars.sh
CC=icx CXX=icpx FC=ifx meson setup builddir
```

@ -408,6 +408,11 @@ class IntelCCompiler(IntelGnuLikeCompiler, CCompiler):
return args
class IntelLLVMCCompiler(ClangCCompiler):
id = 'intel-llvm'
class VisualStudioLikeCCompilerMixin(CompilerMixinBase):
"""Shared methods that apply to MSVC-like C compilers."""
@ -530,6 +535,11 @@ class IntelClCCompiler(IntelVisualStudioLikeCompiler, VisualStudioLikeCCompilerM
return args
class IntelLLVMClCCompiler(IntelClCCompiler):
id = 'intel-llvm-cl'
class ArmCCompiler(ArmCompiler, CCompiler):
def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice,
is_cross: bool, info: 'MachineInfo',

@ -155,7 +155,7 @@ class CPPCompiler(CLikeCompiler, Compiler):
}
# Currently, remapping is only supported for Clang, Elbrus and GCC
assert self.id in frozenset(['clang', 'lcc', 'gcc', 'emscripten', 'armltdclang'])
assert self.id in frozenset(['clang', 'lcc', 'gcc', 'emscripten', 'armltdclang', 'intel-llvm'])
if cpp_std not in CPP_FALLBACKS:
# 'c++03' and 'c++98' don't have fallback types
@ -595,6 +595,11 @@ class IntelCPPCompiler(IntelGnuLikeCompiler, CPPCompiler):
return []
class IntelLLVMCPPCompiler(ClangCPPCompiler):
id = 'intel-llvm'
class VisualStudioLikeCPPCompilerMixin(CompilerMixinBase):
"""Mixin for C++ specific method overrides in MSVC-like compilers."""
@ -783,6 +788,11 @@ class IntelClCPPCompiler(VisualStudioLikeCPPCompilerMixin, IntelVisualStudioLike
return IntelVisualStudioLikeCompiler.get_compiler_check_args(self, mode)
class IntelLLVMClCPPCompiler(IntelClCPPCompiler):
id = 'intel-llvm-cl'
class ArmCPPCompiler(ArmCompiler, CPPCompiler):
def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool,
info: 'MachineInfo', exe_wrapper: T.Optional['ExternalProgram'] = None,

@ -68,11 +68,11 @@ else:
defaults['objc'] = ['clang']
defaults['objcpp'] = ['clang++']
else:
defaults['c'] = ['cc', 'gcc', 'clang', 'nvc', 'pgcc', 'icc']
defaults['cpp'] = ['c++', 'g++', 'clang++', 'nvc++', 'pgc++', 'icpc']
defaults['c'] = ['cc', 'gcc', 'clang', 'nvc', 'pgcc', 'icc', 'icx']
defaults['cpp'] = ['c++', 'g++', 'clang++', 'nvc++', 'pgc++', 'icpc', 'icpx']
defaults['objc'] = ['cc', 'gcc', 'clang']
defaults['objcpp'] = ['c++', 'g++', 'clang++']
defaults['fortran'] = ['gfortran', 'flang', 'nvfortran', 'pgfortran', 'ifort', 'g95']
defaults['fortran'] = ['gfortran', 'flang', 'nvfortran', 'pgfortran', 'ifort', 'ifx', 'g95']
defaults['cs'] = ['mcs', 'csc']
defaults['d'] = ['ldc2', 'ldc', 'gdc', 'dmd']
defaults['java'] = ['javac']
@ -465,6 +465,15 @@ def _detect_c_or_cpp_compiler(env: 'Environment', lang: str, for_machine: Machin
return cls(
compiler, version, for_machine, is_cross, info, target,
exe_wrap, linker=linker)
if 'Intel(R) oneAPI DPC++/C++ Compiler for applications' in err:
version = search_version(err)
target = 'x86' if 'IA-32' in err else 'x86_64'
cls = c.IntelLLVMClCCompiler if lang == 'c' else cpp.IntelLLVMClCPPCompiler
env.coredata.add_lang_args(cls.language, cls, for_machine, env)
linker = linkers.XilinkDynamicLinker(for_machine, [], version=version)
return cls(
compiler, version, for_machine, is_cross, info, target,
exe_wrap, linker=linker)
if 'Microsoft' in out or 'Microsoft' in err:
# Latest versions of Visual Studio print version
# number to stderr but earlier ones print version
@ -513,6 +522,12 @@ def _detect_c_or_cpp_compiler(env: 'Environment', lang: str, for_machine: Machin
return cls(
ccache + compiler, version, for_machine, is_cross, info,
exe_wrap, full_version=full_version, linker=l)
if 'Intel(R) oneAPI' in out:
cls = c.IntelLLVMCCompiler if lang == 'c' else cpp.IntelLLVMCPPCompiler
l = guess_nix_linker(env, compiler, cls, version, for_machine)
return cls(
ccache + compiler, version, for_machine, is_cross, info,
exe_wrap, full_version=full_version, linker=l)
if 'TMS320C2000 C/C++' in out or 'MSP430 C/C++' in out or 'TI ARM C/C++ Compiler' in out:
lnk: T.Union[T.Type[linkers.C2000DynamicLinker], T.Type[linkers.TIDynamicLinker]]
if 'TMS320C2000 C/C++' in out:
@ -673,6 +688,16 @@ def detect_fortran_compiler(env: 'Environment', for_machine: MachineChoice) -> C
compiler, version, for_machine, is_cross, info,
exe_wrap, full_version=full_version, linker=linker)
if 'Intel(R) Fortran Compiler for applications' in err:
version = search_version(err)
target = 'x86' if 'IA-32' in err else 'x86_64'
cls = fortran.IntelLLVMClFortranCompiler
env.coredata.add_lang_args(cls.language, cls, for_machine, env)
linker = linkers.XilinkDynamicLinker(for_machine, [], version=version)
return cls(
compiler, version, for_machine, is_cross, info,
target, exe_wrap, linker=linker)
if 'Intel(R) Visual Fortran' in err or 'Intel(R) Fortran' in err:
version = search_version(err)
target = 'x86' if 'IA-32' in err else 'x86_64'
@ -690,6 +715,13 @@ def detect_fortran_compiler(env: 'Environment', for_machine: MachineChoice) -> C
compiler, version, for_machine, is_cross, info,
exe_wrap, full_version=full_version, linker=linker)
if 'ifx (IFORT)' in out:
cls = fortran.IntelLLVMFortranCompiler
linker = guess_nix_linker(env, compiler, cls, version, for_machine)
return cls(
compiler, version, for_machine, is_cross, info,
exe_wrap, full_version=full_version, linker=linker)
if 'PathScale EKOPath(tm)' in err:
return fortran.PathScaleFortranCompiler(
compiler, version, for_machine, is_cross, info,

@ -327,6 +327,11 @@ class IntelFortranCompiler(IntelGnuLikeCompiler, FortranCompiler):
return ['-gen-dep=' + outtarget, '-gen-depformat=make']
class IntelLLVMFortranCompiler(IntelFortranCompiler):
id = 'intel-llvm'
class IntelClFortranCompiler(IntelVisualStudioLikeCompiler, FortranCompiler):
file_suffixes = ('f90', 'f', 'for', 'ftn', 'fpp', )
@ -367,6 +372,10 @@ class IntelClFortranCompiler(IntelVisualStudioLikeCompiler, FortranCompiler):
return ['/module:' + path]
class IntelLLVMClFortranCompiler(IntelClFortranCompiler):
id = 'intel-llvm-cl'
class PathScaleFortranCompiler(FortranCompiler):
id = 'pathscale'

@ -1059,7 +1059,8 @@ def detect_tests_to_run(only: T.Dict[str, T.List[str]], use_tmp: bool) -> T.List
shutil.which('flang') or
shutil.which('pgfortran') or
shutil.which('nagfor') or
shutil.which('ifort'))
shutil.which('ifort') or
shutil.which('ifx'))
skip_cmake = ((os.environ.get('compiler') == 'msvc2015' and under_ci) or
'cmake' not in tool_vers_map or

Loading…
Cancel
Save