mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] LoongArch: Error out if clang version is less than 17.0.0
@ 2023-08-01  6:30 Tiezhu Yang
  2023-08-01 13:40 ` Nathan Chancellor
  0 siblings, 1 reply; 3+ messages in thread
From: Tiezhu Yang @ 2023-08-01  6:30 UTC (permalink / raw)
  To: Huacai Chen, Nathan Chancellor, Nick Desaulniers
  Cc: loongarch, llvm, linux-kernel, loongson-kernel

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
+
 ifndef CONFIG_EFI_STUB
 KBUILD_IMAGE	:= $(boot)/vmlinux.elf
 else
-- 
2.1.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-02  2:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-01  6:30 [PATCH] LoongArch: Error out if clang version is less than 17.0.0 Tiezhu Yang
2023-08-01 13:40 ` Nathan Chancellor
2023-08-02  2:45   ` Huacai Chen

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®