Rework the world subdir build targets to use the standard SUBDIR_PARALLEL mechanism.

Back in r30113, the 'par-*' targets were added to parallelize portions of
the build in a very similar fashion as the SUBDIR_PARALLEL feature used in
r263778.  Calling a target without 'par-' (for 'parallel') resulted in the
standard bsd.subdir.mk handling without parallelization.  Given we have
SUBDIR_PARALLEL now there is no reason to duplicate the handling here.

In build logs this will result in the ${dir}.${target}__D targets now showing
as the normal ${target}_subdir_${dir} targets.

I audited all of the uses of Makefile.inc1 and Makefile's targets that use
bsd.subdir.mk and found that all but 'all' and 'install' were fine to use
as always parallel.
  - For 'install' (from installworld -j) the ordering of lib/ and libexec/
    before the rest of the system (described in r289433), and etc/ being last
    (described in r289435), is all that matters.  So now a .WAIT is added in
    the proper places when invoking any 'install*' target.  A parallel
    installworld does work and took 46% of the time a non-parallel
    install would take on my system with -j15 to ZFS.
  - For 'all' I left the default handling for this to not run in parallel.  A
    'par-all' target is still used by the 'everything' stage of buildworld
    to continue building in parallel as it already has been.  This works
    because most of the dependencies are handled by the early bootstrap
    phases as well as 'libraries' and 'includes' phases.  This lets
    all of the SUBDIR build in parallel fine, such as bin/ and lib/.  This
    will not work if the user invokes 'all' though as we have dependencies
    spread all over the system with no way to depend between them (except
    for the dirdeps feature in the META_MODE build).  Calling 'make all'
    from the top-level is still useful at least when using SUBDIR_OVERRIDE.

MFC after:	2 weeks
Sponsored by:	EMC / Isilon Storage Division
This commit is contained in:
Bryan Drewery 2015-10-17 03:51:50 +00:00
parent 23ffbc1011
commit fb84a99e0f

View File

@ -63,6 +63,10 @@ SRCDIR?= ${.CURDIR}
SUBDIR= ${SUBDIR_OVERRIDE} SUBDIR= ${SUBDIR_OVERRIDE}
.else .else
SUBDIR= lib libexec SUBDIR= lib libexec
.if make(install*)
# Ensure libraries are installed before progressing.
SUBDIR+=.WAIT
.endif
SUBDIR+=bin SUBDIR+=bin
.if ${MK_CDDL} != "no" .if ${MK_CDDL} != "no"
SUBDIR+=cddl SUBDIR+=cddl
@ -115,6 +119,9 @@ SUBDIR+= ${_DIR}
# by calling 'makedb' in share/man. This is only relevant for # by calling 'makedb' in share/man. This is only relevant for
# install/distribute so they build the whatis file after every manpage is # install/distribute so they build the whatis file after every manpage is
# installed. # installed.
.if make(install*)
SUBDIR+=.WAIT
.endif
SUBDIR+=etc SUBDIR+=etc
.if defined(NOCLEAN) .if defined(NOCLEAN)
@ -589,9 +596,9 @@ _cleanobj:
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
@echo ">>> stage 2.1: cleaning up the object tree" @echo ">>> stage 2.1: cleaning up the object tree"
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/} ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
.if defined(LIB32TMP) .if defined(LIB32TMP)
${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/} ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR}
.endif .endif
.endif .endif
_obj: _obj:
@ -599,7 +606,7 @@ _obj:
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
@echo ">>> stage 2.2: rebuilding the object tree" @echo ">>> stage 2.2: rebuilding the object tree"
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
${_+_}cd ${.CURDIR}; ${WMAKE} par-obj ${_+_}cd ${.CURDIR}; ${WMAKE} obj
_build-tools: _build-tools:
@echo @echo
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
@ -618,7 +625,7 @@ _includes:
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
@echo ">>> stage 4.1: building includes" @echo ">>> stage 4.1: building includes"
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks includes
_libraries: _libraries:
@echo @echo
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
@ -632,7 +639,7 @@ _depend:
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
@echo ">>> stage 4.3: make dependencies" @echo ">>> stage 4.3: make dependencies"
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
${_+_}cd ${.CURDIR}; ${WMAKE} par-depend ${_+_}cd ${.CURDIR}; ${WMAKE} depend
everything: everything:
@echo @echo
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
@ -1944,22 +1951,18 @@ _startup_libs: ${_startup_libs:S/$/__L/}
_prebuild_libs: ${_prebuild_libs:S/$/__L/} _prebuild_libs: ${_prebuild_libs:S/$/__L/}
_generic_libs: ${_generic_libs:S/$/__L/} _generic_libs: ${_generic_libs:S/$/__L/}
.for __target in all clean cleandepend cleandir depend includes obj # Enable SUBDIR_PARALLEL when not calling 'make all', unless called as
.for entry in ${SUBDIR} # 'par-all'. This is because it is unlikely that running 'make all' from
${entry}.${__target}__D: .PHONY .MAKE # the top-level, especially with a SUBDIR_OVERRIDE or LOCAL_DIRS set,
${_+_}@set -e; if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \ # will have a reliable build if SUBDIRs are built in parallel. This is
${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \ # safe for the world stage of buildworld though since it has already
edir=${entry}.${MACHINE_ARCH}; \ # built libraries in a proper order and installed includes into WORLDTMP.
cd ${.CURDIR}/$${edir}; \ # Special handling is done for SUBDIR ordering for 'install*' to avoid
else \ # trashing a system if it crashes mid-install.
${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \ par-all: all .PHONY
edir=${entry}; \ .if !make(all)
cd ${.CURDIR}/$${edir}; \ SUBDIR_PARALLEL=
fi; \ .endif
${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
.endfor
par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
.endfor
.include <bsd.subdir.mk> .include <bsd.subdir.mk>
@ -2267,7 +2270,7 @@ _xi-cross-tools:
.endfor .endfor
_xi-includes: _xi-includes:
${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \ ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
DESTDIR=${XDDESTDIR} DESTDIR=${XDDESTDIR}
_xi-libraries: _xi-libraries: