Index: Makefile.inc1 =================================================================== --- Makefile.inc1 +++ Makefile.inc1 @@ -784,6 +784,7 @@ WMAKEENV= ${CROSSENV} \ INSTALL="${INSTALL_CMD} -U" \ PATH=${TMPPATH} \ + WORLD_SYSROOT=${WORLDTMP} \ SYSROOT=${WORLDTMP} # make hierarchy Index: Makefile.libcompat =================================================================== --- Makefile.libcompat +++ Makefile.libcompat @@ -12,6 +12,7 @@ LIBCOMPATWMAKEENV+= \ INSTALL="${INSTALL_CMD} -U" \ PATH=${TMPPATH} \ + WORLD_SYSROOT=${WORLDTMP} \ SYSROOT=${LIBCOMPATTMP} \ LIBDIR=/usr/lib${libcompat} \ SHLIBDIR=/usr/lib${libcompat} \ Index: share/mk/bsd.compat.mk =================================================================== --- share/mk/bsd.compat.mk +++ share/mk/bsd.compat.mk @@ -142,6 +142,8 @@ .endfor # Shared flags +_libcompat_machine:= ${MACHINE}.${MACHINE_ARCH} +LIBCOMPAT_REPRODUCIBLE_OBJTOP?= ${REPRODUCIBLE_OBJROOT}${_libcompat_machine}/obj-lib${libcompat} LIBCOMPAT_OBJTOP?= ${OBJTOP}/obj-lib${libcompat} LIBCOMPATTMP?= ${LIBCOMPAT_OBJTOP}/tmp @@ -153,6 +155,7 @@ LIBCOMPATWMAKEENV+= MACHINE=${LIBCOMPAT_MACHINE} LIBCOMPATWMAKEENV+= MACHINE_ARCH=${LIBCOMPAT_MACHINE_ARCH} +LIBCOMPATWMAKEENV+= REPRODUCIBLE_OBJTOP=${LIBCOMPAT_REPRODUCIBLE_OBJTOP} # -B is needed to find /usr/lib32/crti.o for GCC and /usr/libsoft/crti.o for # Clang/GCC. @@ -166,6 +169,7 @@ LDFLAGS+= ${CFLAGS} ${LIBCOMPATLDFLAGS} MACHINE= ${LIBCOMPAT_MACHINE} MACHINE_ARCH= ${LIBCOMPAT_MACHINE_ARCH} +REPRODUCIBLE_OBJTOP= ${REPRODUCIBLE_OBJROOT}${_libcompat_machine} .endif .endif Index: share/mk/bsd.own.mk =================================================================== --- share/mk/bsd.own.mk +++ share/mk/bsd.own.mk @@ -283,6 +283,14 @@ # overridden by Makefiles, but the user may choose to set this in src.conf(5). TESTSBASE?= /usr/tests +# Canonical source and object directories, used to fake src roots in reproducible +# builds +REPRODUCIBLE_SRCTOP?= /usr/src +REPRODUCIBLE_SYSDIR?= ${REPRODUCIBLE_SRCTOP}/sys +REPRODUCIBLE_OBJDIRPREFIX?= /usr/obj +REPRODUCIBLE_OBJROOT?= ${REPRODUCIBLE_OBJDIRPREFIX}${REPRODUCIBLE_SRCTOP}/ +REPRODUCIBLE_OBJTOP?= ${REPRODUCIBLE_OBJROOT}${MACHINE}.${MACHINE_ARCH} + DEPENDFILE?= .depend # Compat for the moment -- old bsd.own.mk only included this when _WITHOUT_SRCCONF Index: share/mk/bsd.sys.mk =================================================================== --- share/mk/bsd.sys.mk +++ share/mk/bsd.sys.mk @@ -247,6 +247,31 @@ CFLAGS+= ${SSP_CFLAGS} .endif # SSP && !ARM && !MIPS +.if ${COMPILER_FEATURES:Mfileprefixmap} +CFLAGS+= -ffile-prefix-map=${OBJTOP}/tmp/=/ +.if !empty(SYSROOT:N${OBJTOP}/tmp) +CFLAGS+= -ffile-prefix-map=${SYSROOT}/=/ +.endif +.if !empty(WORLD_SYSROOT:N${OBJTOP}/tmp:N${SYSROOT}) +CFLAGS+= -ffile-prefix-map=${WORLD_SYSROOT}/=/ +.endif +.if !empty(LIBCOMPATTMP:N${OBJTOP}/tmp) +CFLAGS+= -ffile-prefix-map=${LIBCOMPATTMP}=/ +.endif +.if ${MK_REPRODUCIBLE_BUILD:Uno} != "no" +.if ${OBJTOP} != ${REPRODUCIBLE_OBJTOP} +CFLAGS+= -ffile-prefix-map=${OBJTOP}=${REPRODUCIBLE_OBJTOP} +.endif +.if ${SRCTOP} != ${REPRODUCIBLE_SRCTOP} +CFLAGS+= -ffile-prefix-map=${SRCTOP}=${REPRODUCIBLE_SRCTOP} +.endif +#.if defined(LIBCOMPAT_OBJTOP) && \ +# ${LIBCOMPAT_OBJTOP} != ${LIBCOMPAT_REPRODUCIBLE_OBJTOP} +#CFLAGS+= -ffile-prefix-map=${LIBCOMPAT_OBJTOP}=${LIBCOMPAT_REPRODUCIBLE_OBJTOP} +#.endif +.endif +.endif + # Additional flags passed in CFLAGS and CXXFLAGS when MK_DEBUG_FILES is # enabled. DEBUG_FILES_CFLAGS?= -g