Message ID | 1690871446-23713-1-git-send-email-yangtiezhu@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2480692vqg; Mon, 31 Jul 2023 23:38:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlFgFJSTnlet9Q/lpMANS8FmlAiu+DLQiZ9htUPOTn5Bwx8sLJkjF1VpT18wtyhvEUJwAzKC X-Received: by 2002:a17:906:10cd:b0:99b:f52a:bf6 with SMTP id v13-20020a17090610cd00b0099bf52a0bf6mr7862727ejv.6.1690871932485; Mon, 31 Jul 2023 23:38:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690871932; cv=none; d=google.com; s=arc-20160816; b=anRCsUwwvbem+sTeJ/RVz4TcZF13amOWiBrqzbjof7qlh51TOMSlQ038eCDAQf+4Zo yNkSMjAL9pj6OpdCKcRPN0PZQ3UQNVyJOZanqqGuRVGZ4DTSH8sZfb/Bb6XRRTEKZBI3 POwSFyjQTGphnr362kQ0RrKgQqp6LE0fEky20maMunSNJlG524iMwe7bUPPD83m73lxD 9MHHAtenBYSGINFsl83tiGJ3vegJO9YZzHtHSlDGUJMnG9f6JH3KIXa8bj5LTZGVdfwM zRkWTnMr9p/IKiwrbchfXgz5d9Gg0KHn1YGUz202T1IH0xusks0fFZN0omJ6KtzfyI78 0whA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=aLqOzMib/ozgsb++3jP9BFe1fjKfw2zjdVD2p3c84iU=; fh=xB22ndQROENE71QtbezY23JLk4nP1Mmqtf4j5Ck7NkM=; b=ksbUYUAGmZm/Q2G6Z73VapqGBHSiZnu9PUCKUlDWyshGUaYryYwcpAvS5biC7ByHBj BqLH8OSj3tdTv/9vqkXpXZI9OMtcn69j3mxt0Z3Q+yuUFNK1SDuDofVLp3zz792iSOMW VeZg5sCoMOW7nU5IkHU7z2B4Sg+8ibPR48eZIOLu9LnmCSc0fHSu2UgjFjQ3scwLq+4X 2a1MI2JLSlv6AtCv/6QnHTQ/sDnmq3UW0Y5SOR24iB/3EeE+zBmrVbSOYt795p8QTT7L AmnxbqZdfHjNdg1Ezu0VWgXm1QKXBRk1JTrmYU2bfzz3YstaYAUFntlpCGMwQxqWbCAi Au6A== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kj27-20020a170907765b00b0098733a40bb9si8182864ejc.855.2023.07.31.23.38.28; Mon, 31 Jul 2023 23:38:52 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231206AbjHAGa7 (ORCPT <rfc822;cambridge8321@gmail.com> + 99 others); Tue, 1 Aug 2023 02:30:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229554AbjHAGa5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 1 Aug 2023 02:30:57 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0D1C4DB for <linux-kernel@vger.kernel.org>; Mon, 31 Jul 2023 23:30:55 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8DxRvGdpshk6uUNAA--.32938S3; Tue, 01 Aug 2023 14:30:53 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxPCOcpshk8pVDAA--.26385S2; Tue, 01 Aug 2023 14:30:52 +0800 (CST) From: Tiezhu Yang <yangtiezhu@loongson.cn> To: Huacai Chen <chenhuacai@kernel.org>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com> Cc: loongarch@lists.linux.dev, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Subject: [PATCH] LoongArch: Error out if clang version is less than 17.0.0 Date: Tue, 1 Aug 2023 14:30:46 +0800 Message-Id: <1690871446-23713-1-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 X-CM-TRANSID: AQAAf8DxPCOcpshk8pVDAA--.26385S2 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoW7AFykXFW8JryfCr47CFWrtFc_yoW8Cr4fpr 1rZw1DKr4kXryFvrZ7J34DWryY9F97JryIgFyUJryUWry2qws5WrW8KrWagFZrZws7Zay0 gryxG3WS9FyUA3gCm3ZEXasCq-sJn29KB7ZKAUJUUUUr529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUU9Yb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2kKe7AKxVWUXVWUAwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07 AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWU AVWUtwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7V AKI48JMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMxCIbckI1I0E14v2 6r1Y6r17MI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17 CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF 0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIx AIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIev Ja73UjIFyTuYvjxUc0eHDUUUU X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773007727433765674 X-GMAIL-MSGID: 1773007727433765674 |
Series |
LoongArch: Error out if clang version is less than 17.0.0
|
|
Commit Message
Tiezhu Yang
Aug. 1, 2023, 6:30 a.m. UTC
On my test machine, the clang version is 16.0.4, when build kernel
with clang:
make CC=clang loongson3_defconfig
make CC=clang
there exist many errors such as:
clang-16: error: argument unused during compilation: '-mabi=lp64s'
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=clang loongson3_defconfig
make CC=clang menuconfig (set CONFIG_MODULES=n and CONFIG_RELOCATABLE=n)
make CC=clang
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=n.
Link: https://github.com/ClangBuiltLinux/linux/issues/1787
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
arch/loongarch/Makefile | 6 ++++++
1 file changed, 6 insertions(+)
Comments
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=clang loongson3_defconfig > make CC=clang > > there exist many errors such as: > > clang-16: error: argument unused during compilation: '-mabi=lp64s' > 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=clang loongson3_defconfig > make CC=clang menuconfig (set CONFIG_MODULES=n and CONFIG_RELOCATABLE=n) > make CC=clang > > 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=n. > > Link: https://github.com/ClangBuiltLinux/linux/issues/1787 > Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> > --- > 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 := loongson3_defconfig > image-name-y := vmlinux > image-name-$(CONFIG_EFI_ZBOOT) := vmlinuz > > +ifdef CONFIG_CC_IS_CLANG > + ifneq ($(call clang-min-version, 170000),y) > + $(error Sorry, you need a newer clang version >= 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" = s390 ]; then echo 15.0.0 + elif [ "$SRCARCH" = 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. > ifndef CONFIG_EFI_STUB > KBUILD_IMAGE := $(boot)/vmlinux.elf > else > -- > 2.1.0 > > Cheers, Nathan
Hi, On Tue, Aug 1, 2023 at 9:40 PM Nathan Chancellor <nathan@kernel.org> 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=clang loongson3_defconfig > > make CC=clang > > > > there exist many errors such as: > > > > clang-16: error: argument unused during compilation: '-mabi=lp64s' > > 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=clang loongson3_defconfig > > make CC=clang menuconfig (set CONFIG_MODULES=n and CONFIG_RELOCATABLE=n) > > make CC=clang > > > > 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=n. > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/1787 > > Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> > > --- > > 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 := loongson3_defconfig > > image-name-y := vmlinux > > image-name-$(CONFIG_EFI_ZBOOT) := vmlinuz > > > > +ifdef CONFIG_CC_IS_CLANG > > + ifneq ($(call clang-min-version, 170000),y) > > + $(error Sorry, you need a newer clang version >= 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" = s390 ]; then > echo 15.0.0 > + elif [ "$SRCARCH" = 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 := $(boot)/vmlinux.elf > > else > > -- > > 2.1.0 > > > > > > Cheers, > Nathan
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 := loongson3_defconfig image-name-y := vmlinux image-name-$(CONFIG_EFI_ZBOOT) := vmlinuz +ifdef CONFIG_CC_IS_CLANG + ifneq ($(call clang-min-version, 170000),y) + $(error Sorry, you need a newer clang version >= 17.0.0) + endif +endif + ifndef CONFIG_EFI_STUB KBUILD_IMAGE := $(boot)/vmlinux.elf else