Эх сурвалжийг харах

Enable to build wamrc with custom llvm and fix some compile warnings (#672)

Enable to build wamrc with custom llvm, enable to auto detect processor on apple silicon, and fix some compile warnings.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Huang Qi 4 жил өмнө
parent
commit
586752735b

+ 1 - 1
core/iwasm/common/wasm_c_api.c

@@ -2479,7 +2479,7 @@ wasm_func_call(const wasm_func_t *func,
     param_count = wasm_func_param_arity(func);
     result_count = wasm_func_result_arity(func);
     alloc_count = (param_count > result_count) ? param_count : result_count;
-    if (alloc_count > sizeof(argv_buf) / sizeof(uint64)) {
+    if (alloc_count > (size_t)sizeof(argv_buf) / sizeof(uint64)) {
         if (!(argv = malloc_internal(sizeof(uint64) * alloc_count))) {
             goto failed;
         }

+ 3 - 5
core/shared/platform/common/posix/posix_thread.c

@@ -339,8 +339,7 @@ static os_thread_local_attribute uint8 *sigalt_stack_base_addr;
 
 #if defined(__clang__)
 #pragma clang optimize off
-#endif
-#if defined(__GNUC__)
+#elif defined(__GNUC__)
 #pragma GCC push_options
 #pragma GCC optimize("O0")
 __attribute__((no_sanitize_address))
@@ -361,11 +360,10 @@ touch_pages(uint8 *stack_min_addr, uint32 page_size)
     }
     return sum;
 }
-#if defined(__GNUC__)
-#pragma GCC pop_options
-#endif
 #if defined(__clang__)
 #pragma clang optimize on
+#elif defined(__GNUC__)
+#pragma GCC pop_options
 #endif
 
 static bool

+ 2 - 2
core/shared/utils/runtime_timer.c

@@ -19,7 +19,7 @@ typedef struct _app_timer {
     bool is_periodic;
 } app_timer_t;
 
-typedef struct _timer_ctx {
+struct _timer_ctx {
     app_timer_t *app_timers;
     app_timer_t *idle_timers;
     app_timer_t *free_timers;
@@ -33,7 +33,7 @@ typedef struct _timer_ctx {
 
     timer_callback_f timer_callback;
     check_timer_expiry_f refresh_checker;
-} *timer_ctx_t;
+};
 
 uint64
 bh_get_tick_ms()

+ 16 - 10
wamr-compiler/CMakeLists.txt

@@ -50,6 +50,10 @@ if (NOT WAMR_BUILD_TARGET)
     if (("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win32"))
       set (WAMR_BUILD_TARGET "X86_32")
     endif()
+  elseif (WAMR_BUILD_PLATFORM STREQUAL "darwin")
+    if (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64")
+      set (WAMR_BUILD_TARGET "AARCH64")
+    endif ()
   endif()
 endif ()
 
@@ -107,17 +111,19 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
 endif ()
 
 # Enable LLVM
-set (LLVM_SRC_ROOT "${PROJECT_SOURCE_DIR}/../core/deps/llvm")
-if (WAMR_BUILD_PLATFORM STREQUAL "windows")
-  if (NOT EXISTS "${LLVM_SRC_ROOT}/win32build")
-    message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/win32build")
-  endif ()
-  set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/win32build;${CMAKE_PREFIX_PATH}")
-else()
-  if (NOT EXISTS "${LLVM_SRC_ROOT}/build")
-    message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/build")
+if (NOT WAMR_BUILD_WITH_CUSTOM_LLVM)
+  set (LLVM_SRC_ROOT "${PROJECT_SOURCE_DIR}/../core/deps/llvm")
+  if (WAMR_BUILD_PLATFORM STREQUAL "windows")
+    if (NOT EXISTS "${LLVM_SRC_ROOT}/win32build")
+      message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/win32build")
+    endif ()
+    set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/win32build;${CMAKE_PREFIX_PATH}")
+  else()
+    if (NOT EXISTS "${LLVM_SRC_ROOT}/build")
+      message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/build")
+    endif ()
+    set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/build;${CMAKE_PREFIX_PATH}")
   endif ()
-  set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/build;${CMAKE_PREFIX_PATH}")
 endif ()
 
 find_package(LLVM REQUIRED CONFIG)