Skip to content

Commit c535723

Browse files
authored
Merge pull request #83208 from MaxDesiatov/wasm-corelibs-host-compiler
wasmswiftsdk.py: consistently apply `build_runtime_with_host_compiler` Following up on #83134 #82949 #82946 #82944. With these changes I'm able to quickly build and test only Wasm Swift SDK without rebuilding the whole toolchain when latest development snapshot is installed, using this invocation: ``` ./swift/utils/build-script --skip-build-benchmarks --release --skip-early-swift-driver \ --skip-build-lldb --skip-build-cmark --skip-build-llvm --skip-build-swift \ --build-runtime-with-host-compiler --build-wasm-stdlib ``` Timing on M4 MacBook Pro: ``` --- Build Script Analyzer --- Build Percentage Build Duration (sec) Build Phase ================ ==================== =========== 43.6% 257.75 Building wasmswiftsdk 20.6% 121.91 Building wasmthreadsstdlib 20.6% 121.78 Building wasmstdlib 5.4% 32.03 Building wasmllvmruntimelibs 3.6% 21.39 Running tests for wasmthreadsstdlib 3.5% 20.91 Running tests for wasmstdlib 2.7% 15.74 Building wasilibc 0.0% 0.04 macosx-arm64-extractsymbols 0.0% 0.04 macosx-arm64-package 0.0% 0.03 merged-hosts-lipo-core 0.0% 0.03 merged-hosts-lipo Total Duration: 591.65 seconds (9m 51s) ```
2 parents 8506af7 + fa57cfc commit c535723

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

utils/swift_build_support/swift_build_support/products/wasmswiftsdk.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,14 @@ def _append_platform_cmake_options(self, cmake_options, swift_host_triple, has_p
7272
cmake_options.define('CMAKE_CXX_COMPILER_FORCED', 'TRUE')
7373
cmake_options.define('CMAKE_BUILD_TYPE', self.args.build_variant)
7474

75-
# Explicitly choose ar and ranlib from just-built LLVM tools since tools in the host system
76-
# unlikely support Wasm object format.
77-
native_toolchain_path = self.native_toolchain_path(self.args.host_target)
78-
cmake_options.define('CMAKE_AR', os.path.join(
79-
native_toolchain_path, 'bin', 'llvm-ar'))
80-
cmake_options.define('CMAKE_RANLIB', os.path.join(
81-
native_toolchain_path, 'bin', 'llvm-ranlib'))
75+
if not self.args.build_runtime_with_host_compiler:
76+
# Explicitly choose ar and ranlib from just-built LLVM tools since tools in the host system
77+
# unlikely support Wasm object format.
78+
native_toolchain_path = self.native_toolchain_path(self.args.host_target)
79+
cmake_options.define('CMAKE_AR', os.path.join(
80+
native_toolchain_path, 'bin', 'llvm-ar'))
81+
cmake_options.define('CMAKE_RANLIB', os.path.join(
82+
native_toolchain_path, 'bin', 'llvm-ranlib'))
8283

8384
def _build_libxml2(self, swift_host_triple, has_pthread, wasi_sysroot):
8485
libxml2 = CMakeProduct(
@@ -130,7 +131,7 @@ def _build_libxml2(self, swift_host_triple, has_pthread, wasi_sysroot):
130131
libxml2.cmake_options.define('HAVE_PTHREAD_H', cmake_thread_enabled)
131132

132133
libxml2.build_with_cmake([], self.args.build_variant, [],
133-
prefer_native_toolchain=True,
134+
prefer_native_toolchain=not self.args.build_runtime_with_host_compiler,
134135
ignore_extra_cmake_options=True)
135136
with shell.pushd(libxml2.build_dir):
136137
shell.call([self.toolchain.cmake, '--install', '.', '--prefix', '/', '--component', 'development'],
@@ -159,7 +160,7 @@ def _build_foundation(self, swift_host_triple, has_pthread, wasi_sysroot):
159160
foundation.cmake_options.define('LIBXML2_LIBRARY', os.path.join(wasi_sysroot, 'lib'))
160161

161162
foundation.build_with_cmake([], self.args.build_variant, [],
162-
prefer_native_toolchain=True,
163+
prefer_native_toolchain=not self.args.build_runtime_with_host_compiler,
163164
ignore_extra_cmake_options=True)
164165

165166
dest_dir = self._target_package_path(swift_host_triple)
@@ -186,7 +187,7 @@ def _build_swift_testing(self, swift_host_triple, has_pthread, wasi_sysroot):
186187
swift_testing.cmake_options.define('SwiftTesting_MACRO', 'NO')
187188

188189
swift_testing.build_with_cmake([], self.args.build_variant, [],
189-
prefer_native_toolchain=True,
190+
prefer_native_toolchain=not self.args.build_runtime_with_host_compiler,
190191
ignore_extra_cmake_options=True)
191192
dest_dir = self._target_package_path(swift_host_triple)
192193
with shell.pushd(swift_testing.build_dir):
@@ -206,7 +207,7 @@ def _build_xctest(self, swift_host_triple, has_pthread, wasi_sysroot):
206207
xctest.cmake_options.define('BUILD_SHARED_LIBS', 'FALSE')
207208

208209
xctest.build_with_cmake([], self.args.build_variant, [],
209-
prefer_native_toolchain=True,
210+
prefer_native_toolchain=not self.args.build_runtime_with_host_compiler,
210211
ignore_extra_cmake_options=True)
211212
dest_dir = self._target_package_path(swift_host_triple)
212213
with shell.pushd(xctest.build_dir):

0 commit comments

Comments
 (0)