summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2019-07-02 14:36:08 -0700
committerDylan Baker <dylan@pnwbakers.com>2019-07-15 10:59:22 -0700
commitb8368c1617b106d84c1a0ba4c9e91951b776c654 (patch)
tree992fd78201db8fc6ff91a76e72b1edf4310e653c
parent488e852e7063ccb3efc79286f9c3447d4007ec8c (diff)
downloadmeson-b8368c1617b106d84c1a0ba4c9e91951b776c654.tar.gz
compilers: Put Intel compiler classes into the mixins folder
-rw-r--r--mesonbuild/compilers/__init__.py5
-rw-r--r--mesonbuild/compilers/c.py3
-rw-r--r--mesonbuild/compilers/compilers.py100
-rw-r--r--mesonbuild/compilers/cpp.py3
-rw-r--r--mesonbuild/compilers/fortran.py3
-rw-r--r--mesonbuild/compilers/mixins/intel.py134
6 files changed, 139 insertions, 109 deletions
diff --git a/mesonbuild/compilers/__init__.py b/mesonbuild/compilers/__init__.py
index ac3f16080..0be9ed4c9 100644
--- a/mesonbuild/compilers/__init__.py
+++ b/mesonbuild/compilers/__init__.py
@@ -120,8 +120,6 @@ from .compilers import (
sort_clink,
ClangCompiler,
CompilerArgs,
- IntelGnuLikeCompiler,
- IntelVisualStudioLikeCompiler,
)
from .c import (
CCompiler,
@@ -188,4 +186,5 @@ from .rust import RustCompiler
from .swift import SwiftCompiler
from .vala import ValaCompiler
from .mixins.visualstudio import VisualStudioLikeCompiler
-from .mixins.gnu import GnuCompiler, get_macos_dylib_install_name \ No newline at end of file
+from .mixins.gnu import GnuCompiler, get_macos_dylib_install_name
+from .mixins.intel import IntelGnuLikeCompiler, IntelVisualStudioLikeCompiler
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index 3a7c1f9c8..3d7c7794e 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -23,6 +23,7 @@ from .mixins.ccrx import CcrxCompiler
from .mixins.arm import ArmCompiler
from .mixins.visualstudio import VisualStudioLikeCompiler
from .mixins.gnu import GnuCompiler
+from .mixins.intel import IntelGnuLikeCompiler, IntelVisualStudioLikeCompiler
from .compilers import (
gnu_winlibs,
msvc_winlibs,
@@ -31,8 +32,6 @@ from .compilers import (
Compiler,
CompilerType,
ElbrusCompiler,
- IntelGnuLikeCompiler,
- IntelVisualStudioLikeCompiler,
PGICompiler,
)
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index ed41c2e6f..1dcf9437c 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -27,7 +27,6 @@ from ..mesonlib import (
from ..envconfig import (
Properties,
)
-from .mixins.visualstudio import VisualStudioLikeCompiler
from .mixins.gnu import GnuCompiler, GnuLikeCompiler
"""This file contains the data files of all compilers Meson knows
@@ -1560,102 +1559,3 @@ class ArmclangCompiler:
parameter_list[idx] = i[:2] + os.path.normpath(os.path.join(build_dir, i[2:]))
return parameter_list
-
-
-# Tested on linux for ICC 14.0.3, 15.0.6, 16.0.4, 17.0.1, 19.0.0
-class IntelGnuLikeCompiler(GnuLikeCompiler):
-
- def __init__(self, compiler_type):
- super().__init__(compiler_type)
- # As of 19.0.0 ICC doesn't have sanitizer, color, or lto support.
- #
- # It does have IPO, which serves much the same purpose as LOT, but
- # there is an unfortunate rule for using IPO (you can't control the
- # name of the output file) which break assumptions meson makes
- self.base_options = ['b_pch', 'b_lundef', 'b_asneeded', 'b_pgo',
- 'b_coverage', 'b_ndebug', 'b_staticpic', 'b_pie']
- self.id = 'intel'
- self.lang_header = 'none'
-
- def get_optimization_args(self, optimization_level):
- return clike_optimization_args[optimization_level]
-
- def get_pch_suffix(self) -> str:
- return 'pchi'
-
- def get_pch_use_args(self, pch_dir, header):
- return ['-pch', '-pch_dir', os.path.join(pch_dir), '-x',
- self.lang_header, '-include', header, '-x', 'none']
-
- def get_pch_name(self, header_name):
- return os.path.basename(header_name) + '.' + self.get_pch_suffix()
-
- def openmp_flags(self) -> List[str]:
- if version_compare(self.version, '>=15.0.0'):
- return ['-qopenmp']
- else:
- return ['-openmp']
-
- def compiles(self, *args, **kwargs):
- # This covers a case that .get('foo', []) doesn't, that extra_args is
- # defined and is None
- extra_args = kwargs.get('extra_args') or []
- kwargs['extra_args'] = [
- extra_args,
- '-diag-error', '10006', # ignoring unknown option
- '-diag-error', '10148', # Option not supported
- '-diag-error', '10155', # ignoring argument required
- '-diag-error', '10156', # ignoring not argument allowed
- '-diag-error', '10157', # Ignoring argument of the wrong type
- '-diag-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
- '-diag-error', '1292', # unknown __attribute__
- ]
- return super().compiles(*args, **kwargs)
-
- def get_profile_generate_args(self):
- return ['-prof-gen=threadsafe']
-
- def get_profile_use_args(self):
- 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']
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
index 67a574892..89d7197d8 100644
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -26,8 +26,6 @@ from .compilers import (
msvc_winlibs,
ClangCompiler,
ElbrusCompiler,
- IntelGnuLikeCompiler,
- IntelVisualStudioLikeCompiler,
PGICompiler,
ArmclangCompiler,
Compiler,
@@ -38,6 +36,7 @@ from .mixins.ccrx import CcrxCompiler
from .mixins.arm import ArmCompiler
from .mixins.visualstudio import VisualStudioLikeCompiler
from .mixins.gnu import GnuCompiler
+from .mixins.intel import IntelGnuLikeCompiler, IntelVisualStudioLikeCompiler
def non_msvc_eh_options(eh, args):
diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py
index 12f2dbf28..b10d279c4 100644
--- a/mesonbuild/compilers/fortran.py
+++ b/mesonbuild/compilers/fortran.py
@@ -21,15 +21,14 @@ from .compilers import (
Compiler,
ClangCompiler,
ElbrusCompiler,
- IntelGnuLikeCompiler,
PGICompiler,
- IntelVisualStudioLikeCompiler,
)
from .mixins.clike import CLikeCompiler
from .mixins.gnu import (
GnuCompiler, apple_buildtype_linker_args, gnulike_buildtype_args,
gnulike_buildtype_linker_args, gnu_optimization_args,
)
+from .mixins.intel import IntelGnuLikeCompiler, IntelVisualStudioLikeCompiler
from .. import mlog
from mesonbuild.mesonlib import (
diff --git a/mesonbuild/compilers/mixins/intel.py b/mesonbuild/compilers/mixins/intel.py
new file mode 100644
index 000000000..c02f611d2
--- /dev/null
+++ b/mesonbuild/compilers/mixins/intel.py
@@ -0,0 +1,134 @@
+# Copyright 2019 The meson development team
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Abstractions for the Intel Compiler families.
+
+Intel provides both a posix/gcc-like compiler (ICC) and an msvc-like compiler
+(ICL).
+"""
+
+import os
+import typing
+
+from ... import mesonlib
+from .gnu import GnuLikeCompiler
+from .visualstudio import VisualStudioLikeCompiler
+
+# XXX: avoid circular dependencies
+clike_optimization_args = {'0': [],
+ 'g': [],
+ '1': ['-O1'],
+ '2': ['-O2'],
+ '3': ['-O3'],
+ 's': ['-Os'],
+ }
+
+
+# Tested on linux for ICC 14.0.3, 15.0.6, 16.0.4, 17.0.1, 19.0.0
+class IntelGnuLikeCompiler(GnuLikeCompiler):
+
+ def __init__(self, compiler_type):
+ super().__init__(compiler_type)
+ # As of 19.0.0 ICC doesn't have sanitizer, color, or lto support.
+ #
+ # It does have IPO, which serves much the same purpose as LOT, but
+ # there is an unfortunate rule for using IPO (you can't control the
+ # name of the output file) which break assumptions meson makes
+ self.base_options = ['b_pch', 'b_lundef', 'b_asneeded', 'b_pgo',
+ 'b_coverage', 'b_ndebug', 'b_staticpic', 'b_pie']
+ self.id = 'intel'
+ self.lang_header = 'none'
+
+ def get_optimization_args(self, optimization_level):
+ return clike_optimization_args[optimization_level]
+
+ def get_pch_suffix(self) -> str:
+ return 'pchi'
+
+ def get_pch_use_args(self, pch_dir, header):
+ return ['-pch', '-pch_dir', os.path.join(pch_dir), '-x',
+ self.lang_header, '-include', header, '-x', 'none']
+
+ def get_pch_name(self, header_name):
+ return os.path.basename(header_name) + '.' + self.get_pch_suffix()
+
+ def openmp_flags(self) -> typing.List[str]:
+ if mesonlib.version_compare(self.version, '>=15.0.0'):
+ return ['-qopenmp']
+ else:
+ return ['-openmp']
+
+ def compiles(self, *args, **kwargs):
+ # This covers a case that .get('foo', []) doesn't, that extra_args is
+ # defined and is None
+ extra_args = kwargs.get('extra_args') or []
+ kwargs['extra_args'] = [
+ extra_args,
+ '-diag-error', '10006', # ignoring unknown option
+ '-diag-error', '10148', # Option not supported
+ '-diag-error', '10155', # ignoring argument required
+ '-diag-error', '10156', # ignoring not argument allowed
+ '-diag-error', '10157', # Ignoring argument of the wrong type
+ '-diag-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
+ '-diag-error', '1292', # unknown __attribute__
+ ]
+ return super().compiles(*args, **kwargs)
+
+ def get_profile_generate_args(self):
+ return ['-prof-gen=threadsafe']
+
+ def get_profile_use_args(self):
+ 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) -> typing.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 = mesonlib.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']