Skip to content

Commit f895331

Browse files
authored
wasisysroot.py: fix build_runtime_with_host_compiler diagnostics (#83129)
Improve diagnostics when `llvm-ar` is not detected in the currently select toolchain.
1 parent bfa61f7 commit f895331

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

utils/swift_build_support/swift_build_support/products/wasisysroot.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import multiprocessing
1414
import os
15+
import sys
1516

1617
from . import cmake_product
1718
from . import llvm
@@ -55,6 +56,11 @@ def _build(self, host_target, thread_model='single', target_triple='wasm32-wasi'
5556
clang_path = self.toolchain.cc
5657
ar_path = self.toolchain.llvm_ar
5758
nm_path = self.toolchain.llvm_nm
59+
60+
if not ar_path:
61+
print(f"error: `llvm-ar` not found for LLVM toolchain at {clang_path}, "
62+
"select a toolchain that has `llvm-ar` included", file=sys.stderr)
63+
sys.exit(1)
5864
else:
5965
llvm_build_bin_dir = os.path.join(
6066
'..', build_root, '%s-%s' % ('llvm', host_target), 'bin')
@@ -163,6 +169,11 @@ def _build(self, host_target, enable_wasi_threads, compiler_rt_os_dir, target_tr
163169
cxx_path = self.toolchain.cxx
164170
ar_path = self.toolchain.llvm_ar
165171
ranlib_path = self.toolchain.llvm_ranlib
172+
173+
if not ar_path:
174+
print(f"error: `llvm-ar` not found for LLVM toolchain at {cc_path}, "
175+
"select a toolchain that has `llvm-ar` included", file=sys.stderr)
176+
sys.exit(1)
166177
else:
167178
llvm_build_bin_dir = os.path.join(
168179
'..', build_root, '%s-%s' % ('llvm', host_target), 'bin')

0 commit comments

Comments
 (0)