Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp415741rwo; Tue, 1 Aug 2023 20:19:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlH/FlKFnL7v+T+YX7055b6rYOLYPBb+qEZMHFw3R9/T54asR+d0zugTWnd/ueb+oTa8CzCc X-Received: by 2002:a05:620a:28c1:b0:766:77b7:4c73 with SMTP id l1-20020a05620a28c100b0076677b74c73mr17422202qkp.35.1690946350713; Tue, 01 Aug 2023 20:19:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690946350; cv=none; d=google.com; s=arc-20160816; b=ZAvHsG8p4nD5WMRrMOQy2p9/AjISMqG4IXV4z/BFBwkzJ2uWK2+e+sAsDZBfy9o+Nd yYvG6Y1Yiu8ffGtIWMdym0oAoGeF0KamWSmTu9FKsO4rJw7JscIe6PWk0djVoHj4w1X0 qryuJrgdRdHnI7CGrkaE29ESATEfbr6mTCrgJIOToOpUZRRcxjUKamsUXoQv6WRe7nmL yQPx2Gcuaon3zhuADGGR2a1tVqULgZNaWNl7NGfIiHfKYgfX0mRFwMh7YJk0rkt+Rc6P b/waTXe3cKPGtMUT2wVTr0nMMjJuK/koMOeGZQHuxixjweaWi3xFD4Xt/ylAbDa4Br01 SEzg== 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=WUJmphq1XBpfWHJSBEGK2S6zaxoxMINI9eIeroFOv4o=; fh=NqorLqzLiFtin9t7hN6ZQmOBpNRRXljgZoJfoBDBjm4=; b=mFiIg+I5UBRfy4zN3MX6jjdeJWLdgOm64u2nuNAvMGLr0Et/lbvdRVgbCKQmqKxLIu 49JKPaQa5E24XU44RWln1LUdzylpFWtnKUHK1z3JS+STDW+UQBLeQKcuXcxE5C4gMLP9 Dt3kolWkMg4n3M43nxu5EmIvnasTtOx9NxnqlWZQJm+uR/sAw8yjRbX8/qvIQJfltnoF 6Ovfk1bziwlsGDTtggeXhvwEyd1twagT8mX0H0hv5VVKonwiuBuUhP0QvY1kDG7i2PaX 89QnBDDdD3oZun10ootPyABYi1H+n5FM0LGp8Rt8ZpxE4TL/8C4+bgTgxYyDzNo8WC+p dAZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LMopKQll; 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 23-20020a631057000000b0054fdfd26dffsi10018239pgq.337.2023.08.01.20.18.58; Tue, 01 Aug 2023 20:19:10 -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=LMopKQll; 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 S231264AbjHBCqL (ORCPT + 99 others); Tue, 1 Aug 2023 22:46:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230057AbjHBCqK (ORCPT ); Tue, 1 Aug 2023 22:46:10 -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 261881BFD for ; Tue, 1 Aug 2023 19:46:09 -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 A971161796 for ; Wed, 2 Aug 2023 02:46:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E5A7C433CA for ; Wed, 2 Aug 2023 02:46:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690944368; bh=HnyEuLoO+VDuqcAShwayzrYa97t99kvrkI3g8nRH1bE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=LMopKQllqF6Rron/qahG6z+UEuJwBxvo5RihH5w3huG2b4uIaKRh1R610l1VHaqLn OhRxlj7cU9zvuKincTSSr0Rd3KPk/OsMsJECy2YSJ14wr1RZzGapY0XgwnzaMKd9Jn xawTu8ZtgqouoAO3ueUxn2rGB09tQHSbUYKN2Q19k19Gaa4fBIz7kcklHtUjWvn8Lj QfkNGXPwe0iBW2uBPG96AttICFGGYh6xBNtoRO4OBKwmen2dZ0K55kuqqbjGiURcRm oWqt6KFR+Bjq3QU6Mq+fKfFp9bBjr9Cnsjw/6VZvwH0BCukp1XMj9z8y9JtjGDshlX qOml0V3Kmcu/A== Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-5221c6a2d3dso8954780a12.3 for ; Tue, 01 Aug 2023 19:46:07 -0700 (PDT) X-Gm-Message-State: ABy/qLa7xIe9lRGzRPW8YIgoAg3LwVCwrnj9IGml7YyBNxs3LKxTNL9p tj5B8Jt2xRRETiwkNMV5EmsAWlCodkA1mWEFBpY= X-Received: by 2002:aa7:cf8e:0:b0:522:219b:ce05 with SMTP id z14-20020aa7cf8e000000b00522219bce05mr3687014edx.7.1690944366224; Tue, 01 Aug 2023 19:46:06 -0700 (PDT) MIME-Version: 1.0 References: <1690871446-23713-1-git-send-email-yangtiezhu@loongson.cn> <20230801134034.GA3831650@dev-arch.thelio-3990X> In-Reply-To: <20230801134034.GA3831650@dev-arch.thelio-3990X> From: Huacai Chen Date: Wed, 2 Aug 2023 10:45:53 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] LoongArch: Error out if clang version is less than 17.0.0 To: Nathan Chancellor Cc: Tiezhu Yang , Nick Desaulniers , loongarch@lists.linux.dev, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn 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 Hi, On Tue, Aug 1, 2023 at 9:40=E2=80=AFPM Nathan Chancellor wrote: > > Hi Tiezhu, > > On Tue, Aug 01, 2023 at 02:30:46PM +0800, Tiezhu Yang wrote: > > On my test machine, the clang version is 16.0.4, when build kernel > > with clang: > > > > make CC=3Dclang loongson3_defconfig > > make CC=3Dclang > > > > there exist many errors such as: > > > > clang-16: error: argument unused during compilation: '-mabi=3Dlp64s' > > error: unknown register name 'a0' in asm > > error: unknown register name 't0' in asm > > > > the above issues have been fixed in the upstream llvm project recently, > > it works well when update clang version to 17.0.0: > > > > make CC=3Dclang loongson3_defconfig > > make CC=3Dclang menuconfig (set CONFIG_MODULES=3Dn and CONFIG_RELOCAT= ABLE=3Dn) > > make CC=3Dclang > > > > thus 17.0.0 is the minimal clang version to build kernel on LoongArch, > > it is better to error out if clang version is less than 17.0.0, then > > we can do the right thing to update clang version and avoid wasting > > time to analysis kernel errors. > > > > By the way, the clang 17.0.0 still have some issues to build kernel on > > LoongArch, you need to unset CONFIG_MODULES and CONFIG_RELOCATABLE to > > avoid build errors. Additionally, if you want a workable kernel, some > > modules should be set as y instead of m if CONFIG_MODULES=3Dn. > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/1787 > > Signed-off-by: Tiezhu Yang > > --- > > arch/loongarch/Makefile | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile > > index b1e5db5..f07f62a 100644 > > --- a/arch/loongarch/Makefile > > +++ b/arch/loongarch/Makefile > > @@ -10,6 +10,12 @@ KBUILD_DEFCONFIG :=3D loongson3_defconfig > > image-name-y :=3D vmlinux > > image-name-$(CONFIG_EFI_ZBOOT) :=3D vmlinuz > > > > +ifdef CONFIG_CC_IS_CLANG > > + ifneq ($(call clang-min-version, 170000),y) > > + $(error Sorry, you need a newer clang version >=3D 17.0.0) > > + endif > > +endif > > + > > Thanks for the patch! I agree that we should restrict LoongArch to LLVM > 17 and newer. However, there is already existing infrastructure for this > type of check in Kconfig, so we don't need to add anything to > arch/loongarch. Just modify scripts/min-tool-version.sh like so then > there will be a message during configuration time that the compiler is > too old. > > diff --git a/scripts/min-tool-version.sh b/scripts/min-tool-version.sh > index 2ade63149466..572c0526ad61 100755 > --- a/scripts/min-tool-version.sh > +++ b/scripts/min-tool-version.sh > @@ -26,6 +26,8 @@ gcc) > llvm) > if [ "$SRCARCH" =3D s390 ]; then > echo 15.0.0 > + elif [ "$SRCARCH" =3D loongarch ]; then > + echo 17.0.0 > else > echo 11.0.0 > fi > > *** > *** C compiler is too old. > *** Your Clang version: 16.0.6 > *** Minimum Clang version: 17.0.0 > *** > scripts/Kconfig.include:44: Sorry, this C compiler is not supported. This method is better, but since Clang17 cannot build a full-functional kernel (CONFIG_MODULES, may be solved in Clang18), I suggest "fix" it in future until all features can be enabled. Huacai > > > ifndef CONFIG_EFI_STUB > > KBUILD_IMAGE :=3D $(boot)/vmlinux.elf > > else > > -- > > 2.1.0 > > > > > > Cheers, > Nathan