Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Thomas Weißschuh and committed by
Masahiro Yamada
cacd22ce 97282e6d

+1 -18
-17
Documentation/kbuild/reproducible-builds.rst
··· 46 46 `KBUILD_BUILD_USER and KBUILD_BUILD_HOST`_ variables. If you are 47 47 building from a git commit, you could use its committer address. 48 48 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 - 64 49 Generated files in source packages 65 50 ---------------------------------- 66 51 ··· 116 131 117 132 .. _KBUILD_BUILD_TIMESTAMP: kbuild.html#kbuild-build-timestamp 118 133 .. _KBUILD_BUILD_USER and KBUILD_BUILD_HOST: kbuild.html#kbuild-build-user-kbuild-build-host 119 - .. _KCFLAGS: kbuild.html#kcflags 120 - .. _prefix-map options: https://reproducible-builds.org/docs/build-path/ 121 134 .. _Reproducible Builds project: https://reproducible-builds.org/ 122 135 .. _SOURCE_DATE_EPOCH: https://reproducible-builds.org/docs/source-date-epoch/
+1 -1
Makefile
··· 1067 1067 1068 1068 # change __FILE__ to the relative path to the source directory 1069 1069 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)/=) 1071 1071 KBUILD_RUSTFLAGS += --remap-path-prefix=$(srcroot)/= 1072 1072 endif 1073 1073