Skip to content

Commit 355add7

Browse files
committed
gn: Simplify logic for finding Clang resource directory
This code was using a convoluted way of determining the resource directory that doesn't always work (for example, the resource directory is not guaranteed to have a /clang/ component). Replace it with a call to `clang -print-resource-dir`.
1 parent ab21398 commit 355add7

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

gn/standalone/toolchain/linux_find_llvm.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,12 @@ def main():
4646
for clang in candidate_clangs():
4747
if shutil.which(clang) is None:
4848
continue
49-
res = subprocess.check_output([clang, '-print-search-dirs']).decode("utf-8")
50-
for line in res.splitlines():
51-
if not line.startswith('libraries:'):
52-
continue
53-
libs = line.split('=', 1)[1].split(':')
54-
for lib in libs:
55-
if '/clang/' not in lib or not os.path.isdir(lib + '/lib'):
56-
continue
57-
print(os.path.abspath(lib))
58-
print(clang)
59-
print(clang.replace('clang', 'clang++'))
60-
return 0
49+
res = subprocess.check_output([clang,
50+
'-print-resource-dir']).decode("utf-8")
51+
print(os.path.abspath(res.splitlines()[0]))
52+
print(clang)
53+
print(clang.replace('clang', 'clang++'))
54+
return 0
6155
print('Could not find the LLVM lib dir')
6256
return 1
6357

0 commit comments

Comments
 (0)