Skip to content

Commit 19b18a0

Browse files
t-8chmasahir0y
authored andcommitted
kbuild: make all file references relative to source root
-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. Also drop the documentation section advising manual specification of -fdebug-prefix-map for reproducible builds, as it is not necessary anymore. Suggested-by: Ben Hutchings <[email protected]> Link: https://lore.kernel.org/lkml/[email protected]/ Acked-by: Borislav Petkov (AMD) <[email protected]> # arch/x86/ Signed-off-by: Thomas Weißschuh <[email protected]> Acked-by: Ingo Molnar <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 691c37e commit 19b18a0

File tree

4 files changed

+3
-20
lines changed

4 files changed

+3
-20
lines changed

Documentation/kbuild/reproducible-builds.rst

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,6 @@ The kernel embeds the building user and host names in
4646
`KBUILD_BUILD_USER and KBUILD_BUILD_HOST`_ variables. If you are
4747
building from a git commit, you could use its committer address.
4848

49-
Absolute filenames
50-
------------------
51-
52-
When the kernel is built out-of-tree, debug information may include
53-
absolute filenames for the source files. This must be overridden by
54-
including the ``-fdebug-prefix-map`` option in the `KCFLAGS`_ variable.
55-
56-
Depending on the compiler used, the ``__FILE__`` macro may also expand
57-
to an absolute filename in an out-of-tree build. Kbuild automatically
58-
uses the ``-fmacro-prefix-map`` option to prevent this, if it is
59-
supported.
60-
61-
The Reproducible Builds web site has more information about these
62-
`prefix-map options`_.
63-
6449
Generated files in source packages
6550
----------------------------------
6651

@@ -131,7 +116,5 @@ See ``scripts/setlocalversion`` for details.
131116

132117
.. _KBUILD_BUILD_TIMESTAMP: kbuild.html#kbuild-build-timestamp
133118
.. _KBUILD_BUILD_USER and KBUILD_BUILD_HOST: kbuild.html#kbuild-build-user-kbuild-build-host
134-
.. _KCFLAGS: kbuild.html#kcflags
135-
.. _prefix-map options: https://reproducible-builds.org/docs/build-path/
136119
.. _Reproducible Builds project: https://reproducible-builds.org/
137120
.. _SOURCE_DATE_EPOCH: https://reproducible-builds.org/docs/source-date-epoch/

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ endif
10671067

10681068
# change __FILE__ to the relative path to the source directory
10691069
ifdef building_out_of_srctree
1070-
KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srcroot)/=)
1070+
KBUILD_CPPFLAGS += $(call cc-option,-ffile-prefix-map=$(srcroot)/=)
10711071
KBUILD_RUSTFLAGS += --remap-path-prefix=$(srcroot)/=
10721072
endif
10731073

arch/x86/boot/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ targets += cpustr.h
5454

5555
KBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP
5656
KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
57-
KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
57+
KBUILD_CFLAGS += $(call cc-option,-ffile-prefix-map=$(srctree)/=)
5858
KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
5959
KBUILD_CFLAGS += $(CONFIG_CC_IMPLICIT_FALLTHROUGH)
6060

arch/x86/boot/compressed/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ KBUILD_CFLAGS += -fno-stack-protector
3838
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
3939
KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
4040
KBUILD_CFLAGS += -Wno-pointer-sign
41-
KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
41+
KBUILD_CFLAGS += $(call cc-option,-ffile-prefix-map=$(srctree)/=)
4242
KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
4343
KBUILD_CFLAGS += -D__DISABLE_EXPORTS
4444
# Disable relocation relaxation in case the link is not PIE.

0 commit comments

Comments
 (0)