From 750174c0cee95925dd322f37c211577d0ebc0dc4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thibaut=20VAR=C3=88NE?= Date: Thu, 21 Jun 2018 21:14:14 +0200 Subject: [PATCH] phase1: opportunistic use of ccache MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Assuming that CONFIG_CCACHE is disabled in the target config.seed, this patch tries to enable the use of ccache (if available from the host) for the 'dltar' and 'tools' steps, which are the only two steps where the build objects are shared by /all/ workers, and thus the two steps where caching makes the most sense and should provide the most benefits. Signed-off-by: Thibaut VARÈNE --- phase1/master.cfg | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/phase1/master.cfg b/phase1/master.cfg index 80955b5..b0e6422 100644 --- a/phase1/master.cfg +++ b/phase1/master.cfg @@ -203,6 +203,7 @@ from buildbot.process.factory import BuildFactory from buildbot.steps.source.git import Git from buildbot.steps.shell import ShellCommand from buildbot.steps.shell import SetProperty +from buildbot.steps.shell import SetPropertyFromCommand from buildbot.steps.transfer import FileUpload from buildbot.steps.transfer import FileDownload from buildbot.steps.master import MasterShellCommand @@ -299,17 +300,29 @@ def GetCwd(props): else: return "/" +def GetCCache(props): + if props.hasProperty("ccache_command") and "ccache" in props["ccache_command"]: + return props["ccache_command"] + " " + else: + return "" + def GetNextBuild(builder, requests): for r in requests: if r.properties and r.properties.hasProperty("tag"): return r return requests[0] -def MakeEnv(overrides=None): +def MakeEnv(overrides=None, tryccache=False): + if tryccache: + envcc = Interpolate("%(kw:ccache)s%(kw:cc)s", ccache=GetCCache, cc=GetCC) + envcxx = Interpolate("%(kw:ccache)s%(kw:cxx)s", ccache=GetCCache, cxx=GetCXX) + else: + envcc = Interpolate("%(kw:cc)s", cc=GetCC) + envcxx = Interpolate("%(kw:cxx)s", cxx=GetCXX) env = { - 'CC': WithProperties("%(cc)s", cc=GetCC), - 'CXX': WithProperties("%(cxx)s", cxx=GetCXX), - 'CCACHE_BASEDIR': WithProperties("%(cwd)s", cwd=GetCwd) + 'CC': envcc, + 'CXX': envcxx, + 'CCACHE_BASEDIR': Interpolate("%(kw:cwd)s", cwd=GetCwd) } if overrides is not None: env.update(overrides) @@ -430,6 +443,16 @@ for target in targets: command = ["../findbin.pl", "g++", cc_version[0], cc_version[1]], haltOnFailure = True)) + # see if ccache is available + factory.addStep(SetPropertyFromCommand( + property = "ccache_command", + command = ["which", "ccache"], + description = "Testing for ccache command", + haltOnFailure = False, + flunkOnFailure = False, + warnOnFailure = False, + )) + # expire tree if needed if tree_expire > 0: factory.addStep(FileDownload( @@ -623,7 +646,7 @@ for target in targets: name = "dltar", description = "Building and installing GNU tar", command = ["make", WithProperties("-j%(jobs)d", jobs=GetNumJobs), "tools/tar/compile", "V=s"], - env = MakeEnv(), + env = MakeEnv(tryccache=True), haltOnFailure = True )) @@ -648,7 +671,7 @@ for target in targets: name = "tools", description = "Building and installing tools", command = ["make", WithProperties("-j%(jobs)d", jobs=GetNumJobs), "tools/install", "V=s"], - env = MakeEnv(), + env = MakeEnv(tryccache=True), haltOnFailure = True )) -- 2.30.2