From: Masahiro Yamada Date: Sun, 10 Nov 2024 01:34:36 +0000 (+0900) Subject: kbuild: support -fmacro-prefix-map for external modules X-Git-Tag: v6.13-rc1~16^2~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1d3730f0012f;p=thirdparty%2Flinux.git kbuild: support -fmacro-prefix-map for external modules This commit makes -fmacro-prefix-map work for external modules built in a separate output directory. It improves the reproducibility of external modules and provides the benefits described in commit a73619a845d5 ("kbuild: use -fmacro-prefix-map to make __FILE__ a relative path"). When building_out_of_srctree is not defined (e.g., when the kernel or external module is built in the source directory), this option is unnecessary. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- diff --git a/Makefile b/Makefile index 5aba1ac89375d..a4ac0133f7cde 100644 --- a/Makefile +++ b/Makefile @@ -1041,8 +1041,10 @@ ifdef CONFIG_CC_IS_GCC KBUILD_CFLAGS += -fconserve-stack endif -# change __FILE__ to the relative path from the srctree -KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) +# change __FILE__ to the relative path to the source directory +ifdef building_out_of_srctree +KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srcroot)/=) +endif # include additional Makefiles when needed include-y := scripts/Makefile.extrawarn