Skip to contentSkip to conversation

Fix kernel build with LLVM=1

PATCH In review Grigory Vasilyev 2 participants 2 messages Mar 31, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix kernel build with LLVM=1

The wrong logic is using 1 as a suffix instead of -1. So the build script tries to find clang1 file instead of clang.

GEN Makefile
HOSTCC scripts/basic/fixdep
/bin/sh: line 1: clang1: command not found
make[2]: *** [/build/linux/scripts/Makefile.host:95: scripts/basic/fixdep] Error 127 make[1]: *** [/build/linux/Makefile:564: scripts_basic] Error 2
make: *** [Makefile:219: __sub-make] Error 2

Fixes b8321ed4a40c("Merge tag 'kbuild-v5.18-v2'")
---
 Makefile                       | 4 ++--
 tools/scripts/Makefile.include | 4 ++--
 tools/testing/selftests/lib.mk | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
Makefile +2 -2
index 18ecb49f1af6..efca890d4ea3 100644
@@ -426,8 +426,8 @@ HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
 ifneq ($(LLVM),)
 ifneq ($(filter %/,$(LLVM)),)
 LLVM_PREFIX := $(LLVM)
-else ifneq ($(filter -%,$(LLVM)),)
-LLVM_SUFFIX := $(LLVM)
+else ifneq (,$(findstring -, $(LLVM)))
+LLVM_SUFFIX := $(filter -%, $(LLVM))
 endif
 
 HOSTCC	= $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
tools/scripts/Makefile.include +2 -2
index 0efb8f2b33ce..c7a56d7f0bad 100644
@@ -54,8 +54,8 @@ endef
 ifneq ($(LLVM),)
 ifneq ($(filter %/,$(LLVM)),)
 LLVM_PREFIX := $(LLVM)
-else ifneq ($(filter -%,$(LLVM)),)
-LLVM_SUFFIX := $(LLVM)
+else ifneq (,$(findstring -, $(LLVM)))
+LLVM_SUFFIX := $(filter -%, $(LLVM))
 endif
 
 $(call allow-override,CC,$(LLVM_PREFIX)clang$(LLVM_SUFFIX))
tools/testing/selftests/lib.mk +2 -2
index 2a2d240cdc1b..42af066cf39e 100644
@@ -3,8 +3,8 @@
 ifneq ($(LLVM),)
 ifneq ($(filter %/,$(LLVM)),)
 LLVM_PREFIX := $(LLVM)
-else ifneq ($(filter -%,$(LLVM)),)
-LLVM_SUFFIX := $(LLVM)
+else ifneq (,$(findstring -, $(LLVM)))
+LLVM_SUFFIX := $(filter -%, $(LLVM))
 endif
 
 CC := $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
Signature · 1 line
2.35.1
#1 lore raw

Hi Grigory,

Quoted 9 lines · Grigory Vasilyev

The wrong logic is using 1 as a suffix instead of -1. So the build script tries to find clang1 file instead of clang.

GEN Makefile
HOSTCC scripts/basic/fixdep
/bin/sh: line 1: clang1: command not found
make[2]: *** [/build/linux/scripts/Makefile.host:95: scripts/basic/fixdep] Error 127 make[1]: *** [/build/linux/Makefile:564: scripts_basic] Error 2
make: *** [Makefile:219: __sub-make] Error 2

I am confused by this error, what is your build command? The supported uses of LLVM= are:

$ make LLVM=1

to use clang, ld.lld, etc.

$ make LLVM=-1

to use clang-1, ld.lld-1, etc.

$ make LLVM=/path/to/

to use /path/to/clang, /path/to/ld.lld, etc.

I do not really understand how based on the current logic you are ending up with clang1.

$ make -skj"$(nproc)" LLVM=1 distclean defconfig all

works for me here:

$ git show -s --format='%h ("%s")'
478f74a3d808 ("Merge tag 'random-5.18-rc1-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/crng/random")
$ head -1 init/.main.o.cmd
cmd_init/main.o := clang -Wp,-MMD,init/.main.o.d ...

Please provide more information, as this change should not be necessary.

It could be GNU make related?

$ make --version
GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Quoted 4 lines
Fixes b8321ed4a40c("Merge tag 'kbuild-v5.18-v2'")

Normally, you do not add a "Reported-by" for a patch you send, just for the future.

Quoted 54 lines
---
 Makefile                       | 4 ++--
 tools/scripts/Makefile.include | 4 ++--
 tools/testing/selftests/lib.mk | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
Makefile +2 -2
index 18ecb49f1af6..efca890d4ea3 100644
@@ -426,8 +426,8 @@ HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
 ifneq ($(LLVM),)
 ifneq ($(filter %/,$(LLVM)),)
 LLVM_PREFIX := $(LLVM)
-else ifneq ($(filter -%,$(LLVM)),)
-LLVM_SUFFIX := $(LLVM)
+else ifneq (,$(findstring -, $(LLVM)))
+LLVM_SUFFIX := $(filter -%, $(LLVM))
 endif
 
 HOSTCC	= $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
tools/scripts/Makefile.include +2 -2
index 0efb8f2b33ce..c7a56d7f0bad 100644
@@ -54,8 +54,8 @@ endef
 ifneq ($(LLVM),)
 ifneq ($(filter %/,$(LLVM)),)
 LLVM_PREFIX := $(LLVM)
-else ifneq ($(filter -%,$(LLVM)),)
-LLVM_SUFFIX := $(LLVM)
+else ifneq (,$(findstring -, $(LLVM)))
+LLVM_SUFFIX := $(filter -%, $(LLVM))
 endif
 
 $(call allow-override,CC,$(LLVM_PREFIX)clang$(LLVM_SUFFIX))
tools/testing/selftests/lib.mk +2 -2
index 2a2d240cdc1b..42af066cf39e 100644
@@ -3,8 +3,8 @@
 ifneq ($(LLVM),)
 ifneq ($(filter %/,$(LLVM)),)
 LLVM_PREFIX := $(LLVM)
-else ifneq ($(filter -%,$(LLVM)),)
-LLVM_SUFFIX := $(LLVM)
+else ifneq (,$(findstring -, $(LLVM)))
+LLVM_SUFFIX := $(filter -%, $(LLVM))
 endif
 
 CC := $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
Signature · 1 line
2.35.1