From 3a75bb5259abbcae820b47f5f4633c564411893b Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Wed, 10 Apr 2019 09:32:15 -0400 Subject: detect Intel ICL on windows ICL CPP working --- mesonbuild/compilers/__init__.py | 4 ++++ mesonbuild/compilers/c.py | 6 ++++++ mesonbuild/compilers/cpp.py | 9 ++++++++- mesonbuild/environment.py | 20 +++++++++++++++----- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/mesonbuild/compilers/__init__.py b/mesonbuild/compilers/__init__.py index 5de0e59..4cb7ebf 100644 --- a/mesonbuild/compilers/__init__.py +++ b/mesonbuild/compilers/__init__.py @@ -69,6 +69,8 @@ __all__ = [ 'IntelCCompiler', 'IntelCPPCompiler', 'IntelFortranCompiler', + 'IntelClCCompiler', + 'IntelClCPPCompiler', 'JavaCompiler', 'LLVMDCompiler', 'MonoCompiler', @@ -130,6 +132,7 @@ from .c import ( GnuCCompiler, ElbrusCCompiler, IntelCCompiler, + IntelClCCompiler, PGICCompiler, CcrxCCompiler, VisualStudioCCompiler, @@ -143,6 +146,7 @@ from .cpp import ( GnuCPPCompiler, ElbrusCPPCompiler, IntelCPPCompiler, + IntelClCPPCompiler, PGICPPCompiler, CcrxCPPCompiler, VisualStudioCPPCompiler, diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 160e45d..54ca894 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -1722,6 +1722,12 @@ class ClangClCCompiler(VisualStudioCCompiler): self.id = 'clang-cl' +class IntelClCCompiler(VisualStudioCCompiler): + def __init__(self, exelist, version, is_cross, exe_wrap, target): + super().__init__(exelist, version, is_cross, exe_wrap, target) + self.id = 'intel' + + class ArmCCompiler(ArmCompiler, CCompiler): def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None, **kwargs): CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs) diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index 55be58d..7c2253d 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -19,7 +19,7 @@ from .. import coredata from .. import mlog from ..mesonlib import MesonException, version_compare -from .c import CCompiler, VisualStudioCCompiler, ClangClCCompiler +from .c import CCompiler, VisualStudioCCompiler, ClangClCCompiler, IntelClCCompiler from .compilers import ( gnu_winlibs, msvc_winlibs, @@ -406,6 +406,13 @@ class ClangClCPPCompiler(VisualStudioCPPCompiler, ClangClCCompiler): VisualStudioCPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap, target) self.id = 'clang-cl' + +class IntelClCPPCompiler(VisualStudioCPPCompiler, IntelClCCompiler): + def __init__(self, exelist, version, is_cross, exe_wrap, target): + VisualStudioCPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap, target) + self.id = 'intel' + + class ArmCPPCompiler(ArmCompiler, CPPCompiler): def __init__(self, exelist, version, compiler_type, is_cross, exe_wrap=None, **kwargs): CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap, **kwargs) diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index e0cb998..ff24795 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -13,7 +13,6 @@ # limitations under the License. import os, platform, re, sys, shlex, shutil, subprocess -from typing import List from . import coredata from .linkers import ArLinker, ArmarLinker, VisualStudioLinker, DLinker, CcrxLinker @@ -61,6 +60,8 @@ from .compilers import ( IntelCCompiler, IntelCPPCompiler, IntelFortranCompiler, + IntelClCCompiler, + IntelClCPPCompiler, JavaCompiler, MonoCompiler, CudaCompiler, @@ -677,6 +678,7 @@ class Environment: arg = '-v' else: arg = '--version' + try: p, out, err = Popen_safe(compiler + [arg]) except OSError as e: @@ -685,6 +687,11 @@ class Environment: if 'ccrx' in compiler[0]: out = err + if 'icl' in compiler[0]: + # https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-alphabetical-list-of-compiler-options + # https://software.intel.com/en-us/fortran-compiler-developer-guide-and-reference-logo + # most consistent way for ICL is to just let compiler error and tell version + out = err full_version = out.split('\n', 1)[0] version = search_version(out) @@ -784,12 +791,15 @@ class Environment: if mesonlib.for_darwin(want_cross, self): compiler_type = CompilerType.ICC_OSX elif mesonlib.for_windows(want_cross, self): - # TODO: fix ICC on Windows - compiler_type = CompilerType.ICC_WIN + raise EnvironmentException('At the time of authoring, there was no ICC for Windows') else: compiler_type = CompilerType.ICC_STANDARD cls = IntelCCompiler if lang == 'c' else IntelCPPCompiler return cls(ccache + compiler, version, compiler_type, is_cross, exe_wrap, full_version=full_version) + if out.startswith('Intel(R) C++') and mesonlib.for_windows(want_cross, self): + cls = IntelClCCompiler if lang == 'c' else IntelClCPPCompiler + target = 'x64' if 'Intel(R) 64 Compiler' in out else 'x86' + return cls(compiler, version, is_cross, exe_wrap, target) if 'ARM' in out: compiler_type = CompilerType.ARM_WIN cls = ArmCCompiler if lang == 'c' else ArmCPPCompiler @@ -1053,8 +1063,8 @@ class Environment: # up to date language version at time (2016). if exelist is not None: if os.path.basename(exelist[-1]).startswith(('ldmd', 'gdmd')): - raise EnvironmentException('Meson does not support {} as it is only a DMD frontend for another compiler.'.format(exelist[-1]) - 'Please provide a valid value for DC or unset it so that Meson can resolve the compiler by itself.') + raise EnvironmentException('Meson does not support {} as it is only a DMD frontend for another compiler.' + 'Please provide a valid value for DC or unset it so that Meson can resolve the compiler by itself.'.format(exelist[-1])) else: for d in self.default_d: if shutil.which(d): -- cgit v1.1