Fix compilation warnings on Windows (#2868)

This commit is contained in:
Wenyong Huang 2023-12-06 16:12:33 +08:00 committed by GitHub
parent 39d0fabda3
commit 67a887e2d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 11 deletions

View File

@ -55,8 +55,6 @@ def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_fl
"-DLLVM_APPEND_VC_REV:BOOL=ON", "-DLLVM_APPEND_VC_REV:BOOL=ON",
"-DLLVM_BUILD_EXAMPLES:BOOL=OFF", "-DLLVM_BUILD_EXAMPLES:BOOL=OFF",
"-DLLVM_BUILD_LLVM_DYLIB:BOOL=OFF", "-DLLVM_BUILD_LLVM_DYLIB:BOOL=OFF",
"-DLLVM_BUILD_TESTS:BOOL=OFF",
"-DLLVM_CCACHE_BUILD:BOOL=ON",
"-DLLVM_ENABLE_BINDINGS:BOOL=OFF", "-DLLVM_ENABLE_BINDINGS:BOOL=OFF",
"-DLLVM_ENABLE_IDE:BOOL=OFF", "-DLLVM_ENABLE_IDE:BOOL=OFF",
"-DLLVM_ENABLE_LIBEDIT=OFF", "-DLLVM_ENABLE_LIBEDIT=OFF",
@ -68,9 +66,13 @@ def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_fl
"-DLLVM_INCLUDE_UTILS:BOOL=OFF", "-DLLVM_INCLUDE_UTILS:BOOL=OFF",
"-DLLVM_INCLUDE_TESTS:BOOL=OFF", "-DLLVM_INCLUDE_TESTS:BOOL=OFF",
"-DLLVM_OPTIMIZED_TABLEGEN:BOOL=ON", "-DLLVM_OPTIMIZED_TABLEGEN:BOOL=ON",
"-DLLVM_USE_PERF:BOOL=ON",
] ]
# ccache and perf support are not available on Windows
if not "windows" == platform:
LLVM_COMPILE_OPTIONS.append("-DLLVM_CCACHE_BUILD:BOOL=ON")
LLVM_COMPILE_OPTIONS.append("-DLLVM_USE_PERF:BOOL=ON")
# use clang/clang++/lld. but macos doesn't support lld # use clang/clang++/lld. but macos doesn't support lld
if not sys.platform.startswith("darwin") and use_clang: if not sys.platform.startswith("darwin") and use_clang:
if shutil.which("clang") and shutil.which("clang++") and shutil.which("lld"): if shutil.which("clang") and shutil.which("clang++") and shutil.which("lld"):

View File

@ -658,7 +658,8 @@ aot_add_llvm_func(AOTCompContext *comp_ctx, LLVMModuleRef module,
const char *key = "frame-pointer"; const char *key = "frame-pointer";
const char *val = "all"; const char *val = "all";
LLVMAttributeRef no_omit_fp = LLVMCreateStringAttribute( LLVMAttributeRef no_omit_fp = LLVMCreateStringAttribute(
comp_ctx->context, key, strlen(key), val, strlen(val)); comp_ctx->context, key, (unsigned)strlen(key), val,
(unsigned)strlen(val));
if (!no_omit_fp) { if (!no_omit_fp) {
aot_set_last_error("create LLVM attribute (frame-pointer) failed."); aot_set_last_error("create LLVM attribute (frame-pointer) failed.");
goto fail; goto fail;

View File

@ -58,7 +58,7 @@ bh_bitmap_delete(bh_bitmap *bitmap)
* @return true if the index is in range, false otherwise * @return true if the index is in range, false otherwise
*/ */
static inline bool static inline bool
bh_bitmap_is_in_range(bh_bitmap *bitmap, unsigned n) bh_bitmap_is_in_range(bh_bitmap *bitmap, uintptr_t n)
{ {
return n >= bitmap->begin_index && n < bitmap->end_index; return n >= bitmap->begin_index && n < bitmap->end_index;
} }
@ -72,9 +72,9 @@ bh_bitmap_is_in_range(bh_bitmap *bitmap, unsigned n)
* @return value of the bit * @return value of the bit
*/ */
static inline int static inline int
bh_bitmap_get_bit(bh_bitmap *bitmap, unsigned n) bh_bitmap_get_bit(bh_bitmap *bitmap, uintptr_t n)
{ {
unsigned idx = n - bitmap->begin_index; uintptr_t idx = n - bitmap->begin_index;
bh_assert(n >= bitmap->begin_index && n < bitmap->end_index); bh_assert(n >= bitmap->begin_index && n < bitmap->end_index);
return (bitmap->map[idx / 8] >> (idx % 8)) & 1; return (bitmap->map[idx / 8] >> (idx % 8)) & 1;
} }
@ -86,9 +86,9 @@ bh_bitmap_get_bit(bh_bitmap *bitmap, unsigned n)
* @param n the n-th bit to be set * @param n the n-th bit to be set
*/ */
static inline void static inline void
bh_bitmap_set_bit(bh_bitmap *bitmap, unsigned n) bh_bitmap_set_bit(bh_bitmap *bitmap, uintptr_t n)
{ {
unsigned idx = n - bitmap->begin_index; uintptr_t idx = n - bitmap->begin_index;
bh_assert(n >= bitmap->begin_index && n < bitmap->end_index); bh_assert(n >= bitmap->begin_index && n < bitmap->end_index);
bitmap->map[idx / 8] |= 1 << (idx % 8); bitmap->map[idx / 8] |= 1 << (idx % 8);
} }
@ -100,9 +100,9 @@ bh_bitmap_set_bit(bh_bitmap *bitmap, unsigned n)
* @param n the n-th bit to be cleared * @param n the n-th bit to be cleared
*/ */
static inline void static inline void
bh_bitmap_clear_bit(bh_bitmap *bitmap, unsigned n) bh_bitmap_clear_bit(bh_bitmap *bitmap, uintptr_t n)
{ {
unsigned idx = n - bitmap->begin_index; uintptr_t idx = n - bitmap->begin_index;
bh_assert(n >= bitmap->begin_index && n < bitmap->end_index); bh_assert(n >= bitmap->begin_index && n < bitmap->end_index);
bitmap->map[idx / 8] &= ~(1 << (idx % 8)); bitmap->map[idx / 8] &= ~(1 << (idx % 8));
} }