From owner-svn-src-head@freebsd.org Tue Oct 23 06:31:29 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DB9BA1039331; Tue, 23 Oct 2018 06:31:28 +0000 (UTC) (envelope-from arichardson@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 940768C358; Tue, 23 Oct 2018 06:31:27 +0000 (UTC) (envelope-from arichardson@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A3285429C; Tue, 23 Oct 2018 06:31:26 +0000 (UTC) (envelope-from arichardson@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w9N6VQi2008556; Tue, 23 Oct 2018 06:31:26 GMT (envelope-from arichardson@FreeBSD.org) Received: (from arichardson@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w9N6VPR4008554; Tue, 23 Oct 2018 06:31:25 GMT (envelope-from arichardson@FreeBSD.org) Message-Id: <201810230631.w9N6VPR4008554@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arichardson set sender to arichardson@FreeBSD.org using -f From: Alex Richardson Date: Tue, 23 Oct 2018 06:31:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r339636 - in head: . share/mk X-SVN-Group: head X-SVN-Commit-Author: arichardson X-SVN-Commit-Paths: in head: . share/mk X-SVN-Commit-Revision: 339636 X-SVN-Commit-Repository: base 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.29 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: Tue, 23 Oct 2018 06:31:29 -0000 Author: arichardson Date: Tue Oct 23 06:31:25 2018 New Revision: 339636 URL: https://svnweb.freebsd.org/changeset/base/339636 Log: Only compute the X_COMPILER_*/X_LINKER_* variables when needed When building CheriBSD we have to set XLD/XCC/XCFLAGS on the command line. This triggers the $XCC != $CC case in bsd.compiler.mk (and the same for LD in bsd.linker.mk) which causes it to call ${XCC} --version and ${XLD} --version (plus various awk+sed+echo calls) in every subdirectory. For incremental builds and stages that only walk the source tree this is often the majority of the time spent in that directory. By only computing the value of the X_COMPILER_*/X_LINKER_* variables if _WANT_TOOLCHAIN_CROSS_VARS is set we can reduce the number of cc/ld calls to once per build stage instead of once per recursive make. With this change (and no changes to the sources) the `make includes` stage now takes 28 seconds at -j1 instead of 86 seconds. Approved By: brooks (mentor) Differential Revision: https://reviews.freebsd.org/D17046 Modified: head/Makefile.inc1 head/share/mk/bsd.compiler.mk head/share/mk/bsd.linker.mk Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Tue Oct 23 06:31:19 2018 (r339635) +++ head/Makefile.inc1 Tue Oct 23 06:31:25 2018 (r339636) @@ -103,8 +103,11 @@ MK_GCC_BOOTSTRAP= no # here since we will always have the right make, unlike in src/Makefile # Don't include bsd.linker.mk yet until XBINUTILS is handled (after src.opts.mk) _NO_INCLUDE_LINKERMK= t +# We also want the X_COMPILER* variables if we are using an external toolchain. +_WANT_TOOLCHAIN_CROSS_VARS= t .include "share/mk/bsd.compiler.mk" .undef _NO_INCLUDE_LINKERMK +.undef _WANT_TOOLCHAIN_CROSS_VARS # src.opts.mk depends on COMPILER_FEATURES .include "share/mk/src.opts.mk" @@ -205,7 +208,10 @@ X${BINUTIL}?= ${${BINUTIL}} MK_LLD_BOOTSTRAP= no .endif +# We also want the X_LINKER* variables if we are using an external toolchain. +_WANT_TOOLCHAIN_CROSS_VARS= t .include "share/mk/bsd.linker.mk" +.undef _WANT_TOOLCHAIN_CROSS_VARS # Begin WITH_SYSTEM_COMPILER / WITH_SYSTEM_LD Modified: head/share/mk/bsd.compiler.mk ============================================================================== --- head/share/mk/bsd.compiler.mk Tue Oct 23 06:31:19 2018 (r339635) +++ head/share/mk/bsd.compiler.mk Tue Oct 23 06:31:25 2018 (r339636) @@ -116,7 +116,16 @@ ccache-print-options: .PHONY .endif # exists(${CCACHE_BIN}) .endif # ${MK_CCACHE_BUILD} == "yes" -.for cc X_ in CC $${_empty_var_} XCC X_ +_cc_vars=CC $${_empty_var_} +.if !empty(_WANT_TOOLCHAIN_CROSS_VARS) +# Only the toplevel makefile needs to compute the X_COMPILER_* variables. +# Skipping the computation of the unused X_COMPILER_* in the subdirectory +# makefiles can save a noticeable amount of time when walking the whole source +# tree (e.g. during make includes, etc.). +_cc_vars+=XCC X_ +.endif + +.for cc X_ in ${_cc_vars} .if ${cc} == "CC" || !empty(XCC) # Try to import COMPILER_TYPE and COMPILER_VERSION from parent make. # The value is only used/exported for the same environment that impacts Modified: head/share/mk/bsd.linker.mk ============================================================================== --- head/share/mk/bsd.linker.mk Tue Oct 23 06:31:19 2018 (r339635) +++ head/share/mk/bsd.linker.mk Tue Oct 23 06:31:25 2018 (r339636) @@ -26,7 +26,13 @@ .if !target(____) ____: -.for ld X_ in LD $${_empty_var_} XLD X_ +_ld_vars=LD $${_empty_var_} +.if !empty(_WANT_TOOLCHAIN_CROSS_VARS) +# Only the toplevel makefile needs to compute the X_LINKER_* variables. +_ld_vars+=XLD X_ +.endif + +.for ld X_ in ${_ld_vars} .if ${ld} == "LD" || !empty(XLD) # Try to import LINKER_TYPE and LINKER_VERSION from parent make. # The value is only used/exported for the same environment that impacts