From mboxrd@z Thu Jan 1 00:00:00 1970 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 CB9A9C433FE for ; Sun, 27 Feb 2022 23:04:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232148AbiB0XFb (ORCPT ); Sun, 27 Feb 2022 18:05:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232144AbiB0XFb (ORCPT ); Sun, 27 Feb 2022 18:05:31 -0500 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 121EC5AA4B for ; Sun, 27 Feb 2022 15:04:53 -0800 (PST) Received: by mail-io1-xd2d.google.com with SMTP id m185so12903878iof.10 for ; Sun, 27 Feb 2022 15:04:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=eMPAICcK4QOcUsgRz8E97T+w3UaPr0GS8sH9qwWSGXg=; b=TuABxhmm7HCYx1EyphcHUqowSUq4YqzJ+L4Kes63psOESIzptu0Wj4kjFHqT803dkW LXOCN6uuuQNNzwm7+keCDoEdSypmqegF8fR9cDhta1+D1LAa+qBEyNfOQwugQP04bEn2 WKtODuLeAVhFD3oNphX9RDY0KEZz34ygGTQ59ycNT4g6cnY8HQQyveZDnf/kj2lMnJnW EBAWvNuKUKLvFOA4WMP6MFxsRVx7HseHYWEaUVMrMk01HR+NzmWcIN8G6aAEVRgwv9QN 3n7SXvzkvndZsfFAyCqv9qQZMzunQhLtk+NzSYtok3gmgSJCJw2GIFCbdY5fQsEt1yew xOnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=eMPAICcK4QOcUsgRz8E97T+w3UaPr0GS8sH9qwWSGXg=; b=XFi98mYTmoKK2NLgG7WSNcz0AYkAsAHM5dx3r1Cwt3+ip8wfg/fGci6ONuTlbeI8NS EnMphGg5sydIOaA9kmKsMvwddmYLnOmO8v3OHvgdidGnMBIGbvR09q2STygECsywaMs/ sznoaE/UnFXKDcCPboWPDvsLy8bPCbI1j1g81DKh699SL5vVzE9oJr5YX24Dw1XqxCM4 VfkaYPCDcKMefFj071tX4xgkrVTyxB/9ZLOXdHRWiRn/1iHL6CgNWfEJqYi+Cgsaz89x FAkzX0p9s20YPmorae/E0OJM+R1K4E/Mwb/+uo0sT0dcEkTmgCYZr7ug9yIqqyZG7Q1+ zpsg== X-Gm-Message-State: AOAM531PesminljcqK5HzUoIPQAH0y5HS9+p6ugc5FuNuCTbt+GgKJht WQDkbrT9WRtoBMB8uFySKx7OTA== X-Google-Smtp-Source: ABdhPJxe901PQ2e5joOOmSne9hXyiOxCtxiBFuu7rSDYJSL82EmvMjFPqJfxHhSAJuacb9QKHFIrTw== X-Received: by 2002:a02:cf2b:0:b0:30d:69cc:c9c3 with SMTP id s11-20020a02cf2b000000b0030d69ccc9c3mr13575882jar.175.1646003092361; Sun, 27 Feb 2022 15:04:52 -0800 (PST) Received: from [172.22.22.26] (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.googlemail.com with ESMTPSA id p15-20020a056e02104f00b002c1f581288csm5119123ilj.59.2022.02.27.15.04.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 27 Feb 2022 15:04:51 -0800 (PST) Message-ID: Date: Sun, 27 Feb 2022 17:04:50 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [greybus-dev] [PATCH] Kbuild: remove -std=gnu89 from compiler arguments Content-Language: en-US To: Arnd Bergmann , linux-kbuild@vger.kernel.org Cc: Arnd Bergmann , Linus Torvalds , Masahiro Yamada , llvm@lists.linux.dev, Jonathan Corbet , Federico Vaga , Alex Shi , Hu Haowen , Michal Marek , Nick Desaulniers , 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 References: <20220227215408.3180023-1-arnd@kernel.org> From: Alex Elder In-Reply-To: <20220227215408.3180023-1-arnd@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On 2/27/22 3:52 PM, 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 > gnu89 and gnu89, 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. > > Nathan Chancellor reported an additional -Wdeclaration-after-statement > warning that appears in a system header on arm, this still needs a > workaround. > > Since the differences between gnu99, gnu11 and gnu17 are fairly minimal > and mainly impact warnings at the -Wpedantic level that the kernel > never enables, the easiest way is to just leave out the -std=gnu89 > argument entirely, and rely on the compiler default language setting, > which is gnu11 for gcc-5, and gnu1x/gnu17 for all other supported > versions of gcc or clang. > > 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 > --- > I put the suggestion into patch form, based on what we discussed > in the thread. I only gave it minimal testing, but it would > be good to have it in linux-next if we want to do this in the > merge window. Did you determine what needed the new compiler flag based on compilation results? Glancing at the Greybus code, I don't believe there's any reason it needs to shift a negative value. Such warnings could be fixed by making certain variables unsigned, for example. I have no objection, I'll just make a note of it. -Alex > --- > Documentation/process/programming-language.rst | 4 ++-- > .../translations/it_IT/process/programming-language.rst | 4 ++-- > .../translations/zh_CN/process/programming-language.rst | 4 ++-- > .../translations/zh_TW/process/programming-language.rst | 4 ++-- > Makefile | 7 +++---- > arch/arm64/kernel/vdso32/Makefile | 3 +-- > drivers/gpu/drm/i915/Makefile | 1 + > drivers/staging/greybus/tools/Makefile | 3 ++- > fs/btrfs/Makefile | 1 + > scripts/Makefile.extrawarn | 1 + > 10 files changed, 17 insertions(+), 15 deletions(-) > . . . > diff --git a/drivers/staging/greybus/tools/Makefile b/drivers/staging/greybus/tools/Makefile > index ad0ae8053b79..a3bbd73171f2 100644 > --- a/drivers/staging/greybus/tools/Makefile > +++ b/drivers/staging/greybus/tools/Makefile > @@ -12,7 +12,8 @@ CFLAGS += -std=gnu99 -Wall -Wextra -g \ > -Wredundant-decls \ > -Wcast-align \ > -Wsign-compare \ > - -Wno-missing-field-initializers > + -Wno-missing-field-initializers \ > + -Wno-shift-negative-value > > CC := $(CROSS_COMPILE)gcc > . . .