Quellcode durchsuchen

Turn warnings into errors in CI (#4397)

- Apply global warnings in warnings.cmake instead of maintaining them in
  separate files.
- Enable errors during CI when building iwasm and wamrc.
- Since GCC and Clang are the default compilers on Ubuntu and macOS, enabling
  `-Werror` on both platforms can be treated as checking with different
  compilers.
liang.he vor 4 Monaten
Ursprung
Commit
b71a6bf58f
35 geänderte Dateien mit 39 neuen und 63 gelöschten Zeilen
  1. 3 3
      .github/workflows/compilation_on_android_ubuntu.yml
  2. 2 2
      .github/workflows/compilation_on_macos.yml
  3. 0 2
      CMakeLists.txt
  4. 2 0
      build-scripts/config_common.cmake
  5. 1 2
      build-scripts/runtime_lib.cmake
  6. 28 0
      build-scripts/warnings.cmake
  7. 0 3
      product-mini/platforms/android/CMakeLists.txt
  8. 0 5
      product-mini/platforms/cosmopolitan/CMakeLists.txt
  9. 0 3
      product-mini/platforms/ios/CMakeLists.txt
  10. 0 5
      product-mini/platforms/linux/CMakeLists.txt
  11. 0 3
      product-mini/platforms/windows/CMakeLists.txt
  12. 0 1
      samples/basic/CMakeLists.txt
  13. 0 1
      samples/debug-tools/CMakeLists.txt
  14. 0 1
      samples/file/src/CMakeLists.txt
  15. 0 1
      samples/inst-context-threads/CMakeLists.txt
  16. 0 1
      samples/inst-context/CMakeLists.txt
  17. 0 1
      samples/multi-module/CMakeLists.txt
  18. 0 1
      samples/multi-thread/CMakeLists.txt
  19. 0 1
      samples/native-lib/CMakeLists.txt
  20. 0 1
      samples/native-stack-overflow/CMakeLists.txt
  21. 0 1
      samples/ref-types/CMakeLists.txt
  22. 0 1
      samples/shared-heap/CMakeLists.txt
  23. 0 1
      samples/shared-module/CMakeLists.txt
  24. 0 1
      samples/socket-api/CMakeLists.txt
  25. 0 1
      samples/spawn-thread/CMakeLists.txt
  26. 0 1
      samples/terminate/CMakeLists.txt
  27. 0 1
      samples/wasi-threads/CMakeLists.txt
  28. 0 1
      samples/wasm-c-api-imports/CMakeLists.txt
  29. 0 1
      samples/wasm-c-api/CMakeLists.txt
  30. 0 5
      test-tools/aot-analyzer/CMakeLists.txt
  31. 0 5
      tests/standalone/test-invoke-native/CMakeLists.txt
  32. 0 1
      tests/standalone/test-module-malloc/CMakeLists.txt
  33. 0 2
      tests/standalone/test-running-modes/c-embed/CMakeLists.txt
  34. 0 1
      tests/unit/wasm-c-api/CMakeLists.txt
  35. 3 3
      wamr-compiler/CMakeLists.txt

+ 3 - 3
.github/workflows/compilation_on_android_ubuntu.yml

@@ -124,7 +124,7 @@ jobs:
       - name: Build wamrc
         run: |
           mkdir build && cd build
-          cmake ..
+          cmake .. -DCMAKE_C_FLAGS="-Werror"
           cmake --build . --config Release --parallel 4
         working-directory: wamr-compiler
 
@@ -293,7 +293,7 @@ jobs:
         if: matrix.platform == 'linux'
         run: |
           mkdir build && cd build
-          cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
+          cmake .. -DCMAKE_C_FLAGS="-Werror" ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
           cmake --build . --config Release --parallel 4
         working-directory: product-mini/platforms/${{ matrix.platform }}
 
@@ -301,7 +301,7 @@ jobs:
         if: matrix.platform == 'android'
         run: |
           mkdir build && cd build
-          cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }} \
+          cmake .. -DCMAKE_C_FLAGS="-Werror" ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }} \
                 -DWAMR_BUILD_TARGET=X86_64
           cmake --build . --config Release --parallel 4
         working-directory: product-mini/platforms/${{ matrix.platform }}

+ 2 - 2
.github/workflows/compilation_on_macos.yml

@@ -107,7 +107,7 @@ jobs:
       - name: Build wamrc
         run: |
           mkdir build && cd build
-          cmake ..
+          cmake .. -DCMAKE_C_FLAGS="-Werror"
           cmake --build . --config Release --parallel 4
         working-directory: wamr-compiler
 
@@ -213,7 +213,7 @@ jobs:
       - name: Build iwasm
         run: |
           mkdir build && cd build
-          cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
+          cmake .. -DCMAKE_C_FLAGS="-Werror" ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
           cmake --build . --config Release --parallel 4
         working-directory: product-mini/platforms/${{ matrix.platform }}
 

+ 0 - 2
CMakeLists.txt

@@ -126,11 +126,9 @@ include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
 if (NOT WIN32)
   set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security \
                                        -ffunction-sections -fdata-sections \
-                                       -Wno-unused-parameter -Wno-pedantic \
                                        -fvisibility=hidden")
   # Remove the extra spaces for better make log
   string (REGEX REPLACE "  *" " " CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
-  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wno-unused")
 endif()
 
 if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")

+ 2 - 0
build-scripts/config_common.cmake

@@ -81,6 +81,8 @@ elseif (WAMR_BUILD_TARGET MATCHES "THUMB.*")
   set (CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,-mthumb")
 endif ()
 
+include (${CMAKE_CURRENT_LIST_DIR}/warnings.cmake)
+
 if (NOT WAMR_BUILD_INTERP EQUAL 1)
 if (NOT WAMR_BUILD_AOT EQUAL 1)
   message (FATAL_ERROR "-- WAMR Interpreter and AOT must be enabled at least one")

+ 1 - 2
build-scripts/runtime_lib.cmake

@@ -162,8 +162,7 @@ endif ()
 
 ####################### Common sources #######################
 if (NOT MSVC)
-    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -ffunction-sections -fdata-sections \
-                                         -Wall -Wno-unused-parameter -Wno-pedantic")
+    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -ffunction-sections -fdata-sections")
 endif ()
 
 # include the build config template file

+ 28 - 0
build-scripts/warnings.cmake

@@ -0,0 +1,28 @@
+# Copyright (C) 2019 Intel Corporation.  All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+# global additional warnings.
+if (MSVC)
+  # warning level 4
+  add_compile_options(/W4)
+else ()
+  # refer to https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
+  add_compile_options(
+    -Wall -Wextra -Wformat -Wformat-security
+     $<$<COMPILE_LANGUAGE:C>:-Wshadow>
+  )
+  # -pedantic causes warnings like "ISO C forbids initialization between function pointer and ‘void *’" which
+  #   is widely used in the codebase.
+  #
+  # -fpermissive causes warnings like "-fpermissive is valid for C++/ObjC++ but not for C"
+  #
+  add_compile_options (
+    $<$<COMPILE_LANGUAGE:C>:-Wincompatible-pointer-types>
+    $<$<COMPILE_LANGUAGE:C>:-Wimplicit-function-declaration>
+  )
+  # waivers
+  add_compile_options (
+    -Wno-unused
+    -Wno-unused-parameter
+  )
+endif ()

+ 0 - 3
product-mini/platforms/android/CMakeLists.txt

@@ -111,9 +111,6 @@ set_version_info (vmlib)
 
 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE")
 
-set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
-# set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
-
 if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
     set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")

+ 0 - 5
product-mini/platforms/cosmopolitan/CMakeLists.txt

@@ -136,11 +136,6 @@ set_version_info (vmlib)
 
 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
 
-set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wshadow")
-# set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
-
-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wno-unused")
-
 if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
     set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")

+ 0 - 3
product-mini/platforms/ios/CMakeLists.txt

@@ -113,9 +113,6 @@ include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
 
 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE")
 
-set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
-# set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
-
 if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
     set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")

+ 0 - 5
product-mini/platforms/linux/CMakeLists.txt

@@ -139,11 +139,6 @@ check_pie_supported()
 
 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
 
-set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wshadow")
-# set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
-
-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wno-unused")
-
 if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
     set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")

+ 0 - 3
product-mini/platforms/windows/CMakeLists.txt

@@ -114,9 +114,6 @@ if (NOT MINGW)
   set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
 endif ()
 
-# set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
-# set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
-
 if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang" OR MSVC))
     set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")

+ 0 - 1
samples/basic/CMakeLists.txt

@@ -60,7 +60,6 @@ if (NOT MSVC)
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
     set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
   endif ()
-  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
   if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
     if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
       set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")

+ 0 - 1
samples/debug-tools/CMakeLists.txt

@@ -60,7 +60,6 @@ set(WAMR_BUILD_DUMP_CALL_STACK 1) # Otherwise stack trace is not printed (addr2l
 if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
   set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
 endif ()
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
 
 # build out vmlib
 set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)

+ 0 - 1
samples/file/src/CMakeLists.txt

@@ -61,7 +61,6 @@ if (NOT MSVC)
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
     set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
   endif ()
-  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
   if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
     if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
       set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")

+ 0 - 1
samples/inst-context-threads/CMakeLists.txt

@@ -61,7 +61,6 @@ if (NOT MSVC)
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
     set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
   endif ()
-  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
   if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
     if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
       set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")

+ 0 - 1
samples/inst-context/CMakeLists.txt

@@ -60,7 +60,6 @@ if (NOT MSVC)
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
     set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
   endif ()
-  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
   if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
     if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
       set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")

+ 0 - 1
samples/multi-module/CMakeLists.txt

@@ -65,7 +65,6 @@ set(WAMR_BUILD_MULTI_MODULE 1)
 if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
   set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
 endif ()
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
 if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
     set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")

+ 0 - 1
samples/multi-thread/CMakeLists.txt

@@ -54,7 +54,6 @@ set(WAMR_BUILD_LIB_PTHREAD_SEMAPHORE 1)
 if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
   set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
 endif ()
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
 
 # build out vmlib
 set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)

+ 0 - 1
samples/native-lib/CMakeLists.txt

@@ -52,7 +52,6 @@ set (WAMR_BUILD_FAST_INTERP 1)
 if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
   set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
 endif ()
-set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
 
 # build out libiwasm
 set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)

+ 0 - 1
samples/native-stack-overflow/CMakeLists.txt

@@ -60,7 +60,6 @@ if (NOT MSVC)
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
     set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
   endif ()
-  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
   if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
     if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
       set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")

+ 0 - 1
samples/ref-types/CMakeLists.txt

@@ -74,7 +74,6 @@ if (NOT MSVC)
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
     set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
   endif ()
-  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
   if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
     if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
       set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")

+ 0 - 1
samples/shared-heap/CMakeLists.txt

@@ -61,7 +61,6 @@ if (NOT MSVC)
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
     set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
   endif ()
-  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
   if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
     if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
       set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")

+ 0 - 1
samples/shared-module/CMakeLists.txt

@@ -65,7 +65,6 @@ if (NOT MSVC)
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
     set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
   endif ()
-  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
   if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
     if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
       set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")

+ 0 - 1
samples/socket-api/CMakeLists.txt

@@ -177,7 +177,6 @@ set(WAMR_BUILD_REF_TYPES 1)
 if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
   set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
 endif ()
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
 
 # build vmlib static lib
 set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)

+ 0 - 1
samples/spawn-thread/CMakeLists.txt

@@ -53,7 +53,6 @@ set(WAMR_BUILD_SHARED_MEMORY 1)
 if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
   set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
 endif ()
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
 
 # build out vmlib
 set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)

+ 0 - 1
samples/terminate/CMakeLists.txt

@@ -68,7 +68,6 @@ if (NOT MSVC)
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
     set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
   endif ()
-  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
   if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
     if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
       set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")

+ 0 - 1
samples/wasi-threads/CMakeLists.txt

@@ -55,7 +55,6 @@ set(WAMR_BUILD_REF_TYPES 1)
 if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
   set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
 endif ()
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
 
 # build out vmlib
 set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)

+ 0 - 1
samples/wasm-c-api-imports/CMakeLists.txt

@@ -75,7 +75,6 @@ set(WAMR_BUILD_SIMD 0)
 if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
   set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
 endif ()
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
 
 # build out vmlib
 set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)

+ 0 - 1
samples/wasm-c-api/CMakeLists.txt

@@ -86,7 +86,6 @@ if (NOT MSVC)
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
     set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
   endif ()
-  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
   if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
     if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
       set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")

+ 0 - 5
test-tools/aot-analyzer/CMakeLists.txt

@@ -61,11 +61,6 @@ if (NOT DEFINED WAMR_BIG_ENDIAN)
   set (WAMR_BIG_ENDIAN 0)
 endif ()
 
-set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wshadow -Wno-unused-parameter")
-# set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
-
-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wno-unused")
-
 if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
     set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")

+ 0 - 5
tests/standalone/test-invoke-native/CMakeLists.txt

@@ -103,11 +103,6 @@ if (NOT WAMR_BUILD_PLATFORM STREQUAL "darwin")
   set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE")
 endif ()
 
-set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wshadow")
-# set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
-
-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wno-unused")
-
 if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
   if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
     set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")

+ 0 - 1
tests/standalone/test-module-malloc/CMakeLists.txt

@@ -58,7 +58,6 @@ set (WAMR_BUILD_LIBC_WASI 1)
 if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
   set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
 endif ()
-set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
 
 ################ wasm application ###############
 add_subdirectory(wasm-app)

+ 0 - 2
tests/standalone/test-running-modes/c-embed/CMakeLists.txt

@@ -43,8 +43,6 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
 if (NOT WAMR_BUILD_PLATFORM STREQUAL "darwin")
   set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE")
 endif ()
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wshadow")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wno-unused")
 
 # build out vmlib
 include(${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)

+ 0 - 1
tests/unit/wasm-c-api/CMakeLists.txt

@@ -25,7 +25,6 @@ set(WAMR_BUILD_FAST_INTERP 0)
 
 # compiling and linking flags
 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE")
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -mindirect-branch-register")
 
 # build out vmlib
 # hard code path here

+ 3 - 3
wamr-compiler/CMakeLists.txt

@@ -204,13 +204,13 @@ if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*
 endif()
 
 if (NOT MSVC)
-  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security \
-                                       -ffunction-sections -fdata-sections \
-                                       -Wno-unused-parameter -Wno-pedantic")
+  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections")
   # Remove the extra spaces for better make log
   string (REGEX REPLACE "  *" " " CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
 endif()
 
+include (${PROJECT_SOURCE_DIR}/../build-scripts/warnings.cmake)
+
 set (SHARED_DIR ../core/shared)
 set (IWASM_DIR ../core/iwasm)