diff options
author | jack <jack.wilson@otoy.com> | 2023-01-05 17:17:40 +1300 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2023-01-10 12:00:01 -0800 |
commit | 7e4f6df07a1df69f9c1c82a52ec190db596de764 (patch) | |
tree | a585f1e6793275d5adeac73b3a5194ae74327944 /mesonbuild | |
parent | 6ed6c8cdbaed1976f47e685b66d032e3174d5e89 (diff) | |
download | meson-7e4f6df07a1df69f9c1c82a52ec190db596de764.zip meson-7e4f6df07a1df69f9c1c82a52ec190db596de764.tar.gz meson-7e4f6df07a1df69f9c1c82a52ec190db596de764.tar.bz2 |
linkers: detect ld64 as AppleDynamicLinker
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/linkers/detect.py | 29 | ||||
-rw-r--r-- | mesonbuild/linkers/linkers.py | 5 |
2 files changed, 28 insertions, 6 deletions
diff --git a/mesonbuild/linkers/detect.py b/mesonbuild/linkers/detect.py index 8e25f53..97e770c 100644 --- a/mesonbuild/linkers/detect.py +++ b/mesonbuild/linkers/detect.py @@ -21,6 +21,7 @@ from ..mesonlib import ( ) from .linkers import ( AppleDynamicLinker, + LLVMLD64DynamicLinker, GnuGoldDynamicLinker, GnuBFDDynamicLinker, MoldDynamicLinker, @@ -165,7 +166,23 @@ def guess_nix_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty v = search_version(o + e) linker: DynamicLinker if 'LLD' in o.split('\n', maxsplit=1)[0]: - linker = LLVMDynamicLinker( + if isinstance(comp_class.LINKER_PREFIX, str): + cmd = compiler + override + [comp_class.LINKER_PREFIX + '-v'] + extra_args + else: + cmd = compiler + override + comp_class.LINKER_PREFIX + ['-v'] + extra_args + mlog.debug('-----') + mlog.debug(f'Detecting LLD linker via: {join_args(cmd)}') + _, newo, newerr = Popen_safe(cmd) + mlog.debug(f'linker stdout:\n{newo}') + mlog.debug(f'linker stderr:\n{newerr}') + + lld_cls: T.Type[DynamicLinker] + if 'ld64.lld' in newerr: + lld_cls = LLVMLD64DynamicLinker + else: + lld_cls = LLVMDynamicLinker + + linker = lld_cls( compiler, for_machine, comp_class.LINKER_PREFIX, override, version=v) elif 'Snapdragon' in e and 'LLVM' in e: linker = QualcommLLVMDynamicLinker( @@ -208,16 +225,16 @@ def guess_nix_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty __failed_to_detect_linker(compiler, check_args, o, e) linker = AppleDynamicLinker(compiler, for_machine, comp_class.LINKER_PREFIX, override, version=v) elif 'GNU' in o or 'GNU' in e: - cls: T.Type[GnuDynamicLinker] + gnu_cls: T.Type[GnuDynamicLinker] # this is always the only thing on stdout, except for swift # which may or may not redirect the linker stdout to stderr if o.startswith('GNU gold') or e.startswith('GNU gold'): - cls = GnuGoldDynamicLinker + gnu_cls = GnuGoldDynamicLinker elif o.startswith('mold') or e.startswith('mold'): - cls = MoldDynamicLinker + gnu_cls = MoldDynamicLinker else: - cls = GnuBFDDynamicLinker - linker = cls(compiler, for_machine, comp_class.LINKER_PREFIX, override, version=v) + gnu_cls = GnuBFDDynamicLinker + linker = gnu_cls(compiler, for_machine, comp_class.LINKER_PREFIX, override, version=v) elif 'Solaris' in e or 'Solaris' in o: for line in (o+e).split('\n'): if 'ld: Software Generation Utilities' in line: diff --git a/mesonbuild/linkers/linkers.py b/mesonbuild/linkers/linkers.py index 7538cfc..890e526 100644 --- a/mesonbuild/linkers/linkers.py +++ b/mesonbuild/linkers/linkers.py @@ -825,6 +825,11 @@ class AppleDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker): return ["-Wl,-cache_path_lto," + path] +class LLVMLD64DynamicLinker(AppleDynamicLinker): + + id = 'ld64.lld' + + class GnuDynamicLinker(GnuLikeDynamicLinkerMixin, PosixDynamicLinkerMixin, DynamicLinker): """Representation of GNU ld.bfd and ld.gold.""" |