mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
feat(build): Add config to disable warn be considered as errors
The -Werror=all activates error for all warnings in -Wall, however, it
does not activate error for other default warnings, such as:
- int-conversion (pointer from integer w/o a cast)
- incompatible-pointer-types
- discarded-qualifiers
Which are IMO even more important that -Wall.
This commit fixes that by activating error for all warnings (i.e. from
-Wall and default ones) and removing those from -Wextra, as the culprit
commit seemed to address.
Fixes: 60f29236f6
"Build system: Raise warning level" (2016-11-16)
In order to avoid long analysis during esp-idf upgrade, provide a way to
restore the previous -Werror=all behavior that consider only warnings
from -Wall (and not default ones).
Also add a hint to use the Kconfig option on compilation error, but warn
that fixing the code is the preferred way.
Merges https://github.com/espressif/esp-idf/pull/11239
Suggested-By: Ivan Grokhotkov <ivan@espressif.com>
This commit is contained in:
parent
d0eed3a65e
commit
9456c157ff
@ -201,6 +201,17 @@ if(CONFIG_COMPILER_DISABLE_GCC13_WARNINGS)
|
|||||||
"-Wno-dangling-reference")
|
"-Wno-dangling-reference")
|
||||||
endif()
|
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
|
# GCC-specific options
|
||||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||||
list(APPEND compile_options "-fstrict-volatile-bitfields")
|
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.
|
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
|
config COMPILER_DISABLE_GCC12_WARNINGS
|
||||||
bool "Disable new warnings introduced in GCC 12"
|
bool "Disable new warnings introduced in GCC 12"
|
||||||
default "n"
|
default "n"
|
||||||
|
@ -101,12 +101,13 @@ function(__build_set_default_build_specifications)
|
|||||||
"-fdata-sections"
|
"-fdata-sections"
|
||||||
# warning-related flags
|
# warning-related flags
|
||||||
"-Wall"
|
"-Wall"
|
||||||
"-Werror=all"
|
"-Werror"
|
||||||
"-Wno-error=unused-function"
|
"-Wno-error=unused-function"
|
||||||
"-Wno-error=unused-variable"
|
"-Wno-error=unused-variable"
|
||||||
"-Wno-error=unused-but-set-variable"
|
"-Wno-error=unused-but-set-variable"
|
||||||
"-Wno-error=deprecated-declarations"
|
"-Wno-error=deprecated-declarations"
|
||||||
"-Wextra"
|
"-Wextra"
|
||||||
|
"-Wno-error=extra"
|
||||||
"-Wno-unused-parameter"
|
"-Wno-unused-parameter"
|
||||||
"-Wno-sign-compare"
|
"-Wno-sign-compare"
|
||||||
# ignore multiple enum conversion warnings since gcc 11
|
# ignore multiple enum conversion warnings since gcc 11
|
||||||
|
@ -320,6 +320,11 @@
|
|||||||
re: "Error: libusb_open\\(\\) failed with LIBUSB_ERROR_NOT_FOUND"
|
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"
|
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)"
|
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!"
|
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_MODE_STRONG=y
|
||||||
CONFIG_COMPILER_STACK_CHECK=y
|
CONFIG_COMPILER_STACK_CHECK=y
|
||||||
CONFIG_FREERTOS_USE_LIST_DATA_INTEGRITY_CHECK_BYTES=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…
Reference in New Issue
Block a user