Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion stdlib/public/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB_CROSS_COMPILING)
# Don't attempt to build any other Embedded Swift stdlib triples
# when building for WASI.
list(APPEND EMBEDDED_STDLIB_TARGET_TRIPLES
"wasm32 wasm32-unknown-wasip1-wasm wasm32-unknown-wasip1-wasm"
"wasm32 wasm32-unknown-wasip1 wasm32-unknown-wasip1"
)
else()
if("ARM" IN_LIST LLVM_TARGETS_TO_BUILD)
Expand Down
14 changes: 4 additions & 10 deletions stdlib/public/Concurrency/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,13 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB AND SWIFT_SHOULD_BUILD_EMBEDDED_CONCURRENC
list(GET list 2 triple)

if (SWIFT_HOST_VARIANT STREQUAL "linux")
if((NOT "${mod}" MATCHES "-linux-gnu$") AND (NOT "${mod}" MATCHES "-wasip1"))
if(NOT "${mod}" MATCHES "-linux-gnu$")
continue()
endif()
set(extra_c_compile_flags)
set(extra_swift_compile_flags)
elseif (SWIFT_HOST_VARIANT STREQUAL "macosx")
if((NOT "${mod}" MATCHES "-macos$") AND (NOT "${mod}" MATCHES "-wasip1"))
if(NOT "${mod}" MATCHES "-macos$")
continue()
endif()
if("${mod}" MATCHES "riscv")
Expand All @@ -267,14 +267,8 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB AND SWIFT_SHOULD_BUILD_EMBEDDED_CONCURRENC
endif()

elseif (SWIFT_HOST_VARIANT STREQUAL "wasi")
if("${mod}" MATCHES "-wasip1")
set(extra_c_compile_flags "-I${SWIFT_WASI_SYSROOT_PATH}/include/c++/v1")
if(${SWIFT_WASI_SYSROOT_PATH} MATCHES "threads")
list(APPEND extra_c_compile_flags "-I${SWIFT_WASI_SYSROOT_PATH}/include/wasm32-wasip1-threads")
else()
list(APPEND extra_c_compile_flags "-I${SWIFT_WASI_SYSROOT_PATH}/include/wasm32-wasi")
endif()
endif()
set(extra_c_compile_flags)
set(extra_swift_compile_flags)
endif()

set(SWIFT_SDK_embedded_THREADING_PACKAGE none)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def _build(self, host_target, thread_model='single', target_triple='wasm32-wasi'
# check-symbols. The directory is required during sysroot installation step.
os.makedirs(os.path.join(sysroot_build_dir, "share"), exist_ok=True)

sysroot_install_path = WASILibc.sysroot_install_path(build_root, target_triple)
shell.call([
'make', 'install',
'-j', str(build_jobs),
Expand All @@ -74,14 +75,22 @@ def _build(self, host_target, thread_model='single', target_triple='wasm32-wasi'
'-C', self.source_dir,
'OBJDIR=' + os.path.join(self.build_dir, 'obj-' + thread_model),
'SYSROOT=' + sysroot_build_dir,
'INSTALL_DIR=' + WASILibc.sysroot_install_path(build_root, target_triple),
'INSTALL_DIR=' + sysroot_install_path,
'CC=' + os.path.join(clang_tools_path, 'clang'),
'AR=' + os.path.join(llvm_tools_path, 'llvm-ar'),
'NM=' + os.path.join(llvm_tools_path, 'llvm-nm'),
'THREAD_MODEL=' + thread_model,
'TARGET_TRIPLE=' + target_triple,
])

if target_triple == "wasm32-wasi":
# Alias wasm32-wasip1 to wasm32-wasi as Embedded modules use
# wasm32-unknown-wasip1 as the target triple.
for subpath in ["lib", "include"]:
dest_path = os.path.join(sysroot_install_path, subpath, "wasm32-wasip1")
if not os.path.exists(dest_path):
shell.symlink("wasm32-wasi", dest_path)

@classmethod
def get_dependencies(cls):
return [llvm.LLVM]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ def _build_stdlib(self, host_target, target_triple, llvm_cmake_dir):
self.cmake_options.define('SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB:BOOL', 'TRUE')
self.cmake_options.define(
'SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB_CROSS_COMPILING', 'TRUE')
self.cmake_options.define(
'SWIFT_SDK_embedded_ARCH_wasm32-unknown-wasip1_PATH:PATH',
self._wasi_sysroot_path("wasm32-wasi"))

self.add_extra_cmake_options()

Expand Down