Date: Tue, 30 Sep 2025 21:14:41 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: 18a65998107a - stable/14 - sys/conf: Remap paths for reproducibility Message-ID: <202509302114.58ULEfX0010392@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=18a65998107a01972ee74576897b36c51a1e6564 commit 18a65998107a01972ee74576897b36c51a1e6564 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2025-08-21 14:04:14 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2025-09-30 21:14:29 +0000 sys/conf: Remap paths for reproducibility As in bsd.lib.mk and bsd.prog.mk, we need to remap paths in the kernel and in kernel modules when reproducible builds are configured. Add directives to kern.post.mk and kmod.mk to remap the src, obj and sysroot dirs. For the sysroot, we need to pass the value of the SYSROOT variable to the kernel makefiles, which involves changing Makefile.inc1. In so doing I reverted a portion of commit 35fb812adfc21; I can't see any harm in passing the SYSROOT variable down. MFC after: 1 month Sponsored by: The FreeBSD Foundation Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D50953 (cherry picked from commit eebadc7d8590ff8d38fdbcfd90651c931e713648) --- Makefile.inc1 | 2 +- sys/conf/kern.post.mk | 17 +++++++++++++++-- sys/conf/kmod.mk | 23 +++++++++++++++++++++-- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index 84fe2a2eceaf..e3a451b72b10 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -1022,7 +1022,7 @@ DESTDIR_MTREE= ${DISTR_MTREECMD} ${DESTDIR_MTREEFLAGS} METALOG_SORT_CMD= env -i LC_COLLATE=C sort # kernel stage -KMAKEENV= ${WMAKEENV:NSYSROOT=*} +KMAKEENV= ${WMAKEENV} KMAKE= ${TIME_ENV} ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME} # diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk index 320410a337c9..c4e1c9edb65d 100644 --- a/sys/conf/kern.post.mk +++ b/sys/conf/kern.post.mk @@ -365,6 +365,19 @@ _ILINKS+= x86 _ILINKS+= i386 .endif +.if ${MK_REPRODUCIBLE_BUILD} != "no" +PREFIX_SYSDIR=/usr/src/sys +PREFIX_OBJDIR=/usr/obj/usr/src/${MACHINE}.${MACHINE_CPUARCH}/sys/${KERN_IDENT} +CFLAGS+= -ffile-prefix-map=${SYSDIR}=${PREFIX_SYSDIR} +CFLAGS+= -ffile-prefix-map=${.OBJDIR}=${PREFIX_OBJDIR} +.if defined(SYSROOT) +CFLAGS+= -ffile-prefix-map=${SYSROOT}=/sysroot +.endif +.else +PREFIX_SYSDIR=${SYSDIR} +PREFIX_OBJDIR=${.OBJDIR} +.endif + # Ensure that the link exists without depending on it when it exists. # Ensure that debug info references the path in the source tree. .for _link in ${_ILINKS} @@ -372,9 +385,9 @@ _ILINKS+= i386 ${SRCS} ${DEPENDOBJS}: ${_link} .endif .if ${_link} == "machine" -CFLAGS+= -fdebug-prefix-map=./machine=${SYSDIR}/${MACHINE}/include +CFLAGS+= -fdebug-prefix-map=./machine=${PREFIX_SYSDIR}/${MACHINE}/include .else -CFLAGS+= -fdebug-prefix-map=./${_link}=${SYSDIR}/${_link}/include +CFLAGS+= -fdebug-prefix-map=./${_link}=${PREFIX_SYSDIR}/${_link}/include .endif .endfor diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index 9310f1572b41..806007763de2 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -303,6 +303,25 @@ all: ${PROG} beforedepend: ${_ILINKS} beforebuild: ${_ILINKS} +.if ${MK_REPRODUCIBLE_BUILD} != "no" +PREFIX_SYSDIR=/usr/src/sys +CFLAGS+= -ffile-prefix-map=${SYSDIR}=${PREFIX_SYSDIR} +.if defined(KERNBUILDDIR) +PREFIX_KERNBUILDDIR=/usr/obj/usr/src/${MACHINE}.${MACHINE_CPUARCH}/sys/${KERNBUILDDIR:T} +PREFIX_OBJDIR=${PREFIX_KERNBUILDDIR}/modules/usr/src/sys/modules/${.OBJDIR:T} +CFLAGS+= -ffile-prefix-map=${KERNBUILDDIR}=${PREFIX_KERNBUILDDIR} +.else +PREFIX_OBJDIR=/usr/obj/usr/src/${MACHINE}.${MACHINE_CPUARCH}/sys/modules/${.OBJDIR:T} +.endif +CFLAGS+= -ffile-prefix-map=${.OBJDIR}=${PREFIX_OBJDIR} +.if defined(SYSROOT) +CFLAGS+= -ffile-prefix-map=${SYSROOT}=/sysroot +.endif +.else +PREFIX_SYSDIR=${SYSDIR} +PREFIX_OBJDIR=${.OBJDIR} +.endif + # Ensure that the links exist without depending on it when it exists which # causes all the modules to be rebuilt when the directory pointed to changes. # Ensure that debug info references the path in the source tree. @@ -311,9 +330,9 @@ beforebuild: ${_ILINKS} OBJS_DEPEND_GUESS+= ${_link} .endif .if ${_link} == "machine" -CFLAGS+= -fdebug-prefix-map=./machine=${SYSDIR}/${MACHINE}/include +CFLAGS+= -fdebug-prefix-map=./machine=${PREFIX_SYSDIR}/${MACHINE}/include .else -CFLAGS+= -fdebug-prefix-map=./${_link}=${SYSDIR}/${_link}/include +CFLAGS+= -fdebug-prefix-map=./${_link}=${PREFIX_SYSDIR}/${_link}/include .endif .endfor
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202509302114.58ULEfX0010392>