diff options
author | Justin Blanchard <UncombedCoconut@gmail.com> | 2022-07-19 22:31:21 -0400 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2022-07-21 22:00:00 -0700 |
commit | ec388fe7c2b93879499ad782c2da41ec22d003b2 (patch) | |
tree | c37c73c03f009f77ea1838327df719f6a5b2763e | |
parent | 0eed99318b88fbb0c938345e19dc7259cb2ae4b2 (diff) | |
download | meson-ec388fe7c2b93879499ad782c2da41ec22d003b2.zip meson-ec388fe7c2b93879499ad782c2da41ec22d003b2.tar.gz meson-ec388fe7c2b93879499ad782c2da41ec22d003b2.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.py | 2 | ||||
-rw-r--r-- | mesonbuild/compilers/detect.py | 6 | ||||
-rw-r--r-- | mesonbuild/linkers/linkers.py | 15 | ||||
-rw-r--r-- | unittests/allplatformstests.py | 2 |
4 files changed, 13 insertions, 12 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 7f74b24..cad9e11 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 6bc083d..5306e87 100644 --- a/mesonbuild/compilers/detect.py +++ b/mesonbuild/compilers/detect.py @@ -341,13 +341,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 cdb3867..5179ce1 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) |