Skip to content

Commit 5973bc8

Browse files
authored
Merge pull request #80274 from kateinoigakukun/maxd/embedded-wasm-concurrency
Embedded concurrency for WASI fixes
2 parents a05560b + 220ab30 commit 5973bc8

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

stdlib/public/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB_CROSS_COMPILING)
175175
# Don't attempt to build any other Embedded Swift stdlib triples
176176
# when building for WASI.
177177
list(APPEND EMBEDDED_STDLIB_TARGET_TRIPLES
178-
"wasm32 wasm32-unknown-wasip1-wasm wasm32-unknown-wasip1-wasm"
178+
"wasm32 wasm32-unknown-wasip1 wasm32-unknown-wasip1"
179179
)
180180
else()
181181
if("ARM" IN_LIST LLVM_TARGETS_TO_BUILD)

stdlib/public/Concurrency/CMakeLists.txt

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,13 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB AND SWIFT_SHOULD_BUILD_EMBEDDED_CONCURRENC
245245
list(GET list 2 triple)
246246

247247
if (SWIFT_HOST_VARIANT STREQUAL "linux")
248-
if((NOT "${mod}" MATCHES "-linux-gnu$") AND (NOT "${mod}" MATCHES "-wasip1"))
248+
if(NOT "${mod}" MATCHES "-linux-gnu$")
249249
continue()
250250
endif()
251251
set(extra_c_compile_flags)
252252
set(extra_swift_compile_flags)
253253
elseif (SWIFT_HOST_VARIANT STREQUAL "macosx")
254-
if((NOT "${mod}" MATCHES "-macos$") AND (NOT "${mod}" MATCHES "-wasip1"))
254+
if(NOT "${mod}" MATCHES "-macos$")
255255
continue()
256256
endif()
257257
if("${mod}" MATCHES "riscv")
@@ -267,14 +267,8 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB AND SWIFT_SHOULD_BUILD_EMBEDDED_CONCURRENC
267267
endif()
268268

269269
elseif (SWIFT_HOST_VARIANT STREQUAL "wasi")
270-
if("${mod}" MATCHES "-wasip1")
271-
set(extra_c_compile_flags "-I${SWIFT_WASI_SYSROOT_PATH}/include/c++/v1")
272-
if(${SWIFT_WASI_SYSROOT_PATH} MATCHES "threads")
273-
list(APPEND extra_c_compile_flags "-I${SWIFT_WASI_SYSROOT_PATH}/include/wasm32-wasip1-threads")
274-
else()
275-
list(APPEND extra_c_compile_flags "-I${SWIFT_WASI_SYSROOT_PATH}/include/wasm32-wasi")
276-
endif()
277-
endif()
270+
set(extra_c_compile_flags)
271+
set(extra_swift_compile_flags)
278272
endif()
279273

280274
set(SWIFT_SDK_embedded_THREADING_PACKAGE none)

utils/swift_build_support/swift_build_support/products/wasisysroot.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def _build(self, host_target, thread_model='single', target_triple='wasm32-wasi'
6262
# check-symbols. The directory is required during sysroot installation step.
6363
os.makedirs(os.path.join(sysroot_build_dir, "share"), exist_ok=True)
6464

65+
sysroot_install_path = WASILibc.sysroot_install_path(build_root, target_triple)
6566
shell.call([
6667
'make', 'install',
6768
'-j', str(build_jobs),
@@ -74,14 +75,22 @@ def _build(self, host_target, thread_model='single', target_triple='wasm32-wasi'
7475
'-C', self.source_dir,
7576
'OBJDIR=' + os.path.join(self.build_dir, 'obj-' + thread_model),
7677
'SYSROOT=' + sysroot_build_dir,
77-
'INSTALL_DIR=' + WASILibc.sysroot_install_path(build_root, target_triple),
78+
'INSTALL_DIR=' + sysroot_install_path,
7879
'CC=' + os.path.join(clang_tools_path, 'clang'),
7980
'AR=' + os.path.join(llvm_tools_path, 'llvm-ar'),
8081
'NM=' + os.path.join(llvm_tools_path, 'llvm-nm'),
8182
'THREAD_MODEL=' + thread_model,
8283
'TARGET_TRIPLE=' + target_triple,
8384
])
8485

86+
if target_triple == "wasm32-wasi":
87+
# Alias wasm32-wasip1 to wasm32-wasi as Embedded modules use
88+
# wasm32-unknown-wasip1 as the target triple.
89+
for subpath in ["lib", "include"]:
90+
dest_path = os.path.join(sysroot_install_path, subpath, "wasm32-wasip1")
91+
if not os.path.exists(dest_path):
92+
shell.symlink("wasm32-wasi", dest_path)
93+
8594
@classmethod
8695
def get_dependencies(cls):
8796
return [llvm.LLVM]

utils/swift_build_support/swift_build_support/products/wasmstdlib.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ def _build_stdlib(self, host_target, target_triple, llvm_cmake_dir):
167167
self.cmake_options.define('SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB:BOOL', 'TRUE')
168168
self.cmake_options.define(
169169
'SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB_CROSS_COMPILING', 'TRUE')
170+
self.cmake_options.define(
171+
'SWIFT_SDK_embedded_ARCH_wasm32-unknown-wasip1_PATH:PATH',
172+
self._wasi_sysroot_path("wasm32-wasi"))
170173

171174
self.add_extra_cmake_options()
172175

0 commit comments

Comments
 (0)