aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Blanchard <UncombedCoconut@gmail.com>2022-07-19 22:31:21 -0400
committerNirbheek Chauhan <nirbheek@centricular.com>2022-08-08 19:10:31 +0530
commit552e06b7e08303f3419cdf1fe82ab7bb75244777 (patch)
tree6baf05f3f9bfb2d7909d5abfcdfbec43f635620c
parentc6cd781c76e8cbf981e25ebf44cca483157ab477 (diff)
downloadmeson-552e06b7e08303f3419cdf1fe82ab7bb75244777.zip
meson-552e06b7e08303f3419cdf1fe82ab7bb75244777.tar.gz
meson-552e06b7e08303f3419cdf1fe82ab7bb75244777.tar.bz2
ar linker: detect the "osx ld" case (where generating thin archives won't work) based on host OS, not build OS.
-rw-r--r--mesonbuild/backend/ninjabackend.py2
-rw-r--r--mesonbuild/compilers/detect.py6
-rw-r--r--mesonbuild/linkers/linkers.py15
-rw-r--r--unittests/allplatformstests.py2
4 files changed, 13 insertions, 12 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 06348b4..fe4d926 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -2862,7 +2862,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
if target.import_filename:
commands += linker.gen_import_library_args(self.get_import_filename(target))
elif isinstance(target, build.StaticLibrary):
- commands += linker.get_std_link_args(not target.should_install())
+ commands += linker.get_std_link_args(self.environment, not target.should_install())
else:
raise RuntimeError('Unknown build target type.')
return commands
diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py
index 5e147a8..962bc16 100644
--- a/mesonbuild/compilers/detect.py
+++ b/mesonbuild/compilers/detect.py
@@ -342,13 +342,13 @@ def detect_static_linker(env: 'Environment', compiler: Compiler) -> StaticLinker
if out.startswith('The CompCert'):
return CompCertLinker(linker)
if p.returncode == 0:
- return ArLinker(linker)
+ return ArLinker(compiler.for_machine, linker)
if p.returncode == 1 and err.startswith('usage'): # OSX
- return ArLinker(linker)
+ return ArLinker(compiler.for_machine, linker)
if p.returncode == 1 and err.startswith('Usage'): # AIX
return AIXArLinker(linker)
if p.returncode == 1 and err.startswith('ar: bad option: --'): # Solaris
- return ArLinker(linker)
+ return ArLinker(compiler.for_machine, linker)
_handle_exceptions(popen_exceptions, linkers, 'linker')
diff --git a/mesonbuild/linkers/linkers.py b/mesonbuild/linkers/linkers.py
index b74e5fd..589e816 100644
--- a/mesonbuild/linkers/linkers.py
+++ b/mesonbuild/linkers/linkers.py
@@ -59,7 +59,7 @@ class StaticLinker:
def get_exelist(self) -> T.List[str]:
return self.exelist.copy()
- def get_std_link_args(self, is_thin: bool) -> T.List[str]:
+ def get_std_link_args(self, env: 'Environment', is_thin: bool) -> T.List[str]:
return []
def get_buildtype_linker_args(self, buildtype: str) -> T.List[str]:
@@ -176,7 +176,7 @@ class ArLikeLinker(StaticLinker):
# in fact, only the 'ar' id can
return False
- def get_std_link_args(self, is_thin: bool) -> T.List[str]:
+ def get_std_link_args(self, env: 'Environment', is_thin: bool) -> T.List[str]:
return self.std_args
def get_output_args(self, target: str) -> T.List[str]:
@@ -189,7 +189,7 @@ class ArLikeLinker(StaticLinker):
class ArLinker(ArLikeLinker):
id = 'ar'
- def __init__(self, exelist: T.List[str]):
+ def __init__(self, for_machine: mesonlib.MachineChoice, exelist: T.List[str]):
super().__init__(exelist)
stdo = mesonlib.Popen_safe(self.exelist + ['-h'])[1]
# Enable deterministic builds if they are available.
@@ -202,13 +202,14 @@ class ArLinker(ArLikeLinker):
self.std_args = [stdargs]
self.std_thin_args = [stdargs + thinargs]
self.can_rsp = '@<' in stdo
+ self.for_machine = for_machine
def can_linker_accept_rsp(self) -> bool:
return self.can_rsp
- def get_std_link_args(self, is_thin: bool) -> T.List[str]:
+ def get_std_link_args(self, env: 'Environment', is_thin: bool) -> T.List[str]:
# FIXME: osx ld rejects this: "file built for unknown-unsupported file format"
- if is_thin and not mesonlib.is_osx():
+ if is_thin and not env.machines[self.for_machine].is_darwin():
return self.std_thin_args
else:
return self.std_args
@@ -225,7 +226,7 @@ class DLinker(StaticLinker):
self.arch = arch
self.__rsp_syntax = rsp_syntax
- def get_std_link_args(self, is_thin: bool) -> T.List[str]:
+ def get_std_link_args(self, env: 'Environment', is_thin: bool) -> T.List[str]:
return ['-lib']
def get_output_args(self, target: str) -> T.List[str]:
@@ -1159,7 +1160,7 @@ class PGIStaticLinker(StaticLinker):
self.id = 'ar'
self.std_args = ['-r']
- def get_std_link_args(self, is_thin: bool) -> T.List[str]:
+ def get_std_link_args(self, env: 'Environment', is_thin: bool) -> T.List[str]:
return self.std_args
def get_output_args(self, target: str) -> T.List[str]:
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index 26a91b6..3945f1e 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -1450,7 +1450,7 @@ class AllPlatformTests(BasePlatformTests):
extra_args = []
link_cmd = linker.get_exelist()
link_cmd += linker.get_always_args()
- link_cmd += linker.get_std_link_args(False)
+ link_cmd += linker.get_std_link_args(get_fake_env(), False)
link_cmd += linker.get_output_args(outfile)
link_cmd += [objectfile]
self.pbcompile(compiler, source, objectfile, extra_args=extra_args)