Просмотр исходного кода

Fix compilation warnings on Windows (#2868)

Wenyong Huang 2 лет назад
Родитель
Сommit
67a887e2d3
3 измененных файлов с 14 добавлено и 11 удалено
  1. 5 3
      build-scripts/build_llvm.py
  2. 2 1
      core/iwasm/compilation/aot_llvm.c
  3. 7 7
      core/shared/utils/bh_bitmap.h

+ 5 - 3
build-scripts/build_llvm.py

@@ -55,8 +55,6 @@ def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_fl
         "-DLLVM_APPEND_VC_REV:BOOL=ON",
         "-DLLVM_BUILD_EXAMPLES: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_IDE:BOOL=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_TESTS:BOOL=OFF",
         "-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
     if not sys.platform.startswith("darwin") and use_clang:
         if shutil.which("clang") and shutil.which("clang++") and shutil.which("lld"):

+ 2 - 1
core/iwasm/compilation/aot_llvm.c

@@ -658,7 +658,8 @@ aot_add_llvm_func(AOTCompContext *comp_ctx, LLVMModuleRef module,
         const char *key = "frame-pointer";
         const char *val = "all";
         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) {
             aot_set_last_error("create LLVM attribute (frame-pointer) failed.");
             goto fail;

+ 7 - 7
core/shared/utils/bh_bitmap.h

@@ -58,7 +58,7 @@ bh_bitmap_delete(bh_bitmap *bitmap)
  * @return true if the index is in range, false otherwise
  */
 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;
 }
@@ -72,9 +72,9 @@ bh_bitmap_is_in_range(bh_bitmap *bitmap, unsigned n)
  * @return value of the bit
  */
 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);
     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
  */
 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);
     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
  */
 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);
     bitmap->map[idx / 8] &= ~(1 << (idx % 8));
 }