From 0da15a7a19c97d38569ddbe3b919045834408c25 Mon Sep 17 00:00:00 2001 From: Alexey Lapshin Date: Wed, 15 Feb 2023 15:01:52 +0700 Subject: [PATCH] build: add option COMPILER_DISABLE_GCC12_WARNINGS --- CMakeLists.txt | 5 +++++ Kconfig | 7 +++++++ tools/idf_py_actions/hints.yml | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 111891ebce..5869c4c1e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,6 +179,11 @@ if(NOT ${CMAKE_C_COMPILER_VERSION} VERSION_LESS 8.0.0) endif() endif() +if(CONFIG_COMPILER_DISABLE_GCC12_WARNINGS) + list(APPEND compile_options "-Wno-address" + "-Wno-use-after-free") +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 0265e12a11..4f56b70c34 100644 --- a/Kconfig +++ b/Kconfig @@ -505,6 +505,13 @@ mainmenu "Espressif IoT Development Framework Configuration" This option can be enabled for RISC-V targets only. + config COMPILER_DISABLE_GCC12_WARNINGS + bool "Disable new warnings introduced in GCC 12" + default "n" + help + Enable this option if use GCC 12 or newer, and want to disable warnings which don't appear with + GCC 11. + config COMPILER_DUMP_RTL_FILES bool "Dump RTL files during compilation" help diff --git a/tools/idf_py_actions/hints.yml b/tools/idf_py_actions/hints.yml index 564553c57e..3a076619fb 100644 --- a/tools/idf_py_actions/hints.yml +++ b/tools/idf_py_actions/hints.yml @@ -294,3 +294,8 @@ - re: "Error: libusb_open\\(\\) failed with LIBUSB_ERROR_ACCESS" hint: "OpenOCD process does not have permissions to access the USB JTAG/serial device. Please use 'LIBUSB_DEBUG=1 idf.py openocd' to find out the device name and check its access rights." + +- + 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!" + match_to_output: True