mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/gcc_error_on_default_warnings' into 'master'
feat(tools): Make default warnings as errors Closes IDFGH-9945 See merge request espressif/esp-idf!30149
This commit is contained in:
commit
b1768dcd8e
@ -201,6 +201,12 @@ if(CONFIG_COMPILER_DISABLE_GCC13_WARNINGS)
|
||||
"-Wno-dangling-reference")
|
||||
endif()
|
||||
|
||||
if(CONFIG_COMPILER_DISABLE_DEFAULT_ERRORS)
|
||||
if(NOT CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
idf_build_replace_option_from_property(COMPILE_OPTIONS "-Werror" "-Werror=all")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# GCC-specific options
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
list(APPEND compile_options "-fstrict-volatile-bitfields")
|
||||
|
14
Kconfig
14
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"
|
||||
|
@ -61,6 +61,35 @@ function(idf_build_unset_property property)
|
||||
idf_build_set_property(__BUILD_PROPERTIES "${build_properties}")
|
||||
endfunction()
|
||||
|
||||
# idf_build_replace_option_from_property
|
||||
#
|
||||
# @brief Replace specified option with new one in a given property.
|
||||
#
|
||||
# @param[in] property_name the property in which to replace the options (ex.: COMPILE_OPTIONS, C_COMPILE_OPTIONS,..)
|
||||
#
|
||||
# @param[in] option_to_remove the option to be replaced
|
||||
# @param[in] new_option the option to replace with (if empty, the old option will be removed)
|
||||
#
|
||||
# Example usage:
|
||||
# idf_build_replace_options_from_property(COMPILE_OPTIONS "-Werror" "-Werror=all")
|
||||
# idf_build_replace_options_from_property(COMPILE_OPTIONS "-Wno-error=extra" "")
|
||||
#
|
||||
function(idf_build_replace_option_from_property property_name option_to_remove new_option)
|
||||
idf_build_get_property(current_list_of_options ${property_name})
|
||||
|
||||
set(new_list_of_options)
|
||||
foreach(option ${current_list_of_options})
|
||||
if(option STREQUAL option_to_remove)
|
||||
list(APPEND new_list_of_options "${new_option}")
|
||||
else()
|
||||
list(APPEND new_list_of_options "${option}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Set the updated list back
|
||||
idf_build_set_property(${property_name} "${new_list_of_options}")
|
||||
endfunction()
|
||||
|
||||
#
|
||||
# Retrieve the IDF_PATH repository's version, either using a version
|
||||
# file or Git revision. Sets the IDF_VER build property.
|
||||
@ -101,12 +130,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
|
||||
|
@ -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!"
|
||||
|
@ -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
|
||||
|
1
tools/test_apps/system/build_test/sdkconfig.ci.werror
Normal file
1
tools/test_apps/system/build_test/sdkconfig.ci.werror
Normal file
@ -0,0 +1 @@
|
||||
CONFIG_COMPILER_DISABLE_DEFAULT_ERRORS=n
|
Loading…
x
Reference in New Issue
Block a user