aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/compilers/detect.py12
-rw-r--r--mesonbuild/compilers/fortran.py20
-rw-r--r--mesonbuild/linkers/__init__.py2
-rw-r--r--mesonbuild/linkers/linkers.py30
4 files changed, 59 insertions, 5 deletions
diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py
index cd0f252..de1845a 100644
--- a/mesonbuild/compilers/detect.py
+++ b/mesonbuild/compilers/detect.py
@@ -34,6 +34,7 @@ from ..linkers import (
C2000Linker,
C2000DynamicLinker,
DLinker,
+ NAGDynamicLinker,
NvidiaHPC_DynamicLinker,
PGIDynamicLinker,
PGIStaticLinker,
@@ -774,9 +775,14 @@ def detect_fortran_compiler(env: 'Environment', for_machine: MachineChoice) -> C
exe_wrap, full_version=full_version, linker=linker)
if 'NAG Fortran' in err:
- linker = guess_nix_linker(env,
- compiler, NAGFortranCompiler, for_machine)
- return NAGFortranCompiler(
+ full_version = err.split('\n', 1)[0]
+ version = full_version.split()[-1]
+ cls = NAGFortranCompiler
+ env.coredata.add_lang_args(cls.language, cls, for_machine, env)
+ linker = NAGDynamicLinker(
+ 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)
diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py
index 00b0308..1a430a7 100644
--- a/mesonbuild/compilers/fortran.py
+++ b/mesonbuild/compilers/fortran.py
@@ -494,12 +494,28 @@ class NAGFortranCompiler(FortranCompiler):
is_cross, info, exe_wrapper, linker=linker,
full_version=full_version)
self.id = 'nagfor'
+ self.warn_args = {
+ '0': ['-w=all'],
+ '1': [],
+ '2': [],
+ '3': [],
+ }
- def get_warn_args(self, level: str) -> T.List[str]:
- return []
+ def get_always_args(self) -> T.List[str]:
+ return self.get_nagfor_quiet(self.version)
def get_module_outdir_args(self, path: str) -> T.List[str]:
return ['-mdir', path]
+ @staticmethod
+ def get_nagfor_quiet(version: str) -> T.List[str]:
+ return ['-quiet'] if version_compare(version, '>=7100') else []
+
+ def get_pic_args(self) -> T.List[str]:
+ return ['-PIC']
+
+ def get_std_exe_link_args(self) -> T.List[str]:
+ return self.get_always_args()
+
def openmp_flags(self) -> T.List[str]:
return ['-openmp']
diff --git a/mesonbuild/linkers/__init__.py b/mesonbuild/linkers/__init__.py
index 9182fa1..2e5217e 100644
--- a/mesonbuild/linkers/__init__.py
+++ b/mesonbuild/linkers/__init__.py
@@ -53,6 +53,7 @@ from .linkers import (
QualcommLLVMDynamicLinker,
PGIDynamicLinker,
NvidiaHPC_DynamicLinker,
+ NAGDynamicLinker,
VisualStudioLikeLinkerMixin,
MSVCDynamicLinker,
@@ -110,6 +111,7 @@ __all__ = [
'QualcommLLVMDynamicLinker',
'PGIDynamicLinker',
'NvidiaHPC_DynamicLinker',
+ 'NAGDynamicLinker',
'VisualStudioLikeLinkerMixin',
'MSVCDynamicLinker',
diff --git a/mesonbuild/linkers/linkers.py b/mesonbuild/linkers/linkers.py
index e84d0a4..58e4324 100644
--- a/mesonbuild/linkers/linkers.py
+++ b/mesonbuild/linkers/linkers.py
@@ -1045,6 +1045,36 @@ class QualcommLLVMDynamicLinker(LLVMDynamicLinker):
id = 'ld.qcld'
+class NAGDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker):
+
+ """NAG Fortran linker, ld via gcc indirection."""
+
+ id = 'nag'
+
+ def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str,
+ rpath_paths: str, build_rpath: str,
+ install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]:
+ if not rpath_paths and not install_rpath and not build_rpath:
+ return ([], set())
+ args = []
+ origin_placeholder = '$ORIGIN'
+ processed_rpaths = prepare_rpaths(rpath_paths, build_dir, from_dir)
+ all_paths = mesonlib.OrderedSet([os.path.join(origin_placeholder, p) for p in processed_rpaths])
+ if build_rpath != '':
+ all_paths.add(build_rpath)
+ for rp in all_paths:
+ args.extend(self._apply_prefix('-Wl,-Wl,,-rpath,,' + rp))
+
+ return (args, set())
+
+ def get_allow_undefined_args(self) -> T.List[str]:
+ return []
+
+ def get_std_shared_lib_args(self) -> T.List[str]:
+ from ..compilers import NAGFortranCompiler
+ return NAGFortranCompiler.get_nagfor_quiet(self.version) + ['-Wl,-shared']
+
+
class PGIDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker):
"""PGI linker."""