diff options
author | Andrei Alexeyev <akari@taisei-project.org> | 2019-09-10 15:44:53 +0300 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2019-09-10 13:23:22 -0700 |
commit | d768a76ab21f01fe34119d79d5b4b580d9fe564f (patch) | |
tree | 6d80b0ce53f62654f42602d1167ec5b92f49d45c /mesonbuild/environment.py | |
parent | 15f8165bde4631d21688d29d7bcb609bde5a3cfb (diff) | |
download | meson-d768a76ab21f01fe34119d79d5b4b580d9fe564f.zip meson-d768a76ab21f01fe34119d79d5b4b580d9fe564f.tar.gz meson-d768a76ab21f01fe34119d79d5b4b580d9fe564f.tar.bz2 |
Workaround for mingw-llvm linker (lld) misdetection
llvm-mingw uses a wrapper script to inject (among other things) a
-target argument into the clang command, which breaks -Wl,--version.
This confuses Meson into thinking the linker is some unknown version of
Apple ld, which breaks builds.
This patch makes it detect and recover from the issue.
Fixes #5910
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r-- | mesonbuild/environment.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index bd80fbe..b3885b6 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -14,6 +14,7 @@ import os, platform, re, sys, shutil, subprocess, typing import tempfile +import shlex from . import coredata from .linkers import ArLinker, ArmarLinker, VisualStudioLinker, DLinker, CcrxLinker, IntelVisualStudioLinker @@ -708,6 +709,22 @@ class Environment: v = search_version(o) if o.startswith('LLD'): linker = LLVMDynamicLinker(compiler, for_machine, 'lld', prefix, version=v) # type: DynamicLinker + elif e.startswith('lld-link: '): + # Toolchain wrapper got in the way; this happens with e.g. https://github.com/mstorsjo/llvm-mingw + # Let's try to extract the linker invocation command to grab the version. + + _, o, e = Popen_safe(compiler + check_args + ['-v']) + + try: + linker_cmd = re.match(r'.*\n(.*?)\nlld-link: ', e, re.DOTALL).group(1) + linker_cmd = shlex.split(linker_cmd)[0] + except (AttributeError, IndexError, ValueError): + pass + else: + _, o, e = Popen_safe([linker_cmd, '--version']) + v = search_version(o) + + linker = LLVMDynamicLinker(compiler, for_machine, 'lld', prefix, version=v) # first is for apple clang, second is for real gcc elif e.endswith('(use -v to see invocation)\n') or 'macosx_version' in e: if isinstance(prefix, str): |