Enhance uvwasi build process and fix wamrc windows build error (#1046)

And update related document
This commit is contained in:
Wenyong Huang 2022-03-15 21:43:55 +08:00 committed by GitHub
parent 7a0ec1cd17
commit 21d89135da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 23 deletions

View File

@ -2,21 +2,22 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
set (LIBC_WASI_DIR ${CMAKE_CURRENT_LIST_DIR})
set (UVWASI_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../deps/uvwasi)
set (LIBUV_VERSION v1.42.0)
add_definitions (-DWASM_ENABLE_LIBC_WASI=1 -DWASM_ENABLE_UVWASI=1)
include(FetchContent)
## https://libuv.org
## libuv
FetchContent_Declare(
libuv
GIT_REPOSITORY https://github.com/libuv/libuv.git
GIT_TAG ${LIBUV_VERSION})
GIT_TAG ${LIBUV_VERSION}
)
FetchContent_GetProperties(libuv)
if(NOT libuv_POPULATED)
message ("-- Fetching libuv ..")
if (NOT libuv_POPULATED)
message("-- Fetching libuv ..")
FetchContent_Populate(libuv)
include_directories("${libuv_SOURCE_DIR}/include")
add_subdirectory(${libuv_SOURCE_DIR} ${libuv_BINARY_DIR} EXCLUDE_FROM_ALL)
@ -24,8 +25,20 @@ if(NOT libuv_POPULATED)
set_target_properties(uv_a PROPERTIES POSITION_INDEPENDENT_CODE 1)
endif()
include_directories(${UVWASI_DIR}/include)
## uvwasi
FetchContent_Declare(
uvwasi
GIT_REPOSITORY https://github.com/nodejs/uvwasi.git
GIT_TAG main
)
FetchContent_GetProperties(uvwasi)
if (NOT uvwasi_POPULATED)
message("-- Fetching uvwasi ..")
FetchContent_Populate(uvwasi)
include_directories("${uvwasi_SOURCE_DIR}/include")
add_subdirectory(${uvwasi_SOURCE_DIR} ${uvwasi_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
file (GLOB_RECURSE source_all ${LIBC_WASI_DIR}/*.c ${UVWASI_DIR}/src/*.c)
file (GLOB_RECURSE source_all ${LIBC_WASI_DIR}/*.c ${uvwasi_SOURCE_DIR}/src/*.c)
set (LIBC_WASI_SOURCE ${source_all})

View File

@ -51,12 +51,7 @@ cmake -DWAMR_BUILD_PLATFORM=linux -DWAMR_BUILD_TARGET=ARM
- **WAMR_BUILD_LIBC_UVWASI**=1/0 (Experiment), build the [WASI](https://github.com/WebAssembly/WASI) libc subset for WASM app based on [uvwasi](https://github.com/nodejs/uvwasi) implementation, default to disable if not set
> Note: for platform which doesn't support **WAMR_BUILD_LIBC_WASI**, e.g. Windows, developer can try using **WAMR_BUILD_LIBC_UVWASI**. And the uvwasi source code must be cloned under core/deps:
>
> ```bash
> cd <WAMR-ROOT>/core/deps
> git clone https://github.com/nodejs/uvwasi.git
> ```
> Note: for platform which doesn't support **WAMR_BUILD_LIBC_WASI**, e.g. Windows, developer can try using **WAMR_BUILD_LIBC_UVWASI**.
#### **Enable Multi-Module feature**
@ -297,9 +292,6 @@ Make sure `MSVC` and `cmake` are installed and available in the command line env
Then build the source codes:
``` Bash
cd core/deps/
git clone https://github.com/nodejs/uvwasi.git
cd product-mini/platforms/windows/
mkdir build
cd build
@ -335,8 +327,8 @@ pacman -R cmake
pacman -S mingw-w64-x86_64-cmake
```
Then follow the build instructions for Windows above, minus cloning uvwasi and
adding the following arguments for cmake:
Then follow the build instructions for Windows above, and add the following
arguments for cmake:
```Bash
cmake .. -G"Unix Makefiles" \

View File

@ -103,7 +103,8 @@ set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE})
#set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWIN32_LEAN_AND_MEAN -D_WINSOCK_DEPRECATED_NO_WARNINGS")
#set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWIN32_LEAN_AND_MEAN")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_WINSOCK_DEPRECATED_NO_WARNINGS")
if (NOT MINGW)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")

View File

@ -181,7 +181,13 @@ include (${SHARED_DIR}/utils/shared_utils.cmake)
include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
include (${IWASM_DIR}/libraries/thread-mgr/thread_mgr.cmake)
include (${IWASM_DIR}/libraries/libc-builtin/libc_builtin.cmake)
include (${IWASM_DIR}/libraries/libc-wasi/libc_wasi.cmake)
if (NOT MINGW)
if (NOT MSVC)
include (${IWASM_DIR}/libraries/libc-wasi/libc_wasi.cmake)
else()
include (${IWASM_DIR}/libraries/libc-uvwasi/libc_uvwasi.cmake)
endif()
endif()
include (${IWASM_DIR}/libraries/lib-pthread/lib_pthread.cmake)
include (${IWASM_DIR}/common/iwasm_common.cmake)
include (${IWASM_DIR}/interpreter/iwasm_interp.cmake)
@ -253,10 +259,13 @@ add_executable (wamrc main.c)
if (NOT MSVC)
target_link_libraries (wamrc aotclib vmlib LLVMDemangle ${LLVM_AVAILABLE_LIBS} ${lib_ubsan}
-lm -ldl -lpthread ${lib_lldb})
-lm -lpthread ${lib_lldb} ${UV_A_LIBS})
if (MINGW)
target_link_libraries (wamrc -lssp -lWs2_32)
else()
target_link_libraries (wamrc -ldl)
endif()
else()
target_link_libraries (wamrc aotclib vmlib ${lib_lldb} ${LLVM_AVAILABLE_LIBS} ${lib_ubsan})
target_link_libraries (wamrc aotclib vmlib ${lib_lldb} ${LLVM_AVAILABLE_LIBS} ${lib_ubsan}
${UV_A_LIBS})
endif()