aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2020-08-25 23:58:17 +0300
committerGitHub <noreply@github.com>2020-08-25 23:58:17 +0300
commit3a25efc056c00da3fe10240757e3ae538fd57435 (patch)
tree1c6256b0445f8ef49a230fc02a3c1eb396e60c68 /mesonbuild
parent1de1cc22e2fcc56860ee8174e375070c062f5b30 (diff)
parent1b2708eb79a5475dae23b6911021a490b52ea9fc (diff)
downloadmeson-3a25efc056c00da3fe10240757e3ae538fd57435.zip
meson-3a25efc056c00da3fe10240757e3ae538fd57435.tar.gz
meson-3a25efc056c00da3fe10240757e3ae538fd57435.tar.bz2
Merge pull request #7581 from peterh/aix
Add AIX support
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/compilers/mixins/clike.py2
-rw-r--r--mesonbuild/environment.py21
-rw-r--r--mesonbuild/linkers.py44
-rw-r--r--mesonbuild/mesonlib.py3
4 files changed, 65 insertions, 5 deletions
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py
index 4311fa5..77395bf 100644
--- a/mesonbuild/compilers/mixins/clike.py
+++ b/mesonbuild/compilers/mixins/clike.py
@@ -1037,7 +1037,7 @@ class CLikeCompiler:
if ((not extra_dirs and libtype is LibType.PREFER_SHARED) or
libname in self.internal_libs):
cargs = ['-l' + libname]
- largs = self.get_allow_undefined_link_args()
+ largs = self.get_linker_always_args() + self.get_allow_undefined_link_args()
extra_args = cargs + self.linker_to_compiler_args(largs)
if self.links(code, env, extra_args=extra_args, disable_cache=True)[0]:
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index eee336e..f1bd2e1 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -19,7 +19,7 @@ import typing as T
import collections
from . import coredata
-from .linkers import ArLinker, ArmarLinker, VisualStudioLinker, DLinker, CcrxLinker, Xc16Linker, C2000Linker, IntelVisualStudioLinker
+from .linkers import ArLinker, ArmarLinker, VisualStudioLinker, DLinker, CcrxLinker, Xc16Linker, C2000Linker, IntelVisualStudioLinker, AIXArLinker
from . import mesonlib
from .mesonlib import (
MesonException, EnvironmentException, MachineChoice, Popen_safe,
@@ -63,6 +63,7 @@ from .linkers import (
PGIDynamicLinker,
PGIStaticLinker,
SolarisDynamicLinker,
+ AIXDynamicLinker,
XilinkDynamicLinker,
CudaLinker,
VisualStudioLikeLinkerMixin,
@@ -345,7 +346,7 @@ def detect_cpu_family(compilers: CompilersDict) -> str:
"""
if mesonlib.is_windows():
trial = detect_windows_arch(compilers)
- elif mesonlib.is_freebsd() or mesonlib.is_netbsd() or mesonlib.is_openbsd() or mesonlib.is_qnx():
+ elif mesonlib.is_freebsd() or mesonlib.is_netbsd() or mesonlib.is_openbsd() or mesonlib.is_qnx() or mesonlib.is_aix():
trial = platform.processor().lower()
else:
trial = platform.machine().lower()
@@ -385,6 +386,10 @@ def detect_cpu_family(compilers: CompilersDict) -> str:
# ATM there is no 64 bit userland for PA-RISC. Thus always
# report it as 32 bit for simplicity.
trial = 'parisc'
+ elif trial == 'ppc':
+ # AIX always returns powerpc, check here for 64-bit
+ if any_compiler_has_define(compilers, '__64BIT__'):
+ trial = 'ppc64'
if trial not in known_cpu_families:
mlog.warning('Unknown CPU family {!r}, please report this at '
@@ -396,7 +401,7 @@ def detect_cpu_family(compilers: CompilersDict) -> str:
def detect_cpu(compilers: CompilersDict):
if mesonlib.is_windows():
trial = detect_windows_arch(compilers)
- elif mesonlib.is_freebsd() or mesonlib.is_netbsd() or mesonlib.is_openbsd():
+ elif mesonlib.is_freebsd() or mesonlib.is_netbsd() or mesonlib.is_openbsd() or mesonlib.is_aix():
trial = platform.processor().lower()
else:
trial = platform.machine().lower()
@@ -1096,6 +1101,14 @@ class Environment:
linker = SolarisDynamicLinker(
compiler, for_machine, comp_class.LINKER_PREFIX, override,
version=v)
+ elif 'ld: 0706-012 The -- flag is not recognized' in e:
+ if isinstance(comp_class.LINKER_PREFIX, str):
+ _, _, e = Popen_safe(compiler + [comp_class.LINKER_PREFIX + '-V'] + extra_args)
+ else:
+ _, _, e = Popen_safe(compiler + comp_class.LINKER_PREFIX + ['-V'] + extra_args)
+ linker = AIXDynamicLinker(
+ compiler, for_machine, comp_class.LINKER_PREFIX, override,
+ version=search_version(e))
else:
raise EnvironmentException('Unable to determine dynamic linker')
return linker
@@ -1954,7 +1967,7 @@ class Environment:
if p.returncode == 1 and err.startswith('usage'): # OSX
return ArLinker(linker)
if p.returncode == 1 and err.startswith('Usage'): # AIX
- return ArLinker(linker)
+ return AIXArLinker(linker)
if p.returncode == 1 and err.startswith('ar: bad option: --'): # Solaris
return ArLinker(linker)
self._handle_exceptions(popen_exceptions, linkers, 'linker')
diff --git a/mesonbuild/linkers.py b/mesonbuild/linkers.py
index 505aef6..3f65da1 100644
--- a/mesonbuild/linkers.py
+++ b/mesonbuild/linkers.py
@@ -247,6 +247,18 @@ class C2000Linker(StaticLinker):
return ['-r']
+class AIXArLinker(ArLinker):
+
+ def __init__(self, exelist: T.List[str]):
+ StaticLinker.__init__(self, exelist)
+ self.id = 'aixar'
+ self.std_args = ['-csr', '-Xany']
+
+ def can_linker_accept_rsp(self) -> bool:
+ # AIXAr can't accept arguments using the @rsp syntax
+ return False
+
+
def prepare_rpaths(raw_rpaths: str, build_dir: str, from_dir: str) -> T.List[str]:
# The rpaths we write must be relative if they point to the build dir,
# because otherwise they have different length depending on the build
@@ -1145,6 +1157,38 @@ class SolarisDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker):
return self._apply_prefix('-soname,{}{}.{}{}'.format(prefix, shlib_name, suffix, sostr))
+class AIXDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker):
+
+ """Sys-V derived linker used on AIX"""
+
+ def __init__(self, *args, **kwargs):
+ super().__init__('ld.aix', *args, **kwargs)
+
+ def get_always_args(self) -> T.List[str]:
+ return self._apply_prefix(['-bsvr4', '-bnoipath', '-bbigtoc']) + super().get_always_args()
+
+ def no_undefined_args(self) -> T.List[str]:
+ return self._apply_prefix(['-z', 'defs'])
+
+ def get_allow_undefined_args(self) -> T.List[str]:
+ return self._apply_prefix(['-z', 'nodefs'])
+
+ 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]]:
+ all_paths = mesonlib.OrderedSet(['/opt/freeware/lib']) # for libgcc_s.a
+ for p in rpath_paths:
+ all_paths.add(os.path.join(build_dir, p))
+ if build_rpath != '':
+ all_paths.add(build_rpath)
+ if install_rpath != '':
+ all_paths.add(install_rpath)
+ return (self._apply_prefix([x for p in all_paths for x in ('-R', p)]), set())
+
+ def thread_flags(self, env: 'Environment') -> T.List[str]:
+ return ['-pthread']
+
+
class OptlinkDynamicLinker(VisualStudioLikeLinkerMixin, DynamicLinker):
"""Digital Mars dynamic linker for windows."""
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index 760b235..45e3b34 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -533,6 +533,9 @@ def is_hurd() -> bool:
def is_qnx() -> bool:
return platform.system().lower() == 'qnx'
+def is_aix() -> bool:
+ return platform.system().lower() == 'aix'
+
def exe_exists(arglist: T.List[str]) -> bool:
try:
if subprocess.run(arglist, timeout=10).returncode == 0: