Skip to content

Commit 92f225d

Browse files
kateinoigakukunAnka
authored andcommitted
[wasm] Fix cross-compilation on macOS host machine
We didn't set the CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR when cross-compiling stdlib for WASI. This caused the build to fail on macOS host machines as the build system was trying to build some overlays assuming the target is macOS. Additionally, add a default "SWIFT_HOST_VARIANT_SDK" for WASI target even though we don't support it as a host system yet because it's required anyway.
1 parent fc03688 commit 92f225d

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ else()
155155
set(SWIFT_HOST_VARIANT_SDK_default "ANDROID")
156156
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
157157
set(SWIFT_HOST_VARIANT_SDK_default "OSX")
158+
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "WASI")
159+
set(SWIFT_HOST_VARIANT_SDK_default "WASI")
158160
else()
159161
message(FATAL_ERROR "Unable to detect SDK for host system: ${CMAKE_SYSTEM_NAME}")
160162
endif()

utils/swift_build_support/swift_build_support/products/wasmstdlib.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ def build(self, host_target):
4444
def _build(self, host_target, target_triple):
4545
self.cmake_options.define('CMAKE_INSTALL_PREFIX:PATH', '/usr')
4646
self.cmake_options.define('CMAKE_BUILD_TYPE:STRING', self._build_variant)
47+
self.cmake_options.define('CMAKE_SYSTEM_NAME:STRING', 'WASI')
48+
self.cmake_options.define('CMAKE_SYSTEM_PROCESSOR:STRING', 'wasm32')
4749
self.cmake_options.define(
4850
'SWIFT_STDLIB_BUILD_TYPE:STRING', self._build_variant)
4951

0 commit comments

Comments
 (0)