Skip to content

Commit 1d3730f

Browse files
committed
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 a73619a ("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 <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
1 parent 11b3d51 commit 1d3730f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -1041,8 +1041,10 @@ ifdef CONFIG_CC_IS_GCC
10411041
KBUILD_CFLAGS += -fconserve-stack
10421042
endif
10431043

1044-
# change __FILE__ to the relative path from the srctree
1045-
KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
1044+
# change __FILE__ to the relative path to the source directory
1045+
ifdef building_out_of_srctree
1046+
KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srcroot)/=)
1047+
endif
10461048

10471049
# include additional Makefiles when needed
10481050
include-y := scripts/Makefile.extrawarn

0 commit comments

Comments
 (0)