diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2022-07-27 01:56:52 -0400 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2022-08-08 19:10:32 +0530 |
commit | c1ee4461c0aa2918dce31d893c793d06d7e55fb4 (patch) | |
tree | a6b8df161f675be5f6aeacbb21dc2e6b3479e1f1 | |
parent | df5596e9c1ee24e5f6a21ec3dd5983e10232daac (diff) | |
download | meson-c1ee4461c0aa2918dce31d893c793d06d7e55fb4.zip meson-c1ee4461c0aa2918dce31d893c793d06d7e55fb4.tar.gz meson-c1ee4461c0aa2918dce31d893c793d06d7e55fb4.tar.bz2 |
linkers: make sure the linker is actually Apple when matching failure
Not all "use -v" errors are Apple ld, and if it doesn't have better
output with -v instead of --version, we should not assume that is what
it is.
-rw-r--r-- | mesonbuild/linkers/detect.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/mesonbuild/linkers/detect.py b/mesonbuild/linkers/detect.py index 72bd0a1..17c5478 100644 --- a/mesonbuild/linkers/detect.py +++ b/mesonbuild/linkers/detect.py @@ -186,18 +186,24 @@ def guess_nix_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty v = search_version(o) linker = LLVMDynamicLinker(compiler, for_machine, comp_class.LINKER_PREFIX, override, version=v) - # first is for apple clang, second is for real gcc, the third is icc + # first might be apple clang, second is for real gcc, the third is icc elif e.endswith('(use -v to see invocation)\n') or 'macosx_version' in e or 'ld: unknown option:' in e: if isinstance(comp_class.LINKER_PREFIX, str): - _, _, e = Popen_safe(compiler + [comp_class.LINKER_PREFIX + '-v'] + extra_args) + cmd = compiler + [comp_class.LINKER_PREFIX + '-v'] + extra_args else: - _, _, e = Popen_safe(compiler + comp_class.LINKER_PREFIX + ['-v'] + extra_args) - for line in e.split('\n'): + cmd = compiler + comp_class.LINKER_PREFIX + ['-v'] + extra_args + mlog.debug('-----') + mlog.debug(f'Detecting Apple linker via: {join_args(cmd)}') + _, newo, newerr = Popen_safe(cmd) + mlog.debug(f'linker stdout:\n{newo}') + mlog.debug(f'linker stderr:\n{newerr}') + + for line in newerr.split('\n'): if 'PROJECT:ld' in line: v = line.split('-')[1] break else: - v = 'unknown version' + __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] |