compilers: Add basic ICL abstractions

pull/5331/head
Dylan Baker 6 years ago
parent de011e031c
commit fa54f05f09
  1. 8
      mesonbuild/compilers/__init__.py
  2. 33
      mesonbuild/compilers/c.py
  3. 42
      mesonbuild/compilers/compilers.py
  4. 13
      mesonbuild/compilers/cpp.py
  5. 34
      mesonbuild/compilers/fortran.py

@ -66,9 +66,13 @@ __all__ = [
'GnuObjCCompiler', 'GnuObjCCompiler',
'GnuObjCPPCompiler', 'GnuObjCPPCompiler',
'IntelGnuLikeCompiler', 'IntelGnuLikeCompiler',
'IntelVisualStudioLikeCompiler',
'IntelCCompiler', 'IntelCCompiler',
'IntelCPPCompiler', 'IntelCPPCompiler',
'IntelClCCompiler',
'IntelClCPPCompiler',
'IntelFortranCompiler', 'IntelFortranCompiler',
'IntelClFortranCompiler',
'JavaCompiler', 'JavaCompiler',
'LLVMDCompiler', 'LLVMDCompiler',
'MonoCompiler', 'MonoCompiler',
@ -122,6 +126,7 @@ from .compilers import (
IntelGnuLikeCompiler, IntelGnuLikeCompiler,
CcrxCompiler, CcrxCompiler,
VisualStudioLikeCompiler, VisualStudioLikeCompiler,
IntelVisualStudioLikeCompiler,
) )
from .c import ( from .c import (
CCompiler, CCompiler,
@ -132,6 +137,7 @@ from .c import (
GnuCCompiler, GnuCCompiler,
ElbrusCCompiler, ElbrusCCompiler,
IntelCCompiler, IntelCCompiler,
IntelClCCompiler,
PGICCompiler, PGICCompiler,
CcrxCCompiler, CcrxCCompiler,
VisualStudioCCompiler, VisualStudioCCompiler,
@ -145,6 +151,7 @@ from .cpp import (
GnuCPPCompiler, GnuCPPCompiler,
ElbrusCPPCompiler, ElbrusCPPCompiler,
IntelCPPCompiler, IntelCPPCompiler,
IntelClCPPCompiler,
PGICPPCompiler, PGICPPCompiler,
CcrxCPPCompiler, CcrxCPPCompiler,
VisualStudioCPPCompiler, VisualStudioCPPCompiler,
@ -164,6 +171,7 @@ from .fortran import (
ElbrusFortranCompiler, ElbrusFortranCompiler,
FlangFortranCompiler, FlangFortranCompiler,
IntelFortranCompiler, IntelFortranCompiler,
IntelClFortranCompiler,
NAGFortranCompiler, NAGFortranCompiler,
Open64FortranCompiler, Open64FortranCompiler,
PathScaleFortranCompiler, PathScaleFortranCompiler,

@ -16,7 +16,7 @@ import os.path
import typing import typing
from .. import coredata from .. import coredata
from ..mesonlib import MesonException, version_compare from ..mesonlib import MesonException, version_compare, mlog
from .c_function_attributes import C_FUNC_ATTRIBUTES from .c_function_attributes import C_FUNC_ATTRIBUTES
from .clike import CLikeCompiler from .clike import CLikeCompiler
@ -31,6 +31,7 @@ from .compilers import (
GnuCompiler, GnuCompiler,
ElbrusCompiler, ElbrusCompiler,
IntelGnuLikeCompiler, IntelGnuLikeCompiler,
IntelVisualStudioLikeCompiler,
PGICompiler, PGICompiler,
CcrxCompiler, CcrxCompiler,
VisualStudioLikeCompiler, VisualStudioLikeCompiler,
@ -279,6 +280,36 @@ class ClangClCCompiler(VisualStudioLikeCompiler, VisualStudioLikeCCompilerMixin,
self.id = 'clang-cl' self.id = 'clang-cl'
class IntelClCCompiler(IntelVisualStudioLikeCompiler, VisualStudioLikeCCompilerMixin, CCompiler):
"""Intel "ICL" compiler abstraction."""
__have_warned = False
def __init__(self, exelist, version, is_cross, exe_wrap, target):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
IntelVisualStudioLikeCompiler.__init__(self, target)
def get_options(self):
opts = super().get_options()
c_stds = ['none', 'c89', 'c99', 'c11']
opts.update({'c_std': coredata.UserComboOption('c_std', 'C language standard to use',
c_stds,
'none')})
return opts
def get_option_compile_args(self, options):
args = []
std = options['c_std']
if std.value == 'c89':
if not self.__have_warned:
self.__have_warned = True
mlog.warning("ICL doesn't explicitly implement c89, setting the standard to 'none', which is close.")
elif std.value != 'none':
args.append('/Qstd:' + std.value)
return args
class ArmCCompiler(ArmCompiler, CCompiler): class ArmCCompiler(ArmCompiler, CCompiler):
def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None, **kwargs): def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None, **kwargs):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs) CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs)

@ -2344,6 +2344,48 @@ class IntelGnuLikeCompiler(GnuLikeCompiler):
return ['-prof-use'] return ['-prof-use']
class IntelVisualStudioLikeCompiler(VisualStudioLikeCompiler):
"""Abstractions for ICL, the Intel compiler on Windows."""
def __init__(self, target: str):
super().__init__(target)
self.compiler_type = CompilerType.ICC_WIN
self.id = 'intel-cl'
def compile(self, code, *, extra_args=None, **kwargs):
# This covers a case that .get('foo', []) doesn't, that extra_args is
if kwargs.get('mode', 'compile') != 'link':
extra_args = extra_args.copy() if extra_args is not None else []
extra_args.extend([
'/Qdiag-error:10006', # ignoring unknown option
'/Qdiag-error:10148', # Option not supported
'/Qdiag-error:10155', # ignoring argument required
'/Qdiag-error:10156', # ignoring not argument allowed
'/Qdiag-error:10157', # Ignoring argument of the wrong type
'/Qdiag-error:10158', # Argument must be separate. Can be hit by trying an option like -foo-bar=foo when -foo=bar is a valid option but -foo-bar isn't
])
return super().compile(code, extra_args, **kwargs)
def get_toolset_version(self) -> Optional[str]:
# Avoid circular dependencies....
from ..environment import search_version
# ICL provides a cl.exe that returns the version of MSVC it tries to
# emulate, so we'll get the version from that and pass it to the same
# function the real MSVC uses to calculate the toolset version.
_, _, err = Popen_safe(['cl.exe'])
v1, v2, *_ = search_version(err).split('.')
version = int(v1 + v2)
return self._calculate_toolset_version(version)
def get_linker_exelist(self):
return ['xilink']
def openmp_flags(self):
return ['/Qopenmp']
class ArmCompiler: class ArmCompiler:
# Functionality that is common to all ARM family compilers. # Functionality that is common to all ARM family compilers.
def __init__(self, compiler_type): def __init__(self, compiler_type):

@ -28,6 +28,7 @@ from .compilers import (
GnuCompiler, GnuCompiler,
ElbrusCompiler, ElbrusCompiler,
IntelGnuLikeCompiler, IntelGnuLikeCompiler,
IntelVisualStudioLikeCompiler,
PGICompiler, PGICompiler,
ArmCompiler, ArmCompiler,
ArmclangCompiler, ArmclangCompiler,
@ -483,6 +484,18 @@ class ClangClCPPCompiler(CPP11AsCPP14Mixin, VisualStudioLikeCPPCompilerMixin, Vi
return self._get_options_impl(super().get_options(), cpp_stds) return self._get_options_impl(super().get_options(), cpp_stds)
class IntelClCPPCompiler(VisualStudioLikeCPPCompilerMixin, IntelVisualStudioLikeCompiler, CPPCompiler):
def __init__(self, exelist, version, is_cross, exe_wrap, target):
CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
IntelVisualStudioLikeCompiler.__init__(self, target)
def get_options(self):
# This has only been tested with verison 19.0,
cpp_stds = ['none', 'c++11', 'vc++11', 'c++14', 'vc++14', 'c++17', 'vc++17', 'c++latest']
return self._get_options_impl(super().get_options(), cpp_stds)
class ArmCPPCompiler(ArmCompiler, CPPCompiler): class ArmCPPCompiler(ArmCompiler, CPPCompiler):
def __init__(self, exelist, version, compiler_type, is_cross, exe_wrap=None, **kwargs): def __init__(self, exelist, version, compiler_type, is_cross, exe_wrap=None, **kwargs):
CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap, **kwargs) CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap, **kwargs)

@ -27,7 +27,8 @@ from .compilers import (
ClangCompiler, ClangCompiler,
ElbrusCompiler, ElbrusCompiler,
IntelGnuLikeCompiler, IntelGnuLikeCompiler,
PGICompiler PGICompiler,
IntelVisualStudioLikeCompiler,
) )
from .clike import CLikeCompiler from .clike import CLikeCompiler
@ -66,6 +67,7 @@ class FortranCompiler(CLikeCompiler, Compiler):
for_machine = MachineChoice.HOST for_machine = MachineChoice.HOST
extra_flags = environment.coredata.get_external_args(for_machine, self.language) extra_flags = environment.coredata.get_external_args(for_machine, self.language)
extra_flags += environment.coredata.get_external_link_args(for_machine, self.language) extra_flags += environment.coredata.get_external_link_args(for_machine, self.language)
extra_flags += self.get_always_args()
# %% build the test executable # %% build the test executable
pc = subprocess.Popen(self.exelist + extra_flags + [str(source_name), '-o', str(binary_name)]) pc = subprocess.Popen(self.exelist + extra_flags + [str(source_name), '-o', str(binary_name)])
pc.wait() pc.wait()
@ -239,6 +241,36 @@ class IntelFortranCompiler(IntelGnuLikeCompiler, FortranCompiler):
def language_stdlib_only_link_flags(self): def language_stdlib_only_link_flags(self):
return ['-lifcore', '-limf'] return ['-lifcore', '-limf']
class IntelClFortranCompiler(IntelVisualStudioLikeCompiler, FortranCompiler):
file_suffixes = ['f90', 'f', 'for', 'ftn', 'fpp']
always_args = ['/nologo']
BUILD_ARGS = {
'plain': [],
'debug': ["/Zi", "/Od"],
'debugoptimized': ["/Zi", "/O1"],
'release': ["/O2"],
'minsize': ["/Os"],
'custom': [],
}
def __init__(self, exelist, version, is_cross, target: str, exe_wrapper=None):
FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
IntelVisualStudioLikeCompiler.__init__(self, target)
default_warn_args = ['/warn:general', '/warn:truncated_source']
self.warn_args = {'0': [],
'1': default_warn_args,
'2': default_warn_args + ['/warn:unused'],
'3': ['/warn:all']}
def get_module_outdir_args(self, path) -> List[str]:
return ['/module:' + path]
def get_buildtype_args(self, buildtype: str) -> List[str]:
return self.BUILD_ARGS[buildtype]
class PathScaleFortranCompiler(FortranCompiler): class PathScaleFortranCompiler(FortranCompiler):
def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwags): def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwags):

Loading…
Cancel
Save