summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2019-09-05 23:45:54 +0300
committerGitHub <noreply@github.com>2019-09-05 23:45:54 +0300
commitd67d5411bb7fa00226365ebcfc475af08a4ba721 (patch)
treef0636ff994401375e4e1d38cb7d4559e58462d67
parent7b765155347005e01bdd9ae8bfdad7182f27f852 (diff)
parentb9af8f8b6b394903d64e4886712b38a056cd876f (diff)
downloadmeson-d67d5411bb7fa00226365ebcfc475af08a4ba721.tar.gz
Merge pull request #5823 from scivision/linker-pgi-linux
PGI compiler fixes
-rw-r--r--mesonbuild/backend/ninjabackend.py6
-rw-r--r--mesonbuild/compilers/mixins/pgi.py6
-rw-r--r--mesonbuild/environment.py5
-rw-r--r--mesonbuild/linkers.py16
-rwxr-xr-xrun_project_tests.py3
5 files changed, 31 insertions, 5 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 98f244dad..17b4986fd 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -28,7 +28,8 @@ from .. import build
from .. import mlog
from .. import dependencies
from .. import compilers
-from ..compilers import Compiler, CompilerArgs, CCompiler, VisualStudioLikeCompiler, FortranCompiler
+from ..compilers import (Compiler, CompilerArgs, CCompiler, FortranCompiler,
+ PGICCompiler, VisualStudioLikeCompiler)
from ..linkers import ArLinker
from ..mesonlib import (
File, LibType, MachineChoice, MesonException, OrderedSet, PerMachine, ProgressBar, quote_arg
@@ -234,6 +235,9 @@ class NinjaBackend(backends.Backend):
# IFort on windows is MSVC like, but doesn't have /showincludes
if isinstance(compiler, FortranCompiler):
continue
+ if isinstance(compiler, PGICCompiler) and mesonlib.is_windows():
+ # for the purpose of this function, PGI doesn't act enough like MSVC
+ return open(tempfilename, 'a', encoding='utf-8')
if isinstance(compiler, VisualStudioLikeCompiler):
break
else:
diff --git a/mesonbuild/compilers/mixins/pgi.py b/mesonbuild/compilers/mixins/pgi.py
index c13c7bc20..38c7ffdaf 100644
--- a/mesonbuild/compilers/mixins/pgi.py
+++ b/mesonbuild/compilers/mixins/pgi.py
@@ -56,7 +56,7 @@ class PGICompiler:
def get_pic_args(self) -> typing.List[str]:
# PGI -fPIC is Linux only.
- if self.compiler_type.is_linux_compiler():
+ if self.compiler_type.is_standard_compiler:
return ['-fPIC']
return []
@@ -97,3 +97,7 @@ class PGICompiler:
'-I{}'.format(hdr.parent)]
else:
return []
+
+ def thread_flags(self, env):
+ # PGI cannot accept -pthread, it's already threaded
+ return []
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index cf386dab5..6d5716b6d 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -51,6 +51,7 @@ from .linkers import (
MSVCDynamicLinker,
OptlinkDynamicLinker,
PGIDynamicLinker,
+ PGIStaticLinker,
SolarisDynamicLinker,
XildAppleDynamicLinker,
XildLinuxDynamicLinker,
@@ -1340,6 +1341,8 @@ class Environment:
elif isinstance(compiler, IntelClCCompiler):
# Intel has it's own linker that acts like microsoft's lib
linkers = ['xilib']
+ elif isinstance(compiler, (PGICCompiler, PGIFortranCompiler)) and mesonlib.is_windows():
+ linkers = [self.default_static_linker] # this is just a wrapper calling link/lib on Windows, keeping things simple.
else:
linkers = [self.default_static_linker]
popen_exceptions = {}
@@ -1357,6 +1360,8 @@ class Environment:
return IntelVisualStudioLinker(linker, getattr(compiler, 'machine', None))
if '/OUT:' in out.upper() or '/OUT:' in err.upper():
return VisualStudioLinker(linker, getattr(compiler, 'machine', None))
+ if 'ar-Error-Unknown switch: --version' in err:
+ return PGIStaticLinker(linker)
if p.returncode == 0 and ('armar' in linker or 'armar.exe' in linker):
return ArmarLinker(linker)
if 'DMD32 D Compiler' in out or 'DMD64 D Compiler' in out:
diff --git a/mesonbuild/linkers.py b/mesonbuild/linkers.py
index 8de254bfd..795a0a223 100644
--- a/mesonbuild/linkers.py
+++ b/mesonbuild/linkers.py
@@ -739,18 +739,30 @@ class PGIDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker):
# PGI -shared is Linux only.
if mesonlib.is_windows():
return ['-Bdynamic', '-Mmakedll']
- elif mesonlib.is_linux:
+ elif mesonlib.is_linux():
return ['-shared']
return []
def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str,
rpath_paths: str, build_rpath: str,
install_rpath: str) -> typing.List[str]:
- if env.machines[self.for_machine].is_windows():
+ if not env.machines[self.for_machine].is_windows():
return ['-R' + os.path.join(build_dir, p) for p in rpath_paths]
return []
+class PGIStaticLinker(StaticLinker):
+ def __init__(self, exelist: typing.List[str]):
+ super().__init__(exelist)
+ self.id = 'ar'
+ self.std_args = ['-r']
+
+ def get_std_link_args(self) -> typing.List[str]:
+ return self.std_args
+
+ def get_output_args(self, target: str) -> typing.List[str]:
+ return [target]
+
class VisualStudioLikeLinkerMixin:
_BUILDTYPE_ARGS = {
diff --git a/run_project_tests.py b/run_project_tests.py
index 2dff88584..10dc8c603 100755
--- a/run_project_tests.py
+++ b/run_project_tests.py
@@ -114,7 +114,8 @@ def get_relative_files_list_from_dir(fromdir: Path) -> typing.List[Path]:
def platform_fix_name(fname: str, compiler, env) -> str:
# canonicalize compiler
- if compiler in {'clang-cl', 'intel-cl'}:
+ if (compiler in {'clang-cl', 'intel-cl'} or
+ (env.machines.host.is_windows() and compiler == 'pgi')):
canonical_compiler = 'msvc'
else:
canonical_compiler = compiler