Date: Tue, 30 Sep 2025 21:14:40 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: c89e5c0bfca6 - stable/14 - share/mk: Substitute reproducible prefixes in dwarf info Message-ID: <202509302114.58ULEeVw010358@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c89e5c0bfca639f39735572ee518e11f30ed8b20 commit c89e5c0bfca639f39735572ee518e11f30ed8b20 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2025-08-21 14:06:34 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2025-09-30 21:14:29 +0000 share/mk: Substitute reproducible prefixes in dwarf info Ensure that worlds/releases built from different source paths are reproducible. Currently they are not since src and obj paths are embedded in DWARF info. There are some uses of __FILE__ in the src tree as well, and they are similarly handled by this change. Use /usr/src and /usr/obj as the canonical src and obj paths when WITH_REPRODUCIBLE_BUILD is defined. Define a DEBUG_PREFIX variable which is used to ask the compiler to substitute paths in output files using -ffile-prefix-map. Compat builds (i.e., lib32) complicate things since they override OBJROOT to point to obj-${compat} but still refer to headers from the native objroot (e.g., llvm headers). MFC after: 1 month Sponsored by: The FreeBSD Foundation Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D50951 (cherry picked from commit 4f81c42fbd76e25c9fe696fa08296b79c55fbf09) --- share/mk/bsd.debug.mk | 22 ++++++++++++++++++++++ share/mk/bsd.opts.mk | 1 + 2 files changed, 23 insertions(+) diff --git a/share/mk/bsd.debug.mk b/share/mk/bsd.debug.mk index fc80bc103061..cf2fb4356aef 100644 --- a/share/mk/bsd.debug.mk +++ b/share/mk/bsd.debug.mk @@ -13,6 +13,28 @@ CFLAGS+= -DNDEBUG MK_WERROR= no .endif +# If reproducible build mode is enabled, map the root of the source +# directory to /usr/src and the root of the object directory to +# /usr/obj. +.if ${MK_REPRODUCIBLE_BUILD} != "no" && !defined(DEBUG_PREFIX) +.if defined(SRCTOP) +DEBUG_PREFIX+= ${SRCTOP:S,/$,,}=/usr/src +.endif +.if defined(OBJROOT) +# Strip off compat subdirectories, e.g., /usr/obj/usr/src/amd64.amd64/obj-lib32 +# becomes /usr/obj/usr/src/amd64.amd64, since object files compiled there might +# refer to something outside the root. +DEBUG_PREFIX+= ${OBJROOT:S,/$,,:C,/obj-[^/]*$,,}=/usr/obj +.endif +.endif + +.if defined(DEBUG_PREFIX) +.for map in ${DEBUG_PREFIX} +CFLAGS+= -ffile-prefix-map=${map} +CXXFLAGS+= -ffile-prefix-map=${map} +.endfor +.endif + .if defined(DEBUG_FLAGS) CFLAGS+=${DEBUG_FLAGS} CXXFLAGS+=${DEBUG_FLAGS} diff --git a/share/mk/bsd.opts.mk b/share/mk/bsd.opts.mk index b4761333d8c5..b56afb89a44d 100644 --- a/share/mk/bsd.opts.mk +++ b/share/mk/bsd.opts.mk @@ -80,6 +80,7 @@ __DEFAULT_NO_OPTIONS = \ INIT_ALL_ZERO \ INSTALL_AS_USER \ PROFILE \ + REPRODUCIBLE_BUILD \ RETPOLINE \ STALE_STAGED \ UBSAN
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202509302114.58ULEeVw010358>