From a599ed13a1ea946f917bda9de213763636af8182 Mon Sep 17 00:00:00 2001 From: Pieter De Gendt Date: Mon, 15 Apr 2024 19:28:45 +0200 Subject: [PATCH] kconfig: Add symbols for GNU C Extensions Add a symbol to enable GNU C Extensions. And a hidden option for toolchains to signal GNU Extensions support. Signed-off-by: Pieter De Gendt --- CMakeLists.txt | 4 ++++ Kconfig.zephyr | 13 +++++++++++++ cmake/toolchain/armclang/Kconfig | 4 ++++ cmake/toolchain/cross-compile/Kconfig | 7 +++++++ cmake/toolchain/gnuarmemb/Kconfig | 4 ++++ cmake/toolchain/host/Kconfig | 6 ++++++ cmake/toolchain/llvm/Kconfig | 4 ++++ 7 files changed, 42 insertions(+) create mode 100644 cmake/toolchain/host/Kconfig diff --git a/CMakeLists.txt b/CMakeLists.txt index bc1f3facba..8f654bf224 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -971,6 +971,10 @@ if(NOT DEFINED CSTD) else() message(FATAL_ERROR "Unreachable code. Expected C standard to have been chosen.") endif() + + if(CONFIG_GNU_C_EXTENSIONS) + string(REPLACE "c" "gnu" CSTD "${CSTD}") + endif() else() message(DEPRECATION "Global CSTD property is deprecated, see Kconfig.zephyr for C Standard options.") diff --git a/Kconfig.zephyr b/Kconfig.zephyr index 0060afe788..edb9a79593 100644 --- a/Kconfig.zephyr +++ b/Kconfig.zephyr @@ -403,6 +403,19 @@ config STD_C23 endchoice +config TOOLCHAIN_SUPPORTS_GNU_EXTENSIONS + bool + default y if "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "zephyr" + help + Hidden option to signal that toolchain supports GNU Extensions. + +config GNU_C_EXTENSIONS + bool "GNU C Extensions" + depends on TOOLCHAIN_SUPPORTS_GNU_EXTENSIONS + help + Enable GNU C Extensions. GNU C provides several language features + not found in ISO standard C. + config CODING_GUIDELINE_CHECK bool "Enforce coding guideline rules" help diff --git a/cmake/toolchain/armclang/Kconfig b/cmake/toolchain/armclang/Kconfig index 19b7bcca51..27be295057 100644 --- a/cmake/toolchain/armclang/Kconfig +++ b/cmake/toolchain/armclang/Kconfig @@ -23,3 +23,7 @@ config ARMCLANG_STD_LIBC not provided by ARM Compiler standard libraries. endchoice + +config TOOLCHAIN_ARMCLANG_SUPPORTS_GNU_EXTENSIONS + def_bool y + select TOOLCHAIN_SUPPORTS_GNU_EXTENSIONS diff --git a/cmake/toolchain/cross-compile/Kconfig b/cmake/toolchain/cross-compile/Kconfig index d2da9acbd8..1f2fbd37d1 100644 --- a/cmake/toolchain/cross-compile/Kconfig +++ b/cmake/toolchain/cross-compile/Kconfig @@ -7,3 +7,10 @@ config TOOLCHAIN_CROSS_COMPILE_SUPPORTS_THREAD_LOCAL_STORAGE help Set this if the cross-compile toolchain being used for the build supports thread local storage. + +config TOOLCHAIN_CROSS_COMPILE_SUPPORTS_GNU_EXTENSIONS + bool "Cross-compile toolchain supports GNU Extensions" + select TOOLCHAIN_SUPPORTS_GNU_EXTENSIONS + help + Set this if the cross-compile toolchain being used for the build + supports GNU Extensions. diff --git a/cmake/toolchain/gnuarmemb/Kconfig b/cmake/toolchain/gnuarmemb/Kconfig index 702d503ddd..9d34449f4c 100644 --- a/cmake/toolchain/gnuarmemb/Kconfig +++ b/cmake/toolchain/gnuarmemb/Kconfig @@ -7,3 +7,7 @@ config TOOLCHAIN_GNUARMEMB def_bool y select HAS_NEWLIB_LIBC_NANO select NEWLIB_LIBC_SUPPORTED + +config TOOLCHAIN_GNUARMEMB_SUPPORTS_GNU_EXTENSIONS + def_bool y + select TOOLCHAIN_SUPPORTS_GNU_EXTENSIONS diff --git a/cmake/toolchain/host/Kconfig b/cmake/toolchain/host/Kconfig new file mode 100644 index 0000000000..8195849135 --- /dev/null +++ b/cmake/toolchain/host/Kconfig @@ -0,0 +1,6 @@ +# Copyright (c) 2024 Basalte bv +# SPDX-License-Identifier: Apache-2.0 + +config TOOLCHAIN_HOST_SUPPORTS_GNU_EXTENSIONS + def_bool y + select TOOLCHAIN_SUPPORTS_GNU_EXTENSIONS diff --git a/cmake/toolchain/llvm/Kconfig b/cmake/toolchain/llvm/Kconfig index 0e2e3e8586..1886f50cfe 100644 --- a/cmake/toolchain/llvm/Kconfig +++ b/cmake/toolchain/llvm/Kconfig @@ -22,3 +22,7 @@ config TOOLCHAIN_LLVM_SUPPORTS_THREAD_LOCAL_STORAGE depends on RISCV def_bool y select TOOLCHAIN_SUPPORTS_THREAD_LOCAL_STORAGE + +config TOOLCHAIN_LLVM_SUPPORTS_GNU_EXTENSIONS + def_bool y + select TOOLCHAIN_SUPPORTS_GNU_EXTENSIONS