* [PATCH] kbuild: initialize CLANG_FLAGS correctly in the top Makefile
@ 2019-07-29 9:15 Masahiro Yamada
2019-07-29 9:38 ` Masahiro Yamada
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Masahiro Yamada @ 2019-07-29 9:15 UTC (permalink / raw)
To: linux-kbuild
Cc: Stephen Boyd, Nick Desaulniers, Nathan Chancellor,
Masahiro Yamada, stable, Michal Marek, clang-built-linux,
linux-kernel
CLANG_FLAGS is initialized by the following line:
CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%))
..., which is run only when CROSS_COMPILE is set.
Some build targets (bindeb-pkg etc.) recurse to the top Makefile.
When you build the kernel with Clang but without CROSS_COMPILE,
the same compiler flags such as -no-integrated-as are accumulated
into CLANG_FLAGS.
If you run 'make CC=clang' and then 'make CC=clang bindeb-pkg',
Kbuild will recompile everything needlessly due to the build command
change.
Fix this by correctly initializing CLANG_FLAGS.
Fixes: 238bcbc4e07f ("kbuild: consolidate Clang compiler flags")
Cc: <stable@vger.kernel.org> # v4.20+
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index fa0fbe7851ea..5ee6f6889869 100644
--- a/Makefile
+++ b/Makefile
@@ -472,6 +472,7 @@ KBUILD_CFLAGS_MODULE := -DMODULE
KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
KBUILD_LDFLAGS :=
GCC_PLUGINS_CFLAGS :=
+CLANG_FLAGS :=
export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
export CPP AR NM STRIP OBJCOPY OBJDUMP PAHOLE KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS
@@ -519,7 +520,7 @@ endif
ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
ifneq ($(CROSS_COMPILE),)
-CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%))
+CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)
GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] kbuild: initialize CLANG_FLAGS correctly in the top Makefile
2019-07-29 9:15 [PATCH] kbuild: initialize CLANG_FLAGS correctly in the top Makefile Masahiro Yamada
@ 2019-07-29 9:38 ` Masahiro Yamada
2019-07-29 16:04 ` Nathan Chancellor
2019-07-30 16:45 ` Masahiro Yamada
2 siblings, 0 replies; 5+ messages in thread
From: Masahiro Yamada @ 2019-07-29 9:38 UTC (permalink / raw)
To: Linux Kbuild mailing list
Cc: Stephen Boyd, Nick Desaulniers, Nathan Chancellor, stable,
Michal Marek, clang-built-linux, Linux Kernel Mailing List
On Mon, Jul 29, 2019 at 6:16 PM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> CLANG_FLAGS is initialized by the following line:
>
> CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%))
>
> ..., which is run only when CROSS_COMPILE is set.
>
> Some build targets (bindeb-pkg etc.) recurse to the top Makefile.
>
> When you build the kernel with Clang but without CROSS_COMPILE,
> the same compiler flags such as -no-integrated-as are accumulated
> into CLANG_FLAGS.
>
> If you run 'make CC=clang' and then 'make CC=clang bindeb-pkg',
> Kbuild will recompile everything needlessly due to the build command
> change.
>
> Fix this by correctly initializing CLANG_FLAGS.
>
> Fixes: 238bcbc4e07f ("kbuild: consolidate Clang compiler flags")
> Cc: <stable@vger.kernel.org> # v4.20+
This should be v5.0+
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kbuild: initialize CLANG_FLAGS correctly in the top Makefile
2019-07-29 9:15 [PATCH] kbuild: initialize CLANG_FLAGS correctly in the top Makefile Masahiro Yamada
2019-07-29 9:38 ` Masahiro Yamada
@ 2019-07-29 16:04 ` Nathan Chancellor
2019-07-29 16:21 ` Nick Desaulniers
2019-07-30 16:45 ` Masahiro Yamada
2 siblings, 1 reply; 5+ messages in thread
From: Nathan Chancellor @ 2019-07-29 16:04 UTC (permalink / raw)
To: Masahiro Yamada
Cc: linux-kbuild, Stephen Boyd, Nick Desaulniers, stable,
Michal Marek, clang-built-linux, linux-kernel
On Mon, Jul 29, 2019 at 06:15:17PM +0900, Masahiro Yamada wrote:
> CLANG_FLAGS is initialized by the following line:
>
> CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%))
>
> ..., which is run only when CROSS_COMPILE is set.
>
> Some build targets (bindeb-pkg etc.) recurse to the top Makefile.
>
> When you build the kernel with Clang but without CROSS_COMPILE,
> the same compiler flags such as -no-integrated-as are accumulated
> into CLANG_FLAGS.
>
> If you run 'make CC=clang' and then 'make CC=clang bindeb-pkg',
> Kbuild will recompile everything needlessly due to the build command
> change.
>
> Fix this by correctly initializing CLANG_FLAGS.
>
> Fixes: 238bcbc4e07f ("kbuild: consolidate Clang compiler flags")
> Cc: <stable@vger.kernel.org> # v4.20+
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kbuild: initialize CLANG_FLAGS correctly in the top Makefile
2019-07-29 16:04 ` Nathan Chancellor
@ 2019-07-29 16:21 ` Nick Desaulniers
0 siblings, 0 replies; 5+ messages in thread
From: Nick Desaulniers @ 2019-07-29 16:21 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Masahiro Yamada, Linux Kbuild mailing list, Stephen Boyd,
# 3.4.x, Michal Marek, clang-built-linux, LKML
On Mon, Jul 29, 2019 at 9:04 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> On Mon, Jul 29, 2019 at 06:15:17PM +0900, Masahiro Yamada wrote:
> > CLANG_FLAGS is initialized by the following line:
> >
> > CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%))
> >
> > ..., which is run only when CROSS_COMPILE is set.
> >
> > Some build targets (bindeb-pkg etc.) recurse to the top Makefile.
> >
> > When you build the kernel with Clang but without CROSS_COMPILE,
> > the same compiler flags such as -no-integrated-as are accumulated
> > into CLANG_FLAGS.
> >
> > If you run 'make CC=clang' and then 'make CC=clang bindeb-pkg',
> > Kbuild will recompile everything needlessly due to the build command
> > change.
> >
> > Fix this by correctly initializing CLANG_FLAGS.
> >
> > Fixes: 238bcbc4e07f ("kbuild: consolidate Clang compiler flags")
> > Cc: <stable@vger.kernel.org> # v4.20+
> > Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>
> Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Acked-by: Nick Desaulniers <ndesaulniers@google.com>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kbuild: initialize CLANG_FLAGS correctly in the top Makefile
2019-07-29 9:15 [PATCH] kbuild: initialize CLANG_FLAGS correctly in the top Makefile Masahiro Yamada
2019-07-29 9:38 ` Masahiro Yamada
2019-07-29 16:04 ` Nathan Chancellor
@ 2019-07-30 16:45 ` Masahiro Yamada
2 siblings, 0 replies; 5+ messages in thread
From: Masahiro Yamada @ 2019-07-30 16:45 UTC (permalink / raw)
To: Linux Kbuild mailing list
Cc: Stephen Boyd, Nick Desaulniers, Nathan Chancellor, stable,
Michal Marek, clang-built-linux, Linux Kernel Mailing List
On Mon, Jul 29, 2019 at 6:16 PM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> CLANG_FLAGS is initialized by the following line:
>
> CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%))
>
> ..., which is run only when CROSS_COMPILE is set.
>
> Some build targets (bindeb-pkg etc.) recurse to the top Makefile.
>
> When you build the kernel with Clang but without CROSS_COMPILE,
> the same compiler flags such as -no-integrated-as are accumulated
> into CLANG_FLAGS.
>
> If you run 'make CC=clang' and then 'make CC=clang bindeb-pkg',
> Kbuild will recompile everything needlessly due to the build command
> change.
>
> Fix this by correctly initializing CLANG_FLAGS.
>
> Fixes: 238bcbc4e07f ("kbuild: consolidate Clang compiler flags")
> Cc: <stable@vger.kernel.org> # v4.20+
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
Applied to linux-kbuild.
>
> Makefile | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index fa0fbe7851ea..5ee6f6889869 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -472,6 +472,7 @@ KBUILD_CFLAGS_MODULE := -DMODULE
> KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
> KBUILD_LDFLAGS :=
> GCC_PLUGINS_CFLAGS :=
> +CLANG_FLAGS :=
>
> export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
> export CPP AR NM STRIP OBJCOPY OBJDUMP PAHOLE KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS
> @@ -519,7 +520,7 @@ endif
>
> ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
> ifneq ($(CROSS_COMPILE),)
> -CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%))
> +CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
> GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
> CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)
> GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
> --
> 2.17.1
>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-07-30 16:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-29 9:15 [PATCH] kbuild: initialize CLANG_FLAGS correctly in the top Makefile Masahiro Yamada
2019-07-29 9:38 ` Masahiro Yamada
2019-07-29 16:04 ` Nathan Chancellor
2019-07-29 16:21 ` Nick Desaulniers
2019-07-30 16:45 ` Masahiro Yamada
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).