Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp11993450rwd; Thu, 22 Jun 2023 23:13:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5M3nvWBENraDLCOo04ic+R1YoE4QRYHuwdMEHGNrHmtuFOcsrkUp4rZx1jz5OKpbLdO8HL X-Received: by 2002:a17:902:9f97:b0:1b3:7def:3754 with SMTP id g23-20020a1709029f9700b001b37def3754mr21950244plq.28.1687500824046; Thu, 22 Jun 2023 23:13:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687500824; cv=none; d=google.com; s=arc-20160816; b=iiMkBNT57DSVeoZMPvNTHdaAnVPuAeYWVaUtaapsk7lJyNcZ+Mt9Jpw5ePyCsVYS0U wW0WS7FDmGv5+3aJ1ejOlLX/D/ERx/qfGfQ5uJ3ZV6AVMi5TpC4Cn9Ia6d5gSFdpPKew 8BCa0d+qL1dUgGF9yUYZGDVCNN13uTpYIYBbAUt/+27P5ca3HoS8GyieX3JoXFT+7q3u hUpjYW9B2LxKKxPyN9NwQWpPZ/9NkNJLEVfXB+8TxgDrgtGRDO66Y2kGKt3HR8zsdmVi lTuW4QrL756Vl9Bl4lKYxYqyPMgUiNT3qZo+zJoZdpza6XAINktcTsYEoBgX/l1YgPFN emeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=X3Lf/Xo9Oer2gXshG3KMBGZaWwCk0jwy3R+bKrcFtmw=; b=I3MxFwFLSUlU2wOGUZG3ZQBlg+JmUob9/KtselXWCmYhkorwOF38g5ttC+mWOLdTqd m+ThJAmvRvAdweBmqBSke6mHLj1O/jLi9SHNy06IE48h08spBn/1E5I3uLMAtBw1PNFH S/OdDCEztp9U6SpiRvMoS7Q2/ZSOPgj8fzXT7kLWymlW6eBMAcsVkf9ewKaVz5uavlz9 8zzzBBTOiQhGdt5Xd2AFdh5CHdNZ4drBRKvlrpJCh82pGTa3tUIkx3NmH8cmuizO2gSE Zrn/22RTrlCjGMQha7ocfh7up3NZ/G7EuqbjhYPFnZMs3PJ1+Q3miM98jiI1YXZsDf+i q+xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nc6tMgv5; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ki3-20020a170903068300b001afc602cd5esi5062816plb.90.2023.06.22.23.13.29; Thu, 22 Jun 2023 23:13:43 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=nc6tMgv5; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230120AbjFWFlT (ORCPT + 99 others); Fri, 23 Jun 2023 01:41:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjFWFlO (ORCPT ); Fri, 23 Jun 2023 01:41:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB0771A4; Thu, 22 Jun 2023 22:41:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6001B6198B; Fri, 23 Jun 2023 05:41:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8786C433CC; Fri, 23 Jun 2023 05:41:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687498871; bh=qPapvU2ug5XUbs86vSozf1HW7Fb3vlj9IaJ8Cc/jUhc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=nc6tMgv5HOQX4XZ9WiULPUOvoFoQr1wOklN1Ab/DKOFOR1LR/VPo6fglicjtk6nQL 7bVs+K3n1Om48IszfVTJzdmt95vDF3BJ5Al5CXjce8zVZdF6qix6H9GdjnK2VA102z J/86+fiwxg0uUj3IDhln0JWz+sIJbKakfNjmgc70IlepZwLrPZuIFgknJYptlfgwWb IXmHDWFKkSZOOeCbUhT+VEoL58A5djkE7LxWdfejRtdKZP36sg4kPw6IbH0hb8GnAQ Yvg3Q+LFIYX8Cy1J0DOJKdLSZWGkDivSNYSuCUw1Cc5Hf8XmASjR/4GA1eA0SbBzud Ug1f50gFCOaRQ== Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-1a9a42edfc9so187059fac.0; Thu, 22 Jun 2023 22:41:11 -0700 (PDT) X-Gm-Message-State: AC+VfDxIevFXfO3gn/NErQ5d1srMadBFygS/4AD71hCwmCwDv3+Xf9Ac 3zhPysUZgi7QK9vJRDiA5rIUhm6HcjrzDzFsq3g= X-Received: by 2002:a05:6871:288:b0:1a6:c3d3:969c with SMTP id i8-20020a056871028800b001a6c3d3969cmr19108557oae.45.1687498870905; Thu, 22 Jun 2023 22:41:10 -0700 (PDT) MIME-Version: 1.0 References: <20230409145358.2538266-1-masahiroy@kernel.org> <20230531213319.GA2201875@dev-arch.thelio-3990X> <20230602152519.GA3007575@dev-arch.thelio-3990X> In-Reply-To: From: Masahiro Yamada Date: Fri, 23 Jun 2023 14:40:34 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] kbuild: add $(CLANG_CFLAGS) to KBUILD_CPPFLAGS To: Fangrui Song Cc: Nathan Chancellor , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Rini , Nick Desaulniers , Nicolas Schier , Tom Rix , llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 On Fri, Jun 23, 2023 at 2:07=E2=80=AFAM Fangrui Song w= rote: > > On Sat, Jun 3, 2023 at 9:33=E2=80=AFAM Masahiro Yamada wrote: > > > > On Sat, Jun 3, 2023 at 12:25=E2=80=AFAM Nathan Chancellor wrote: > > > > > > On Wed, May 31, 2023 at 02:33:23PM -0700, Nathan Chancellor wrote: > > > > Hi Masahiro, > > > > > > > > On Sun, Apr 09, 2023 at 11:53:57PM +0900, Masahiro Yamada wrote: > > > > > When preprocessing arch/*/kernel/vmlinux.lds.S, the target triple= is > > > > > not passed to $(CPP) because we add it only to KBUILD_{C,A}FLAGS. > > > > > > > > > > As a result, the linker script is preprocessed with predefined ma= cros > > > > > for the build host instead of the target. > > > > > > > > > > Assuming you use an x86 build machine, compare the following: > > > > > > > > > > $ clang -dM -E -x c /dev/null > > > > > $ clang -dM -E -x c /dev/null -target aarch64-linux-gnu > > > > > > > > > > There is no actual problem presumably because our linker scripts = do not > > > > > rely on such predefined macros, but it is better to define correc= t ones. > > > > > > > > > > Move $(CFLAGS_CFLAGS) to KBUILD_CPPFLAGS, so that all *.c, *.S, *= .lds.S > > > > > will be processed with the proper target triple. > > > > > > > > > > Reported-by: Tom Rini > > > > > Signed-off-by: Masahiro Yamada > > > > > --- > > > > > > > > > > scripts/Makefile.clang | 3 +-- > > > > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > > > > > > > diff --git a/scripts/Makefile.clang b/scripts/Makefile.clang > > > > > index 70b354fa1cb4..93ca059cc3b8 100644 > > > > > --- a/scripts/Makefile.clang > > > > > +++ b/scripts/Makefile.clang > > > > > @@ -38,6 +38,5 @@ CLANG_FLAGS +=3D -Werror=3Dunknown-warnin= g-option > > > > > CLANG_FLAGS +=3D -Werror=3Dignored-optimization-argument > > > > > CLANG_FLAGS +=3D -Werror=3Doption-ignored > > > > > CLANG_FLAGS +=3D -Werror=3Dunused-command-line-argument > > > > > -KBUILD_CFLAGS +=3D $(CLANG_FLAGS) > > > > > -KBUILD_AFLAGS +=3D $(CLANG_FLAGS) > > > > > +KBUILD_CPPFLAGS +=3D $(CLANG_FLAGS) > > > > > export CLANG_FLAGS > > > > > -- > > > > > 2.37.2 > > > > > > > > > > > > > I am doubling back to this change, as the lack of '--target' in > > > > KBUILD_CPPFLAGS is now an active bug with clang-17 due to a new cha= nge > > > > that rejects '-mbig-endian' and '-mlittle-endian' when not supporte= d by > > > > the target, which breaks the arm64 vDSO build when preprocessing it= s > > > > linker script: > > > > > > > > # Turn on CONFIG_CPU_BIG_ENDIAN in menuconfig > > > > $ make -skj"$(nproc)" ARCH=3Darm64 LLVM=3D1 O=3Dbuild mrproper vi= rtconfig menuconfig arch/arm64/kernel/vdso/ > > > > ... > > > > clang: error: unsupported option '-mbig-endian' for target 'x86_6= 4-pc-linux-gnu' > > > > make[3]: *** [.../scripts/Makefile.build:387: arch/arm64/kernel/v= dso/vdso.lds] Error 1 > > > > ... > > > > > > > > https://github.com/llvm/llvm-project/commit/d81ce04587c006b673119= 8956c522c93d0df1050 > > > > https://github.com/ClangBuiltLinux/linux/issues/1859 > > > > > > > > This change resolves that issue. I was able to figure out why those= new > > > > warnings appeared for ARCH=3Dmips, it is the shell invocation for > > > > CHECKFLAGS. The following diff resolves it for me: > > > > > > > > diff --git a/arch/mips/Makefile b/arch/mips/Makefile > > > > index a7a4ee66a9d3..ef7b05ae92ce 100644 > > > > --- a/arch/mips/Makefile > > > > +++ b/arch/mips/Makefile > > > > @@ -346,7 +346,7 @@ KBUILD_CFLAGS +=3D -fno-asynchronous-unwind-tab= les > > > > KBUILD_LDFLAGS +=3D -m $(ld-emul) > > > > > > > > ifdef CONFIG_MIPS > > > > -CHECKFLAGS +=3D $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -x c /dev/nu= ll | \ > > > > +CHECKFLAGS +=3D $(shell $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) = -dM -E -x c /dev/null | \ > > > > grep -E -vw '__GNUC_(MINOR_|PATCHLEVEL_)?_' | \ > > > > sed -e "s/^\#define /-D'/" -e "s/ /'=3D'/" -e "s/$$/'/" -e 's= /\$$/&&/g') > > > > endif > > > > > > > > I will run this change plus that diff through my build matrix to se= e if > > > > any other issues pop up. If not, I will respond with some tags and > > > > perhaps this could be taken as a fix for 6.4 so that it could > > > > potentially be backported? > > > > > > I found two more issues lurking in PowerPC. I have attached suggested > > > patches for all the issues I have uncovered to this email, please fee= l > > > free to use them or do something different if you feel there is a bet= ter > > > fix. With those issues resolved in one way or another, consider the > > > original change: > > > > > > Reviewed-by: Nathan Chancellor > > > Tested-by: Nathan Chancellor > > > > > > If it would work better for you, I am more than happy to take over th= is > > > series as well. > > > > > > Cheers, > > > Nathan > > > > Thanks. All the three patches look good to me. > > > > I will apply them, then mine on top. > > Drive-by reply from > https://github.com/ClangBuiltLinux/continuous-integration2/pull/585 > > Hi Masahiro, one nit:) If the patch still has time to adjust the > commit message, perhaps consider replacing > > -target aarch64-linux-gnu with --target=3Daarch64-linux-gnu > > as the former is a deprecated driver option since Clang 3.x (long time ag= o). > > > Assuming you use an x86 build machine, compare the following: > > You may drop "Assuming you use an x86 build machine" and add > --target=3Dx86_64-linux-gnu to the `clang -dM -E -x c /dev/null` command > :) Thanks for the suggestion, but I do not want to change the commit ID unless there is something terribly wrong. Nathan recorded the commit ID in the CBL bug tracker. --=20 Best Regards Masahiro Yamada