Re: [PATCH] kbuild: use prefix-map for host and user progs

Nicolas Schier <[email protected]>
Newsgroups org.kernel.vger.linux-kbuild,org.kernel.vger.linux-kernel
Organization FRITZ! Technology GmbH
Message-ID <20260819-super-seriema-of-attraction-4c0a0d@l-nschier-aarch64>
On Wed, Aug 19, 2026 at 09:53:38AM +0200, Thomas Weißschuh wrote:
> 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 <[email protected]>
> ---
>  Makefile | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 130926fa592e..322b5ce9f218 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1188,7 +1188,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
> 
> ---

Thanks!

Reviewed-by: Nicolas Schier <[email protected]>
Tested-by: Nicolas Schier <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.