Re: [PATCH v2] kbuild: make all file references relative to source root

From: Nathan Chancellor
Date: Mon Mar 17 2025 - 13:21:47 EST


On Sun, Mar 16, 2025 at 08:08:37PM +0100, Ben Hutchings wrote:
> On Sat, 2025-03-15 at 14:20 +0100, Thomas Weißschuh wrote:
> > -fmacro-prefix-map only affects __FILE__ and __BASE_FILE__.
> > Other references, for example in debug information, are not affected.
> > This makes handling of file references in the compiler outputs harder to
> > use and creates problems for reproducible builds.
> >
> > Switch to -ffile-prefix map which affects all references.
>
> This appears to cover all the C sources, but not quite all the assembly
> sources:
>
> [...]
>
> > --- a/arch/x86/boot/Makefile
> > +++ b/arch/x86/boot/Makefile
> > @@ -54,7 +54,7 @@ targets += cpustr.h
> >
> > KBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP
> > KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
> > -KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
> > +KBUILD_CFLAGS += $(call cc-option,-ffile-prefix-map=$(srctree)/=)
> [...]
>
> I think this addition to KBUILD_CFLAGS needs to be done before the
> assignment to KBUILD_AFLAGS.

This probably belongs in KBUILD_CPPFLAGS then, similar to clang's
'--target' flag and other options that we always want invoked?

Cheers,
Nathan