mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-08 20:56:13 +00:00
Enhance uvwasi build process and fix wamrc windows build error (#1046)
And update related document
This commit is contained in:
parent
7a0ec1cd17
commit
21d89135da
|
@ -2,21 +2,22 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
|
||||||
set (LIBC_WASI_DIR ${CMAKE_CURRENT_LIST_DIR})
|
set (LIBC_WASI_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||||
set (UVWASI_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../deps/uvwasi)
|
|
||||||
set (LIBUV_VERSION v1.42.0)
|
set (LIBUV_VERSION v1.42.0)
|
||||||
|
|
||||||
add_definitions (-DWASM_ENABLE_LIBC_WASI=1 -DWASM_ENABLE_UVWASI=1)
|
add_definitions (-DWASM_ENABLE_LIBC_WASI=1 -DWASM_ENABLE_UVWASI=1)
|
||||||
|
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
## https://libuv.org
|
|
||||||
|
## libuv
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
libuv
|
libuv
|
||||||
GIT_REPOSITORY https://github.com/libuv/libuv.git
|
GIT_REPOSITORY https://github.com/libuv/libuv.git
|
||||||
GIT_TAG ${LIBUV_VERSION})
|
GIT_TAG ${LIBUV_VERSION}
|
||||||
|
)
|
||||||
FetchContent_GetProperties(libuv)
|
FetchContent_GetProperties(libuv)
|
||||||
if(NOT libuv_POPULATED)
|
if (NOT libuv_POPULATED)
|
||||||
message ("-- Fetching libuv ..")
|
message("-- Fetching libuv ..")
|
||||||
FetchContent_Populate(libuv)
|
FetchContent_Populate(libuv)
|
||||||
include_directories("${libuv_SOURCE_DIR}/include")
|
include_directories("${libuv_SOURCE_DIR}/include")
|
||||||
add_subdirectory(${libuv_SOURCE_DIR} ${libuv_BINARY_DIR} EXCLUDE_FROM_ALL)
|
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)
|
set_target_properties(uv_a PROPERTIES POSITION_INDEPENDENT_CODE 1)
|
||||||
endif()
|
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})
|
set (LIBC_WASI_SOURCE ${source_all})
|
||||||
|
|
|
@ -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
|
- **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:
|
> Note: for platform which doesn't support **WAMR_BUILD_LIBC_WASI**, e.g. Windows, developer can try using **WAMR_BUILD_LIBC_UVWASI**.
|
||||||
>
|
|
||||||
> ```bash
|
|
||||||
> cd <WAMR-ROOT>/core/deps
|
|
||||||
> git clone https://github.com/nodejs/uvwasi.git
|
|
||||||
> ```
|
|
||||||
|
|
||||||
#### **Enable Multi-Module feature**
|
#### **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:
|
Then build the source codes:
|
||||||
``` Bash
|
``` Bash
|
||||||
cd core/deps/
|
|
||||||
git clone https://github.com/nodejs/uvwasi.git
|
|
||||||
|
|
||||||
cd product-mini/platforms/windows/
|
cd product-mini/platforms/windows/
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
|
@ -335,8 +327,8 @@ pacman -R cmake
|
||||||
pacman -S mingw-w64-x86_64-cmake
|
pacman -S mingw-w64-x86_64-cmake
|
||||||
```
|
```
|
||||||
|
|
||||||
Then follow the build instructions for Windows above, minus cloning uvwasi and
|
Then follow the build instructions for Windows above, and add the following
|
||||||
adding the following arguments for cmake:
|
arguments for cmake:
|
||||||
|
|
||||||
```Bash
|
```Bash
|
||||||
cmake .. -G"Unix Makefiles" \
|
cmake .. -G"Unix Makefiles" \
|
||||||
|
|
|
@ -103,7 +103,8 @@ set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
|
||||||
include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
|
include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
|
||||||
add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE})
|
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)
|
if (NOT MINGW)
|
||||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
|
||||||
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
|
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
|
||||||
|
|
|
@ -181,7 +181,13 @@ include (${SHARED_DIR}/utils/shared_utils.cmake)
|
||||||
include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
|
include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
|
||||||
include (${IWASM_DIR}/libraries/thread-mgr/thread_mgr.cmake)
|
include (${IWASM_DIR}/libraries/thread-mgr/thread_mgr.cmake)
|
||||||
include (${IWASM_DIR}/libraries/libc-builtin/libc_builtin.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}/libraries/lib-pthread/lib_pthread.cmake)
|
||||||
include (${IWASM_DIR}/common/iwasm_common.cmake)
|
include (${IWASM_DIR}/common/iwasm_common.cmake)
|
||||||
include (${IWASM_DIR}/interpreter/iwasm_interp.cmake)
|
include (${IWASM_DIR}/interpreter/iwasm_interp.cmake)
|
||||||
|
@ -253,10 +259,13 @@ add_executable (wamrc main.c)
|
||||||
|
|
||||||
if (NOT MSVC)
|
if (NOT MSVC)
|
||||||
target_link_libraries (wamrc aotclib vmlib LLVMDemangle ${LLVM_AVAILABLE_LIBS} ${lib_ubsan}
|
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)
|
if (MINGW)
|
||||||
target_link_libraries (wamrc -lssp -lWs2_32)
|
target_link_libraries (wamrc -lssp -lWs2_32)
|
||||||
|
else()
|
||||||
|
target_link_libraries (wamrc -ldl)
|
||||||
endif()
|
endif()
|
||||||
else()
|
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()
|
endif()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user