Re: [PATCH v2] kbuild: make all file references relative to source root
From: Ben Hutchings
Date: Sun Mar 16 2025 - 15:09:30 EST
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.
Also, in some older versions of gcc the -ffile-prefix-map option didn't
affect assembly sources - gas only understands --debug-prefix-map and
gcc did not do the necessary conversion. But this works properly since
at least gcc 12, so I wouldn't worry too much about it.
Ben.
--
Ben Hutchings
Lowery's Law:
If it jams, force it. If it breaks, it needed replacing anyway.
Attachment:
signature.asc
Description: This is a digitally signed message part