kbuild: use prefix-map for host and user progs

Host and user progs may also use __FILE__.

Make sure it shows up canonicalized, as in regular kernel code.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Nicolas Schier <n.schier@fritz.com>
Tested-by: Nicolas Schier <n.schier@fritz.com>
Link: https://patch.msgid.link/20260819-kbuild-prefix-map-v1-1-f5168b96fac0@linutronix.de
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
This commit is contained in:
Thomas Weißschuh 2026-08-19 09:53:38 +02:00 committed by Nathan Chancellor
parent ba0e6a6f0f
commit 7c1bcd3f12
No known key found for this signature in database
GPG Key ID: 1D6B269171C01A96

View File

@ -1199,7 +1199,10 @@ export CFLAGS_GCOV
# change __FILE__ to the relative path to the source directory
ifdef building_out_of_srctree
KBUILD_CPPFLAGS += -fmacro-prefix-map=$(srcroot)/=
CFLAGS_PREFIX_MAP := -fmacro-prefix-map=$(srcroot)/=
KBUILD_CPPFLAGS += $(CFLAGS_PREFIX_MAP)
KBUILD_USERCFLAGS += $(CFLAGS_PREFIX_MAP)
KBUILD_HOSTCFLAGS += $(CFLAGS_PREFIX_MAP)
ifeq ($(call rustc-option-yn, --remap-path-scope=macro),y)
KBUILD_RUSTFLAGS += --remap-path-prefix=$(srcroot)/= --remap-path-scope=macro
endif