Skip to content

wasmswiftsdk.py: consistently apply build_runtime_with_host_compiler #83208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ def _append_platform_cmake_options(self, cmake_options, swift_host_triple, has_p
cmake_options.define('CMAKE_CXX_COMPILER_FORCED', 'TRUE')
cmake_options.define('CMAKE_BUILD_TYPE', self.args.build_variant)

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

def _build_libxml2(self, swift_host_triple, has_pthread, wasi_sysroot):
libxml2 = CMakeProduct(
Expand Down Expand Up @@ -130,7 +131,7 @@ def _build_libxml2(self, swift_host_triple, has_pthread, wasi_sysroot):
libxml2.cmake_options.define('HAVE_PTHREAD_H', cmake_thread_enabled)

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

foundation.build_with_cmake([], self.args.build_variant, [],
prefer_native_toolchain=True,
prefer_native_toolchain=not self.args.build_runtime_with_host_compiler,
ignore_extra_cmake_options=True)

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

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

xctest.build_with_cmake([], self.args.build_variant, [],
prefer_native_toolchain=True,
prefer_native_toolchain=not self.args.build_runtime_with_host_compiler,
ignore_extra_cmake_options=True)
dest_dir = self._target_package_path(swift_host_triple)
with shell.pushd(xctest.build_dir):
Expand Down