mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Huacai Chen <chenhuacai@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	loongarch@lists.linux.dev, llvm@lists.linux.dev,
	linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn
Subject: Re: [PATCH] LoongArch: Error out if clang version is less than 17.0.0
Date: Tue, 1 Aug 2023 06:40:34 -0700	[thread overview]
Message-ID: <20230801134034.GA3831650@dev-arch.thelio-3990X> (raw)
In-Reply-To: <1690871446-23713-1-git-send-email-yangtiezhu@loongson.cn>

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

  reply	other threads:[~2023-08-01 13:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-01  6:30 Tiezhu Yang
2023-08-01 13:40 ` Nathan Chancellor [this message]
2023-08-02  2:45   ` Huacai Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230801134034.GA3831650@dev-arch.thelio-3990X \
    --to=nathan@kernel.org \
    --cc=chenhuacai@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=loongarch@lists.linux.dev \
    --cc=loongson-kernel@lists.loongnix.cn \
    --cc=ndesaulniers@google.com \
    --cc=yangtiezhu@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®