Allow to control built-in libraries for wamrc from command line options (#2928)

Allow to control built-in libraries for wamrc from command line options:
```bash
cmake -DWAMR_BUILD_LIBC_WASI=1/0
cmake -DWAMR_BUILD_LIBC_BUILTIN=1/0
cmake -DWAMR_BUILD_LIB_PTHREAD=1/0
cmake -DWAMR_BUILD_LIB_WASI_THREADS=1/0
```
And add some messages to show the status.
This commit is contained in:
liang.he 2023-12-28 22:20:55 +08:00 committed by GitHub
parent 5edd85d055
commit 6c839042d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,7 +44,6 @@ add_definitions(-DWASM_ENABLE_CUSTOM_NAME_SECTION=1)
add_definitions(-DWASM_ENABLE_DUMP_CALL_STACK=1)
add_definitions(-DWASM_ENABLE_PERF_PROFILING=1)
add_definitions(-DWASM_ENABLE_LOAD_CUSTOM_SECTION=1)
add_definitions(-DWASM_ENABLE_LIB_WASI_THREADS=1)
add_definitions(-DWASM_ENABLE_MODULE_INST_CONTEXT=1)
if (WAMR_BUILD_LLVM_LEGACY_PM EQUAL 1)
@ -199,31 +198,97 @@ include_directories (${SHARED_DIR}/include
enable_language (ASM)
if (NOT MINGW AND NOT MSVC)
set(WAMR_BUILD_LIBC_WASI 1)
else()
set(WAMR_BUILD_LIBC_UVWASI 1)
endif()
if ((NOT DEFINED WAMR_BUILD_LIBC_WASI) AND (NOT DEFINED WAMR_BUILD_LIBC_UVWASI))
set (WAMR_BUILD_LIBC_WASI 1)
endif ()
if ((WAMR_BUILD_LIBC_WASI EQUAL 1) AND (WAMR_BUILD_LIBC_UVWASI EQUAL 1))
message (WARNING "-- pick WAMR_BULID_LIBC_UVWASI when both are enabled")
set (WAMR_BUILD_LIBC_WASI 0)
endif ()
else ()
if (NOT DEFINED WAMR_BUILD_LIBC_UVWASI)
set (WAMR_BUILD_LIBC_UVWASI 1)
endif ()
if (WAMR_BUILD_LIBC_WASI EQUAL 1)
message (WARNING "-- don't accept WAMR_BUILD_LIBC_WASI=1 on MINGW or MSVC")
set (WAMR_BUILD_LIBC_WASI 0)
endif ()
endif ()
if (NOT DEFINED WAMR_BUILD_LIBC_BUILTIN)
set (WAMR_BUILD_LIBC_BUILTIN 1)
endif ()
if (NOT DEFINED WAMR_BUILD_LIB_PTHREAD)
set (WAMR_BUILD_LIB_PTHREAD 1)
endif ()
if (NOT DEFINED WAMR_BUILD_LIB_WASI_THREADS)
set (WAMR_BUILD_LIB_WASI_THREADS 1)
endif ()
if (WAMR_BUILD_LIBC_UVWASI EQUAL 1)
message ("-- Libc WASI enabled with uvwasi implementation")
endif ()
if (WAMR_BUILD_LIBC_WASI EQUAL 1)
message ("-- Libc WASI enabled")
endif ()
if ((NOT WAMR_BUILD_LIBC_WASI) AND (NOT WAMR_BUILD_LIBC_UVWASI))
message ("-- Libc WASI disabled")
endif ()
if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1)
message ("-- Libc builtin enabled")
else ()
message ("-- Libc builtin disabled")
endif ()
if (WAMR_BUILD_LIB_PTHREAD EQUAL 1)
message ("-- Lib pthread enabled")
else ()
message ("-- Lib pthread disabled")
endif ()
if (WAMR_BUILD_LIB_WASI_THREADS EQUAL 1)
message ("-- Lib wasi-threads enabled")
else ()
message ("-- Lib wasi-threads disabled")
endif ()
include (${SHARED_DIR}/platform/${WAMR_BUILD_PLATFORM}/shared_platform.cmake)
include (${SHARED_DIR}/mem-alloc/mem_alloc.cmake)
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)
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-wasi-threads/lib_wasi_threads.cmake)
include (${IWASM_DIR}/common/iwasm_common.cmake)
include (${IWASM_DIR}/interpreter/iwasm_interp.cmake)
include (${IWASM_DIR}/aot/iwasm_aot.cmake)
include (${IWASM_DIR}/compilation/iwasm_compl.cmake)
if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1)
include (${IWASM_DIR}/libraries/libc-builtin/libc_builtin.cmake)
endif ()
if (WAMR_BUILD_LIBC_UVWASI EQUAL 1)
include (${IWASM_DIR}/libraries/libc-uvwasi/libc_uvwasi.cmake)
endif ()
if (WAMR_BUILD_LIBC_WASI EQUAL 1)
include (${IWASM_DIR}/libraries/libc-wasi/libc_wasi.cmake)
endif ()
if (WAMR_BUILD_LIB_PTHREAD EQUAL 1)
include (${IWASM_DIR}/libraries/lib-pthread/lib_pthread.cmake)
endif ()
if (WAMR_BUILD_LIB_WASI_THREADS EQUAL 1)
include (${IWASM_DIR}/libraries/lib-wasi-threads/lib_wasi_threads.cmake)
endif ()
# set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang" OR MSVC))