diff options
author | Michael Hirsch, Ph.D <scivision@users.noreply.github.com> | 2019-12-02 11:22:18 -0500 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-12-04 21:48:34 +0200 |
commit | b1c8f765fa6e2af0d185d2a20dc68c7567c916eb (patch) | |
tree | 633b67aa672ea615f8cee6b020559bee8e64f5c1 /mesonbuild/compilers/mixins/intel.py | |
parent | 41bebebb7bb146976806bf45bc32ded34b05ca87 (diff) | |
download | meson-b1c8f765fa6e2af0d185d2a20dc68c7567c916eb.zip meson-b1c8f765fa6e2af0d185d2a20dc68c7567c916eb.tar.gz meson-b1c8f765fa6e2af0d185d2a20dc68c7567c916eb.tar.bz2 |
intel/intel-cl: use appropriate buildtype options
This puts appropriate default options across buildtype for Intel and
Intel-Cl compilers, for C, C++ and Fortran. Prior to this PR, the
behavior of Intel compilers vs. GNUlike was not the same, in
particular, debug traceback available by default for GNUlike compilers
was not present with Intel compilers.
Diffstat (limited to 'mesonbuild/compilers/mixins/intel.py')
-rw-r--r-- | mesonbuild/compilers/mixins/intel.py | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/mesonbuild/compilers/mixins/intel.py b/mesonbuild/compilers/mixins/intel.py index 72c6fdf..cf26a14 100644 --- a/mesonbuild/compilers/mixins/intel.py +++ b/mesonbuild/compilers/mixins/intel.py @@ -14,8 +14,10 @@ """Abstractions for the Intel Compiler families. -Intel provides both a posix/gcc-like compiler (ICC) and an msvc-like compiler -(ICL). +Intel provides both a posix/gcc-like compiler (ICC) for MacOS and Linux, +with Meson mixin IntelGnuLikeCompiler. +For Windows, the Intel msvc-like compiler (ICL) Meson mixin +is IntelVisualStudioLikeCompiler. """ import os @@ -30,9 +32,18 @@ if typing.TYPE_CHECKING: # XXX: avoid circular dependencies # TODO: this belongs in a posix compiler class +# NOTE: the default Intel optimization is -O2, unlike GNU which defaults to -O0. +# this can be surprising, particularly for debug builds, so we specify the +# default as -O0. +# https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-o +# https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-g +# https://software.intel.com/en-us/fortran-compiler-developer-guide-and-reference-o +# https://software.intel.com/en-us/fortran-compiler-developer-guide-and-reference-g +# https://software.intel.com/en-us/fortran-compiler-developer-guide-and-reference-traceback +# https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html clike_optimization_args = { - '0': [], - 'g': [], + '0': ['-O0'], + 'g': ['-O0'], '1': ['-O1'], '2': ['-O2'], '3': ['-O3'], @@ -43,6 +54,15 @@ clike_optimization_args = { # Tested on linux for ICC 14.0.3, 15.0.6, 16.0.4, 17.0.1, 19.0.0 class IntelGnuLikeCompiler(GnuLikeCompiler): + BUILD_ARGS = { + 'plain': [], + 'debug': ["-g", "-O0", "-traceback"], + 'debugoptimized': ["-g", "-O1", "-traceback"], + 'release': ["-O2"], + 'minsize': ["-Os"], + 'custom': [], + } + def __init__(self): super().__init__() # As of 19.0.0 ICC doesn't have sanitizer, color, or lto support. @@ -96,11 +116,23 @@ class IntelGnuLikeCompiler(GnuLikeCompiler): def get_profile_use_args(self) -> typing.List[str]: return ['-prof-use'] + def get_buildtype_args(self, buildtype: str) -> typing.List[str]: + return self.BUILD_ARGS[buildtype] + class IntelVisualStudioLikeCompiler(VisualStudioLikeCompiler): """Abstractions for ICL, the Intel compiler on Windows.""" + BUILD_ARGS = { + 'plain': [], + 'debug': ["/Zi", "/Od", "/traceback"], + 'debugoptimized': ["/Zi", "/O1", "/traceback"], + 'release': ["/O2"], + 'minsize': ["/Os"], + 'custom': [], + } + def __init__(self, target: str): super().__init__(target) self.id = 'intel-cl' @@ -133,3 +165,6 @@ class IntelVisualStudioLikeCompiler(VisualStudioLikeCompiler): def openmp_flags(self) -> typing.List[str]: return ['/Qopenmp'] + + def get_buildtype_args(self, buildtype: str) -> typing.List[str]: + return self.BUILD_ARGS[buildtype] |