diff --git a/CMakeLists.txt b/CMakeLists.txt index ef957586dc..6ec62c5134 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -201,6 +201,17 @@ if(CONFIG_COMPILER_DISABLE_GCC13_WARNINGS) "-Wno-dangling-reference") endif() +if(CONFIG_COMPILER_DISABLE_DEFAULT_ERRORS) + set(compiler_flags "-Wno-error") + if(NOT CMAKE_C_COMPILER_ID MATCHES "Clang") + list(APPEND compiler_flags "-Werror=all") + endif() + + list(APPEND compile_options ${compiler_flags}) + list(APPEND c_compile_options ${compiler_flags}) + list(APPEND cxx_compile_options ${compiler_flags}) +endif() + # GCC-specific options if(CMAKE_C_COMPILER_ID STREQUAL "GNU") list(APPEND compile_options "-fstrict-volatile-bitfields") diff --git a/Kconfig b/Kconfig index 26584d0aad..d7240e6329 100644 --- a/Kconfig +++ b/Kconfig @@ -541,6 +541,20 @@ mainmenu "Espressif IoT Development Framework Configuration" This option can be enabled for RISC-V targets only. + config COMPILER_DISABLE_DEFAULT_ERRORS + bool "Disable errors for default warnings" + default "y" + help + Enable this option if you do not want default warnings to be considered as errors, + especially when updating IDF. + + This is a temporary flag that could help to allow upgrade while having + some time to address the warnings raised by those default warnings. + Alternatives are: + 1) fix code (preferred), + 2) remove specific warnings, + 3) do not consider specific warnings as error. + config COMPILER_DISABLE_GCC12_WARNINGS bool "Disable new warnings introduced in GCC 12" default "n" diff --git a/tools/cmake/build.cmake b/tools/cmake/build.cmake index 85b11d0039..8fd16c4c0d 100644 --- a/tools/cmake/build.cmake +++ b/tools/cmake/build.cmake @@ -101,12 +101,13 @@ function(__build_set_default_build_specifications) "-fdata-sections" # warning-related flags "-Wall" - "-Werror=all" + "-Werror" "-Wno-error=unused-function" "-Wno-error=unused-variable" "-Wno-error=unused-but-set-variable" "-Wno-error=deprecated-declarations" "-Wextra" + "-Wno-error=extra" "-Wno-unused-parameter" "-Wno-sign-compare" # ignore multiple enum conversion warnings since gcc 11 diff --git a/tools/idf_py_actions/hints.yml b/tools/idf_py_actions/hints.yml index baff996045..78a16b9be4 100644 --- a/tools/idf_py_actions/hints.yml +++ b/tools/idf_py_actions/hints.yml @@ -320,6 +320,11 @@ re: "Error: libusb_open\\(\\) failed with LIBUSB_ERROR_NOT_FOUND" hint: "Device drivers are not correct.\nPlease check configuration of USB drivers: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/jtag-debugging/configure-ft2232h-jtag.html?highlight=zadig#configure-usb-drivers" +- + re: "-Werror=(address-of-packed-member|aggressive-loop-optimizations|attribute-warning|builtin-macro-redefined|cpp|designated-init|deprecated-declarations|discarded-array-qualifiers|discarded-qualifiers|div-by-zero|endif-labels|free-nonheap-object|if-not-aligned|ignored-attributes|incompatible-pointer-types|int-conversion|int-to-pointer-cast|lto-type-mismatch|multichar|overflow|override-init-side-effects|packed-bitfield-compat|pointer-compare|pointer-to-int-cast|return-local-addr|scalar-storage-order|shift-count-negative|shift-count-overflow|sizeof-array-argument|stringop-truncation| switch-bool|switch-outside-range|varargs)" + hint: "The error(s) '{}' may appear after IDF upgrade since previous versions were not considering those warnings as errors.\nTo suppress these warnings use 'idf.py menuconfig' to enable configure option 'Compiler options' -> 'Disabe errors for default warnings'\nPlease note that this is not a permanent solution, and this option will be removed in a future update of the ESP-IDF.\nIt is strongly recommended to fix all warnings, as they may indicate potential issues!" + match_to_output: True + - re: "(-Werror=address|-Werror=use-after-free)" hint: "The warning(s) '{}' may appear after compiler update above GCC-12\nTo suppress these warnings use 'idf.py menuconfig' to enable configure option 'Compiler options' -> 'Disable new warnings introduced in GCC 12'\nPlease note that this is not a permanent solution, and this option will be removed in a future update of the ESP-IDF.\nIt is strongly recommended to fix all warnings, as they may indicate potential issues!" diff --git a/tools/test_apps/configs/sdkconfig.debug_helpers b/tools/test_apps/configs/sdkconfig.debug_helpers index 9bb49614b9..2193c60124 100644 --- a/tools/test_apps/configs/sdkconfig.debug_helpers +++ b/tools/test_apps/configs/sdkconfig.debug_helpers @@ -5,3 +5,4 @@ CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y CONFIG_COMPILER_STACK_CHECK_MODE_STRONG=y CONFIG_COMPILER_STACK_CHECK=y CONFIG_FREERTOS_USE_LIST_DATA_INTEGRITY_CHECK_BYTES=y +CONFIG_COMPILER_DISABLE_DEFAULT_ERRORS=n diff --git a/tools/test_apps/system/build_test/sdkconfig.ci.werror b/tools/test_apps/system/build_test/sdkconfig.ci.werror new file mode 100644 index 0000000000..613937594c --- /dev/null +++ b/tools/test_apps/system/build_test/sdkconfig.ci.werror @@ -0,0 +1 @@ +CONFIG_COMPILER_DISABLE_DEFAULT_ERRORS=n