diff options
-rw-r--r-- | mesonbuild/compilers/fortran.py | 13 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/intel.py | 43 |
2 files changed, 40 insertions, 16 deletions
diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index 3003fcd..fdd6204 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -273,6 +273,7 @@ class SunFortranCompiler(FortranCompiler): class IntelFortranCompiler(IntelGnuLikeCompiler, FortranCompiler): + def __init__(self, exelist, version, for_machine: MachineChoice, is_cross, info: 'MachineInfo', exe_wrapper=None, **kwargs): @@ -326,15 +327,6 @@ 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, for_machine: MachineChoice, is_cross, target: str, info: 'MachineInfo', exe_wrapper=None, **kwargs): @@ -367,9 +359,6 @@ class IntelClFortranCompiler(IntelVisualStudioLikeCompiler, FortranCompiler): 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): def __init__(self, exelist, version, for_machine: MachineChoice, 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] |