Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3179959pxm; Mon, 28 Feb 2022 13:52:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/ZXvz7VtnnE/18FjsJQeDQP9SnWcEHwQOmGk2dh5hZOjJe4tSYn89g3L7GUPbt+N0fXpK X-Received: by 2002:a17:906:974e:b0:6bb:4f90:a6ae with SMTP id o14-20020a170906974e00b006bb4f90a6aemr17062043ejy.452.1646085176422; Mon, 28 Feb 2022 13:52:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646085176; cv=none; d=google.com; s=arc-20160816; b=tI0Zoy91myX6Iu2ilgUymy9W+pT029JbVRdxkkPk28tvfWnaYLxKVA7gXz8OoGBMYT ZX8R9jmo7Q7zf9bjGtJ3yBVLviDgGLhnyKBmtcjbtG3+rt9Ubq69j/8/cC1CNBORE9iR Jr1GRNCUvb3APVxCg+E5YsFrNve7M8W1cf3XGf/ordATxNT3vD5/DUVhiz/aVd1sMrWU F9rkKJZd7NOTVF2pcnDq99wIjN7eIA8LG9JVxa8zoZ3XNRkJCZWECHtAdhEuuBLX1Btr 4UqlLUZTORud5voKke0TsjkGMXG7IH8LpS0aeHIInwDoGA8nzrTsH4ea4DuQ45b+ILdT 8i4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SDEQwyNhO1YP2PlPCVZv2QT+trnELH3tuuISdUJhH/A=; b=Wsj3+exempQA6a2VliaOnr6UVBsHa+QceRDDNYCiKz76/+FPhFio2wBJGpE+R2EJ3Q Jo3qwQiCaGmwJzQ+kvz7ipv6mzZDk0DYuPBw0qtueRUxqa+5QdIdGPttpt5pDxqdrd5R m9SfUr8LIgshshla3zqmij/K/jLHIyiW47gkV2TH2mAEIpH36L0dSR/ild/981Gk6KKs 90Gxm1MZAEpBc5nrQdAG7FH1vwM2u1EcvF0X9czFJyCHazZVRAKe9XlMMad4sZYdBfwk MU3ZG33frSTbZU5QalBAmml3iBCPWX6a14CDMeFKVpNIozdqyPl2AN36CE6SIQ5z+cQ+ obRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="d9xMn/X4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i18-20020a170906699200b006bbb2eae0c3si6795249ejr.476.2022.02.28.13.52.33; Mon, 28 Feb 2022 13:52:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="d9xMn/X4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230527AbiB1Vmc (ORCPT + 99 others); Mon, 28 Feb 2022 16:42:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230525AbiB1Vmb (ORCPT ); Mon, 28 Feb 2022 16:42:31 -0500 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3348214CC80 for ; Mon, 28 Feb 2022 13:41:51 -0800 (PST) Received: by mail-pg1-x52b.google.com with SMTP id 139so12714506pge.1 for ; Mon, 28 Feb 2022 13:41:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=SDEQwyNhO1YP2PlPCVZv2QT+trnELH3tuuISdUJhH/A=; b=d9xMn/X4LpBqF7CCmU2zh6/QLyVNBTRuNZU+e7jV9ejFO0/bkIPnXV0yhaKjw6dJm8 FJS3J2mi6lbO85oN/dNF+rqWxtAJUijNlNeALlXJL+eaCxB0tcq950US1kKVvr8mqukF e0ToSOH4Si3JfzpFzCogjXNl1DMde6d8MLn9SuHccOTRwzid1E81/cSQ/4tTUtiOrMCh 9TojhlCRrVYJxHlgtGOmRoGhypN9RiWcKC8aFAkMrBK4RGw8XoilLoTMd70dGA9hdZYh n+kv4MVL49Db4WfNBmaeThQEFLAURei7cyQEoj8G+S/4PT3zkCcTFjR/aTe5mw8oJWud 4tvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=SDEQwyNhO1YP2PlPCVZv2QT+trnELH3tuuISdUJhH/A=; b=Hhwy/3i4l51pFXpxUfevhV6PEVp0+C0xE1T6c5pMY+rqnQ4kx7vYgeDiyUAXDNpaT5 tT1ChnWb15aUO6OnNa3Ak+r1XnAmNUCLehfTsvCYJk75/jgkuPGIUqBJwSns6cyhtqWI v9IK/FU+xt5SxKB5j2hftMh4Dt/F2UDyHR2H2BD47X8joYrHqoC54F2EGPuXTe+v+khv M8HyPBabWUu1XTo/OwzmJEWqCiD4CRrZEmI4iVeUEsNiLkH/A//Eht0LaTmQToM54+Nf YY0TnCx7JOvOa61nm8MZud0JJ0QxUtm3VhFPkGEXAu9yViTXSoGP9+l80zvwm3oe+7Bu 44XA== X-Gm-Message-State: AOAM530G8sCQVTV/kxL10Rwj5hqyFA5kiu1UmYxV1gnvq51M9rTbVjgv SS/TqsGQenw/MDZ3iLlJpSt0sQ== X-Received: by 2002:a05:6a00:26e0:b0:4e1:7131:de2b with SMTP id p32-20020a056a0026e000b004e17131de2bmr23819114pfw.20.1646084510471; Mon, 28 Feb 2022 13:41:50 -0800 (PST) Received: from google.com ([2620:15c:2ce:200:777f:ae46:e31e:b07e]) by smtp.gmail.com with ESMTPSA id 23-20020a17090a0b9700b001b8f602eaeasm259006pjr.53.2022.02.28.13.41.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 13:41:50 -0800 (PST) Date: Mon, 28 Feb 2022 13:41:45 -0800 From: Fangrui Song To: Nick Desaulniers Cc: Arnd Bergmann , linux-kbuild@vger.kernel.org, Arnd Bergmann , Linus Torvalds , Masahiro Yamada , llvm@lists.linux.dev, Jonathan Corbet , Federico Vaga , Alex Shi , Hu Haowen , Michal Marek , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc-tw-discuss@lists.sourceforge.net, linux-arm-kernel@lists.infradead.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev, linux-btrfs@vger.kernel.org Subject: Re: [PATCH] [v2] Kbuild: move to -std=gnu11 Message-ID: <20220228214145.o37bgp3zl3rxpeo4@google.com> References: <20220228103142.3301082-1-arnd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-18.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for the patch! (Was always wondering which of binutils and kernel would migrate to C99+ earlier... binutils won) On 2022-02-28, Nick Desaulniers wrote: >On Mon, Feb 28, 2022 at 2:32 AM Arnd Bergmann wrote: >> >> 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=gnu11 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 > >More precisely, the semantics of "extern inline" functions changed >between ISO C90 and ISO C99. Perhaps a clearer explanation to readers is: "extern inline" and "inline" swap semantics with gnu_inline (-fgnu89-inline or __attribute__((__gnu_inline__))). >That's the only concern I have, which I doubt is an issue. The kernel >is already covered by the function attribute as you note. > >Just to have some measure: >$ git grep -rn "extern inline" | wc -l >116 "^inline" behaves like C99+ "extern inline" Agree this is handled by #define inline inline __gnu_inline __inline_maybe_unused notrace >Most of those are in arch/alpha/ which is curious; I wonder if those >were intentional. > >(I do worry about Makefiles that completely reset KBUILD_CFLAGS >though; the function attributes still take precedence). > >> gnu89 and gnu11, but this was taken care of by defining 'inline' to >> include __attribute__((gnu_inline)) in order to allow building with >> clang a while ago. >> >> One minor issue that remains is an added gcc warning for shifts of >> negative integers when building with -Werror, which happens with the >> 'make W=1' option, as well as for three drivers in the kernel that always >> enable -Werror, but it was only observed with the i915 driver so far. >> To be on the safe side, add -Wno-shift-negative-value to any -Wextra >> in a Makefile. >> >> Nathan Chancellor reported an additional -Wdeclaration-after-statement >> warning that appears in a system header on arm, this still needs a >> workaround. > >Ack; I think we can just fix this in clang. > >> >> 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. > >I agree. With the fixup to s/Werror/Wextra. > >Reviewed-by: Nick Desaulniers > >> >> Link: https://lore.kernel.org/lkml/CAHk-=wiyCH7xeHcmiFJ-YgXUy2Jaj7pnkdKpcovt8fYbVFW3TA@mail.gmail.com/ >> Link: https://github.com/ClangBuiltLinux/linux/issues/1603 >> Suggested-by: Linus Torvalds >> Cc: Masahiro Yamada >> Cc: linux-kbuild@vger.kernel.org >> Cc: llvm@lists.linux.dev >> Signed-off-by: Arnd Bergmann > >-- >Thanks, >~Nick Desaulniers >