Re: We need to do something about build times

From: Tatsuki Makino <tatsuki_makino_at_hotmail.com>
Date: Wed, 01 Nov 2023 04:49:11 UTC
Sorry, I think this is getting too far off topic by now.
But there is something that bothered me when using this.

Tatsuki Makino wrote on 2023/10/31 18:20:
> .if 1
> STAGEDIRPREFIX=	${LOCALBASE}/.stage
> STAGEDIR=	${STAGEDIRPREFIX}${.CURDIR}/${_WRKDIR}/stage
> _PORTS_DIRECTORIES+=	${STAGEDIRPREFIX}
> _USES_fetch+=	980:..stagedirprefix
> ${STAGEDIRPREFIX}/😈: .NOTMAIN .PHONY ${STAGEDIRPREFIX}
> 	@${CHMOD} -R 1777 ${STAGEDIRPREFIX}
> 	@${TOUCH} ${TOUCH_FLAGS} ${.TARGET:Q}
> ..stagedirprefix: .NOTMAIN .PHONY ${STAGEDIRPREFIX}/😈
> .endif

This changes the value of STAGEDIR, but STAGEDIR does not take into consider that outside of WRKDIR is given.
Specifically, STAGEDIR is explicitly removed only when restage target is run, but that is all.
If anything outside of WRKDIR is used, it will not be removed by running the clean target.
The following workarounds are also needed.

do-clean-stagedir: .NOTMAIN .PHONY
	@if [ -d ${STAGEDIR} -a -w ${STAGEDIR} ] ; then ${RM} -r ${STAGEDIR} ; fi
do-clean: .NOTMAIN do-clean-stagedir

However, in poudriere, this has a negligible impact.
USE_TMPFS="localbase" umounts already mounted tmpfs just before mounting localbase tmpfs.
This only keeps the memory in use until the builder is finished using it again, and does not cause memory leaks due to file hoarding.

One more thing.
The files detected by the following command uses the _USES_${target} variable by assignment rather than appending.

grep -n -r -e "_USES_[a-z"\$"].*=" /usr/ports/Mk/Uses/ | grep -v -e "[?+]="

If these are used in USES, there may be unexplained malfunctions, or workarounds may have been taken in anticipation of malfunctions.

Regards.