Re: linux-next: manual merge of the rust tree with the kbuild tree

From: Stephen Rothwell
Date: Thu Aug 12 2021 - 02:35:12 EST


Hi Nick,

On Wed, 11 Aug 2021 10:04:36 -0700 Nick Desaulniers <ndesaulniers@xxxxxxxxxx> wrote:
>
> Thanks Stephen for taking the time to resolve this and send a patch.
> We owe you one. We knew this conflict was coming.
>
> Miguel, would you mind rolling this patch into your tree, then
> crediting Stephen if possible (on the patch that adds
> TENTATIVE_CLANG_FLAGS)?
>
> I think the above `ifneq ($(findstring clang,$(CC_VERSION_TEXT)),)`
> should stay in the top level Makefile though. It does look nicer to
> bury it in scripts/Makefile.clang, but I worry that someone doing a
> GCC build might trip the $(error) in that file (if CROSS_COMPILE was
> set and we're building a non-llvm-supported target).

OK, I have changed the patch today to be this:

From: Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx>
Date: Wed, 11 Aug 2021 17:18:36 +1000
Subject: [PATCH] fixup for rust integration with Makefile.clang creation

Signed-off-by: Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx>
---
Makefile | 17 -----------------
scripts/Makefile.clang | 19 +++++++++++++------
2 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/Makefile b/Makefile
index 5d504a1dcb06..3638ce07f208 100644
--- a/Makefile
+++ b/Makefile
@@ -625,22 +625,7 @@ endif
# and from include/config/auto.conf.cmd to detect the compiler upgrade.
CC_VERSION_TEXT = $(subst $(pound),,$(shell LC_ALL=C $(CC) --version 2>/dev/null | head -n 1))

-TENTATIVE_CLANG_FLAGS := -Werror=unknown-warning-option
-
-ifneq ($(CROSS_COMPILE),)
-TENTATIVE_CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
-endif
-ifeq ($(LLVM_IAS),1)
-TENTATIVE_CLANG_FLAGS += -integrated-as
-else
-TENTATIVE_CLANG_FLAGS += -no-integrated-as
-GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
-TENTATIVE_CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE))
-endif
-
-export TENTATIVE_CLANG_FLAGS
-
ifneq ($(findstring clang,$(CC_VERSION_TEXT)),)
include $(srctree)/scripts/Makefile.clang
endif

diff --git a/scripts/Makefile.clang b/scripts/Makefile.clang
index 3ae63bd35582..555b5255d9b3 100644
--- a/scripts/Makefile.clang
+++ b/scripts/Makefile.clang
@@ -12,24 +12,29 @@ CLANG_TARGET_FLAGS_s390 := s390x-linux-gnu
CLANG_TARGET_FLAGS_x86 := x86_64-linux-gnu
CLANG_TARGET_FLAGS := $(CLANG_TARGET_FLAGS_$(SRCARCH))

+TENTATIVE_CLANG_FLAGS := -Werror=unknown-warning-option
+
ifeq ($(CROSS_COMPILE),)
ifeq ($(CLANG_TARGET_FLAGS),)
$(error Specify CROSS_COMPILE or add '--target=' option to scripts/Makefile.clang)
else
-CLANG_FLAGS += --target=$(CLANG_TARGET_FLAGS)
+TENTATIVE_CLANG_FLAGS += --target=$(CLANG_TARGET_FLAGS)
endif # CLANG_TARGET_FLAGS
else
-CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
+TENTATIVE_CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
endif # CROSS_COMPILE

ifeq ($(LLVM_IAS),0)
-CLANG_FLAGS += -no-integrated-as
+TENTATIVE_CLANG_FLAGS += -no-integrated-as
GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
-CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE))
+TENTATIVE_CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE))
else
-CLANG_FLAGS += -integrated-as
+TENTATIVE_CLANG_FLAGS += -integrated-as
endif
-CLANG_FLAGS += -Werror=unknown-warning-option
+
+export TENTATIVE_CLANG_FLAGS
+
+CLANG_FLAGS += $(TENTATIVE_CLANG_FLAGS)
KBUILD_CFLAGS += $(CLANG_FLAGS)
KBUILD_AFLAGS += $(CLANG_FLAGS)
export CLANG_FLAGS
--
2.30.2

Please give it a spin when linux-next has been released.

--
Cheers,
Stephen Rothwell

Attachment: pgpJdXYxX_aco.pgp
Description: OpenPGP digital signature