From nobody Tue Jun 23 08:12:54 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFBD0C433FE for ; Tue, 8 Mar 2022 21:57:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344879AbiCHV6D (ORCPT ); Tue, 8 Mar 2022 16:58:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350577AbiCHV55 (ORCPT ); Tue, 8 Mar 2022 16:57:57 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E78D50E07; Tue, 8 Mar 2022 13:57:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E6039B81D86; Tue, 8 Mar 2022 21:56:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BC43C340F9; Tue, 8 Mar 2022 21:56:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646776617; bh=MSDAfiFmxb619SbNV0Do6ViYQlOLDRcmxvg0q5mQXVg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MGcDWHDdpzSijirtmAR+bbuZP2FzIWh8GyKHYDevUEiMiwo5oAaKV8kVMjuWYTcZl QeSIFMI4XCpErcpUaSG8ulhzpgVPJq1gCUwI2SftIEoafLPwXA74zMnYRIuI9kTY/X KgnJDTclYL4o7ODLvWSOpj6I+iUf88LiLWNYyLbA7TH1AV8VLlm6n/u5EdB49MrJ/0 fZ6Baio/T7JaQ+1y35Ic458d1rPh0QxXs87jgA7/VFNJDxsC5tvBs5XaBZ8JRQFPRT yr9CvKVbA37y+Jz7GPiMGTrG6R8VI5WacCYe6SzjSOqr6DEaT6eV/xkTes5b6yWItb +wXyUC9EAOI6Q== From: Arnd Bergmann To: Masahiro Yamada Cc: alexs@kernel.org, arnd@arndb.de, arnd@kernel.org, dsterba@suse.com, elver@google.com, jani.nikula@intel.com, linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, mark.rutland@arm.com, ndesaulniers@google.com, ojeda@kernel.org, torvalds@linux-foundation.org Subject: [PATCH 1/4] [v4] Kbuild: add -Wno-shift-negative-value where -Wextra is used Date: Tue, 8 Mar 2022 22:56:12 +0100 Message-Id: <20220308215615.14183-2-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220308215615.14183-1-arnd@kernel.org> References: <20220308215615.14183-1-arnd@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann As a preparation for moving to -std=3Dgnu11, turn off the -Wshift-negative-value option. This warning is enabled by gcc when building with -Wextra for c99 or higher, but not for c89. Since the kernel already relies on well-defined overflow behavior, the warning is not helpful and can simply be disabled in all locations that use -Wextra. Signed-off-by: Arnd Bergmann Acked-by: David Sterba Acked-by: Jani Nikula Reviewed-by: Nathan Chancellor Tested-by: Sedat Dilek # LLVM/Clang v13.0.0 (x86-64) --- [v4] split into a separate patch --- drivers/gpu/drm/i915/Makefile | 1 + drivers/staging/greybus/tools/Makefile | 3 ++- fs/btrfs/Makefile | 1 + scripts/Makefile.extrawarn | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 1b62b9f65196..1618a6e0af4e 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -17,6 +17,7 @@ subdir-ccflags-y +=3D -Wno-unused-parameter subdir-ccflags-y +=3D -Wno-type-limits subdir-ccflags-y +=3D -Wno-missing-field-initializers subdir-ccflags-y +=3D -Wno-sign-compare +subdir-ccflags-y +=3D -Wno-shift-negative-value subdir-ccflags-y +=3D $(call cc-disable-warning, unused-but-set-variable) subdir-ccflags-y +=3D $(call cc-disable-warning, frame-address) subdir-ccflags-$(CONFIG_DRM_I915_WERROR) +=3D -Werror diff --git a/drivers/staging/greybus/tools/Makefile b/drivers/staging/greyb= us/tools/Makefile index ad0ae8053b79..a3bbd73171f2 100644 --- a/drivers/staging/greybus/tools/Makefile +++ b/drivers/staging/greybus/tools/Makefile @@ -12,7 +12,8 @@ CFLAGS +=3D -std=3Dgnu99 -Wall -Wextra -g \ -Wredundant-decls \ -Wcast-align \ -Wsign-compare \ - -Wno-missing-field-initializers + -Wno-missing-field-initializers \ + -Wno-shift-negative-value =20 CC :=3D $(CROSS_COMPILE)gcc =20 diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile index 4188ba3fd8c3..99f9995670ea 100644 --- a/fs/btrfs/Makefile +++ b/fs/btrfs/Makefile @@ -17,6 +17,7 @@ subdir-ccflags-y +=3D $(condflags) subdir-ccflags-y +=3D -Wno-missing-field-initializers subdir-ccflags-y +=3D -Wno-sign-compare subdir-ccflags-y +=3D -Wno-type-limits +subdir-ccflags-y +=3D -Wno-shift-negative-value =20 obj-$(CONFIG_BTRFS_FS) :=3D btrfs.o =20 diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index 8be892887d71..650d0b8ceec3 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -36,6 +36,7 @@ KBUILD_CFLAGS +=3D $(call cc-option, -Wstringop-truncatio= n) KBUILD_CFLAGS +=3D -Wno-missing-field-initializers KBUILD_CFLAGS +=3D -Wno-sign-compare KBUILD_CFLAGS +=3D -Wno-type-limits +KBUILD_CFLAGS +=3D -Wno-shift-negative-value =20 KBUILD_CPPFLAGS +=3D -DKBUILD_EXTRA_WARN1 =20 --=20 2.29.2 From nobody Tue Jun 23 08:12:54 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A88ECC433F5 for ; Tue, 8 Mar 2022 21:57:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347430AbiCHV6G (ORCPT ); Tue, 8 Mar 2022 16:58:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243452AbiCHV6B (ORCPT ); Tue, 8 Mar 2022 16:58:01 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41AC04BBA6; Tue, 8 Mar 2022 13:57:04 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C7E51B81DFE; Tue, 8 Mar 2022 21:57:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32FCFC340F5; Tue, 8 Mar 2022 21:56:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646776621; bh=kZiBj8WpI2fstszcS5G2ImYcEYy1OBAxph3sAglZWZ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P/v3lLMIxlIPHFA/PnpXNemtS0XpAMXf8tpt5zjVUDIWnVsaZZH2aBng6tCm0ArRJ 7PYoMuwz8FVCbkjSLOkQSge61tlXQqa47vYOqwBxQ3EEG23e2yu5TApxzZ/Ofe2ll+ nxZKZYELICcE3cjcMcGMcGC9rmfbsWpBs7TYC6ZC4OZ4WFYAzeI0ELECGARqu5UIAU 6SIg0Fh2aGPfK8sdAvGyY051HgY7JTYA3LQ5kR1PWlgcfMHWw6Sp22qRapbHav0Yds 63Tfbz+jXGgv9geBl5ROGwefc5TIPszPaLb1qMRNA4MGAyzBj2t0S/5ZYVMkeH6Y4H OwmsGkztuLGrQ== From: Arnd Bergmann To: Masahiro Yamada Cc: alexs@kernel.org, arnd@arndb.de, arnd@kernel.org, dsterba@suse.com, elver@google.com, jani.nikula@intel.com, linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, mark.rutland@arm.com, ndesaulniers@google.com, ojeda@kernel.org, torvalds@linux-foundation.org Subject: [PATCH 2/4] [v4] Kbuild: use -Wdeclaration-after-statement Date: Tue, 8 Mar 2022 22:56:13 +0100 Message-Id: <20220308215615.14183-3-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220308215615.14183-1-arnd@kernel.org> References: <20220308215615.14183-1-arnd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Rutland The kernel is moving from using `-std=3Dgnu89` to `-std=3Dgnu11`, permitting the use of additional C11 features such as for-loop initial declarations. One contentious aspect of C99 is that it permits mixed declarations and code, and for now at least, it seems preferable to enforce that declarations must come first. These warnings were already enabled in the kernel itself, but not for KBUILD_USERCFLAGS or the compat VDSO on arch/arm64, which uses a separate set of CFLAGS. This patch fixes an existing violation in modpost.c, which is not reported because of the missing flag in KBUILD_USERCFLAGS: | scripts/mod/modpost.c: In function =E2=80=98match=E2=80=99: | scripts/mod/modpost.c:837:3: warning: ISO C90 forbids mixed declarations = and code [-Wdeclaration-after-statement] | 837 | const char *endp =3D p + strlen(p) - 1; | | ^~~~~ Signed-off-by: Mark Rutland [arnd: don't add a duplicate flag to the default set, update changelog] Signed-off-by: Arnd Bergmann Reviewed-by: Nathan Chancellor Tested-by: Sedat Dilek # LLVM/Clang v13.0.0 (x86-64) --- [v4] move ahead of actual std=3Dgnu11 change --- Makefile | 3 ++- arch/arm64/kernel/vdso32/Makefile | 1 + scripts/mod/modpost.c | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a82095c69fdd..c791bfd5a471 100644 --- a/Makefile +++ b/Makefile @@ -432,7 +432,8 @@ HOSTCXX =3D g++ endif =20 KBUILD_USERHOSTCFLAGS :=3D -Wall -Wmissing-prototypes -Wstrict-prototypes \ - -O2 -fomit-frame-pointer -std=3Dgnu89 + -O2 -fomit-frame-pointer -std=3Dgnu89 \ + -Wdeclaration-after-statement KBUILD_USERCFLAGS :=3D $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS) KBUILD_USERLDFLAGS :=3D $(USERLDFLAGS) =20 diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/M= akefile index 6c01b63ff56d..f46457f1f4f0 100644 --- a/arch/arm64/kernel/vdso32/Makefile +++ b/arch/arm64/kernel/vdso32/Makefile @@ -68,6 +68,7 @@ VDSO_CFLAGS +=3D -Wall -Wundef -Wstrict-prototypes -Wno-t= rigraphs \ -fno-strict-aliasing -fno-common \ -Werror-implicit-function-declaration \ -Wno-format-security \ + -Wdeclaration-after-statement \ -std=3Dgnu89 VDSO_CFLAGS +=3D -O2 # Some useful compiler-dependent flags from top-level Makefile diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 6bfa33217914..fe693304b120 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -833,8 +833,10 @@ static int match(const char *sym, const char * const p= at[]) { const char *p; while (*pat) { + const char *endp; + p =3D *pat++; - const char *endp =3D p + strlen(p) - 1; + endp =3D p + strlen(p) - 1; =20 /* "*foo*" */ if (*p =3D=3D '*' && *endp =3D=3D '*') { --=20 2.29.2 From nobody Tue Jun 23 08:12:54 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B804BC433EF for ; Tue, 8 Mar 2022 21:57:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347550AbiCHV6J (ORCPT ); Tue, 8 Mar 2022 16:58:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344765AbiCHV6E (ORCPT ); Tue, 8 Mar 2022 16:58:04 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8918655BE3; Tue, 8 Mar 2022 13:57:06 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1A82A6190F; Tue, 8 Mar 2022 21:57:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 011FCC340F6; Tue, 8 Mar 2022 21:57:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646776625; bh=cZHVvYurJxQgFY5AgNyvVfreqItHQzRF163PJAcCkJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iwBiCBszTgq6qEM/tl6vNQkyX5wXU23YrjiCWnPo/9gGIDDjyS3HCdCXKpp6n7RTc 7Zn4CPsVkpKvl1KsuzYPJACqh6OBvBuDJcMFWF2J7NjMY1poqdPrkdjbC2o8T11wJ6 PhLSzCZxp74RdLLseLMB3zPXh/caO3tcLkqzKGgE+ZIOe/6digHFiXhtEoQKGIv4DD VN3FbYcvOo2UvV+GKhNYpuSvnHXdxOAe26XGkECxdWC9mfG5xAmVfFX7yrKtykYCuE puIbTzWgiauvCB8R3LVNpwbjkHHkDL7SrOHwQ/SWzqot80IrpqQlbD8qXRF5CiHqnM IkTE6siqH113A== From: Arnd Bergmann To: Masahiro Yamada Cc: alexs@kernel.org, arnd@arndb.de, arnd@kernel.org, dsterba@suse.com, elver@google.com, jani.nikula@intel.com, linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, mark.rutland@arm.com, ndesaulniers@google.com, ojeda@kernel.org, torvalds@linux-foundation.org, Sedat Dilek Subject: [PATCH 3/4] [v4] Kbuild: move to -std=gnu11 Date: Tue, 8 Mar 2022 22:56:14 +0100 Message-Id: <20220308215615.14183-4-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220308215615.14183-1-arnd@kernel.org> References: <20220308215615.14183-1-arnd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann During a patch discussion, Linus brought up the option of changing the C standard version from gnu89 to gnu99, which allows using variable declaration inside of a for() loop. While the C99, C11 and later standards introduce many other features, most of these are already available in gnu89 as GNU extensions as well. An earlier attempt to do this when gcc-5 started defaulting to -std=3Dgnu11 failed because at the time that caused warnings about designated initializers with older compilers. Now that gcc-5.1 is the minimum compiler version used for building kernels, that is no longer a concern. Similarly, the behavior of 'inline' functions changes between gnu89 using gnu_inline behavior and gnu11 using standard c99+ behavior, but this was taken care of by defining 'inline' to include __attribute__((gnu_inline)) in order to allow building with clang a while ago. Nathan Chancellor reported a new -Wdeclaration-after-statement warning that appears in a system header on arm, this still needs a workaround. The differences between gnu99, gnu11, gnu1x and gnu17 are fairly minimal and mainly impact warnings at the -Wpedantic level that the kernel never enables. Between these, gnu11 is the newest version that is supported by all supported compiler versions, though it is only the default on gcc-5, while all other supported versions of gcc or clang default to gnu1x/gnu17. Link: https://lore.kernel.org/lkml/CAHk-=3DwiyCH7xeHcmiFJ-YgXUy2Jaj7pnkdKpc= ovt8fYbVFW3TA@mail.gmail.com/ Link: https://github.com/ClangBuiltLinux/linux/issues/1603 Suggested-by: Linus Torvalds Acked-by: Marco Elver Acked-by: Jani Nikula Acked-by: David Sterba Tested-by: Sedat Dilek Reviewed-by: Alex Shi Reviewed-by: Nick Desaulniers Reviewed-by: Miguel Ojeda Signed-off-by: Arnd Bergmann Reviewed-by: Nathan Chancellor Tested-by: Sedat Dilek # LLVM/Clang v13.0.0 (x86-64) --- [v4] - split -Wno-shift-negative-value into a separate patch [v3] - split out USERCFLAGS to a separate patch - add -Wdeclaration-after-statement patch from Mark Rutland - leave out C17 reference - more rewording the descrption [v2] - added -std=3Dgnu11 back, rather than just relying on the default - minor changes to changelog text --- Documentation/process/programming-language.rst | 6 +++--- .../translations/it_IT/process/programming-language.rst | 4 ++-- .../translations/zh_CN/process/programming-language.rst | 3 +-- .../translations/zh_TW/process/programming-language.rst | 3 +-- Makefile | 4 ++-- arch/arm64/kernel/vdso32/Makefile | 2 +- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Documentation/process/programming-language.rst b/Documentation= /process/programming-language.rst index ec474a70a02f..5fc9160ca1fa 100644 --- a/Documentation/process/programming-language.rst +++ b/Documentation/process/programming-language.rst @@ -5,9 +5,9 @@ Programming Language =20 The kernel is written in the C programming language [c-language]_. More precisely, the kernel is typically compiled with ``gcc`` [gcc]_ -under ``-std=3Dgnu89`` [gcc-c-dialect-options]_: the GNU dialect of ISO C90 -(including some C99 features). ``clang`` [clang]_ is also supported, see -docs on :ref:`Building Linux with Clang/LLVM `. +under ``-std=3Dgnu11`` [gcc-c-dialect-options]_: the GNU dialect of ISO C1= 1. +``clang`` [clang]_ is also supported, see docs on +:ref:`Building Linux with Clang/LLVM `. =20 This dialect contains many extensions to the language [gnu-extensions]_, and many of them are used within the kernel as a matter of course. diff --git a/Documentation/translations/it_IT/process/programming-language.= rst b/Documentation/translations/it_IT/process/programming-language.rst index 41db2598ce11..c1a9b481a6f9 100644 --- a/Documentation/translations/it_IT/process/programming-language.rst +++ b/Documentation/translations/it_IT/process/programming-language.rst @@ -10,8 +10,8 @@ Linguaggio di programmazione =20 Il kernel =C3=A8 scritto nel linguaggio di programmazione C [it-c-language= ]_. Pi=C3=B9 precisamente, il kernel viene compilato con ``gcc`` [it-gcc]_ usa= ndo -l'opzione ``-std=3Dgnu89`` [it-gcc-c-dialect-options]_: il dialetto GNU -dello standard ISO C90 (con l'aggiunta di alcune funzionalit=C3=A0 da C99). +l'opzione ``-std=3Dgnu11`` [it-gcc-c-dialect-options]_: il dialetto GNU +dello standard ISO C11. Linux supporta anche ``clang`` [it-clang]_, leggete la documentazione :ref:`Building Linux with Clang/LLVM `. =20 diff --git a/Documentation/translations/zh_CN/process/programming-language.= rst b/Documentation/translations/zh_CN/process/programming-language.rst index 2a47a1d2ec20..fabdc338dbfb 100644 --- a/Documentation/translations/zh_CN/process/programming-language.rst +++ b/Documentation/translations/zh_CN/process/programming-language.rst @@ -9,8 +9,7 @@ =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 =E5=86=85=E6=A0=B8=E6=98=AF=E7=94=A8C=E8=AF=AD=E8=A8=80 :ref:`c-language <= cn_c-language>` =E7=BC=96=E5=86=99=E7=9A=84=E3=80=82=E6=9B=B4=E5=87=86=E7= =A1=AE=E5=9C=B0=E8=AF=B4=EF=BC=8C=E5=86=85=E6=A0=B8=E9=80=9A=E5=B8=B8=E6=98= =AF=E7=94=A8 :ref:`gcc ` -=E5=9C=A8 ``-std=3Dgnu89`` :ref:`gcc-c-dialect-options ` =E4=B8=8B=E7=BC=96=E8=AF=91=E7=9A=84=EF=BC=9AISO C90=E7=9A=84 GNU = =E6=96=B9=E8=A8=80=EF=BC=88 -=E5=8C=85=E6=8B=AC=E4=B8=80=E4=BA=9BC99=E7=89=B9=E6=80=A7=EF=BC=89 +=E5=9C=A8 ``-std=3Dgnu11`` :ref:`gcc-c-dialect-options ` =E4=B8=8B=E7=BC=96=E8=AF=91=E7=9A=84=EF=BC=9AISO C11=E7=9A=84 GNU = =E6=96=B9=E8=A8=80 =20 =E8=BF=99=E7=A7=8D=E6=96=B9=E8=A8=80=E5=8C=85=E5=90=AB=E5=AF=B9=E8=AF=AD= =E8=A8=80 :ref:`gnu-extensions ` =E7=9A=84=E8=AE=B8=E5= =A4=9A=E6=89=A9=E5=B1=95=EF=BC=8C=E5=BD=93=E7=84=B6=EF=BC=8C=E5=AE=83=E4=BB= =AC=E8=AE=B8=E5=A4=9A=E9=83=BD=E5=9C=A8=E5=86=85=E6=A0=B8=E4=B8=AD=E4=BD=BF= =E7=94=A8=E3=80=82 =20 diff --git a/Documentation/translations/zh_TW/process/programming-language.= rst b/Documentation/translations/zh_TW/process/programming-language.rst index 54e3699eadf8..144bdaf81a41 100644 --- a/Documentation/translations/zh_TW/process/programming-language.rst +++ b/Documentation/translations/zh_TW/process/programming-language.rst @@ -12,8 +12,7 @@ =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 =E5=85=A7=E6=A0=B8=E6=98=AF=E7=94=A8C=E8=AA=9E=E8=A8=80 :ref:`c-language <= tw_c-language>` =E7=B7=A8=E5=AF=AB=E7=9A=84=E3=80=82=E6=9B=B4=E6=BA=96=E7= =A2=BA=E5=9C=B0=E8=AA=AA=EF=BC=8C=E5=85=A7=E6=A0=B8=E9=80=9A=E5=B8=B8=E6=98= =AF=E7=94=A8 :ref:`gcc ` -=E5=9C=A8 ``-std=3Dgnu89`` :ref:`gcc-c-dialect-options ` =E4=B8=8B=E7=B7=A8=E8=AD=AF=E7=9A=84=EF=BC=9AISO C90=E7=9A=84 GNU = =E6=96=B9=E8=A8=80=EF=BC=88 -=E5=8C=85=E6=8B=AC=E4=B8=80=E4=BA=9BC99=E7=89=B9=E6=80=A7=EF=BC=89 +=E5=9C=A8 ``-std=3Dgnu11`` :ref:`gcc-c-dialect-options ` =E4=B8=8B=E7=B7=A8=E8=AD=AF=E7=9A=84=EF=BC=9AISO C11=E7=9A=84 GNU = =E6=96=B9=E8=A8=80 =20 =E9=80=99=E7=A8=AE=E6=96=B9=E8=A8=80=E5=8C=85=E5=90=AB=E5=B0=8D=E8=AA=9E= =E8=A8=80 :ref:`gnu-extensions ` =E7=9A=84=E8=A8=B1=E5= =A4=9A=E6=93=B4=E5=B1=95=EF=BC=8C=E7=95=B6=E7=84=B6=EF=BC=8C=E5=AE=83=E5=80= =91=E8=A8=B1=E5=A4=9A=E9=83=BD=E5=9C=A8=E5=85=A7=E6=A0=B8=E4=B8=AD=E4=BD=BF= =E7=94=A8=E3=80=82 =20 diff --git a/Makefile b/Makefile index c791bfd5a471..1ba8dc523952 100644 --- a/Makefile +++ b/Makefile @@ -517,7 +517,7 @@ KBUILD_CFLAGS :=3D -Wall -Wundef -Werror=3Dstrict-pro= totypes -Wno-trigraphs \ -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \ -Werror=3Dimplicit-function-declaration -Werror=3Dimplicit-int \ -Werror=3Dreturn-type -Wno-format-security \ - -std=3Dgnu89 + -std=3Dgnu11 KBUILD_CPPFLAGS :=3D -D__KERNEL__ KBUILD_AFLAGS_KERNEL :=3D KBUILD_CFLAGS_KERNEL :=3D @@ -785,7 +785,7 @@ KBUILD_CFLAGS +=3D $(KBUILD_CFLAGS-y) $(CONFIG_CC_IMPLI= CIT_FALLTHROUGH) =20 ifdef CONFIG_CC_IS_CLANG KBUILD_CPPFLAGS +=3D -Qunused-arguments -# The kernel builds with '-std=3Dgnu89' so use of GNU extensions is accept= able. +# The kernel builds with '-std=3Dgnu11' so use of GNU extensions is accept= able. KBUILD_CFLAGS +=3D -Wno-gnu # CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as= the # source of a reference will be _MergedGlobals and not on of the whitelist= ed names. diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/M= akefile index f46457f1f4f0..ed181bedbffc 100644 --- a/arch/arm64/kernel/vdso32/Makefile +++ b/arch/arm64/kernel/vdso32/Makefile @@ -69,7 +69,7 @@ VDSO_CFLAGS +=3D -Wall -Wundef -Wstrict-prototypes -Wno-t= rigraphs \ -Werror-implicit-function-declaration \ -Wno-format-security \ -Wdeclaration-after-statement \ - -std=3Dgnu89 + -std=3Dgnu11 VDSO_CFLAGS +=3D -O2 # Some useful compiler-dependent flags from top-level Makefile VDSO_CFLAGS +=3D $(call cc32-option,-Wdeclaration-after-statement,) --=20 2.29.2 From nobody Tue Jun 23 08:12:54 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2ABACC433FE for ; Tue, 8 Mar 2022 21:57:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350559AbiCHV6N (ORCPT ); Tue, 8 Mar 2022 16:58:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350520AbiCHV6J (ORCPT ); Tue, 8 Mar 2022 16:58:09 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF89656C3B; Tue, 8 Mar 2022 13:57:11 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 79442B81DFE; Tue, 8 Mar 2022 21:57:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2B2AC340EC; Tue, 8 Mar 2022 21:57:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646776629; bh=eGD/su/n2B61nqlOmpuFpZhwnQeDphrdFbvHLaijoSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b7OJ9Rf2Y+g8br7xVIjyOlcfvW8+SyMmqJCm6j/ZXEEyA4S+LY+3b8r4799BuOLYk TLWFQ5r2ZbzLJTRSMjAzXn/8CWEfEfz1etzwIxlED128hvB271uttJhrCazgihEbWI ZL1t0qMlBb2KK9yZ1W+SfHMT4ii+vS/0aMPrtuDh443A3/VIYXgiF7k4hXqJeKl8C9 NIjUTtcubyLdk09OagrHy1D+bABzL0S6Jg3Seoq8jjBHPgnXrOeqAzoMcl/uKsiSOv th/iWa4NXq8H+a/FDexq0GqMBOEUlcUVL//Cz2ehBBxRMMuabOH5nsxZdwJ6hBII3t FbwQteQSri0DA== From: Arnd Bergmann To: Masahiro Yamada Cc: alexs@kernel.org, arnd@arndb.de, arnd@kernel.org, dsterba@suse.com, elver@google.com, jani.nikula@intel.com, linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, mark.rutland@arm.com, ndesaulniers@google.com, ojeda@kernel.org, torvalds@linux-foundation.org Subject: [PATCH 4/4] Kbuild: use -std=gnu11 for KBUILD_USERCFLAGS Date: Tue, 8 Mar 2022 22:56:15 +0100 Message-Id: <20220308215615.14183-5-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220308215615.14183-1-arnd@kernel.org> References: <20220308215615.14183-1-arnd@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann As we change the C language standard for the kernel from gnu89 to gnu11, it makes sense to also update the version for user space compilation. Some users have older native compilers than what they use for kernel builds, so I considered using gnu99 as the default version for wider compatibility with gcc-4.6 and earlier. However, testing with older compilers showed that we already require HOSTCC version 5.1 as well because a lot of host tools include linux/compiler.h that uses __has_attribute(): CC tools/objtool/exec-cmd.o In file included from tools/include/linux/compiler_types.h:36:0, from tools/include/linux/compiler.h:5, from exec-cmd.c:2: tools/include/linux/compiler-gcc.h:19:5: error: "__has_attribute" is not de= fined [-Werror=3Dundef] Signed-off-by: Arnd Bergmann Reviewed-by: Nathan Chancellor Tested-by: Sedat Dilek # LLVM/Clang v13.0.0 (x86-64) --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1ba8dc523952..e0b11ddd0760 100644 --- a/Makefile +++ b/Makefile @@ -432,7 +432,7 @@ HOSTCXX =3D g++ endif =20 KBUILD_USERHOSTCFLAGS :=3D -Wall -Wmissing-prototypes -Wstrict-prototypes \ - -O2 -fomit-frame-pointer -std=3Dgnu89 \ + -O2 -fomit-frame-pointer -std=3Dgnu11 \ -Wdeclaration-after-statement KBUILD_USERCFLAGS :=3D $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS) KBUILD_USERLDFLAGS :=3D $(USERLDFLAGS) --=20 2.29.2