Add wamrc AoT compiler building support for Windows(MSVC) (#332)

This commit is contained in:
sophy228
2020-08-11 11:30:51 +08:00
committed by GitHub
parent 3be29c3f46
commit 8ad9c1775f
23 changed files with 1186 additions and 23 deletions

View File

@ -29,6 +29,16 @@ typedef struct {
#define REG_ATOMIC_WAIT_SYM()
#endif
#if (defined(_WIN32) || defined(_WIN32_)) && defined(NDEBUG)
#define REG_COMMON_SYMBOLS \
REG_SYM(aot_set_exception_with_id), \
REG_SYM(aot_invoke_native), \
REG_SYM(aot_call_indirect), \
REG_SYM(wasm_runtime_enlarge_memory), \
REG_SYM(wasm_runtime_set_exception), \
REG_BULK_MEMORY_SYM() \
REG_ATOMIC_WAIT_SYM()
#else /* else of (defined(_WIN32) || defined(_WIN32_)) && defined(NDEBUG) */
#define REG_COMMON_SYMBOLS \
REG_SYM(aot_set_exception_with_id), \
REG_SYM(aot_invoke_native), \
@ -49,6 +59,7 @@ typedef struct {
REG_SYM(rintf), \
REG_BULK_MEMORY_SYM() \
REG_ATOMIC_WAIT_SYM()
#endif /* end of (defined(_WIN32) || defined(_WIN32_)) && defined(NDEBUG) */
#define CHECK_RELOC_OFFSET(data_size) do { \
if (!check_reloc_offset(target_section_size, reloc_offset, data_size, \

View File

@ -1747,7 +1747,7 @@ aot_set_aux_stack(WASMExecEnv *exec_env,
set the initial value for the global */
uint32 global_offset =
module->globals[stack_top_idx].data_offset;
uint8 *global_addr = module_inst->global_data.ptr + global_offset;
uint8 *global_addr = (uint8 *)module_inst->global_data.ptr + global_offset;
*(int32*)global_addr = start_offset;
/* The aux stack boundary is a constant value,

View File

@ -15,11 +15,13 @@ void __umoddi3();
static SymbolMap target_sym_map[] = {
REG_COMMON_SYMBOLS
#if !defined(_WIN32) && !defined(_WIN32_)
/* compiler-rt symbols that come from compiler(e.g. gcc) */
REG_SYM(__divdi3),
REG_SYM(__udivdi3),
REG_SYM(__moddi3),
REG_SYM(__umoddi3)
#endif
};
static void

View File

@ -0,0 +1,27 @@
;
; Copyright (C) 2019 Intel Corporation. All rights reserved.
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
;
.386
.model flat
.code
_invokeNative PROC
push ebp
mov ebp,esp
mov ecx, [ebp+16] ; ecx = argc */
mov edx, [ebp+12] ; edx = argv */
test ecx, ecx
jz skip_push_args ; if ecx == 0, skip pushing arguments */
lea edx, [edx+ecx*4-4] ; edx = edx + ecx * 4 - 4 */
sub edx,esp ; edx = edx - esp */
loop_push:
push [esp+edx]
loop loop_push ; loop ecx counts */
skip_push_args:
mov edx, [ebp+8] ; edx = func_ptr */
call edx
leave
ret
_invokeNative ENDP
END

View File

@ -13,7 +13,11 @@ file (GLOB c_source_all ${IWASM_COMMON_DIR}/*.c)
if (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_em64.s)
elseif (WAMR_BUILD_TARGET STREQUAL "X86_32")
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_ia32.s)
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_ia32.asm)
else ()
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_ia32.s)
endif ()
elseif (WAMR_BUILD_TARGET MATCHES "ARM.*")
if (WAMR_BUILD_TARGET MATCHES "ARM.*_VFP")
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_arm_vfp.s)

View File

@ -1785,7 +1785,7 @@ aot_global_set(const AOTModuleInstance *inst_aot,
.type;
}
data = inst_aot->global_data.ptr + data_offset;
data = (void *)((uint8 *)inst_aot->global_data.ptr + data_offset);
switch (val_type_rt) {
case VALUE_TYPE_I32:
bh_assert(WASM_I32 == v->kind);
@ -1834,7 +1834,7 @@ aot_global_get(const AOTModuleInstance *inst_aot,
.type;
}
data = inst_aot->global_data.ptr + data_offset;
data = (void *)((uint8 *)inst_aot->global_data.ptr + data_offset);
switch (val_type_rt) {
case VALUE_TYPE_I32:
out->kind = WASM_I32;

View File

@ -91,7 +91,9 @@ struct wasm_export_type_t {
};
/* Runtime Objects */
struct wasm_ref_t {};
struct wasm_ref_t {
uint32 obj;
};
struct wasm_trap_t {
wasm_byte_vec_t *message;

View File

@ -8,6 +8,11 @@
#include "wasm_export.h"
#include "../interpreter/wasm.h"
#if defined(_WIN32) || defined(_WIN32_)
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#endif
void
wasm_runtime_set_exception(wasm_module_inst_t module, const char *exception);
@ -213,8 +218,17 @@ _vprintf_wa(out_func_t out, void *ctx, const char *fmt, _va_list ap,
padding = PAD_ZERO_BEFORE;
goto still_might_format;
}
/* Fall through */
case '1' ... '9':
goto handle_1_to_9;
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
handle_1_to_9:
if (min_width < 0) {
min_width = *fmt - '0';
} else {