* [PATCH] kbuild: introduce include/generated/global-rebuild.h
@ 2025-05-03 8:41 Masahiro Yamada
2025-05-06 10:52 ` Nicolas Schier
0 siblings, 1 reply; 2+ messages in thread
From: Masahiro Yamada @ 2025-05-03 8:41 UTC (permalink / raw)
To: linux-kbuild
Cc: linux-kernel, Masahiro Yamada, Kees Cook, Anton Ivanov,
Johannes Berg, Nathan Chancellor, Nicolas Schier,
Richard Weinberger, linux-um
Sometimes we need to trigger a global rebuild of the kernel tree -
for instance, when any of the GCC plugins changes. [1]
This commit provides a simple mechanism to force a global rebuild
using a single header file.
The top-level Makefile creates include/generated/global-rebuild.h if
it does not exist, and this file is included by all kernel sources.
You can touch it in a build rule when a global rebuild is required.
The following is an example change to the GCC plugin build rule.
quiet_cmd_plugin_cxx_so_c = HOSTCXX $@
- cmd_plugin_cxx_so_c = $(HOSTCXX) $(plugin_cxxflags) $(plugin_ldflags) -o $@ $<
+ cmd_plugin_cxx_so_c = $(HOSTCXX) $(plugin_cxxflags) $(plugin_ldflags) -o $@ $<; touch include/generated/global-rebuild.h
Link: https://lore.kernel.org/linux-kbuild/CAK7LNATDbxc+3HQ6zoSk9t-Lkf4MSNmEUN6S5EqoVWnBQw_K6g@mail.gmail.com/T/#me069145443a17f0b464c13814424dbba0d970863 [1]
Cc: Kees Cook <kees@kernel.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
Makefile | 9 ++++++++-
arch/um/Makefile | 3 ++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 5aa9ee52a765..64811eebd549 100644
--- a/Makefile
+++ b/Makefile
@@ -558,7 +558,8 @@ USERINCLUDE := \
-I$(srctree)/include/uapi \
-I$(objtree)/include/generated/uapi \
-include $(srctree)/include/linux/compiler-version.h \
- -include $(srctree)/include/linux/kconfig.h
+ -include $(srctree)/include/linux/kconfig.h \
+ -include $(objtree)/include/generated/global-rebuild.h
# Use LINUXINCLUDE when you must reference the include/ directory.
# Needed to be compatible with the O= option
@@ -1257,6 +1258,11 @@ endif
include/config/kernel.release: FORCE
$(call filechk,kernel.release)
+filechk_empty = printf ''
+
+include/generated/global-rebuild.h: FORCE
+ $(call filechk,empty)
+
# Additional helpers built in scripts/
# Carefully list dependencies so we do not try to build scripts twice
# in parallel
@@ -1273,6 +1279,7 @@ scripts: scripts_basic scripts_dtc
PHONY += prepare archprepare
archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \
+ include/generated/global-rebuild.h \
asm-generic $(version_h) include/generated/utsrelease.h \
include/generated/compile.h include/generated/autoconf.h \
include/generated/rustc_cfg remove-stale-files
diff --git a/arch/um/Makefile b/arch/um/Makefile
index 1d36a613aad8..f564a26c1364 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -73,7 +73,8 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \
-D_FILE_OFFSET_BITS=64 -idirafter $(srctree)/include \
-idirafter $(objtree)/include -D__KERNEL__ -D__UM_HOST__ \
-include $(srctree)/include/linux/compiler-version.h \
- -include $(srctree)/include/linux/kconfig.h
+ -include $(srctree)/include/linux/kconfig.h \
+ -include $(objtree)/include/generated/global-rebuild.h
#This will adjust *FLAGS accordingly to the platform.
include $(srctree)/$(ARCH_DIR)/Makefile-os-Linux
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] kbuild: introduce include/generated/global-rebuild.h
2025-05-03 8:41 [PATCH] kbuild: introduce include/generated/global-rebuild.h Masahiro Yamada
@ 2025-05-06 10:52 ` Nicolas Schier
0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Schier @ 2025-05-06 10:52 UTC (permalink / raw)
To: Masahiro Yamada
Cc: linux-kbuild, linux-kernel, Kees Cook, Anton Ivanov,
Johannes Berg, Nathan Chancellor, Richard Weinberger, linux-um
On Sat, May 03, 2025 at 05:41:43PM +0900, Masahiro Yamada wrote:
> Sometimes we need to trigger a global rebuild of the kernel tree -
> for instance, when any of the GCC plugins changes. [1]
>
> This commit provides a simple mechanism to force a global rebuild
> using a single header file.
>
> The top-level Makefile creates include/generated/global-rebuild.h if
> it does not exist, and this file is included by all kernel sources.
>
> You can touch it in a build rule when a global rebuild is required.
>
> The following is an example change to the GCC plugin build rule.
>
> quiet_cmd_plugin_cxx_so_c = HOSTCXX $@
> - cmd_plugin_cxx_so_c = $(HOSTCXX) $(plugin_cxxflags) $(plugin_ldflags) -o $@ $<
> + cmd_plugin_cxx_so_c = $(HOSTCXX) $(plugin_cxxflags) $(plugin_ldflags) -o $@ $<; touch include/generated/global-rebuild.h
>
> Link: https://lore.kernel.org/linux-kbuild/CAK7LNATDbxc+3HQ6zoSk9t-Lkf4MSNmEUN6S5EqoVWnBQw_K6g@mail.gmail.com/T/#me069145443a17f0b464c13814424dbba0d970863 [1]
> Cc: Kees Cook <kees@kernel.org>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
> Makefile | 9 ++++++++-
> arch/um/Makefile | 3 ++-
> 2 files changed, 10 insertions(+), 2 deletions(-)
>
Looks good to me, thanks!
Reviewed-by: Nicolas Schier <n.schier@avm.de>
Tested-by: Nicolas Schier <n.schier@avm.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-05-06 13:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-03 8:41 [PATCH] kbuild: introduce include/generated/global-rebuild.h Masahiro Yamada
2025-05-06 10:52 ` Nicolas Schier
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).