From 1c70bae952b511b1fc36ef7a3d7c06fe86911d7c Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Tue, 9 Apr 2019 13:37:17 -0400 Subject: order fortran compiler search order more sanely, remove unsupported compiler names --- mesonbuild/environment.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 0c0f00a..fa3d965 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -456,7 +456,8 @@ class Environment: # List of potential compilers. if mesonlib.is_windows(): self.default_c = ['cl', 'cc', 'gcc', 'clang', 'clang-cl', 'pgcc'] - self.default_cpp = ['cl', 'c++', 'g++', 'clang++', 'clang-cl', 'pgc++'] + # There is currently no pgc++ for Windows, only for Mac and Linux. + self.default_cpp = ['cl', 'c++', 'g++', 'clang++', 'clang-cl'] else: self.default_c = ['cc', 'gcc', 'clang', 'pgcc'] self.default_cpp = ['c++', 'g++', 'clang++', 'pgc++'] @@ -467,7 +468,7 @@ class Environment: self.default_objc = ['cc'] self.default_objcpp = ['c++'] self.default_d = ['ldc2', 'ldc', 'gdc', 'dmd'] - self.default_fortran = ['gfortran', 'g95', 'f95', 'f90', 'f77', 'ifort', 'pgfortran'] + self.default_fortran = ['gfortran', 'flang', 'pgfortran', 'ifort', 'g95'] self.default_java = ['javac'] self.default_cuda = ['nvcc'] self.default_rust = ['rustc'] @@ -1039,7 +1040,7 @@ 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 doesn\'t support %s as it\'s 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.' % exelist[-1]) + raise EnvironmentException('Meson doesn\'t support %s as it\'s 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.' % exelist[-1]) else: for d in self.default_d: if shutil.which(d): -- cgit v1.1 From efff0046512744969d7fa000da1dfab3bf29ad63 Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Tue, 9 Apr 2019 13:38:37 -0400 Subject: cleanup unused imports PEP8 --- mesonbuild/environment.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index fa3d965..697b596 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -12,14 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import configparser, os, platform, re, sys, shlex, shutil, subprocess -import typing +import os, platform, re, sys, shlex, shutil, subprocess from . import coredata from .linkers import ArLinker, ArmarLinker, VisualStudioLinker, DLinker, CcrxLinker from . import mesonlib from .mesonlib import ( - MesonException, EnvironmentException, MachineChoice, PerMachine, Popen_safe, + MesonException, EnvironmentException, MachineChoice, Popen_safe, ) from . import mlog @@ -38,7 +37,6 @@ from .compilers import ( is_source, ) from .compilers import ( - Compiler, ArmCCompiler, ArmCPPCompiler, ArmclangCCompiler, -- cgit v1.1 From 25fa5d090fab2522082280ea36484bd4ac9e9aa2 Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Tue, 9 Apr 2019 13:40:27 -0400 Subject: cleanup C/CXX compiler names, adding Intel like for Fortran --- mesonbuild/environment.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 697b596..57fe4e5 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -453,12 +453,13 @@ class Environment: # List of potential compilers. if mesonlib.is_windows(): - self.default_c = ['cl', 'cc', 'gcc', 'clang', 'clang-cl', 'pgcc'] + # Intel C and C++ compiler is icl on Windows, but icc and icpc elsewhere. + self.default_c = ['cl', 'cc', 'gcc', 'clang', 'clang-cl', 'pgcc', 'icl'] # There is currently no pgc++ for Windows, only for Mac and Linux. - self.default_cpp = ['cl', 'c++', 'g++', 'clang++', 'clang-cl'] + self.default_cpp = ['cl', 'c++', 'g++', 'clang++', 'clang-cl', 'icl'] else: - self.default_c = ['cc', 'gcc', 'clang', 'pgcc'] - self.default_cpp = ['c++', 'g++', 'clang++', 'pgc++'] + self.default_c = ['cc', 'gcc', 'clang', 'pgcc', 'icc'] + self.default_cpp = ['c++', 'g++', 'clang++', 'pgc++', 'icpc'] if mesonlib.is_windows(): self.default_cs = ['csc', 'mcs'] else: -- cgit v1.1 From ee40533b61ba9694e783e3333362e91fff964171 Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Sun, 7 Apr 2019 00:52:03 -0400 Subject: better default order for fotran compiler search correct PGI windows detection doc cleanup PGI detect --- mesonbuild/compilers/c.py | 4 ++-- mesonbuild/compilers/compilers.py | 15 +++++++++++---- mesonbuild/compilers/cpp.py | 4 ++-- mesonbuild/compilers/fortran.py | 4 ++-- mesonbuild/environment.py | 21 ++++++++++++++++++--- 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 94ef336..160e45d 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -1324,9 +1324,9 @@ class GnuCCompiler(GnuCompiler, CCompiler): class PGICCompiler(PGICompiler, CCompiler): - def __init__(self, exelist, version, 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) - PGICompiler.__init__(self, CompilerType.PGI_STANDARD) + PGICompiler.__init__(self, compiler_type) class ElbrusCCompiler(GnuCCompiler, ElbrusCompiler): diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 87a83e5..04cc31a 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -1397,18 +1397,20 @@ class CompilerType(enum.Enum): CCRX_WIN = 40 PGI_STANDARD = 50 + PGI_OSX = 51 + PGI_WIN = 52 @property def is_standard_compiler(self): - return self.name in ('GCC_STANDARD', 'CLANG_STANDARD', 'ICC_STANDARD') + return self.name in ('GCC_STANDARD', 'CLANG_STANDARD', 'ICC_STANDARD', 'PGI_STANDARD') @property def is_osx_compiler(self): - return self.name in ('GCC_OSX', 'CLANG_OSX', 'ICC_OSX') + return self.name in ('GCC_OSX', 'CLANG_OSX', 'ICC_OSX', 'PGI_OSX') @property def is_windows_compiler(self): - return self.name in ('GCC_MINGW', 'GCC_CYGWIN', 'CLANG_MINGW', 'ICC_WIN', 'ARM_WIN', 'CCRX_WIN') + return self.name in ('GCC_MINGW', 'GCC_CYGWIN', 'CLANG_MINGW', 'ICC_WIN', 'ARM_WIN', 'CCRX_WIN', 'PGI_WIN') def get_macos_dylib_install_name(prefix, shlib_name, suffix, soversion): @@ -1690,7 +1692,7 @@ class GnuCompiler(GnuLikeCompiler): class PGICompiler: - def __init__(self, compiler_type=None): + def __init__(self, compiler_type): self.id = 'pgi' self.compiler_type = compiler_type @@ -1706,6 +1708,11 @@ class PGICompiler: def get_no_warn_args(self) -> List[str]: return ['-silent'] + def get_pic_args(self) -> List[str]: + if self.compiler_type.is_osx_compiler or self.compiler_type.is_windows_compiler: + return [] # PGI -fPIC is Linux only. + return ['-fPIC'] + def openmp_flags(self) -> List[str]: return ['-mp'] diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index 87e6ffc..55be58d 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -238,9 +238,9 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler): class PGICPPCompiler(PGICompiler, CPPCompiler): - def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwargs): + def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None, **kwargs): CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs) - PGICompiler.__init__(self, CompilerType.PGI_STANDARD) + PGICompiler.__init__(self, compiler_type) class ElbrusCPPCompiler(GnuCPPCompiler, ElbrusCompiler): diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index 0f7c38e..dd54fd0 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -423,9 +423,9 @@ class PathScaleFortranCompiler(FortranCompiler): class PGIFortranCompiler(PGICompiler, FortranCompiler): - def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwags): + def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None, **kwags): FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwags) - PGICompiler.__init__(self, CompilerType.PGI_STANDARD) + PGICompiler.__init__(self, compiler_type) class FlangFortranCompiler(ClangCompiler, FortranCompiler): diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 57fe4e5..e0cb998 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -13,6 +13,7 @@ # 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 @@ -769,9 +770,16 @@ class Environment: target = 'x86' cls = VisualStudioCCompiler if lang == 'c' else VisualStudioCPPCompiler return cls(compiler, version, is_cross, exe_wrap, target) + if 'PGI Compilers' in out: + if mesonlib.for_darwin(want_cross, self): + compiler_type = CompilerType.PGI_OSX + elif mesonlib.for_windows(want_cross, self): + compiler_type = CompilerType.PGI_WIN + else: + compiler_type = CompilerType.PGI_STANDARD cls = PGICCompiler if lang == 'c' else PGICPPCompiler - return cls(ccache + compiler, version, is_cross, exe_wrap) + return cls(ccache + compiler, version, compiler_type, is_cross, exe_wrap) if '(ICC)' in out: if mesonlib.for_darwin(want_cross, self): compiler_type = CompilerType.ICC_OSX @@ -883,7 +891,13 @@ class Environment: return PathScaleFortranCompiler(compiler, version, is_cross, exe_wrap, full_version=full_version) if 'PGI Compilers' in out: - return PGIFortranCompiler(compiler, version, is_cross, exe_wrap, full_version=full_version) + if mesonlib.for_darwin(want_cross, self): + compiler_type = CompilerType.PGI_OSX + elif mesonlib.for_windows(want_cross, self): + compiler_type = CompilerType.PGI_WIN + else: + compiler_type = CompilerType.PGI_STANDARD + return PGIFortranCompiler(compiler, version, compiler_type, is_cross, exe_wrap, full_version=full_version) if 'flang' in out or 'clang' in out: return FlangFortranCompiler(compiler, version, is_cross, exe_wrap, full_version=full_version) @@ -1039,7 +1053,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 doesn\'t support %s as it\'s 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.' % exelist[-1]) + 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.') else: for d in self.default_d: if shutil.which(d): -- cgit v1.1 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 From 50f23815658bb704f454c83edfe2cc7e4e419628 Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Fri, 12 Apr 2019 01:21:00 -0400 Subject: enable Windows Intel compiler --- mesonbuild/environment.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index ff24795..bf2cce9 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -779,9 +779,9 @@ class Environment: return cls(compiler, version, is_cross, exe_wrap, target) if 'PGI Compilers' in out: - if mesonlib.for_darwin(want_cross, self): + if mesonlib.for_darwin(is_cross, self): compiler_type = CompilerType.PGI_OSX - elif mesonlib.for_windows(want_cross, self): + elif mesonlib.for_windows(is_cross, self): compiler_type = CompilerType.PGI_WIN else: compiler_type = CompilerType.PGI_STANDARD @@ -864,6 +864,13 @@ class Environment: popen_exceptions[' '.join(compiler + [arg])] = e continue + if mesonlib.for_windows(is_cross, self): + if 'ifort' 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 + version = search_version(out) full_version = out.split('\n', 1)[0] @@ -894,16 +901,16 @@ class Environment: version = search_version(err) return SunFortranCompiler(compiler, version, is_cross, exe_wrap, full_version=full_version) - if 'ifort (IFORT)' in out: + if 'ifort (IFORT)' in out or out.startswith('Intel(R) Visual Fortran'): return IntelFortranCompiler(compiler, version, is_cross, exe_wrap, full_version=full_version) if 'PathScale EKOPath(tm)' in err: return PathScaleFortranCompiler(compiler, version, is_cross, exe_wrap, full_version=full_version) if 'PGI Compilers' in out: - if mesonlib.for_darwin(want_cross, self): + if mesonlib.for_darwin(is_cross, self): compiler_type = CompilerType.PGI_OSX - elif mesonlib.for_windows(want_cross, self): + elif mesonlib.for_windows(is_cross, self): compiler_type = CompilerType.PGI_WIN else: compiler_type = CompilerType.PGI_STANDARD -- cgit v1.1