From f3a620abee5e26dda04f7a747a54ab075f45b70d Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 28 Mar 2020 18:57:25 +0900 Subject: [PATCH 2/2] kbuild: change the default of HOST{CC,CXX} to cc and c++ I have been thinking how to cater to those who want to build host programs with Clang. We could use the variable 'LLVM' to switch the default of HOST{CC,CXX}: ifneq ($(LLVM),) HOSTCC = clang HOSTCXX = clang++ else HOSTCC = gcc HOSTCXX = g++ endif But, I do not know how many people care about this. There is no tricky code in userspace programs, and we know we can compile them with GCC, Clang, or whatever. No matter what you use for host programs, it makes no difference to the kernel itself. If you are so addicted to LLVM or if you are using a system with no GCC installation, probably you had already had 'cc' and 'c++' point to Clang. So, another approach is to just leave this up to the system. You can manually set up symlinks, or maybe your distro provides 'alternatives'. $ update-alternatives --list cc /usr/bin/clang /usr/bin/gcc $ update-alternatives --list c++ /usr/bin/clang++ /usr/bin/g++ I have no idea what to do for tools/objtool/Makefile, which uses HOSTAR and HOSTLD, but this is because objtool intentionally opts out Kbuild. If objtool is willing to join the Kbuild infrastructure, a patch exists: https://patchwork.kernel.org/patch/10839051/ Signed-off-by: Masahiro Yamada --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f192f9bd8343..ecdd34ad0750 100644 --- a/Makefile +++ b/Makefile @@ -399,8 +399,8 @@ HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null) HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null) HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null) -HOSTCC = gcc -HOSTCXX = g++ +HOSTCC = cc +HOSTCXX = c++ KBUILD_HOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \ -fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS) \ $(HOSTCFLAGS) -- 2.17.1