pull/640/head
Sy Brand 6 months ago
parent 5bfe919641
commit 00c89d2612

@ -11,7 +11,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
project(wasi-sdk)
include(ExternalProject)
set(WASI_SDK_TARGETS "wasm32-wasi;wasm32-wasip1;wasm32-wasip2;wasm32-wasip1-threads;wasm32-wasi-threads"
set(WASI_SDK_TARGETS "wasm32-wasip3"
CACHE STRING "List of WASI targets to build")
option(WASI_SDK_BUILD_TOOLCHAIN "Build a toolchain instead of the sysroot" OFF)

@ -23,7 +23,7 @@ find_program(MAKE make REQUIRED)
option(WASI_SDK_DEBUG_PREFIX_MAP "Pass `-fdebug-prefix-map` for built artifacts" ON)
option(WASI_SDK_INCLUDE_TESTS "Whether or not to build tests by default" OFF)
option(WASI_SDK_INSTALL_TO_CLANG_RESOURCE_DIR "Whether or not to modify the compiler's resource directory" OFF)
option(WASI_SDK_LTO "Whether or not to build LTO assets" ON)
option(WASI_SDK_LTO "Whether or not to build LTO assets" OFF)
set(WASI_SDK_CPU_CFLAGS "-mcpu=lime1" CACHE STRING "CFLAGS to specify wasm features to enable")
set(wasi_tmp_install ${CMAKE_CURRENT_BINARY_DIR}/install)
@ -98,8 +98,7 @@ function(define_compiler_rt target)
add_dependencies(compiler-rt-build compiler-rt-build-${target})
endfunction()
define_compiler_rt(wasm32-wasi)
define_compiler_rt(wasm32-wasip1-threads)
define_compiler_rt(wasm32-wasip3)
# In addition to the default installation of `compiler-rt` itself also copy
# around some headers and make copies of the `wasi` directory as `wasip1` and
@ -115,16 +114,6 @@ add_custom_target(compiler-rt-post-build
COMMAND ${CMAKE_COMMAND} -E copy_directory
${clang_resource_dir}/include ${wasi_resource_dir}/include
# Copy the `lib/wasm32-unknown-wasi` folder to `lib/wasm32-unknown-wasi{p1,p2}` to ensure that those
# OS-strings also work for looking up the compiler-rt.a file.
COMMAND ${CMAKE_COMMAND} -E copy_directory
${wasi_resource_dir}/lib/wasm32-unknown-wasi ${wasi_resource_dir}/lib/wasm32-unknown-wasip1
COMMAND ${CMAKE_COMMAND} -E copy_directory
${wasi_resource_dir}/lib/wasm32-unknown-wasi ${wasi_resource_dir}/lib/wasm32-unknown-wasip2
# Copy the `lib/wasm32-unknown-wasip1-threads` folder to `lib/wasm32-unknown-wasi-threads`
COMMAND ${CMAKE_COMMAND} -E copy_directory
${wasi_resource_dir}/lib/wasm32-unknown-wasip1-threads ${wasi_resource_dir}/lib/wasm32-unknown-wasi-threads
COMMENT "finalizing compiler-rt installation"
)
add_dependencies(compiler-rt-post-build compiler-rt-build)
@ -152,7 +141,7 @@ function(define_wasi_libc_sub target target_suffix lto)
if(${target} MATCHES threads)
set(libcompiler_rt_a ${wasi_resource_dir}/lib/wasm32-unknown-wasip1-threads/libclang_rt.builtins.a)
else()
set(libcompiler_rt_a ${wasi_resource_dir}/lib/wasm32-unknown-wasip1/libclang_rt.builtins.a)
set(libcompiler_rt_a ${wasi_resource_dir}/lib/wasm32-unknown-wasip3/libclang_rt.builtins.a)
endif()
set(extra_cmake_args)
@ -312,7 +301,7 @@ function(define_libcxx target)
endfunction()
foreach(target IN LISTS WASI_SDK_TARGETS)
define_libcxx(${target})
#define_libcxx(${target})
endforeach()
# =============================================================================
@ -336,7 +325,7 @@ endif()
add_custom_target(build ALL)
foreach(target IN LISTS WASI_SDK_TARGETS)
add_custom_target(build-${target})
add_dependencies(build-${target} libcxx-${target} wasi-libc-${target} compiler-rt)
add_dependencies(build-${target} wasi-libc-${target} compiler-rt)
add_dependencies(build build-${target})
endforeach()

@ -82,8 +82,8 @@ ExternalProject_Add(llvm-build
-DLLVM_ENABLE_ZLIB=OFF
-DLLVM_ENABLE_ZSTD=OFF
-DLLVM_STATIC_LINK_CXX_STDLIB=ON
-DLLVM_INCLUDE_TESTS=OFF
-DLLVM_INCLUDE_UTILS=OFF
-DLLVM_INCLUDE_TESTS=ON
-DLLVM_INCLUDE_UTILS=ON
-DLLVM_INCLUDE_BENCHMARKS=OFF
-DLLVM_INCLUDE_EXAMPLES=OFF
-DLLVM_TARGETS_TO_BUILD=WebAssembly
@ -123,16 +123,35 @@ set(wasm_component_ld_version 0.5.20)
if(RUST_TARGET)
set(rust_target_flag --target=${RUST_TARGET})
endif()
add_custom_command(
OUTPUT ${wasm_component_ld}
COMMAND
cargo install --root ${wasm_component_ld_root} ${rust_target_flag}
wasm-component-ld@${wasm_component_ld_version}
COMMAND
cmake -E make_directory ${wasi_tmp_install}/bin
COMMAND
cmake -E copy ${wasm_component_ld} ${wasi_tmp_install}/bin
COMMENT "Building `wasm-component-ld` ...")
# Option to use local wasm-component-ld source instead of cargo install
set(WASM_COMPONENT_LD_SOURCE "" CACHE PATH "Path to wasm-component-ld source directory")
if(WASM_COMPONENT_LD_SOURCE)
# Build from local source
add_custom_command(
OUTPUT ${wasm_component_ld}
COMMAND
cargo install --root ${wasm_component_ld_root} ${rust_target_flag}
--path ${WASM_COMPONENT_LD_SOURCE}
COMMAND
cmake -E make_directory ${wasi_tmp_install}/bin
COMMAND
cmake -E copy ${wasm_component_ld} ${wasi_tmp_install}/bin
COMMENT "Building `wasm-component-ld` from ${WASM_COMPONENT_LD_SOURCE}...")
else()
# Install from crates.io
add_custom_command(
OUTPUT ${wasm_component_ld}
COMMAND
cargo install --root ${wasm_component_ld_root} ${rust_target_flag}
wasm-component-ld@${wasm_component_ld_version}
COMMAND
cmake -E make_directory ${wasi_tmp_install}/bin
COMMAND
cmake -E copy ${wasm_component_ld} ${wasi_tmp_install}/bin
COMMENT "Building `wasm-component-ld` ...")
endif()
add_custom_target(wasm-component-ld DEPENDS ${wasm_component_ld})
add_dependencies(build wasm-component-ld)

@ -1 +1 @@
Subproject commit 222fc11f2b8f25f6a0f4976272ef1bb7bf49521d
Subproject commit 24cb457d6615fbc39e03099690da0fc096b1246b

@ -1 +1 @@
Subproject commit 6036a9f3e349315faba2732a32508d5dc9d6d928
Subproject commit 7b8632e0c8dc3d6ac44d5fd557137d96ef23cfb8
Loading…
Cancel
Save