[PATCH] toolchain/gcc: set dialects for each version

Bas Mevissen abuse at basmevissen.nl
Thu Jan 27 10:10:07 PST 2022


On 1/25/22 18:02, Stijn Tintel wrote:
> GCC has an option "-std=" to set the language standard for C and C++.
> Newer GCC versions sometimes switch to newer standards by default. This
> has the potential to break the OpenWrt toolchain build whenever a distro
> introduces a new GCC version that uses a newer dialect by default.
> 
> Let's set the default dialects used for each of the GCC versions we
> support, to avoid these toolchain build failures in the future.
> 

Shouldn't the logic be different? It is the software that is to be 
compiled that is written in a certain version or versions of C or C++ 
language.

OpenWRT should set a default C and C++ language version and packages or 
any other software compiled with the OpenWRT build should override it 
when they need it.

A package might for example define that they can be compiled with 
version C++11 to C++20 or require at least C++17 (and hence require a 
minimum GCC version).

How does this currently work? Are packages assumed to be compilable with 
the default C or C++ language version of the default (host or target) 
GCC version?

Regards,

Bas.


> Signed-off-by: Stijn Tintel <stijn at linux-ipv6.be>
> ---
>   toolchain/gcc/common.mk | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/toolchain/gcc/common.mk b/toolchain/gcc/common.mk
> index bef4fa37f8..3e31a139cd 100644
> --- a/toolchain/gcc/common.mk
> +++ b/toolchain/gcc/common.mk
> @@ -29,14 +29,20 @@ PKG_SOURCE_URL:=@GNU/gcc/gcc-$(PKG_VERSION)
>   PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
>   
>   ifeq ($(PKG_VERSION),8.4.0)
> +  C_DIALECT=-std=gnu17
> +  CXX_DIALECT=-std=gnu++14
>     PKG_HASH:=e30a6e52d10e1f27ed55104ad233c30bd1e99cfb5ff98ab022dc941edd1b2dd4
>   endif
>   
>   ifeq ($(PKG_VERSION),10.3.0)
> +  C_DIALECT=-std=gnu17
> +  CXX_DIALECT=-std=gnu++14
>     PKG_HASH:=64f404c1a650f27fc33da242e1f2df54952e3963a49e06e73f6940f3223ac344
>   endif
>   
>   ifeq ($(PKG_VERSION),11.2.0)
> +  C_DIALECT=-std=gnu17
> +  CXX_DIALECT=-std=gnu++17
>     PKG_HASH:=d08edc536b54c372a1010ff6619dd274c0f1603aa49212ba20f7aa2cda36fa8b
>   endif
>   
> @@ -86,6 +92,8 @@ GCC_CONFIGURE:= \
>   		CFLAGS="-O2 -fbracket-depth=512 -pipe" \
>   		CXXFLAGS="-O2 -fbracket-depth=512 -pipe" \
>   	) \
> +	CFLAGS="$(CFLAGS) $(C_DIALECT)" \
> +	CXXFLAGS="$(CXXFLAGS) $(CXX_DIALECT)" \
>   	$(HOST_SOURCE_DIR)/configure \
>   		--with-bugurl=$(BUGURL) \
>   		--with-pkgversion="$(PKGVERSION)" \



More information about the openwrt-devel mailing list