Skip to content

Commit cacd22c

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 <ben@decadent.org.uk> Link: https://lore.kernel.org/lkml/c49cc967294f9a3a4a34f69b6a8727a6d3959ed8.camel@decadent.org.uk/ Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent 97282e6 commit cacd22c

File tree

2 files changed

+1
-18
lines changed

2 files changed

+1
-18
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

0 commit comments

Comments
 (0)