diff --git a/docs/markdown/Reference-tables.md b/docs/markdown/Reference-tables.md index 3be129fe1..55c1a99ab 100644 --- a/docs/markdown/Reference-tables.md +++ b/docs/markdown/Reference-tables.md @@ -25,6 +25,7 @@ These are return values of the `get_id` (Compiler family) and | mono | Xamarin C# compiler | | | msvc | Microsoft Visual Studio | msvc | | nagfor | The NAG Fortran compiler | | +| nvidia_hpc| NVidia HPC SDK compilers | | | open64 | The Open64 Fortran Compiler | | | pathscale | The Pathscale Fortran compiler | | | pgi | Portland PGI C/C++/Fortran compilers | | diff --git a/docs/markdown/snippets/add_nvidia_hpc_sdk_compilers.md b/docs/markdown/snippets/add_nvidia_hpc_sdk_compilers.md new file mode 100644 index 000000000..1d9acf92b --- /dev/null +++ b/docs/markdown/snippets/add_nvidia_hpc_sdk_compilers.md @@ -0,0 +1,3 @@ +## Added NVidia HPC SDK compilers + +Added support for `nvidia_hpc` NVidia HPC SDK compilers, which are currently in public beta testing. diff --git a/mesonbuild/compilers/__init__.py b/mesonbuild/compilers/__init__.py index fd47545d1..2e673da7a 100644 --- a/mesonbuild/compilers/__init__.py +++ b/mesonbuild/compilers/__init__.py @@ -85,6 +85,9 @@ __all__ = [ 'ObjCPPCompiler', 'Open64FortranCompiler', 'PathScaleFortranCompiler', + 'NvidiaHPC_CCompiler', + 'NvidiaHPC_CPPCompiler', + 'NvidiaHPC_FortranCompiler', 'PGICCompiler', 'PGICPPCompiler', 'PGIFortranCompiler', @@ -135,6 +138,7 @@ from .c import ( EmscriptenCCompiler, IntelCCompiler, IntelClCCompiler, + NvidiaHPC_CCompiler, PGICCompiler, CcrxCCompiler, Xc16CCompiler, @@ -153,6 +157,7 @@ from .cpp import ( EmscriptenCPPCompiler, IntelCPPCompiler, IntelClCPPCompiler, + NvidiaHPC_CPPCompiler, PGICPPCompiler, CcrxCPPCompiler, C2000CPPCompiler, @@ -177,6 +182,7 @@ from .fortran import ( NAGFortranCompiler, Open64FortranCompiler, PathScaleFortranCompiler, + NvidiaHPC_FortranCompiler, PGIFortranCompiler, SunFortranCompiler, ) diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 95851be1d..936b04c8b 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -255,6 +255,15 @@ class PGICCompiler(PGICompiler, CCompiler): PGICompiler.__init__(self) +class NvidiaHPC_CCompiler(PGICompiler, CCompiler): + def __init__(self, exelist, version, for_machine: MachineChoice, + is_cross, info: 'MachineInfo', exe_wrapper=None, **kwargs): + CCompiler.__init__(self, exelist, version, for_machine, is_cross, + info, exe_wrapper, **kwargs) + PGICompiler.__init__(self) + self.id = 'nvidia_hpc' + + class ElbrusCCompiler(GnuCCompiler, ElbrusCompiler): def __init__(self, exelist, version, for_machine: MachineChoice, is_cross, info: 'MachineInfo', exe_wrapper=None, diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index f2a160bc7..698c71ae0 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -156,7 +156,7 @@ class CPPCompiler(CLikeCompiler, Compiler): class ClangCPPCompiler(ClangCompiler, CPPCompiler): def __init__(self, exelist, version, for_machine: MachineChoice, is_cross, info: 'MachineInfo', exe_wrapper=None, - defines : T.Optional[T.List[str]] = None, **kwargs): + defines: T.Optional[T.List[str]] = None, **kwargs): CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, info, exe_wrapper, **kwargs) ClangCompiler.__init__(self, defines) @@ -240,8 +240,8 @@ class ArmclangCPPCompiler(ArmclangCompiler, CPPCompiler): def __init__(self, exelist, version, for_machine: MachineChoice, is_cross, info: 'MachineInfo', exe_wrapper=None, **kwargs): CPPCompiler.__init__(self, exelist=exelist, version=version, - for_machine=for_machine, is_cross=is_cross, - info=info, exe_wrapper=exe_wrapper, **kwargs) + for_machine=for_machine, is_cross=is_cross, + info=info, exe_wrapper=exe_wrapper, **kwargs) ArmclangCompiler.__init__(self) default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'] self.warn_args = {'0': [], @@ -305,7 +305,7 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler): 'std': coredata.UserComboOption( 'C++ language standard to use', ['none', 'c++98', 'c++03', 'c++11', 'c++14', 'c++17', 'c++1z', 'c++2a', - 'gnu++03', 'gnu++11', 'gnu++14', 'gnu++17', 'gnu++1z', 'gnu++2a'], + 'gnu++03', 'gnu++11', 'gnu++14', 'gnu++17', 'gnu++1z', 'gnu++2a'], 'none', ), 'debugstl': coredata.UserBooleanOption( @@ -356,6 +356,15 @@ class PGICPPCompiler(PGICompiler, CPPCompiler): PGICompiler.__init__(self) +class NvidiaHPC_CPPCompiler(PGICompiler, CPPCompiler): + def __init__(self, exelist, version, for_machine: MachineChoice, + is_cross, info: 'MachineInfo', exe_wrapper=None, **kwargs): + CPPCompiler.__init__(self, exelist, version, for_machine, is_cross, info, exe_wrapper, **kwargs) + PGICompiler.__init__(self) + + self.id = 'nvidia_hpc' + + class ElbrusCPPCompiler(GnuCPPCompiler, ElbrusCompiler): def __init__(self, exelist, version, for_machine: MachineChoice, is_cross, info: 'MachineInfo', exe_wrapper=None, diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index af83c0e56..7ca307381 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -418,6 +418,23 @@ class PGIFortranCompiler(PGICompiler, FortranCompiler): return ['-lpgf90rtl', '-lpgf90', '-lpgf90_rpm1', '-lpgf902', '-lpgf90rtl', '-lpgftnrtl', '-lrt'] + +class NvidiaHPC_FortranCompiler(PGICompiler, FortranCompiler): + def __init__(self, exelist, version, for_machine: MachineChoice, + is_cross, info: 'MachineInfo', exe_wrapper=None, + **kwargs): + FortranCompiler.__init__(self, exelist, version, for_machine, + is_cross, info, exe_wrapper, **kwargs) + PGICompiler.__init__(self) + + self.id = 'nvidia_hpc' + default_warn_args = ['-Minform=inform'] + self.warn_args = {'0': [], + '1': default_warn_args, + '2': default_warn_args, + '3': default_warn_args + ['-Mdclchk']} + + class FlangFortranCompiler(ClangCompiler, FortranCompiler): def __init__(self, exelist, version, for_machine: MachineChoice, is_cross, info: 'MachineInfo', exe_wrapper=None, diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index da2d513e6..18ecff4a4 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -58,6 +58,8 @@ from .linkers import ( QualcommLLVMDynamicLinker, MSVCDynamicLinker, OptlinkDynamicLinker, + NvidiaHPC_DynamicLinker, + NvidiaHPC_StaticLinker, PGIDynamicLinker, PGIStaticLinker, SolarisDynamicLinker, @@ -105,6 +107,9 @@ from .compilers import ( NAGFortranCompiler, Open64FortranCompiler, PathScaleFortranCompiler, + NvidiaHPC_CCompiler, + NvidiaHPC_CPPCompiler, + NvidiaHPC_FortranCompiler, PGICCompiler, PGICPPCompiler, PGIFortranCompiler, @@ -768,11 +773,11 @@ class Environment: self.default_objc = [] self.default_objcpp = [] else: - self.default_c = ['cc', 'gcc', 'clang', 'pgcc', 'icc'] - self.default_cpp = ['c++', 'g++', 'clang++', 'pgc++', 'icpc'] + self.default_c = ['cc', 'gcc', 'clang', 'nvc', 'pgcc', 'icc'] + self.default_cpp = ['c++', 'g++', 'clang++', 'nvc++', 'pgc++', 'icpc'] self.default_objc = ['cc', 'gcc', 'clang'] self.default_objcpp = ['c++', 'g++', 'clang++'] - self.default_fortran = ['gfortran', 'flang', 'pgfortran', 'ifort', 'g95'] + self.default_fortran = ['gfortran', 'flang', 'nvfortran', 'pgfortran', 'ifort', 'g95'] self.default_cs = ['mcs', 'csc'] self.default_d = ['ldc2', 'ldc', 'gdc', 'dmd'] self.default_java = ['javac'] @@ -1303,6 +1308,13 @@ class Environment: return cls( ccache + compiler, version, for_machine, is_cross, info, exe_wrap, linker=linker) + if 'NVIDIA Compilers and Tools' in out: + cls = NvidiaHPC_CCompiler if lang == 'c' else NvidiaHPC_CPPCompiler + self.coredata.add_lang_args(cls.language, cls, for_machine, self) + linker = NvidiaHPC_DynamicLinker(compiler, for_machine, cls.LINKER_PREFIX, [], version=version) + return cls( + ccache + compiler, version, for_machine, is_cross, + info, exe_wrap, linker=linker) if '(ICC)' in out: cls = IntelCCompiler if lang == 'c' else IntelCPPCompiler l = self._guess_nix_linker(compiler, cls, for_machine) @@ -1474,6 +1486,15 @@ class Environment: compiler, version, for_machine, is_cross, info, exe_wrap, full_version=full_version, linker=linker) + if 'NVIDIA Compilers and Tools' in out: + cls = NvidiaHPC_FortranCompiler + self.coredata.add_lang_args(cls.language, cls, for_machine, self) + linker = PGIDynamicLinker(compiler, for_machine, + cls.LINKER_PREFIX, [], version=version) + return cls( + compiler, version, for_machine, is_cross, info, exe_wrap, + full_version=full_version, linker=linker) + if 'flang' in out or 'clang' in out: linker = self._guess_nix_linker( compiler, FlangFortranCompiler, for_machine) diff --git a/mesonbuild/linkers.py b/mesonbuild/linkers.py index 3ce711137..505aef61b 100644 --- a/mesonbuild/linkers.py +++ b/mesonbuild/linkers.py @@ -712,7 +712,7 @@ class GnuDynamicLinker(GnuLikeDynamicLinkerMixin, PosixDynamicLinkerMixin, Dynam """Representation of GNU ld.bfd and ld.gold.""" def get_accepts_rsp(self) -> bool: - return True; + return True class GnuGoldDynamicLinker(GnuDynamicLinker): @@ -964,6 +964,8 @@ class PGIDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker): return (['-R' + os.path.join(build_dir, p) for p in rpath_paths], set()) return ([], set()) +NvidiaHPC_DynamicLinker = PGIDynamicLinker + class PGIStaticLinker(StaticLinker): def __init__(self, exelist: T.List[str]): @@ -977,6 +979,8 @@ class PGIStaticLinker(StaticLinker): def get_output_args(self, target: str) -> T.List[str]: return [target] +NvidiaHPC_StaticLinker = PGIStaticLinker + class VisualStudioLikeLinkerMixin: