Skip to content

Commit 113ddb4

Browse files
authored
wasisysroot.py: respect args.build_runtime_with_host_compiler (#82946)
This allows quickly building WASI sysroot when `--skip-build-llvm --skip-build-swift --build-runtime-with-host-compiler --build-wasm-stdlib` combination of options is passed to `build-script`.
1 parent d8a12e9 commit 113ddb4

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

utils/swift_build_support/swift_build_support/products/wasisysroot.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,20 @@ def build(self, host_target):
5050

5151
def _build(self, host_target, thread_model='single', target_triple='wasm32-wasi'):
5252
build_root = os.path.dirname(self.build_dir)
53-
llvm_build_bin_dir = os.path.join(
54-
'..', build_root, '%s-%s' % ('llvm', host_target), 'bin')
55-
llvm_tools_path = self.args.native_llvm_tools_path or llvm_build_bin_dir
56-
clang_tools_path = self.args.native_clang_tools_path or llvm_build_bin_dir
53+
54+
if self.args.build_runtime_with_host_compiler:
55+
clang_path = self.toolchain.cc
56+
ar_path = self.toolchain.llvm_ar
57+
nm_path = self.toolchain.llvm_nm
58+
else:
59+
llvm_build_bin_dir = os.path.join(
60+
'..', build_root, '%s-%s' % ('llvm', host_target), 'bin')
61+
llvm_tools_path = self.args.native_llvm_tools_path or llvm_build_bin_dir
62+
clang_tools_path = self.args.native_clang_tools_path or llvm_build_bin_dir
63+
clang_path = os.path.join(clang_tools_path, 'clang')
64+
ar_path = os.path.join(llvm_tools_path, 'llvm-ar')
65+
nm_path = os.path.join(llvm_tools_path, 'llvm-nm')
66+
5767
build_jobs = self.args.build_jobs or multiprocessing.cpu_count()
5868

5969
sysroot_build_dir = WASILibc.sysroot_build_path(
@@ -67,9 +77,9 @@ def _build(self, host_target, thread_model='single', target_triple='wasm32-wasi'
6777
'OBJDIR=' + os.path.join(self.build_dir, 'obj-' + thread_model),
6878
'SYSROOT=' + sysroot_build_dir,
6979
'INSTALL_DIR=' + sysroot_install_path,
70-
'CC=' + os.path.join(clang_tools_path, 'clang'),
71-
'AR=' + os.path.join(llvm_tools_path, 'llvm-ar'),
72-
'NM=' + os.path.join(llvm_tools_path, 'llvm-nm'),
80+
'CC=' + clang_path,
81+
'AR=' + ar_path,
82+
'NM=' + nm_path,
7383
'THREAD_MODEL=' + thread_model,
7484
'TARGET_TRIPLE=' + target_triple,
7585
])

0 commit comments

Comments
 (0)