Skip to content

Commit 5867527

Browse files
authored
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 <[email protected]>
1 parent 28f1040 commit 5867527

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

core/iwasm/common/wasm_c_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2479,7 +2479,7 @@ wasm_func_call(const wasm_func_t *func,
24792479
param_count = wasm_func_param_arity(func);
24802480
result_count = wasm_func_result_arity(func);
24812481
alloc_count = (param_count > result_count) ? param_count : result_count;
2482-
if (alloc_count > sizeof(argv_buf) / sizeof(uint64)) {
2482+
if (alloc_count > (size_t)sizeof(argv_buf) / sizeof(uint64)) {
24832483
if (!(argv = malloc_internal(sizeof(uint64) * alloc_count))) {
24842484
goto failed;
24852485
}

core/shared/platform/common/posix/posix_thread.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,7 @@ static os_thread_local_attribute uint8 *sigalt_stack_base_addr;
339339

340340
#if defined(__clang__)
341341
#pragma clang optimize off
342-
#endif
343-
#if defined(__GNUC__)
342+
#elif defined(__GNUC__)
344343
#pragma GCC push_options
345344
#pragma GCC optimize("O0")
346345
__attribute__((no_sanitize_address))
@@ -361,11 +360,10 @@ touch_pages(uint8 *stack_min_addr, uint32 page_size)
361360
}
362361
return sum;
363362
}
364-
#if defined(__GNUC__)
365-
#pragma GCC pop_options
366-
#endif
367363
#if defined(__clang__)
368364
#pragma clang optimize on
365+
#elif defined(__GNUC__)
366+
#pragma GCC pop_options
369367
#endif
370368

371369
static bool

core/shared/utils/runtime_timer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ typedef struct _app_timer {
1919
bool is_periodic;
2020
} app_timer_t;
2121

22-
typedef struct _timer_ctx {
22+
struct _timer_ctx {
2323
app_timer_t *app_timers;
2424
app_timer_t *idle_timers;
2525
app_timer_t *free_timers;
@@ -33,7 +33,7 @@ typedef struct _timer_ctx {
3333

3434
timer_callback_f timer_callback;
3535
check_timer_expiry_f refresh_checker;
36-
} *timer_ctx_t;
36+
};
3737

3838
uint64
3939
bh_get_tick_ms()

wamr-compiler/CMakeLists.txt

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ if (NOT WAMR_BUILD_TARGET)
5050
if (("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win32"))
5151
set (WAMR_BUILD_TARGET "X86_32")
5252
endif()
53+
elseif (WAMR_BUILD_PLATFORM STREQUAL "darwin")
54+
if (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64")
55+
set (WAMR_BUILD_TARGET "AARCH64")
56+
endif ()
5357
endif()
5458
endif ()
5559

@@ -107,17 +111,19 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
107111
endif ()
108112

109113
# Enable LLVM
110-
set (LLVM_SRC_ROOT "${PROJECT_SOURCE_DIR}/../core/deps/llvm")
111-
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
112-
if (NOT EXISTS "${LLVM_SRC_ROOT}/win32build")
113-
message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/win32build")
114-
endif ()
115-
set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/win32build;${CMAKE_PREFIX_PATH}")
116-
else()
117-
if (NOT EXISTS "${LLVM_SRC_ROOT}/build")
118-
message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/build")
114+
if (NOT WAMR_BUILD_WITH_CUSTOM_LLVM)
115+
set (LLVM_SRC_ROOT "${PROJECT_SOURCE_DIR}/../core/deps/llvm")
116+
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
117+
if (NOT EXISTS "${LLVM_SRC_ROOT}/win32build")
118+
message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/win32build")
119+
endif ()
120+
set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/win32build;${CMAKE_PREFIX_PATH}")
121+
else()
122+
if (NOT EXISTS "${LLVM_SRC_ROOT}/build")
123+
message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/build")
124+
endif ()
125+
set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/build;${CMAKE_PREFIX_PATH}")
119126
endif ()
120-
set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/build;${CMAKE_PREFIX_PATH}")
121127
endif ()
122128

123129
find_package(LLVM REQUIRED CONFIG)

0 commit comments

Comments
 (0)