Skip to content

Commit

Permalink
[lldb] [lit] Fix finding lld-link when it is not in 'compiler dir'
Browse files Browse the repository at this point in the history
Fix the build helper to find lld-link via PATH lookup, rather than
making a fragile assumption that it will be present in the 'compiler
directory'.  This fixes tests on Gentoo where clang and lld
are installed in different directories.

Differential Revision: https://reviews.llvm.org/D58001

llvm-svn: 353701
  • Loading branch information
mgorny committed Feb 11, 2019
1 parent 8780771 commit c1adbc6
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lldb/lit/helper/build.py
Expand Up @@ -283,19 +283,17 @@ def __init__(self, toolchain_type, args):
print('Using alternate compiler "{0}" to match selected target.'.format(self.compiler))

if self.mode == 'link' or self.mode == 'compile-and-link':
self.linker = self._find_linker('link') if toolchain_type == 'msvc' else self._find_linker('lld-link')
self.linker = self._find_linker('link') if toolchain_type == 'msvc' else self._find_linker('lld-link', args.tools_dir)
if not self.linker:
raise ValueError('Unable to find an appropriate linker.')

self.compile_env, self.link_env = self._get_visual_studio_environment()

def _find_linker(self, name):
if sys.platform == 'win32':
name = name + '.exe'
def _find_linker(self, name, search_paths=[]):
compiler_dir = os.path.dirname(self.compiler)
linker_path = os.path.join(compiler_dir, name)
if not os.path.exists(linker_path):
raise ValueError('Could not find \'{}\''.format(linker_path))
linker_path = find_executable(name, [compiler_dir] + search_paths)
if linker_path is None:
raise ValueError('Could not find \'{}\''.format(name))
return linker_path

def _get_vc_install_dir(self):
Expand Down

0 comments on commit c1adbc6

Please sign in to comment.