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 | |
| open64 | The Open64 Fortran Compiler | |
| pathscale | The Pathscale Fortran compiler | |
| pgi | The Portland Fortran compiler | |
| pgi | Portland PGI C/C++/Fortran compilers | |
| rustc | Rust compiler | |
| sun | Sun Fortran 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',
'Open64FortranCompiler',
'PathScaleFortranCompiler',
'PGICCompiler',
'PGICPPCompiler',
'PGIFortranCompiler',
'RustCompiler',
'CcrxCCompiler',
@ -127,6 +129,7 @@ from .c import (
GnuCCompiler,
ElbrusCCompiler,
IntelCCompiler,
PGICCompiler,
CcrxCCompiler,
VisualStudioCCompiler,
)
@ -139,6 +142,7 @@ from .cpp import (
GnuCPPCompiler,
ElbrusCPPCompiler,
IntelCPPCompiler,
PGICPPCompiler,
CcrxCPPCompiler,
VisualStudioCPPCompiler,
)

@ -40,10 +40,12 @@ from .compilers import (
ClangCompiler,
Compiler,
CompilerArgs,
CompilerType,
CrossNoRunException,
GnuCompiler,
ElbrusCompiler,
IntelCompiler,
PGICompiler,
RunResult,
CcrxCompiler,
)
@ -1222,6 +1224,12 @@ class GnuCCompiler(GnuCompiler, CCompiler):
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):
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)

@ -14,6 +14,7 @@
import abc, contextlib, enum, os.path, re, tempfile, shlex
import subprocess
from typing import List
from ..linkers import StaticLinker
from .. import coredata
@ -166,6 +167,13 @@ msvc_buildtype_args = {'plain': [],
'custom': [],
}
pgi_buildtype_args = {'plain': [],
'debug': [],
'debugoptimized': [],
'release': [],
'minsize': [],
'custom': [],
}
apple_buildtype_linker_args = {'plain': [],
'debug': [],
'debugoptimized': [],
@ -197,6 +205,13 @@ ccrx_buildtype_linker_args = {'plain': [],
'minsize': [],
'custom': [],
}
pgi_buildtype_linker_args = {'plain': [],
'debug': [],
'debugoptimized': [],
'release': [],
'minsize': [],
'custom': [],
}
msvc_buildtype_linker_args = {'plain': [],
'debug': [],
@ -1601,7 +1616,7 @@ class GnuCompiler(GnuLikeCompiler):
class PGICompiler:
def __init__(self, compiler_type):
def __init__(self, compiler_type=None):
self.id = 'pgi'
self.compiler_type = compiler_type
@ -1610,18 +1625,41 @@ class PGICompiler:
'2': default_warn_args,
'3': default_warn_args}
def get_module_incdir_args(self):
return ('-module', )
def get_module_incdir_args(self) -> List[str]:
return ('-module', )
def get_no_warn_args(self) -> List[str]:
return ['-silent']
def get_no_warn_args(self):
return ['-silent']
def openmp_flags(self) -> List[str]:
return ['-mp']
def openmp_flags(self):
return ['-mp']
def get_buildtype_args(self, buildtype: str) -> List[str]:
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):
return []
def get_dependency_gen_args(self, outtarget, outfile):
return []
def get_always_args(self):
return []
class ElbrusCompiler(GnuCompiler):
# Elbrus compiler is nearly like GCC, but does not support

@ -23,10 +23,12 @@ from .c import CCompiler, VisualStudioCCompiler, ClangClCCompiler
from .compilers import (
gnu_winlibs,
msvc_winlibs,
CompilerType,
ClangCompiler,
GnuCompiler,
ElbrusCompiler,
IntelCompiler,
PGICompiler,
ArmCompiler,
ArmclangCompiler,
CcrxCompiler,
@ -232,6 +234,12 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler):
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):
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)

@ -376,12 +376,6 @@ class PGIFortranCompiler(PGICompiler, FortranCompiler):
FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwags)
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):
def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwags):
@ -393,7 +387,6 @@ class FlangFortranCompiler(ClangCompiler, FortranCompiler):
'2': default_warn_args,
'3': default_warn_args}
class Open64FortranCompiler(FortranCompiler):
def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwags):
FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwags)

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

Loading…
Cancel
Save