From owner-svn-src-head@freebsd.org Wed Dec 2 01:50:24 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EA98AA3EF6B; Wed, 2 Dec 2015 01:50:23 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C4A8C1DD1; Wed, 2 Dec 2015 01:50:23 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tB21oM9U076462; Wed, 2 Dec 2015 01:50:22 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tB21oMtW076460; Wed, 2 Dec 2015 01:50:22 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201512020150.tB21oMtW076460@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Wed, 2 Dec 2015 01:50:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r291635 - in head: . share/mk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Dec 2015 01:50:24 -0000 Author: bdrewery Date: Wed Dec 2 01:50:22 2015 New Revision: 291635 URL: https://svnweb.freebsd.org/changeset/base/291635 Log: bsd.subdir.mk: Only recurse on called targets, rather than dependencies. This is to fix 'make all' causing it to recurse on both 'all' and 'buildconfig' due to 'buildconfig' being in ALL_SUBDIR_TARGETS and being a dependency of 'all'. This now adds all of the '*includes', '*files' targets as subdir targets, allowing them to recurse. This also removes the need for some 'realinstall' hacks in bsd.subdir.mk since it no longer recurses; only 'install' will recurse and call the proper 'beforeinstall', 'realinstall', and 'afterinstall' in each sub-directory. This fixes 'make includes' and 'make files' to not be a rerolled ${MAKE} sub-shell but to rather just recurse on 'inclues' and 'files'. This avoids various issues such as the one fixed in r289462. As such revert Makefile.inc1 back to using 'includes' which avoids an extra tree walk and parallelizes the includes phases better. Makefile.inc1 includes a guard so that 'make all' will not use SUBDIR_PARALLEL, added in r289438. This is so users do not get a probably broken build if they run 'make all' from the top-level. Before the change in this commit, the workaround for 'make everything' was 'par-all' which would depend on 'all' and cause a proper parallel recursion. Now that will not work so a new _PARALLEL_SUBUDIR_OK is used to allow it. This is still part of an effort to combine bsd.(files|incs|confs).mk and move some of its logic out of bsd.subdir.mk, as attempted in r289282 and reverted in r289331. This commit fixes the problems found there which was mostly double recursing during 'includes' which would recurse on itself and 'buildincludes' and 'installincludes', all in parallel. The logic is still in bsd.subdir.mk for now. I've been cautious about this commit but have experienced no breakage on the tree except for the 'par-all' case which was already a hack. If something foo is depending on something bar that should recurse, it is very likely that the foo target is being recursed on already meaning that bar will still effectively recurse once sub-directories call foo. Discussed on: arch@ MFC after: never Sponsored by: EMC / Isilon Storage Division Modified: head/Makefile.inc1 head/share/mk/bsd.subdir.mk Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Wed Dec 2 01:49:22 2015 (r291634) +++ head/Makefile.inc1 Wed Dec 2 01:50:22 2015 (r291635) @@ -643,12 +643,9 @@ _includes: # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last. ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \ - buildincludes - ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \ - installincludes + includes .if !empty(SUBDIR_OVERRIDE) && make(buildworld) - ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks buildincludes - ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks installincludes + ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks includes .endif _libraries: @echo @@ -669,7 +666,7 @@ everything: @echo "--------------------------------------------------------------" @echo ">>> stage 4.4: building everything" @echo "--------------------------------------------------------------" - ${_+_}cd ${.CURDIR}; ${WMAKE} par-all + ${_+_}cd ${.CURDIR}; _PARALLEL_SUBUDIR_OK=1 ${WMAKE} all .if defined(LIB32TMP) build32: .PHONY @echo @@ -2010,16 +2007,15 @@ _startup_libs: ${_startup_libs:S/$/__L/} _prebuild_libs: ${_prebuild_libs:S/$/__L/} _generic_libs: ${_generic_libs:S/$/__L/} -# Enable SUBDIR_PARALLEL when not calling 'make all', unless called as -# 'par-all'. This is because it is unlikely that running 'make all' from -# the top-level, especially with a SUBDIR_OVERRIDE or LOCAL_DIRS set, -# will have a reliable build if SUBDIRs are built in parallel. This is -# safe for the world stage of buildworld though since it has already -# built libraries in a proper order and installed includes into WORLDTMP. -# Special handling is done for SUBDIR ordering for 'install*' to avoid -# trashing a system if it crashes mid-install. -par-all: all .PHONY -.if !make(all) +# Enable SUBDIR_PARALLEL when not calling 'make all', unless called from +# 'everything' with _PARALLEL_SUBUDIR_OK set. This is because it is unlikely +# that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE +# or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in +# parallel. This is safe for the world stage of buildworld though since it has +# already built libraries in a proper order and installed includes into +# WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to +# avoid trashing a system if it crashes mid-install. +.if !make(all) || defined(_PARALLEL_SUBUDIR_OK) SUBDIR_PARALLEL= .endif @@ -2359,9 +2355,7 @@ _xi-cross-tools: .PHONY .endfor _xi-includes: .PHONY - ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 buildincludes \ - DESTDIR=${XDDESTDIR} - ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 installincludes \ + ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \ DESTDIR=${XDDESTDIR} _xi-libraries: .PHONY Modified: head/share/mk/bsd.subdir.mk ============================================================================== --- head/share/mk/bsd.subdir.mk Wed Dec 2 01:49:22 2015 (r291634) +++ head/share/mk/bsd.subdir.mk Wed Dec 2 01:50:22 2015 (r291635) @@ -36,10 +36,11 @@ .if !target(____) ____: -ALL_SUBDIR_TARGETS= all all-man buildconfig checkdpadd clean cleandepend \ - cleandir cleanilinks cleanobj depend distribute \ - installconfig lint maninstall manlint obj objlink \ - realinstall regress tags \ +ALL_SUBDIR_TARGETS= all all-man buildconfig buildfiles buildincludes \ + checkdpadd clean cleandepend cleandir cleanilinks \ + cleanobj depend distribute files includes installconfig \ + installfiles installincludes install lint maninstall \ + manlint obj objlink regress tags \ ${SUBDIR_TARGETS} # Described above. @@ -71,6 +72,27 @@ distribute: .MAKE .endfor .endif +# Convenience targets to run 'build${target}' and 'install${target}' when +# calling 'make ${target}'. +.for __target in files includes +.if !target(${__target}) +${__target}: build${__target} install${__target} +.ORDER: build${__target} install${__target} +.endif +.endfor + +# Make 'install' supports a before and after target. Actual install +# hooks are placed in 'realinstall'. +.if !target(install) +.for __stage in before real after +.if !target(${__stage}install) +${__stage}install: +.endif +.endfor +install: beforeinstall realinstall afterinstall +.ORDER: beforeinstall realinstall afterinstall +.endif + # Subdir code shared among 'make ', 'make ' and SUBDIR_PARALLEL. _SUBDIR_SH= \ if test -d ${.CURDIR}/$${dir}.${MACHINE_ARCH}; then \ @@ -82,7 +104,7 @@ _SUBDIR_SH= \ _SUBDIR: .USEBEFORE .if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR) - @${_+_}target=${.TARGET:S,realinstall,install,}; \ + @${_+_}target=${.TARGET}; \ for dir in ${SUBDIR:N.WAIT}; do ( ${_SUBDIR_SH} ); done .endif @@ -101,6 +123,10 @@ SUBDIR:= ${SUBDIR:N.WAIT} .else _is_standalone_target= 0 .endif +# Only recurse on directly-called targets. I.e., don't recurse on dependencies +# such as 'install' becoming {before,real,after}install, just recurse +# 'install'. +.if make(${__target}) .if defined(SUBDIR_PARALLEL) || ${_is_standalone_target} == 1 __subdir_targets= .for __dir in ${SUBDIR} @@ -116,7 +142,7 @@ __deps+= ${__target}_subdir_${__dep} .endif ${__target}_subdir_${__dir}: .PHONY .MAKE ${__deps} .if !defined(NO_SUBDIR) - @${_+_}target=${__target:realinstall=install}; \ + @${_+_}target=${__target}; \ dir=${__dir}; \ ${_SUBDIR_SH}; .endif @@ -126,35 +152,11 @@ ${__target}: ${__subdir_targets} .else ${__target}: _SUBDIR .endif # SUBDIR_PARALLEL || _is_standalone_target +.elif !target(${__target}) +${__target}: +.endif # make(${__target}) .endfor # __target in ${ALL_SUBDIR_TARGETS} -# This is to support 'make includes' calling 'make buildincludes' and -# 'make installincludes' in the proper order, and to support these -# targets as SUBDIR_TARGETS. -.for __target in files includes -.for __stage in build install -${__stage}${__target}: -.if make(${__stage}${__target}) -${__stage}${__target}: _SUBDIR -.endif -.endfor -.if !target(${__target}) -${__target}: .MAKE - ${_+_}cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target} -.endif -.endfor - -.endif - -.if !target(install) -.if !target(beforeinstall) -beforeinstall: -.endif -.if !target(afterinstall) -afterinstall: -.endif -install: beforeinstall realinstall afterinstall -.ORDER: beforeinstall realinstall afterinstall -.endif +.endif # !target(_SUBDIR) .endif