aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Cohn <robert.s.cohn@intel.com>2022-10-09 09:14:52 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2022-10-24 18:55:22 +0300
commit1939e567d6dc7be5cc9495cacde6b984e58409a0 (patch)
treedf970e2821e0b5b95841ba75e7ffab906f8af958
parent942aea230f5e517d5add194240c8943f28d79943 (diff)
downloadmeson-1939e567d6dc7be5cc9495cacde6b984e58409a0.zip
meson-1939e567d6dc7be5cc9495cacde6b984e58409a0.tar.gz
meson-1939e567d6dc7be5cc9495cacde6b984e58409a0.tar.bz2
basic support for oneapi compilers
-rw-r--r--docs/markdown/Reference-tables.md2
-rw-r--r--docs/markdown/snippets/oneapi_compilers.md8
-rw-r--r--mesonbuild/compilers/c.py10
-rw-r--r--mesonbuild/compilers/cpp.py12
-rw-r--r--mesonbuild/compilers/detect.py38
-rw-r--r--mesonbuild/compilers/fortran.py9
-rwxr-xr-xrun_project_tests.py3
7 files changed, 77 insertions, 5 deletions
diff --git a/docs/markdown/Reference-tables.md b/docs/markdown/Reference-tables.md
index fde816d..d2df3c8 100644
--- a/docs/markdown/Reference-tables.md
+++ b/docs/markdown/Reference-tables.md
@@ -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 | |
diff --git a/docs/markdown/snippets/oneapi_compilers.md b/docs/markdown/snippets/oneapi_compilers.md
new file mode 100644
index 0000000..a456e30
--- /dev/null
+++ b/docs/markdown/snippets/oneapi_compilers.md
@@ -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
+```
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index 4ca3689..c41a7e2 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -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',
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
index 16831c6..c9ca842 100644
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -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,
diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py
index 64f6276..fcaae4a 100644
--- a/mesonbuild/compilers/detect.py
+++ b/mesonbuild/compilers/detect.py
@@ -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,
diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py
index af9d1e7..bbe0b78 100644
--- a/mesonbuild/compilers/fortran.py
+++ b/mesonbuild/compilers/fortran.py
@@ -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'
diff --git a/run_project_tests.py b/run_project_tests.py
index 51a8f1f..74ddd9e 100755
--- a/run_project_tests.py
+++ b/run_project_tests.py
@@ -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