Add PGI C and C++ compilers (#4803)

pull/4816/head
Michael Hirsch, Ph.D 6 years ago committed by Jussi Pakkanen
parent 20248fa919
commit 72486afd08
  1. 2
      docs/markdown/Reference-tables.md
  2. 6
      docs/markdown/snippets/pgi_compilers.md
  3. 4
      mesonbuild/compilers/__init__.py
  4. 8
      mesonbuild/compilers/c.py
  5. 52
      mesonbuild/compilers/compilers.py
  6. 8
      mesonbuild/compilers/cpp.py
  7. 7
      mesonbuild/compilers/fortran.py
  8. 14
      mesonbuild/environment.py

@ -24,7 +24,7 @@ These are return values of the `get_id` (Compiler family) and
| nagfor | The NAG Fortran compiler | | | nagfor | The NAG Fortran compiler | |
| open64 | The Open64 Fortran Compiler | | | open64 | The Open64 Fortran Compiler | |
| pathscale | The Pathscale Fortran compiler | | | pathscale | The Pathscale Fortran compiler | |
| pgi | The Portland Fortran compiler | | | pgi | Portland PGI C/C++/Fortran compilers | |
| rustc | Rust compiler | | | rustc | Rust compiler | |
| sun | Sun Fortran compiler | | | sun | Sun Fortran compiler | |
| valac | Vala compiler | | | valac | Vala compiler | |

@ -0,0 +1,6 @@
## Added PGI compiler support
Nvidia / PGI C, C++ and Fortran [no-cost](https://www.pgroup.com/products/community.htm) compilers are now supported.
They have been tested on Linux so far.

@ -78,6 +78,8 @@ __all__ = [
'ObjCPPCompiler', 'ObjCPPCompiler',
'Open64FortranCompiler', 'Open64FortranCompiler',
'PathScaleFortranCompiler', 'PathScaleFortranCompiler',
'PGICCompiler',
'PGICPPCompiler',
'PGIFortranCompiler', 'PGIFortranCompiler',
'RustCompiler', 'RustCompiler',
'CcrxCCompiler', 'CcrxCCompiler',
@ -127,6 +129,7 @@ from .c import (
GnuCCompiler, GnuCCompiler,
ElbrusCCompiler, ElbrusCCompiler,
IntelCCompiler, IntelCCompiler,
PGICCompiler,
CcrxCCompiler, CcrxCCompiler,
VisualStudioCCompiler, VisualStudioCCompiler,
) )
@ -139,6 +142,7 @@ from .cpp import (
GnuCPPCompiler, GnuCPPCompiler,
ElbrusCPPCompiler, ElbrusCPPCompiler,
IntelCPPCompiler, IntelCPPCompiler,
PGICPPCompiler,
CcrxCPPCompiler, CcrxCPPCompiler,
VisualStudioCPPCompiler, VisualStudioCPPCompiler,
) )

@ -40,10 +40,12 @@ from .compilers import (
ClangCompiler, ClangCompiler,
Compiler, Compiler,
CompilerArgs, CompilerArgs,
CompilerType,
CrossNoRunException, CrossNoRunException,
GnuCompiler, GnuCompiler,
ElbrusCompiler, ElbrusCompiler,
IntelCompiler, IntelCompiler,
PGICompiler,
RunResult, RunResult,
CcrxCompiler, CcrxCompiler,
) )
@ -1222,6 +1224,12 @@ class GnuCCompiler(GnuCompiler, CCompiler):
return ['-fpch-preprocess', '-include', os.path.basename(header)] return ['-fpch-preprocess', '-include', os.path.basename(header)]
class PGICCompiler(PGICompiler, CCompiler):
def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwargs):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs)
PGICompiler.__init__(self, CompilerType.PGI_STANDARD)
class ElbrusCCompiler(GnuCCompiler, ElbrusCompiler): class ElbrusCCompiler(GnuCCompiler, ElbrusCompiler):
def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None, defines=None, **kwargs): def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None, defines=None, **kwargs):
GnuCCompiler.__init__(self, exelist, version, compiler_type, is_cross, exe_wrapper, defines, **kwargs) GnuCCompiler.__init__(self, exelist, version, compiler_type, is_cross, exe_wrapper, defines, **kwargs)

@ -14,6 +14,7 @@
import abc, contextlib, enum, os.path, re, tempfile, shlex import abc, contextlib, enum, os.path, re, tempfile, shlex
import subprocess import subprocess
from typing import List
from ..linkers import StaticLinker from ..linkers import StaticLinker
from .. import coredata from .. import coredata
@ -166,6 +167,13 @@ msvc_buildtype_args = {'plain': [],
'custom': [], 'custom': [],
} }
pgi_buildtype_args = {'plain': [],
'debug': [],
'debugoptimized': [],
'release': [],
'minsize': [],
'custom': [],
}
apple_buildtype_linker_args = {'plain': [], apple_buildtype_linker_args = {'plain': [],
'debug': [], 'debug': [],
'debugoptimized': [], 'debugoptimized': [],
@ -197,6 +205,13 @@ ccrx_buildtype_linker_args = {'plain': [],
'minsize': [], 'minsize': [],
'custom': [], 'custom': [],
} }
pgi_buildtype_linker_args = {'plain': [],
'debug': [],
'debugoptimized': [],
'release': [],
'minsize': [],
'custom': [],
}
msvc_buildtype_linker_args = {'plain': [], msvc_buildtype_linker_args = {'plain': [],
'debug': [], 'debug': [],
@ -1601,7 +1616,7 @@ class GnuCompiler(GnuLikeCompiler):
class PGICompiler: class PGICompiler:
def __init__(self, compiler_type): def __init__(self, compiler_type=None):
self.id = 'pgi' self.id = 'pgi'
self.compiler_type = compiler_type self.compiler_type = compiler_type
@ -1610,18 +1625,41 @@ class PGICompiler:
'2': default_warn_args, '2': default_warn_args,
'3': default_warn_args} '3': default_warn_args}
def get_module_incdir_args(self): def get_module_incdir_args(self) -> List[str]:
return ('-module', ) return ('-module', )
def get_no_warn_args(self) -> List[str]:
return ['-silent']
def get_no_warn_args(self): def openmp_flags(self) -> List[str]:
return ['-silent'] return ['-mp']
def openmp_flags(self): def get_buildtype_args(self, buildtype: str) -> List[str]:
return ['-mp'] return pgi_buildtype_args[buildtype]
def get_buildtype_linker_args(self, buildtype: str) -> List[str]:
return pgi_buildtype_linker_args[buildtype]
def get_optimization_args(self, optimization_level: str) -> List[str]:
return clike_optimization_args[optimization_level]
def get_debug_args(self, is_debug: bool) -> List[str]:
return clike_debug_args[is_debug]
def compute_parameters_with_absolute_paths(self, parameter_list: List[str], build_dir: str):
for idx, i in enumerate(parameter_list):
if i[:2] == '-I' or i[:2] == '-L':
parameter_list[idx] = i[:2] + os.path.normpath(os.path.join(build_dir, i[2:]))
def get_allow_undefined_link_args(self): def get_allow_undefined_link_args(self):
return [] return []
def get_dependency_gen_args(self, outtarget, outfile):
return []
def get_always_args(self):
return []
class ElbrusCompiler(GnuCompiler): class ElbrusCompiler(GnuCompiler):
# Elbrus compiler is nearly like GCC, but does not support # Elbrus compiler is nearly like GCC, but does not support

@ -23,10 +23,12 @@ from .c import CCompiler, VisualStudioCCompiler, ClangClCCompiler
from .compilers import ( from .compilers import (
gnu_winlibs, gnu_winlibs,
msvc_winlibs, msvc_winlibs,
CompilerType,
ClangCompiler, ClangCompiler,
GnuCompiler, GnuCompiler,
ElbrusCompiler, ElbrusCompiler,
IntelCompiler, IntelCompiler,
PGICompiler,
ArmCompiler, ArmCompiler,
ArmclangCompiler, ArmclangCompiler,
CcrxCompiler, CcrxCompiler,
@ -232,6 +234,12 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler):
return ['-lstdc++'] return ['-lstdc++']
class PGICPPCompiler(PGICompiler, CPPCompiler):
def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwargs):
CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs)
PGICompiler.__init__(self, CompilerType.PGI_STANDARD)
class ElbrusCPPCompiler(GnuCPPCompiler, ElbrusCompiler): class ElbrusCPPCompiler(GnuCPPCompiler, ElbrusCompiler):
def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None, defines=None, **kwargs): def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None, defines=None, **kwargs):
GnuCPPCompiler.__init__(self, exelist, version, compiler_type, is_cross, exe_wrapper, defines, **kwargs) GnuCPPCompiler.__init__(self, exelist, version, compiler_type, is_cross, exe_wrapper, defines, **kwargs)

@ -376,12 +376,6 @@ class PGIFortranCompiler(PGICompiler, FortranCompiler):
FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwags) FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwags)
PGICompiler.__init__(self, CompilerType.PGI_STANDARD) PGICompiler.__init__(self, CompilerType.PGI_STANDARD)
def get_always_args(self):
"""PGI doesn't have -pipe."""
val = super().get_always_args()
val.remove('-pipe')
return val
class FlangFortranCompiler(ClangCompiler, FortranCompiler): class FlangFortranCompiler(ClangCompiler, FortranCompiler):
def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwags): def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwags):
@ -393,7 +387,6 @@ class FlangFortranCompiler(ClangCompiler, FortranCompiler):
'2': default_warn_args, '2': default_warn_args,
'3': default_warn_args} '3': default_warn_args}
class Open64FortranCompiler(FortranCompiler): class Open64FortranCompiler(FortranCompiler):
def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwags): def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwags):
FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwags) FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwags)

@ -63,6 +63,8 @@ from .compilers import (
NAGFortranCompiler, NAGFortranCompiler,
Open64FortranCompiler, Open64FortranCompiler,
PathScaleFortranCompiler, PathScaleFortranCompiler,
PGICCompiler,
PGICPPCompiler,
PGIFortranCompiler, PGIFortranCompiler,
RustCompiler, RustCompiler,
CcrxCCompiler, CcrxCCompiler,
@ -394,11 +396,11 @@ class Environment:
# List of potential compilers. # List of potential compilers.
if mesonlib.is_windows(): if mesonlib.is_windows():
self.default_c = ['cl', 'cc', 'gcc', 'clang', 'clang-cl'] self.default_c = ['cl', 'cc', 'gcc', 'clang', 'clang-cl', 'pgcc']
self.default_cpp = ['cl', 'c++', 'g++', 'clang++', 'clang-cl'] self.default_cpp = ['cl', 'c++', 'g++', 'clang++', 'clang-cl', 'pgc++']
else: else:
self.default_c = ['cc', 'gcc', 'clang'] self.default_c = ['cc', 'gcc', 'clang', 'pgcc']
self.default_cpp = ['c++', 'g++', 'clang++'] self.default_cpp = ['c++', 'g++', 'clang++', 'pgc++']
if mesonlib.is_windows(): if mesonlib.is_windows():
self.default_cs = ['csc', 'mcs'] self.default_cs = ['csc', 'mcs']
else: else:
@ -582,6 +584,7 @@ class Environment:
def _detect_c_or_cpp_compiler(self, lang, want_cross): def _detect_c_or_cpp_compiler(self, lang, want_cross):
popen_exceptions = {} popen_exceptions = {}
compilers, ccache, is_cross, exe_wrap = self._get_compilers(lang, want_cross) compilers, ccache, is_cross, exe_wrap = self._get_compilers(lang, want_cross)
for compiler in compilers: for compiler in compilers:
if isinstance(compiler, str): if isinstance(compiler, str):
compiler = [compiler] compiler = [compiler]
@ -704,6 +707,9 @@ class Environment:
target = 'x86' target = 'x86'
cls = VisualStudioCCompiler if lang == 'c' else VisualStudioCPPCompiler cls = VisualStudioCCompiler if lang == 'c' else VisualStudioCPPCompiler
return cls(compiler, version, is_cross, exe_wrap, target) return cls(compiler, version, is_cross, exe_wrap, target)
if 'PGI Compilers' in out:
cls = PGICCompiler if lang == 'c' else PGICPPCompiler
return cls(ccache + compiler, version, is_cross, exe_wrap)
if '(ICC)' in out: if '(ICC)' in out:
if mesonlib.for_darwin(want_cross, self): if mesonlib.for_darwin(want_cross, self):
compiler_type = CompilerType.ICC_OSX compiler_type = CompilerType.ICC_OSX

Loading…
Cancel
Save