Fix windows build error and compilation warnings (#3095)

Fix wamrc build error reported on Windows:
```bash
CMake Error at CMakeLists.txt:84 (message):
  Unsupported CMAKE_HOST_SYSTEM_PROCESSOR AMD64
```
And clear several compilation warnings.
This commit is contained in:
Wenyong Huang 2024-01-29 18:57:57 +08:00 committed by GitHub
parent b98f150f82
commit 7f8e2133ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 19 deletions

View File

@ -1934,8 +1934,8 @@ wasm_frame_vec_clone_internal(Vector *src, Vector *out)
return;
}
bh_memcpy_s(out->data, src->num_elems * sizeof(WASMCApiFrame), src->data,
src->num_elems * sizeof(WASMCApiFrame));
bh_memcpy_s(out->data, (uint32)(src->num_elems * sizeof(WASMCApiFrame)),
src->data, (uint32)(src->num_elems * sizeof(WASMCApiFrame)));
out->num_elems = src->num_elems;
}
@ -2962,8 +2962,10 @@ wasm_func_new_basic(wasm_store_t *store, const wasm_functype_t *type,
if (!(func->type = wasm_functype_copy(type))) {
goto failed;
}
func->param_count = func->type->params->num_elems;
func->result_count = func->type->results->num_elems;
/* func type's param_count and result_count were checked in
loader and are no larger than UINT16_MAX */
func->param_count = (uint16)func->type->params->num_elems;
func->result_count = (uint16)func->type->results->num_elems;
RETURN_OBJ(func, wasm_func_delete)
}
@ -2994,8 +2996,10 @@ wasm_func_new_with_env_basic(wasm_store_t *store, const wasm_functype_t *type,
if (!(func->type = wasm_functype_copy(type))) {
goto failed;
}
func->param_count = func->type->params->num_elems;
func->result_count = func->type->results->num_elems;
/* func type's param_count and result_count were checked in
loader and are no larger than UINT16_MAX */
func->param_count = (uint16)func->type->params->num_elems;
func->result_count = (uint16)func->type->results->num_elems;
RETURN_OBJ(func, wasm_func_delete)
}
@ -3085,8 +3089,10 @@ wasm_func_new_internal(wasm_store_t *store, uint16 func_idx_rt,
if (!func->type) {
goto failed;
}
func->param_count = func->type->params->num_elems;
func->result_count = func->type->results->num_elems;
/* func type's param_count and result_count were checked in
loader and are no larger than UINT16_MAX */
func->param_count = (uint16)func->type->params->num_elems;
func->result_count = (uint16)func->type->results->num_elems;
/* will add name information when processing "exports" */
func->store = store;

View File

@ -59,30 +59,31 @@ if (DEFINED WAMR_BUILD_AOT_FUNC_PREFIX)
endif ()
if (NOT WAMR_BUILD_TARGET)
if (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
string(TOLOWER "${CMAKE_HOST_SYSTEM_PROCESSOR}" HOST_SYSTEM_PROCESSOR)
if (${HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set (WAMR_BUILD_TARGET "X86_64")
elseif (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "i686")
elseif (${HOST_SYSTEM_PROCESSOR} STREQUAL "i686")
set (WAMR_BUILD_TARGET "X86_32")
elseif (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "amd64")
elseif (${HOST_SYSTEM_PROCESSOR} STREQUAL "amd64")
set (WAMR_BUILD_TARGET "AMD_64")
elseif (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "aarch64"
OR CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64")
elseif (${HOST_SYSTEM_PROCESSOR} STREQUAL "aarch64"
OR ${HOST_SYSTEM_PROCESSOR} STREQUAL "arm64")
set (WAMR_BUILD_TARGET "AARCH64")
elseif (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm.*")
elseif (${HOST_SYSTEM_PROCESSOR} MATCHES "arm.*")
message(STATUS "Assuming ${CMAKE_HOST_SYSTEM_PROCESSOR} as ARM_32")
set (WAMR_BUILD_TARGET "ARM_32")
elseif (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "mips")
elseif (${HOST_SYSTEM_PROCESSOR} STREQUAL "mips")
set (WAMR_BUILD_TARGET "MIPS_32")
elseif (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "xtensa")
elseif (${HOST_SYSTEM_PROCESSOR} STREQUAL "xtensa")
set (WAMR_BUILD_TARGET "XTENSA_32")
elseif (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "riscv64")
elseif (${HOST_SYSTEM_PROCESSOR} STREQUAL "riscv64")
set (WAMR_BUILD_TARGET "RISCV64")
elseif (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "riscv")
elseif (${HOST_SYSTEM_PROCESSOR} STREQUAL "riscv")
message(STATUS "Assuming ${CMAKE_HOST_SYSTEM_PROCESSOR} as RISCV32")
set (WAMR_BUILD_TARGET "RISCV32")
else ()
message (FATAL_ERROR "Unsupported CMAKE_HOST_SYSTEM_PROCESSOR "
"${CMAKE_HOST_SYSTEM_PROCESSOR}")
"${CMAKE_HOST_SYSTEM_PROCESSOR}")
endif()
if (WAMR_BUILD_PLATFORM STREQUAL "windows")