blob: 7c74625f71203bed85fdcb7ceb7f99329cf11415 [file] [log] [blame]
Daniel Dunbar235aa412009-07-18 07:16:15 +00001import buildbot
2import buildbot.process.factory
David Deanf8b35442012-12-11 00:35:12 +00003import os
4
5from buildbot.process.properties import WithProperties
David Blaikie8cbf62f2013-01-12 21:32:31 +00006from buildbot.steps.shell import Configure, ShellCommand, SetProperty
Daniel Dunbar44abe742009-07-19 01:59:03 +00007from buildbot.steps.shell import WarningCountingShellCommand
David Deanf8b35442012-12-11 00:35:12 +00008from buildbot.steps.source import SVN
Daniel Dunbar44abe742009-07-19 01:59:03 +00009from buildbot.steps.transfer import FileDownload
David Deanf8b35442012-12-11 00:35:12 +000010from zorg.buildbot.Artifacts import GetCompilerArtifacts, uploadArtifacts
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +000011from zorg.buildbot.builders.Util import getConfigArgs
David Blaikie7c3cbca2013-01-12 08:14:35 +000012from zorg.buildbot.commands import DejaGNUCommand
David Blaikie17ef8892013-01-12 08:09:00 +000013from zorg.buildbot.commands import SuppressionDejaGNUCommand
David Deanf8b35442012-12-11 00:35:12 +000014from zorg.buildbot.commands.BatchFileDownload import BatchFileDownload
David Blaikie8ec37522013-01-09 21:24:24 +000015from zorg.buildbot.commands.LitTestCommand import LitTestCommand
David Deanf8b35442012-12-11 00:35:12 +000016from zorg.buildbot.PhasedBuilderUtils import GetLatestValidated, find_cc
Michael Gottesmanc8294c52013-03-30 23:43:59 +000017from zorg.buildbot.PhasedBuilderUtils import find_liblto, SVNCleanupStep
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000018
Galina Kistanovaf4d79352011-10-20 20:46:52 +000019def getClangBuildFactory(
20 triple=None,
21 clean=True,
22 test=True,
23 package_dst=None,
24 run_cxx_tests=False,
25 examples=False,
26 valgrind=False,
27 valgrindLeakCheck=False,
28 outOfDir=False,
29 useTwoStage=False,
30 completely_clean=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +000031 make='make',
32 jobs="%(jobs)s",
33 stage1_config='Debug+Asserts',
34 stage2_config='Release+Asserts',
35 env={}, # Environmental variables for all steps.
36 extra_configure_args=[],
37 use_pty_in_tests=False,
Peter Collingbourned49ac282011-10-25 14:38:45 +000038 trunk_revision=None,
39 force_checkout=False,
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +000040 extra_clean_step=None,
David Blaikiea76da842012-08-13 22:24:46 +000041 checkout_compiler_rt=False,
42 run_gdb=False,
David Blaikiedad03d52012-11-16 22:37:12 +000043 run_modern_gdb=False,
David Blaikie41d09c32013-01-02 21:11:09 +000044 run_gcc=False):
Galina Kistanovaf4d79352011-10-20 20:46:52 +000045 # Prepare environmental variables. Set here all env we want everywhere.
46 merged_env = {
47 'TERM' : 'dumb' # Make sure Clang doesn't use color escape sequences.
48 }
49 if env is not None:
50 # Overwrite pre-set items with the given ones, so user can set anything.
51 merged_env.update(env)
David Blaikie2f7eb282012-08-24 18:37:00 +000052
David Blaikiedad03d52012-11-16 22:37:12 +000053 if run_gdb or run_gcc or run_modern_gdb:
David Blaikie88511c72012-08-24 23:14:06 +000054 outOfDir = True
Galina Kistanovaf4d79352011-10-20 20:46:52 +000055
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000056 # Don't use in-dir builds with a two stage build process.
Daniel Dunbar3efb7822010-02-26 19:20:00 +000057 inDir = not outOfDir and not useTwoStage
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000058 if inDir:
59 llvm_srcdir = "llvm"
60 llvm_1_objdir = "llvm"
David Blaikie88511c72012-08-24 23:14:06 +000061 llvm_1_installdir = None
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000062 else:
63 llvm_srcdir = "llvm.src"
64 llvm_1_objdir = "llvm.obj"
65 llvm_1_installdir = "llvm.install.1"
66 llvm_2_objdir = "llvm.obj.2"
Daniel Dunbar22d594a2010-07-31 05:29:16 +000067 llvm_2_installdir = "llvm.install"
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000068
Daniel Dunbar235aa412009-07-18 07:16:15 +000069 f = buildbot.process.factory.BuildFactory()
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000070
71 # Determine the build directory.
72 f.addStep(buildbot.steps.shell.SetProperty(name="get_builddir",
73 command=["pwd"],
74 property="builddir",
75 description="set build dir",
Galina Kistanovaf4d79352011-10-20 20:46:52 +000076 workdir=".",
77 env=merged_env))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000078
Daniel Dunbar06b20f12010-04-08 18:29:38 +000079 # Blow away completely, if requested.
80 if completely_clean:
81 f.addStep(ShellCommand(name="rm-llvm.src",
82 command=["rm", "-rf", llvm_srcdir],
83 haltOnFailure=True,
84 description=["rm src dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +000085 workdir=".",
86 env=merged_env))
Daniel Dunbar06b20f12010-04-08 18:29:38 +000087
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000088 # Checkout sources.
Peter Collingbourned49ac282011-10-25 14:38:45 +000089 if trunk_revision:
90 # The SVN build step provides no mechanism to check out a specific revision
91 # based on a property, so just run the commands directly here.
92 svn_co = ['svn', 'checkout']
93 if force_checkout:
94 svn_co += ['--force']
95 svn_co += ['--revision', WithProperties(trunk_revision)]
96
97 svn_co_llvm = svn_co + \
98 [WithProperties('http://llvm.org/svn/llvm-project/llvm/trunk@%s' %
99 trunk_revision),
100 llvm_srcdir]
101 svn_co_clang = svn_co + \
102 [WithProperties('http://llvm.org/svn/llvm-project/cfe/trunk@%s' %
103 trunk_revision),
104 '%s/tools/clang' % llvm_srcdir]
David Blaikie845ae0d2012-08-10 00:51:38 +0000105 svn_co_clang_tools_extra = svn_co + \
106 [WithProperties('http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@%s' %
107 trunk_revision),
108 '%s/tools/clang/tools/extra' % llvm_srcdir]
Peter Collingbourned49ac282011-10-25 14:38:45 +0000109
110 f.addStep(ShellCommand(name='svn-llvm',
111 command=svn_co_llvm,
112 haltOnFailure=True,
113 workdir='.'))
114 f.addStep(ShellCommand(name='svn-clang',
115 command=svn_co_clang,
116 haltOnFailure=True,
117 workdir='.'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000118 f.addStep(ShellCommand(name='svn-clang-tools-extra',
119 command=svn_co_clang_tools_extra,
120 haltOnFailure=True,
121 workdir='.'))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000122 else:
123 f.addStep(SVN(name='svn-llvm',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000124 mode='update',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000125 baseURL='http://llvm.org/svn/llvm-project/llvm/',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000126 defaultBranch='trunk',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000127 workdir=llvm_srcdir))
128 f.addStep(SVN(name='svn-clang',
129 mode='update',
130 baseURL='http://llvm.org/svn/llvm-project/cfe/',
131 defaultBranch='trunk',
132 workdir='%s/tools/clang' % llvm_srcdir))
David Blaikie845ae0d2012-08-10 00:51:38 +0000133 f.addStep(SVN(name='svn-clang-tools-extra',
134 mode='update',
135 baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
136 defaultBranch='trunk',
137 workdir='%s/tools/clang/tools/extra' % llvm_srcdir))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000138 if checkout_compiler_rt:
139 f.addStep(SVN(name='svn-compiler-rt',
140 mode='update',
141 baseURL='http://llvm.org/svn/llvm-project/compiler-rt/',
142 defaultBranch='trunk',
143 workdir='%s/projects/compiler-rt' % llvm_srcdir))
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000144
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000145 # Clean up llvm (stage 1); unless in-dir.
146 if clean and llvm_srcdir != llvm_1_objdir:
147 f.addStep(ShellCommand(name="rm-llvm.obj.stage1",
148 command=["rm", "-rf", llvm_1_objdir],
149 haltOnFailure=True,
150 description=["rm build dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000151 workdir=".",
152 env=merged_env))
Andrew Trick70fa9d22011-08-25 23:38:51 +0000153
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000154 # Force without llvm-gcc so we don't run afoul of Frontend test failures.
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000155 base_configure_args = [WithProperties("%%(builddir)s/%s/configure" % llvm_srcdir),
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000156 '--disable-bindings']
157 base_configure_args += extra_configure_args
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000158 if triple:
Andrew Trick70fa9d22011-08-25 23:38:51 +0000159 base_configure_args += ['--build=%s' % triple,
David Dean7da22862012-10-01 19:57:30 +0000160 '--host=%s' % triple]
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000161 args = base_configure_args + ["--without-llvmgcc", "--without-llvmgxx"]
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000162 args.append(WithProperties("--prefix=%%(builddir)s/%s" % llvm_1_installdir))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000163 args += getConfigArgs(stage1_config)
David Blaikie8cbf62f2013-01-12 21:32:31 +0000164 if not clean:
165 f.addStep(SetProperty(name="Makefile_isready",
166 workdir=llvm_1_objdir,
167 command=["sh", "-c",
Galina Kistanovaf7275a42013-03-22 21:42:55 +0000168 "test -e Makefile.config && echo OK || echo Missing"],
David Blaikie8cbf62f2013-01-12 21:32:31 +0000169 flunkOnFailure=False,
170 property="exists_Makefile"))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000171 f.addStep(Configure(command=args,
172 workdir=llvm_1_objdir,
173 description=['configuring',stage1_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000174 descriptionDone=['configure',stage1_config],
David Blaikie8cbf62f2013-01-12 21:32:31 +0000175 env=merged_env,
176 doStepIf=lambda step: step.build.getProperty("exists_Makefile") != "OK"))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000177
178 # Make clean if using in-dir builds.
179 if clean and llvm_srcdir == llvm_1_objdir:
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000180 f.addStep(WarningCountingShellCommand(name="clean-llvm",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000181 command=[make, "clean"],
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000182 haltOnFailure=True,
183 description="cleaning llvm",
184 descriptionDone="clean llvm",
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000185 workdir=llvm_1_objdir,
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000186 doStepIf=clean,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000187 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000188
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000189 if extra_clean_step:
190 f.addStep(extra_clean_step)
191
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000192 f.addStep(WarningCountingShellCommand(name="compile",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000193 command=['nice', '-n', '10',
194 make, WithProperties("-j%s" % jobs)],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000195 haltOnFailure=True,
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000196 description=["compiling", stage1_config],
197 descriptionDone=["compile", stage1_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000198 workdir=llvm_1_objdir,
199 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000200
201 if examples:
202 f.addStep(WarningCountingShellCommand(name="compile.examples",
203 command=['nice', '-n', '10',
204 make, WithProperties("-j%s" % jobs),
205 "BUILD_EXAMPLES=1"],
206 haltOnFailure=True,
207 description=["compilinge", stage1_config, "examples"],
208 descriptionDone=["compile", stage1_config, "examples"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000209 workdir=llvm_1_objdir,
210 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000211
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000212 clangTestArgs = '-v -j %s' % jobs
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000213 if valgrind:
Daniel Dunbar89184b92010-04-18 19:09:32 +0000214 clangTestArgs += ' --vg'
Daniel Dunbara1bebce2010-03-21 01:24:00 +0000215 if valgrindLeakCheck:
216 clangTestArgs += ' --vg-leak'
Nick Lewycky8d26e472011-08-27 21:18:56 +0000217 clangTestArgs += ' --vg-arg --suppressions=%(builddir)s/llvm/tools/clang/utils/valgrind/x86_64-pc-linux-gnu_gcc-4.3.3.supp --vg-arg --suppressions=%(builddir)s/llvm/utils/valgrind/x86_64-pc-linux-gnu.supp'
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000218 extraTestDirs = ''
219 if run_cxx_tests:
220 extraTestDirs += '%(builddir)s/llvm/tools/clang/utils/C++Tests'
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000221 if test:
David Blaikie7a99cd52013-01-12 20:50:32 +0000222 f.addStep(LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000223 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000224 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000225 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie7e6f8a12012-08-31 20:46:27 +0000226 description=["checking"],
227 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000228 workdir=llvm_1_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000229 usePTY=use_pty_in_tests,
230 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000231
232 # Install llvm and clang.
233 if llvm_1_installdir:
Daniel Dunbar9870de32010-03-28 22:25:31 +0000234 f.addStep(ShellCommand(name="rm-install.clang.stage1",
235 command=["rm", "-rf", llvm_1_installdir],
236 haltOnFailure=True,
237 description=["rm install dir", "clang"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000238 workdir=".",
239 env=merged_env))
Daniel Dunbar9870de32010-03-28 22:25:31 +0000240 f.addStep(WarningCountingShellCommand(name="install.clang.stage1",
241 command = ['nice', '-n', '10',
242 make, 'install-clang'],
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000243 haltOnFailure=True,
Daniel Dunbar9870de32010-03-28 22:25:31 +0000244 description=["install", "clang",
245 stage1_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000246 workdir=llvm_1_objdir,
247 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000248
David Blaikiedad03d52012-11-16 22:37:12 +0000249 if run_gdb or run_gcc or run_modern_gdb:
David Blaikiea76da842012-08-13 22:24:46 +0000250 ignores = getClangTestsIgnoresFromPath(os.path.expanduser('~/public/clang-tests'), 'clang-x86_64-darwin10')
251 install_prefix = "%%(builddir)s/%s" % llvm_1_installdir
252 if run_gdb:
253 addClangGDBTests(f, ignores, install_prefix)
David Blaikiedad03d52012-11-16 22:37:12 +0000254 if run_modern_gdb:
David Blaikie41d09c32013-01-02 21:11:09 +0000255 addModernClangGDBTests(f, jobs, install_prefix)
David Blaikiea76da842012-08-13 22:24:46 +0000256 if run_gcc:
257 addClangGCCTests(f, ignores, install_prefix)
258
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000259 if not useTwoStage:
Daniel Dunbardedf6572010-11-13 00:23:34 +0000260 if package_dst:
261 name = WithProperties(
262 "%(builddir)s/" + llvm_1_objdir +
263 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
264 f.addStep(ShellCommand(name='pkg.tar',
265 description="tar root",
266 command=["tar", "zcvf", name, "./"],
267 workdir=llvm_1_installdir,
268 warnOnFailure=True,
269 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000270 haltOnFailure=False,
271 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000272 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000273 description="upload root",
Daniel Dunbardedf6572010-11-13 00:23:34 +0000274 command=["scp", name,
275 WithProperties(
276 package_dst + "/%(buildername)s")],
277 workdir=".",
278 warnOnFailure=True,
279 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000280 haltOnFailure=False,
281 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000282
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000283 return f
284
285 # Clean up llvm (stage 2).
286 if clean:
287 f.addStep(ShellCommand(name="rm-llvm.obj.stage2",
288 command=["rm", "-rf", llvm_2_objdir],
289 haltOnFailure=True,
290 description=["rm build dir", "llvm", "(stage 2)"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000291 workdir=".",
292 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000293
294 # Configure llvm (stage 2).
295 args = base_configure_args + ["--without-llvmgcc", "--without-llvmgxx"]
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000296 args.append(WithProperties("--prefix=%(builddir)s/" + llvm_2_installdir))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000297 args += getConfigArgs(stage2_config)
Benjamin Kramer9c6fed72012-07-20 10:18:32 +0000298 local_env = dict(merged_env)
299 local_env.update({
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000300 'CC' : WithProperties("%%(builddir)s/%s/bin/clang" % llvm_1_installdir),
301 'CXX' : WithProperties("%%(builddir)s/%s/bin/clang++" % llvm_1_installdir)})
302
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000303 f.addStep(Configure(name="configure.llvm.stage2",
304 command=args,
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000305 haltOnFailure=True,
306 workdir=llvm_2_objdir,
307 description=["configure", "llvm", "(stage 2)",
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000308 stage2_config],
309 env=local_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000310
311 # Build llvm (stage 2).
312 f.addStep(WarningCountingShellCommand(name="compile.llvm.stage2",
313 command=['nice', '-n', '10',
314 make, WithProperties("-j%s" % jobs)],
315 haltOnFailure=True,
316 description=["compiling", "(stage 2)",
317 stage2_config],
318 descriptionDone=["compile", "(stage 2)",
319 stage2_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000320 workdir=llvm_2_objdir,
321 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000322
323 if test:
David Blaikief52bb942013-01-12 20:53:55 +0000324 f.addStep(LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000325 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000326 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000327 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie7e6f8a12012-08-31 20:46:27 +0000328 description=["checking"],
329 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000330 workdir=llvm_2_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000331 usePTY=use_pty_in_tests,
332 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000333
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000334 # Install clang (stage 2).
Daniel Dunbar9870de32010-03-28 22:25:31 +0000335 f.addStep(ShellCommand(name="rm-install.clang.stage2",
336 command=["rm", "-rf", llvm_2_installdir],
337 haltOnFailure=True,
338 description=["rm install dir", "clang"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000339 workdir=".",
340 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000341 f.addStep(WarningCountingShellCommand(name="install.clang.stage2",
342 command = ['nice', '-n', '10',
343 make, 'install-clang'],
344 haltOnFailure=True,
345 description=["install", "clang",
346 "(stage 2)"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000347 workdir=llvm_2_objdir,
348 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000349
350 if package_dst:
351 name = WithProperties(
352 "%(builddir)s/" + llvm_2_objdir +
353 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
354 f.addStep(ShellCommand(name='pkg.tar',
355 description="tar root",
356 command=["tar", "zcvf", name, "./"],
357 workdir=llvm_2_installdir,
358 warnOnFailure=True,
359 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000360 haltOnFailure=False,
361 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000362 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000363 description="upload root",
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000364 command=["scp", name,
365 WithProperties(
366 package_dst + "/%(buildername)s")],
367 workdir=".",
368 warnOnFailure=True,
369 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000370 haltOnFailure=False,
371 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000372
Daniel Dunbar235aa412009-07-18 07:16:15 +0000373 return f
Daniel Dunbar44abe742009-07-19 01:59:03 +0000374
Daniel Dunbarc51a59e2010-09-23 14:57:45 +0000375def getClangMSVCBuildFactory(update=True, clean=True, vcDrive='c', jobs=1, cmake=r"cmake"):
Daniel Dunbar44abe742009-07-19 01:59:03 +0000376 f = buildbot.process.factory.BuildFactory()
377
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000378 if update:
Daniel Dunbar44abe742009-07-19 01:59:03 +0000379 f.addStep(SVN(name='svn-llvm',
380 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
381 defaultBranch='trunk',
382 workdir='llvm'))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000383 f.addStep(SVN(name='svn-clang',
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000384 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
Daniel Dunbar44abe742009-07-19 01:59:03 +0000385 defaultBranch='trunk',
386 workdir='llvm/tools/clang'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000387 f.addStep(SVN(name='svn-clang-tools-extra',
388 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
389 defaultBranch='trunk',
390 workdir='llvm/tools/clang/tools/extra'))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000391
392 # Full & fast clean.
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000393 if clean:
Daniel Dunbar44abe742009-07-19 01:59:03 +0000394 f.addStep(ShellCommand(name='clean-1',
395 command=['del','/s/q','build'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000396 warnOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000397 description='cleaning',
398 descriptionDone='clean',
399 workdir='llvm'))
400 f.addStep(ShellCommand(name='clean-2',
401 command=['rmdir','/s/q','build'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000402 warnOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000403 description='cleaning',
404 descriptionDone='clean',
405 workdir='llvm'))
406
407 # Create the project files.
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000408
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000409 # Use batch files instead of ShellCommand directly, Windows quoting is
410 # borked. FIXME: See buildbot ticket #595 and buildbot ticket #377.
411 f.addStep(BatchFileDownload(name='cmakegen',
Daniel Dunbar06b20f12010-04-08 18:29:38 +0000412 command=[cmake,
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000413 "-DLLVM_TARGETS_TO_BUILD:=X86",
Daniel Dunbar1ddedce2010-09-24 19:57:34 +0000414 "-DLLVM_INCLUDE_EXAMPLES:=OFF",
415 "-DLLVM_INCLUDE_TESTS:=OFF",
416 "-DLLVM_TARGETS_TO_BUILD:=X86",
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000417 "-G",
418 "Visual Studio 9 2008",
419 ".."],
420 workdir="llvm\\build"))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000421 f.addStep(ShellCommand(name='cmake',
422 command=['cmakegen.bat'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000423 haltOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000424 description='cmake gen',
425 workdir='llvm\\build'))
426
427 # Build it.
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000428 f.addStep(BatchFileDownload(name='vcbuild',
429 command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""",
430 "/M%d" % jobs,
431 "LLVM.sln",
432 "Debug|Win32"],
433 workdir="llvm\\build"))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000434 f.addStep(WarningCountingShellCommand(name='vcbuild',
435 command=['vcbuild.bat'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000436 haltOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000437 description='vcbuild',
438 workdir='llvm\\build',
439 warningPattern=" warning C.*:"))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000440
441 # Build clang-test project.
442 f.addStep(BatchFileDownload(name='vcbuild_test',
443 command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""",
444 "clang-test.vcproj",
445 "Debug|Win32"],
446 workdir="llvm\\build\\tools\\clang\\test"))
David Blaikief52bb942013-01-12 20:53:55 +0000447 f.addStep(LitTestCommand(name='test-clang',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000448 command=["vcbuild_test.bat"],
449 workdir="llvm\\build\\tools\\clang\\test"))
450
Daniel Dunbar44abe742009-07-19 01:59:03 +0000451 return f
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000452
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000453# Builds on Windows using CMake, MinGW(32|64), and no Microsoft tools.
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000454def getClangMinGWBuildFactory(update=True, clean=True, jobs=6, cmake=r"cmake"):
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000455 f = buildbot.process.factory.BuildFactory()
456
457 if update:
458 f.addStep(SVN(name='svn-llvm',
459 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
460 defaultBranch='trunk',
461 workdir='llvm'))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000462 f.addStep(SVN(name='svn-clang',
463 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
464 defaultBranch='trunk',
465 workdir='llvm/tools/clang'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000466 f.addStep(SVN(name='svn-clang-tools-extra',
467 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
468 defaultBranch='trunk',
469 workdir='llvm/tools/clang/tools/extra'))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000470
471 # Full & fast clean.
472 if clean:
473 # note: This command is redundant as the next command removes everything
474 f.addStep(ShellCommand(name='clean-1',
475 command=['del','/s/q','build'],
476 warnOnFailure=True,
477 description='cleaning',
478 descriptionDone='clean',
479 workdir='llvm'))
480 f.addStep(ShellCommand(name='clean-2',
481 command=['rmdir','/s/q','build'],
482 warnOnFailure=True,
483 description='cleaning',
484 descriptionDone='clean',
485 workdir='llvm'))
486
487 # Create the Makefiles.
488
489 # Use batch files instead of ShellCommand directly, Windows quoting is
490 # borked. FIXME: See buildbot ticket #595 and buildbot ticket #377.
491 f.addStep(BatchFileDownload(name='cmakegen',
492 command=[cmake,
493 "-DLLVM_TARGETS_TO_BUILD:=X86",
494 "-DLLVM_INCLUDE_EXAMPLES:=OFF",
495 "-DLLVM_INCLUDE_TESTS:=OFF",
496 "-DLLVM_TARGETS_TO_BUILD:=X86",
497 "-G",
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000498 "Ninja",
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000499 ".."],
500 workdir="llvm\\build"))
501 f.addStep(ShellCommand(name='cmake',
502 command=['cmakegen.bat'],
503 haltOnFailure=True,
504 description='cmake gen',
505 workdir='llvm\\build'))
506
507 # Build it.
508 f.addStep(BatchFileDownload(name='makeall',
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000509 command=["ninja", "-j", "%d" % jobs],
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000510 haltOnFailure=True,
511 workdir='llvm\\build'))
512
513 f.addStep(WarningCountingShellCommand(name='makeall',
514 command=['makeall.bat'],
515 haltOnFailure=True,
516 description='makeall',
517 workdir='llvm\\build'))
518
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000519 # Build global check project (make check) (sources not checked out...).
520 if 0:
521 f.addStep(BatchFileDownload(name='makecheck',
522 command=["ninja", "check"],
523 workdir='llvm\\build'))
524 f.addStep(WarningCountingShellCommand(name='check',
525 command=['makecheck.bat'],
526 description='make check',
527 workdir='llvm\\build'))
Galina Kistanova049d76c2012-06-09 00:56:05 +0000528
529 # Build clang-test project (make clang-test).
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000530 f.addStep(BatchFileDownload(name='maketest',
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000531 command=["ninja", "clang-test"],
Galina Kistanova049d76c2012-06-09 00:56:05 +0000532 workdir="llvm\\build"))
David Blaikief52bb942013-01-12 20:53:55 +0000533 f.addStep(LitTestCommand(name='clang-test',
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000534 command=["maketest.bat"],
Galina Kistanova049d76c2012-06-09 00:56:05 +0000535 workdir="llvm\\build"))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000536
537 return f
538
Daniel Dunbar7363d032011-02-27 03:22:35 +0000539def addClangGCCTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install",
540 languages = ('gcc', 'g++', 'objc', 'obj-c++')):
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000541 make_vars = [WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000542 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000543 WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000544 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000545 f.addStep(SVN(name='svn-clang-tests', mode='update',
546 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
547 defaultBranch='trunk', workdir='clang-tests'))
548 gcc_dg_ignores = ignores.get('gcc-4_2-testsuite', {})
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000549 for lang in languages:
David Blaikie17ef8892013-01-12 08:09:00 +0000550 f.addStep(SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000551 name='test-gcc-4_2-testsuite-%s' % lang,
552 command=["make", "-k", "check-%s" % lang] + make_vars,
553 description="gcc-4_2-testsuite (%s)" % lang,
554 workdir='clang-tests/gcc-4_2-testsuite',
David Dean2bd0c3a2011-10-18 16:36:28 +0000555 logfiles={ 'dg.sum' : 'obj/%s/%s.sum' % (lang, lang),
556 '%s.log' % lang : 'obj/%s/%s.log' % (lang, lang)},
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000557 ignore=gcc_dg_ignores.get(lang, [])))
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000558
Daniel Dunbar7363d032011-02-27 03:22:35 +0000559def addClangGDBTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install"):
560 make_vars = [WithProperties(
561 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
562 WithProperties(
563 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
564 f.addStep(SVN(name='svn-clang-tests', mode='update',
565 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
566 defaultBranch='trunk', workdir='clang-tests'))
David Blaikie17ef8892013-01-12 08:09:00 +0000567 f.addStep(SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar7363d032011-02-27 03:22:35 +0000568 name='test-gdb-1472-testsuite',
569 command=["make", "-k", "check"] + make_vars,
570 description="gdb-1472-testsuite",
571 workdir='clang-tests/gdb-1472-testsuite',
David Blaikie7ec695f2012-10-09 22:17:09 +0000572 logfiles={ 'dg.sum' : 'obj/filtered.gdb.sum',
David Blaikie624f4392012-11-05 22:34:35 +0000573 'gdb.log' : 'obj/gdb.log' }))
Daniel Dunbar7363d032011-02-27 03:22:35 +0000574
David Blaikie41d09c32013-01-02 21:11:09 +0000575def addModernClangGDBTests(f, jobs, install_prefix):
David Blaikie1bc5c372012-12-05 05:29:12 +0000576 make_vars = [WithProperties('RUNTESTFLAGS=CC_FOR_TARGET=\'{0}/bin/clang\' '
577 'CXX_FOR_TARGET=\'{0}/bin/clang++\' '
David Blaikie41d09c32013-01-02 21:11:09 +0000578 'CFLAGS_FOR_TARGET=\'-w -fno-omit-frame-pointer '
579 '-mno-omit-leaf-frame-pointer -fno-limit-debug-info\''
David Blaikief89877b2013-01-29 23:46:26 +0000580 .format(install_prefix))]
David Blaikiedad03d52012-11-16 22:37:12 +0000581 f.addStep(SVN(name='svn-clang-tests', mode='update',
David Blaikief3f300b2012-11-17 01:13:41 +0000582 svnurl='http://llvm.org/svn/llvm-project/clang-tests-external/trunk/gdb/7.5',
David Blaikiedad03d52012-11-16 22:37:12 +0000583 workdir='clang-tests/src'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000584 f.addStep(Configure(command='../src/configure',
David Blaikief3f300b2012-11-17 01:13:41 +0000585 workdir='clang-tests/build/'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000586 f.addStep(WarningCountingShellCommand(name='gdb-75-build',
587 command=['make', WithProperties('-j%s' % jobs)],
588 haltOnFailure=True,
589 workdir='clang-tests/build'))
David Blaikie7c3cbca2013-01-12 08:14:35 +0000590 f.addStep(DejaGNUCommand.DejaGNUCommand(
David Blaikiedad03d52012-11-16 22:37:12 +0000591 name='gdb-75-check',
David Blaikieb83bfdf2012-12-05 04:33:42 +0000592 command=['make', '-k', WithProperties('-j%s' % jobs), 'check'] + make_vars,
David Blaikiedad03d52012-11-16 22:37:12 +0000593 workdir='clang-tests/build',
David Blaikie1bc5c372012-12-05 05:29:12 +0000594 logfiles={'dg.sum':'gdb/testsuite/gdb.sum',
595 'gdb.log':'gdb/testsuite/gdb.log'}))
David Blaikiedad03d52012-11-16 22:37:12 +0000596
597
598
Daniel Dunbar7363d032011-02-27 03:22:35 +0000599# FIXME: Deprecated.
600addClangTests = addClangGCCTests
601
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000602def getClangTestsIgnoresFromPath(path, key):
603 def readList(path):
604 if not os.path.exists(path):
605 return []
606
607 f = open(path)
608 lines = [ln.strip() for ln in f]
609 f.close()
610 return lines
611
612 ignores = {}
613
614 gcc_dg_ignores = {}
615 for lang in ('gcc', 'g++', 'objc', 'obj-c++'):
616 lang_path = os.path.join(path, 'gcc-4_2-testsuite', 'expected_results',
617 key, lang)
618 gcc_dg_ignores[lang] = (
619 readList(os.path.join(lang_path, 'FAIL.txt')) +
620 readList(os.path.join(lang_path, 'UNRESOLVED.txt')) +
621 readList(os.path.join(lang_path, 'XPASS.txt')))
622 ignores['gcc-4_2-testsuite' ] = gcc_dg_ignores
623
Daniel Dunbar7363d032011-02-27 03:22:35 +0000624 ignores_path = os.path.join(path, 'gdb-1472-testsuite', 'expected_results',
625 key)
626 gdb_dg_ignores = (
627 readList(os.path.join(ignores_path, 'FAIL.txt')) +
628 readList(os.path.join(ignores_path, 'UNRESOLVED.txt')) +
629 readList(os.path.join(ignores_path, 'XPASS.txt')))
630 ignores['gdb-1472-testsuite' ] = gdb_dg_ignores
631
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000632 return ignores
David Deanf8b35442012-12-11 00:35:12 +0000633
634from zorg.buildbot.PhasedBuilderUtils import getBuildDir, setProperty
Michael Gottesman94e9ee42013-04-04 06:52:04 +0000635from zorg.buildbot.builders.Util import _did_last_build_fail
David Deanf8b35442012-12-11 00:35:12 +0000636from buildbot.steps.source.svn import SVN as HostSVN
637
Michael Gottesman94e9ee42013-04-04 06:52:04 +0000638def phasedClang(config_options, is_bootstrap=True, use_lto=False,
639 incremental=False):
David Deanf8b35442012-12-11 00:35:12 +0000640 # Create an instance of the Builder.
641 f = buildbot.process.factory.BuildFactory()
642 # Determine the build directory.
643 f = getBuildDir(f)
644 # get rid of old archives from prior builds
645 f.addStep(buildbot.steps.shell.ShellCommand(
646 name='rm.archives', command=['sh', '-c', 'rm -rfv *gz'],
647 haltOnFailure=False, description=['rm archives'],
648 workdir=WithProperties('%(builddir)s')))
649 # Clean the build directory.
650 clang_build_dir = 'clang-build'
Michael Gottesman94e9ee42013-04-04 06:52:04 +0000651 if incremental:
652 f.addStep(buildbot.steps.shell.ShellCommand(
653 name='rm.clang-build', command=['rm', '-rfv', clang_build_dir],
654 haltOnFailure=False, description=['rm dir', clang_build_dir],
655 workdir=WithProperties('%(builddir)s'),
656 doStepIf=_did_last_build_fail))
657 else:
658 f.addStep(buildbot.steps.shell.ShellCommand(
659 name='rm.clang-build', command=['rm', '-rfv', clang_build_dir],
660 haltOnFailure=False, description=['rm dir', clang_build_dir],
661 workdir=WithProperties('%(builddir)s')))
662
David Deanf8b35442012-12-11 00:35:12 +0000663 # Cleanup the clang link, which buildbot's SVN always_purge does not know
664 # (in 8.5 this changed to method='fresh')
665 # how to remove correctly. If we don't do this, the LLVM update steps will
666 # end up doing a clobber every time.
667 #
668 # FIXME: Should file a Trac for this, but I am lazy.
669 f.addStep(buildbot.steps.shell.ShellCommand(
670 name='rm.clang-sources-link',
671 command=['rm', '-rfv', 'llvm/tools/clang'],
672 haltOnFailure=False, description=['rm', 'clang sources link'],
673 workdir=WithProperties('%(builddir)s')))
674 f.addStep(buildbot.steps.shell.ShellCommand(
675 name='rm.compiler-rt-sources-link',
676 command=['rm', '-rfv', 'llvm/projects/compiler-rt'],
677 haltOnFailure=False, description=['rm', 'compiler-rt sources link'],
678 workdir=WithProperties('%(builddir)s')))
679 # Pull sources.
Michael Gottesmanc8294c52013-03-30 23:43:59 +0000680 f = SVNCleanupStep(f, 'llvm')
David Deanf8b35442012-12-11 00:35:12 +0000681 f.addStep(HostSVN(name='pull.llvm', mode='incremental', method='fresh',
682 repourl='http://llvm.org/svn/llvm-project/llvm/trunk',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000683 retry=(60, 5), workdir='llvm', description='pull.llvm',
684 alwaysUseLatest=False))
Michael Gottesmanc8294c52013-03-30 23:43:59 +0000685 f = SVNCleanupStep(f, 'clang.src')
David Deanf8b35442012-12-11 00:35:12 +0000686 f.addStep(HostSVN(name='pull.clang', mode='incremental', method='fresh',
687 repourl='http://llvm.org/svn/llvm-project/cfe/trunk',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000688 workdir='clang.src', retry=(60, 5),
David Deanf8b35442012-12-11 00:35:12 +0000689 description='pull.clang', alwaysUseLatest=False))
Michael Gottesmanc8294c52013-03-30 23:43:59 +0000690 f = SVNCleanupStep(f, 'clang-tools-extra.src')
Michael Gottesman1dcf8f82013-03-28 06:20:57 +0000691 f.addStep(HostSVN(name='pull.clang-tools-extra', mode='incremental',
692 method='fresh',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000693 repourl='http://llvm.org/svn/llvm-project/'
694 'clang-tools-extra/trunk',
Michael Gottesman1dcf8f82013-03-28 06:20:57 +0000695 workdir='clang-tools-extra.src', alwaysUseLatest=False,
696 retry=(60, 5), description='pull.clang-tools-extra'))
Michael Gottesmanc8294c52013-03-30 23:43:59 +0000697 f = SVNCleanupStep(f, 'compiler-rt.src')
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000698 f.addStep(HostSVN(name='pull.compiler-rt', mode='incremental',
699 method='fresh',
700 repourl='http://llvm.org/svn/llvm-project/compiler-rt/'
701 'trunk',
702 workdir='compiler-rt.src', alwaysUseLatest=False,
703 retry=(60, 5), description='pull.compiler-rt'))
704 # Create symlinks to the clang compiler-rt sources inside the LLVM tree.
David Deanf8b35442012-12-11 00:35:12 +0000705 # We don't actually check out the sources there, because the SVN purge
706 # would always remove them then.
707 f.addStep(buildbot.steps.shell.ShellCommand(
708 name='ln.clang-sources', haltOnFailure=True,
709 command=['ln', '-sfv', '../../clang.src', 'clang'],
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000710 workdir='llvm/tools', description=['ln', 'clang sources']))
David Deanf8b35442012-12-11 00:35:12 +0000711 f.addStep(buildbot.steps.shell.ShellCommand(
712 name='ln.compiler-rt-sources',
713 command=['ln', '-sfv', '../../compiler-rt.src', 'compiler-rt'],
714 haltOnFailure=True, workdir='llvm/projects',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000715 description=['ln', 'compiler-rt sources']))
Michael Gottesmanbcab1992013-03-28 18:37:21 +0000716 # TODO: We used to use a symlink here but it seems to not work. I am trying
717 # to get this builder to work so I am just going to copy it instead.
Michael Gottesman1dcf8f82013-03-28 06:20:57 +0000718 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesman4a68b872013-03-28 19:03:52 +0000719 name='rm.clang-tools-extra-source',
720 command=['rm', '-rfv', 'extra'],
721 haltOnFailure=True, workdir='clang.src/tools',
722 description=['rm', 'clang-tools-extra sources']))
723 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmanbcab1992013-03-28 18:37:21 +0000724 name='cp.clang-tools-extra-sources',
Michael Gottesman03495922013-03-28 18:40:44 +0000725 command=['cp', '-Rfv', '../../clang-tools-extra.src', 'extra'],
Michael Gottesman1dcf8f82013-03-28 06:20:57 +0000726 haltOnFailure=True, workdir='clang.src/tools',
Michael Gottesmanbcab1992013-03-28 18:37:21 +0000727 description=['cp', 'clang-tools-extra sources']))
David Deanf8b35442012-12-11 00:35:12 +0000728 # Checkout the supplemental 'debuginfo-tests' repository.
729 debuginfo_url = 'http://llvm.org/svn/llvm-project/debuginfo-tests/trunk'
730 f.addStep(HostSVN(name='pull.debug-info tests', mode='incremental',
731 repourl=debuginfo_url,
732 method='fresh',
733 workdir='llvm/tools/clang/test/debuginfo-tests',
734 alwaysUseLatest=False, retry = (60, 5),
735 description='pull.debug-info tests'))
736 # Clean the install directory.
737 f.addStep(buildbot.steps.shell.ShellCommand(
738 name='rm.clang-install', command=['rm', '-rfv', 'clang-install'],
739 haltOnFailure=False, description=['rm dir', 'clang-install'],
740 workdir=WithProperties('%(builddir)s')))
741 # Construct the configure arguments.
742 configure_args = ['../llvm/configure']
743 configure_args.extend(config_options)
744 configure_args.extend(['--disable-bindings', '--with-llvmcc=clang',
745 '--without-llvmgcc', '--without-llvmgxx',
746 '--enable-keep-symbols'])
747 configure_args.append(
Michael Gottesman65d940f2013-03-13 21:51:16 +0000748 WithProperties('--prefix=%(builddir)s/clang-install'))
Michael Gottesmanca56e8f2013-03-06 22:27:38 +0000749
David Deanf8b35442012-12-11 00:35:12 +0000750 # If we are using a previously built compiler, download it and override CC
751 # and CXX.
752 if is_bootstrap:
753 f = GetCompilerArtifacts(f)
754 else:
755 f = GetLatestValidated(f)
756 cc_command = ['find', 'host-compiler', '-name', 'clang']
757 f.addStep(buildbot.steps.shell.SetProperty(
758 name='find.cc',
759 command=cc_command,
760 extract_fn=find_cc,
761 workdir=WithProperties('%(builddir)s')))
762 f.addStep(buildbot.steps.shell.ShellCommand(
763 name='sanity.test', haltOnFailure=True,
764 command=[WithProperties('%(builddir)s/%(cc_path)s'), '-v'],
765 description=['sanity test']))
766 configure_args.extend([
767 WithProperties('CC=%(builddir)s/%(cc_path)s'),
768 WithProperties('CXX=%(builddir)s/%(cc_path)s++')])
Michael Gottesman65d940f2013-03-13 21:51:16 +0000769
770 # If we need to use lto, find liblto, add in proper flags here, etc.
771 if use_lto:
Michael Gottesman01f0a622013-03-13 22:38:38 +0000772 liblto_command = ['find', WithProperties('%(builddir)s/host-compiler'),
773 '-name', 'libLTO.dylib']
Michael Gottesman1da57ae2013-03-13 21:54:23 +0000774 f.addStep(buildbot.steps.shell.SetProperty(
Michael Gottesman65d940f2013-03-13 21:51:16 +0000775 name='find.liblto',
776 command=liblto_command,
777 extract_fn=find_liblto,
778 workdir=WithProperties('%(builddir)s')))
779 configure_args.append(
780 '--with-extra-options=-flto -gline-tables-only')
781
David Deanf8b35442012-12-11 00:35:12 +0000782 # Configure the LLVM build.
783 f.addStep(buildbot.steps.shell.ShellCommand(
784 name='configure.with.host', command=configure_args,
785 haltOnFailure=True, description=['configure'],
786 workdir=clang_build_dir))
787 # Build the compiler.
Michael Gottesman65d940f2013-03-13 21:51:16 +0000788 make_command = ['make', '-j', WithProperties('%(jobs)s')]
Michael Gottesmanbab77ac2013-03-14 05:36:53 +0000789 timeout = 20*60 # Normal timeout is 20 minutes.
Michael Gottesman65d940f2013-03-13 21:51:16 +0000790 if use_lto:
791 make_command.append(WithProperties('DYLD_LIBRARY_PATH=%(liblto_path)s'))
Michael Gottesman4ec74de2013-03-25 20:23:45 +0000792 timeout = 120*60 # LTO timeout is 120 minutes.
Michael Gottesman65d940f2013-03-13 21:51:16 +0000793
David Deanf8b35442012-12-11 00:35:12 +0000794 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesman65d940f2013-03-13 21:51:16 +0000795 name='make', command=make_command,
Michael Gottesmanbab77ac2013-03-14 05:36:53 +0000796 haltOnFailure=True, description=['make'], workdir=clang_build_dir,
797 timeout=timeout))
David Deanf8b35442012-12-11 00:35:12 +0000798 # Use make install-clang to produce minimal archive for use by downstream
799 # builders.
800 f.addStep(buildbot.steps.shell.ShellCommand(
801 name='make.install-clang', haltOnFailure=True,
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000802 command=['make', 'install-clang', '-j',
803 WithProperties('%(jobs)s'),
804 'RC_SUPPORTED_ARCHS=armv7 i386 x86_64'],
David Deanf8b35442012-12-11 00:35:12 +0000805 description=['make install'], workdir=clang_build_dir))
806 # Save artifacts of this build for use by other builders.
807 f = uploadArtifacts(f)
808 # Run the LLVM and Clang regression tests.
David Blaikie8ec37522013-01-09 21:24:24 +0000809 f.addStep(LitTestCommand(name='run.llvm.tests', haltOnFailure=True,
David Deanf8b35442012-12-11 00:35:12 +0000810 command=['make', '-j', WithProperties('%(jobs)s'),
David Blaikie4715cb42013-01-02 21:53:19 +0000811 'VERBOSE=1', 'check-all'],
812 description=['all', 'tests'],
David Blaikieee45c6e2013-01-02 21:50:47 +0000813 workdir=clang_build_dir))
David Deanf8b35442012-12-11 00:35:12 +0000814 return f