blob: aa01c06960d07a586e6441f5c0ddec315909c31c [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
Reid Kleckner25a26b02015-03-09 22:30:25 +00005from buildbot.process.properties import WithProperties, Property
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
Michael Gottesmana6b5be82013-06-28 21:57:20 +000010
Michael Gottesman960bcfa2013-08-30 05:46:15 +000011import zorg.buildbot.util.artifacts as artifacts
Michael Gottesmana6b5be82013-06-28 21:57:20 +000012import zorg.buildbot.builders.Util as builders_util
Michael Gottesmandc771a02013-08-30 05:46:22 +000013import zorg.buildbot.util.phasedbuilderutils as phasedbuilderutils
Michael Gottesmana6b5be82013-06-28 21:57:20 +000014import zorg.buildbot.commands as commands
15import zorg.buildbot.commands.BatchFileDownload as batch_file_download
16import zorg.buildbot.commands.LitTestCommand as lit_test_command
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000017
Galina Kistanovaf4d79352011-10-20 20:46:52 +000018def getClangBuildFactory(
19 triple=None,
20 clean=True,
21 test=True,
22 package_dst=None,
23 run_cxx_tests=False,
24 examples=False,
25 valgrind=False,
26 valgrindLeakCheck=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +000027 useTwoStage=False,
28 completely_clean=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +000029 make='make',
30 jobs="%(jobs)s",
31 stage1_config='Debug+Asserts',
32 stage2_config='Release+Asserts',
33 env={}, # Environmental variables for all steps.
34 extra_configure_args=[],
35 use_pty_in_tests=False,
Peter Collingbourned49ac282011-10-25 14:38:45 +000036 trunk_revision=None,
37 force_checkout=False,
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +000038 extra_clean_step=None,
David Blaikiea76da842012-08-13 22:24:46 +000039 checkout_compiler_rt=False,
40 run_gdb=False,
David Blaikiedad03d52012-11-16 22:37:12 +000041 run_modern_gdb=False,
Galina Kistanova10836402013-09-26 20:42:52 +000042 run_gcc=False,
Richard Smith02389162014-09-26 23:53:06 +000043 merge_functions=False,
44 cmake=None,
45 modules=False):
46 assert not modules or (cmake and useTwoStage), \
47 "modules build requires 2 stage cmake build for now"
48
Galina Kistanovaf4d79352011-10-20 20:46:52 +000049 # Prepare environmental variables. Set here all env we want everywhere.
50 merged_env = {
51 'TERM' : 'dumb' # Make sure Clang doesn't use color escape sequences.
52 }
53 if env is not None:
54 # Overwrite pre-set items with the given ones, so user can set anything.
55 merged_env.update(env)
David Blaikie2f7eb282012-08-24 18:37:00 +000056
Jonathan Roelofs62415e52015-02-28 00:03:17 +000057 llvm_srcdir = "llvm.src"
58 llvm_1_objdir = "llvm.obj"
59 llvm_1_installdir = "llvm.install.1"
60 llvm_2_objdir = "llvm.obj.2"
61 llvm_2_installdir = "llvm.install"
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000062
Daniel Dunbar235aa412009-07-18 07:16:15 +000063 f = buildbot.process.factory.BuildFactory()
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000064
65 # Determine the build directory.
66 f.addStep(buildbot.steps.shell.SetProperty(name="get_builddir",
67 command=["pwd"],
68 property="builddir",
69 description="set build dir",
Galina Kistanovaf4d79352011-10-20 20:46:52 +000070 workdir=".",
71 env=merged_env))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000072
Daniel Dunbar06b20f12010-04-08 18:29:38 +000073 # Blow away completely, if requested.
74 if completely_clean:
75 f.addStep(ShellCommand(name="rm-llvm.src",
76 command=["rm", "-rf", llvm_srcdir],
77 haltOnFailure=True,
78 description=["rm src dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +000079 workdir=".",
80 env=merged_env))
Daniel Dunbar06b20f12010-04-08 18:29:38 +000081
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000082 # Checkout sources.
Peter Collingbourned49ac282011-10-25 14:38:45 +000083 if trunk_revision:
84 # The SVN build step provides no mechanism to check out a specific revision
85 # based on a property, so just run the commands directly here.
86 svn_co = ['svn', 'checkout']
87 if force_checkout:
88 svn_co += ['--force']
89 svn_co += ['--revision', WithProperties(trunk_revision)]
90
91 svn_co_llvm = svn_co + \
92 [WithProperties('http://llvm.org/svn/llvm-project/llvm/trunk@%s' %
93 trunk_revision),
94 llvm_srcdir]
95 svn_co_clang = svn_co + \
96 [WithProperties('http://llvm.org/svn/llvm-project/cfe/trunk@%s' %
97 trunk_revision),
98 '%s/tools/clang' % llvm_srcdir]
David Blaikie845ae0d2012-08-10 00:51:38 +000099 svn_co_clang_tools_extra = svn_co + \
100 [WithProperties('http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@%s' %
101 trunk_revision),
102 '%s/tools/clang/tools/extra' % llvm_srcdir]
Peter Collingbourned49ac282011-10-25 14:38:45 +0000103
104 f.addStep(ShellCommand(name='svn-llvm',
105 command=svn_co_llvm,
106 haltOnFailure=True,
107 workdir='.'))
108 f.addStep(ShellCommand(name='svn-clang',
109 command=svn_co_clang,
110 haltOnFailure=True,
111 workdir='.'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000112 f.addStep(ShellCommand(name='svn-clang-tools-extra',
113 command=svn_co_clang_tools_extra,
114 haltOnFailure=True,
115 workdir='.'))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000116 else:
117 f.addStep(SVN(name='svn-llvm',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000118 mode='update',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000119 baseURL='http://llvm.org/svn/llvm-project/llvm/',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000120 defaultBranch='trunk',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000121 workdir=llvm_srcdir))
122 f.addStep(SVN(name='svn-clang',
123 mode='update',
124 baseURL='http://llvm.org/svn/llvm-project/cfe/',
125 defaultBranch='trunk',
126 workdir='%s/tools/clang' % llvm_srcdir))
David Blaikie845ae0d2012-08-10 00:51:38 +0000127 f.addStep(SVN(name='svn-clang-tools-extra',
128 mode='update',
129 baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
130 defaultBranch='trunk',
131 workdir='%s/tools/clang/tools/extra' % llvm_srcdir))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000132 if checkout_compiler_rt:
133 f.addStep(SVN(name='svn-compiler-rt',
134 mode='update',
135 baseURL='http://llvm.org/svn/llvm-project/compiler-rt/',
136 defaultBranch='trunk',
137 workdir='%s/projects/compiler-rt' % llvm_srcdir))
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000138
Galina Kistanova10836402013-09-26 20:42:52 +0000139 # Revert and apply patch mergeFunctions in required
140 if merge_functions:
141 f.addStep(ShellCommand(name="revert_patch_MergeFunctions",
142 command=["svn", "-R", "revert", '.'],
143 haltOnFailure=True,
144 description=["revert patch MergeFunctions"],
145 workdir='%s/tools/clang' % llvm_srcdir,
146 env=merged_env))
147
148 if merge_functions:
149 f.addStep(ShellCommand(name="patch_MergeFunctions",
150 command=["patch", "-Np0", "-i", '../../utils/Misc/mergefunctions.clang.svn.patch'],
151 haltOnFailure=True,
152 description=["patch MergeFunctions"],
153 workdir='%s/tools/clang' % llvm_srcdir,
154 env=merged_env))
155
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000156 # Clean up llvm (stage 1); unless in-dir.
157 if clean and llvm_srcdir != llvm_1_objdir:
158 f.addStep(ShellCommand(name="rm-llvm.obj.stage1",
159 command=["rm", "-rf", llvm_1_objdir],
160 haltOnFailure=True,
161 description=["rm build dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000162 workdir=".",
163 env=merged_env))
Andrew Trick70fa9d22011-08-25 23:38:51 +0000164
David Blaikie8cbf62f2013-01-12 21:32:31 +0000165 if not clean:
Richard Smith02389162014-09-26 23:53:06 +0000166 if cmake:
167 expected_makefile = 'Makefile'
168 else:
169 expected_makefile = 'Makefile.config'
David Blaikie8cbf62f2013-01-12 21:32:31 +0000170 f.addStep(SetProperty(name="Makefile_isready",
171 workdir=llvm_1_objdir,
172 command=["sh", "-c",
Richard Smith02389162014-09-26 23:53:06 +0000173 "test -e %s && echo OK || echo Missing" % expected_makefile],
David Blaikie8cbf62f2013-01-12 21:32:31 +0000174 flunkOnFailure=False,
175 property="exists_Makefile"))
Richard Smith02389162014-09-26 23:53:06 +0000176
177 if not cmake:
178 # Force without llvm-gcc so we don't run afoul of Frontend test failures.
179 base_configure_args = [WithProperties("%%(builddir)s/%s/configure" % llvm_srcdir),
180 '--disable-bindings']
181 base_configure_args += extra_configure_args
182 if triple:
183 base_configure_args += ['--build=%s' % triple,
184 '--host=%s' % triple]
185 args = base_configure_args + [WithProperties("--prefix=%%(builddir)s/%s" % llvm_1_installdir)]
186 args += builders_util.getConfigArgs(stage1_config)
187
188 f.addStep(Configure(command=args,
189 workdir=llvm_1_objdir,
190 description=['configuring',stage1_config],
191 descriptionDone=['configure',stage1_config],
192 env=merged_env,
193 doStepIf=lambda step: step.build.getProperty("exists_Makefile") != "OK"))
194 else:
195 cmake_triple_arg = []
196 if triple:
197 cmake_triple_arg = ['-DLLVM_HOST_TRIPLE=%s' % triple]
198 f.addStep(ShellCommand(name='cmake',
199 command=[cmake,
200 '-DLLVM_BUILD_TESTS=ON',
201 '-DCMAKE_BUILD_TYPE=%s' % stage1_config] +
202 cmake_triple_arg +
203 extra_configure_args +
204 ["../" + llvm_srcdir],
205 description='cmake stage1',
206 workdir=llvm_1_objdir,
207 env=merged_env,
208 doStepIf=lambda step: step.build.getProperty("exists_Makefile") != "OK"))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000209
210 # Make clean if using in-dir builds.
211 if clean and llvm_srcdir == llvm_1_objdir:
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000212 f.addStep(WarningCountingShellCommand(name="clean-llvm",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000213 command=[make, "clean"],
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000214 haltOnFailure=True,
215 description="cleaning llvm",
216 descriptionDone="clean llvm",
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000217 workdir=llvm_1_objdir,
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000218 doStepIf=clean,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000219 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000220
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000221 if extra_clean_step:
222 f.addStep(extra_clean_step)
223
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000224 f.addStep(WarningCountingShellCommand(name="compile",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000225 command=['nice', '-n', '10',
226 make, WithProperties("-j%s" % jobs)],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000227 haltOnFailure=True,
David Blaikie05517332013-12-19 23:29:12 +0000228 flunkOnFailure=not run_gdb,
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000229 description=["compiling", stage1_config],
230 descriptionDone=["compile", stage1_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000231 workdir=llvm_1_objdir,
232 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000233
234 if examples:
235 f.addStep(WarningCountingShellCommand(name="compile.examples",
236 command=['nice', '-n', '10',
237 make, WithProperties("-j%s" % jobs),
238 "BUILD_EXAMPLES=1"],
239 haltOnFailure=True,
Richard Smith65e6f5d2014-09-25 18:18:35 +0000240 description=["compiling", stage1_config, "examples"],
Daniel Dunbar256fed42009-11-25 21:11:08 +0000241 descriptionDone=["compile", stage1_config, "examples"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000242 workdir=llvm_1_objdir,
243 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000244
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000245 clangTestArgs = '-v -j %s' % jobs
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000246 if valgrind:
Daniel Dunbar89184b92010-04-18 19:09:32 +0000247 clangTestArgs += ' --vg'
Daniel Dunbara1bebce2010-03-21 01:24:00 +0000248 if valgrindLeakCheck:
249 clangTestArgs += ' --vg-leak'
Nick Lewycky8d26e472011-08-27 21:18:56 +0000250 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 +0000251 extraTestDirs = ''
252 if run_cxx_tests:
253 extraTestDirs += '%(builddir)s/llvm/tools/clang/utils/C++Tests'
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000254 if test:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000255 f.addStep(lit_test_command.LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000256 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000257 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000258 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie05517332013-12-19 23:29:12 +0000259 flunkOnFailure=not run_gdb,
David Blaikie7e6f8a12012-08-31 20:46:27 +0000260 description=["checking"],
261 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000262 workdir=llvm_1_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000263 usePTY=use_pty_in_tests,
264 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000265
266 # Install llvm and clang.
Richard Smith02389162014-09-26 23:53:06 +0000267 if llvm_1_installdir and not cmake: # FIXME: install for cmake build
Daniel Dunbar9870de32010-03-28 22:25:31 +0000268 f.addStep(ShellCommand(name="rm-install.clang.stage1",
269 command=["rm", "-rf", llvm_1_installdir],
270 haltOnFailure=True,
271 description=["rm install dir", "clang"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000272 workdir=".",
273 env=merged_env))
Daniel Dunbar9870de32010-03-28 22:25:31 +0000274 f.addStep(WarningCountingShellCommand(name="install.clang.stage1",
275 command = ['nice', '-n', '10',
276 make, 'install-clang'],
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000277 haltOnFailure=True,
Daniel Dunbar9870de32010-03-28 22:25:31 +0000278 description=["install", "clang",
279 stage1_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000280 workdir=llvm_1_objdir,
281 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000282
David Blaikiedad03d52012-11-16 22:37:12 +0000283 if run_gdb or run_gcc or run_modern_gdb:
David Blaikiea76da842012-08-13 22:24:46 +0000284 ignores = getClangTestsIgnoresFromPath(os.path.expanduser('~/public/clang-tests'), 'clang-x86_64-darwin10')
285 install_prefix = "%%(builddir)s/%s" % llvm_1_installdir
286 if run_gdb:
287 addClangGDBTests(f, ignores, install_prefix)
David Blaikiedad03d52012-11-16 22:37:12 +0000288 if run_modern_gdb:
David Blaikie41d09c32013-01-02 21:11:09 +0000289 addModernClangGDBTests(f, jobs, install_prefix)
David Blaikiea76da842012-08-13 22:24:46 +0000290 if run_gcc:
291 addClangGCCTests(f, ignores, install_prefix)
292
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000293 if not useTwoStage:
Daniel Dunbardedf6572010-11-13 00:23:34 +0000294 if package_dst:
295 name = WithProperties(
296 "%(builddir)s/" + llvm_1_objdir +
297 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
298 f.addStep(ShellCommand(name='pkg.tar',
299 description="tar root",
300 command=["tar", "zcvf", name, "./"],
301 workdir=llvm_1_installdir,
302 warnOnFailure=True,
303 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000304 haltOnFailure=False,
305 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000306 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000307 description="upload root",
Daniel Dunbardedf6572010-11-13 00:23:34 +0000308 command=["scp", name,
309 WithProperties(
310 package_dst + "/%(buildername)s")],
311 workdir=".",
312 warnOnFailure=True,
313 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000314 haltOnFailure=False,
315 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000316
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000317 return f
318
319 # Clean up llvm (stage 2).
Richard Smith02389162014-09-26 23:53:06 +0000320 #
321 # FIXME: It does not make much sense to skip this for a bootstrap builder.
322 # Check whether there is any reason to skip cleaning here and if not, remove
323 # this condition.
324 if clean or cmake:
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000325 f.addStep(ShellCommand(name="rm-llvm.obj.stage2",
326 command=["rm", "-rf", llvm_2_objdir],
327 haltOnFailure=True,
328 description=["rm build dir", "llvm", "(stage 2)"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000329 workdir=".",
330 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000331
332 # Configure llvm (stage 2).
Richard Smith02389162014-09-26 23:53:06 +0000333 if not cmake:
334 args = base_configure_args + [WithProperties("--prefix=%(builddir)s/" + llvm_2_installdir)]
335 args += builders_util.getConfigArgs(stage2_config)
336 local_env = dict(merged_env)
337 local_env.update({
338 'CC' : WithProperties("%%(builddir)s/%s/bin/clang" % llvm_1_installdir),
339 'CXX' : WithProperties("%%(builddir)s/%s/bin/clang++" % llvm_1_installdir)})
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000340
Richard Smith02389162014-09-26 23:53:06 +0000341 f.addStep(Configure(name="configure.llvm.stage2",
342 command=args,
343 haltOnFailure=True,
344 workdir=llvm_2_objdir,
345 description=["configure", "llvm", "(stage 2)",
346 stage2_config],
347 env=local_env))
348 else:
349 c_flags = ''
350 cxx_flags = ''
351 extra_args = []
352 if modules:
353 c_flags += '-fmodules-cache-path=%%(builddir)s/%s/module-cache' % llvm_2_objdir
354 # Modules requires libc++ for now (we don't have a module map for libstdc++ yet).
355 cxx_flags += '-stdlib=libc++'
356 extra_args = ['-DLLVM_ENABLE_MODULES=1']
357
358 f.addStep(ShellCommand(name='cmake',
359 command=[cmake] + extra_args + [
360 '-DLLVM_BUILD_TESTS=ON',
361 WithProperties('-DCMAKE_C_COMPILER=%%(builddir)s/%s/bin/clang' % llvm_1_objdir), # FIXME use installdir
362 WithProperties('-DCMAKE_CXX_COMPILER=%%(builddir)s/%s/bin/clang++' % llvm_1_objdir),
363 '-DCMAKE_BUILD_TYPE=%s' % stage2_config,
364 WithProperties('-DCMAKE_C_FLAGS=%s' % c_flags),
365 WithProperties('-DCMAKE_CXX_FLAGS=%s %s' % (c_flags, cxx_flags)),
366 "../" + llvm_srcdir],
367 description='cmake stage2',
368 workdir=llvm_2_objdir,
369 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000370
Richard Smith35c28622015-03-26 00:18:15 +0000371 if modules:
372 f.addStep(WarningCountingShellCommand(name="compile.llvm.stage2.intrinsics_gen",
373 command=['nice', '-n', '10',
374 make, "intrinsics_gen", WithProperties("-j%s" % jobs)],
375 haltOnFailure=True,
376 description=["compiling", "(stage 2 intrinsics.gen)",
377 stage2_config],
378 descriptionDone=["compile", "(stage 2 intrinsics.gen)",
379 stage2_config],
380 workdir=llvm_2_objdir,
381 env=merged_env))
382
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000383 # Build llvm (stage 2).
384 f.addStep(WarningCountingShellCommand(name="compile.llvm.stage2",
385 command=['nice', '-n', '10',
386 make, WithProperties("-j%s" % jobs)],
387 haltOnFailure=True,
388 description=["compiling", "(stage 2)",
389 stage2_config],
390 descriptionDone=["compile", "(stage 2)",
391 stage2_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000392 workdir=llvm_2_objdir,
393 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000394
395 if test:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000396 f.addStep(lit_test_command.LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000397 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000398 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000399 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie7e6f8a12012-08-31 20:46:27 +0000400 description=["checking"],
401 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000402 workdir=llvm_2_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000403 usePTY=use_pty_in_tests,
404 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000405
Richard Smith02389162014-09-26 23:53:06 +0000406 if llvm_2_installdir and not cmake: # FIXME: install for cmake build
407 # Install clang (stage 2).
408 f.addStep(ShellCommand(name="rm-install.clang.stage2",
409 command=["rm", "-rf", llvm_2_installdir],
410 haltOnFailure=True,
411 description=["rm install dir", "clang"],
412 workdir=".",
413 env=merged_env))
414 f.addStep(WarningCountingShellCommand(name="install.clang.stage2",
415 command = ['nice', '-n', '10',
416 make, 'install-clang'],
417 haltOnFailure=True,
418 description=["install", "clang",
419 "(stage 2)"],
420 workdir=llvm_2_objdir,
421 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000422
423 if package_dst:
424 name = WithProperties(
425 "%(builddir)s/" + llvm_2_objdir +
426 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
427 f.addStep(ShellCommand(name='pkg.tar',
428 description="tar root",
429 command=["tar", "zcvf", name, "./"],
430 workdir=llvm_2_installdir,
431 warnOnFailure=True,
432 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000433 haltOnFailure=False,
434 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000435 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000436 description="upload root",
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000437 command=["scp", name,
438 WithProperties(
439 package_dst + "/%(buildername)s")],
440 workdir=".",
441 warnOnFailure=True,
442 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000443 haltOnFailure=False,
444 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000445
Daniel Dunbar235aa412009-07-18 07:16:15 +0000446 return f
Daniel Dunbar44abe742009-07-19 01:59:03 +0000447
Renato Golin61aed7f2015-06-17 19:12:50 +0000448def addSVNUpdateSteps(f,
449 checkout_clang_tools_extra,
450 checkout_compiler_rt,
451 checkout_test_suite):
Renato Goline402f582014-09-04 19:25:24 +0000452 # We *must* checkout at least Clang+LLVM
453 f.addStep(SVN(name='svn-llvm',
454 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
455 defaultBranch='trunk',
456 workdir='llvm'))
457 f.addStep(SVN(name='svn-clang',
458 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
459 defaultBranch='trunk',
460 workdir='llvm/tools/clang'))
461
462 # Extra stuff that will be built/tested
463 if checkout_clang_tools_extra:
464 f.addStep(SVN(name='svn-clang-tools-extra',
465 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
466 defaultBranch='trunk',
467 workdir='llvm/tools/clang/tools/extra'))
468 if checkout_compiler_rt:
469 f.addStep(SVN(name='svn-compiler-rt',
470 mode='update', baseURL='http://llvm.org/svn/llvm-project/compiler-rt/',
471 defaultBranch='trunk',
472 workdir='llvm/projects/compiler-rt'))
Renato Golin61aed7f2015-06-17 19:12:50 +0000473 if checkout_test_suite:
474 f.addStep(SVN(name='svn-lnt',
475 mode='update', baseURL='http://llvm.org/svn/llvm-project/lnt/',
476 defaultBranch='trunk',
477 workdir='test/lnt'))
478 f.addStep(SVN(name='svn-test-suite',
479 mode='update', baseURL='http://llvm.org/svn/llvm-project/test-suite/',
480 defaultBranch='trunk',
481 workdir='test/test-suite'))
Renato Goline402f582014-09-04 19:25:24 +0000482
Reid Kleckner25a26b02015-03-09 22:30:25 +0000483
484def getClangCMakeBuildFactory(
485 clean=True,
486 test=True,
487 cmake='cmake',
488 jobs=None,
489
490 # VS tools environment variable if using MSVC. For example,
491 # %VS120COMNTOOLS% selects the 2013 toolchain.
492 vs=None,
493 vs_target_arch='x86',
494
495 # Multi-stage compilation
496 useTwoStage=False,
497 testStage1=True,
498 stage1_config='Release',
499 stage2_config='Release',
500
Renato Golin61aed7f2015-06-17 19:12:50 +0000501 # Test-suite
502 runTestSuite=False,
503 nt_flags=[],
504 submitURL=None,
505 testerName=None,
506
Reid Kleckner25a26b02015-03-09 22:30:25 +0000507 # Environmental variables for all steps.
508 env={},
509 extra_cmake_args=[],
510
511 # Extra repositories
512 checkout_clang_tools_extra=True,
513 checkout_compiler_rt=True):
514
515 ############# PREPARING
516 f = buildbot.process.factory.BuildFactory()
517
Renato Golin61aed7f2015-06-17 19:12:50 +0000518 addSVNUpdateSteps(f,
519 checkout_clang_tools_extra=checkout_clang_tools_extra,
520 checkout_compiler_rt=checkout_compiler_rt,
521 checkout_test_suite=runTestSuite)
Reid Kleckner25a26b02015-03-09 22:30:25 +0000522
Renato Goline402f582014-09-04 19:25:24 +0000523 # If jobs not defined, Ninja will choose a suitable value
Renato Golincc83db32015-06-17 19:23:40 +0000524 jobs_cmd = []
525 lit_args = "'-v"
Renato Goline402f582014-09-04 19:25:24 +0000526 if jobs is not None:
Renato Golincc83db32015-06-17 19:23:40 +0000527 jobs_cmd = ["-j"+str(jobs)]
528 lit_args += " -j"+str(jobs)+"'"
Renato Goline402f582014-09-04 19:25:24 +0000529 else:
Renato Golincc83db32015-06-17 19:23:40 +0000530 lit_args += "'"
531 ninja_cmd = ['ninja'] + jobs_cmd
532 ninja_install_cmd = ['ninja', 'install'] + jobs_cmd
533 ninja_check_cmd = ['ninja', 'check-all'] + jobs_cmd
Reid Kleckner25a26b02015-03-09 22:30:25 +0000534 check_build_cmd = ["sh", "-c",
535 "test -e build.ninja && echo OK || echo Missing"]
536 if vs:
537 check_build_cmd = ["cmd", "/c", "if exist build.ninja (echo OK) " +
538 " else (echo Missing & exit 1)"]
Renato Goline402f582014-09-04 19:25:24 +0000539
540 # Global configurations
Renato Golincc83db32015-06-17 19:23:40 +0000541 stage1_build = 'stage1'
542 stage1_install = 'stage1.install'
543 stage2_build = 'stage2'
544 stage2_install = 'stage2.install'
Renato Goline402f582014-09-04 19:25:24 +0000545
Reid Kleckner25a26b02015-03-09 22:30:25 +0000546 # Set up VS environment, if appropriate.
547 if vs:
548 f.addStep(SetProperty(
549 command=builders_util.getVisualStudioEnvironment(vs, vs_target_arch),
550 extract_fn=builders_util.extractSlaveEnvironment))
551 assert not env, "Can't have custom builder env vars with VS"
552 env = Property('slave_env')
553
554
Renato Goline402f582014-09-04 19:25:24 +0000555 ############# CLEANING
556 if clean:
557 f.addStep(ShellCommand(name='clean stage 1',
558 command=['rm','-rf',stage1_build],
559 warnOnFailure=True,
560 description='cleaning stage 1',
561 descriptionDone='clean',
562 workdir='.',
563 env=env))
564 else:
565 f.addStep(SetProperty(name="check ninja files 1",
566 workdir=stage1_build,
Reid Kleckner25a26b02015-03-09 22:30:25 +0000567 command=check_build_cmd,
Renato Goline402f582014-09-04 19:25:24 +0000568 flunkOnFailure=False,
569 property="exists_ninja_1"))
570
571
572 ############# STAGE 1
573 f.addStep(ShellCommand(name='cmake stage 1',
574 command=[cmake, "-G", "Ninja", "../llvm",
575 "-DCMAKE_BUILD_TYPE="+stage1_config,
576 "-DLLVM_ENABLE_ASSERTIONS=True",
577 "-DLLVM_LIT_ARGS="+lit_args,
578 "-DCMAKE_INSTALL_PREFIX=../"+stage1_install]
579 + extra_cmake_args,
580 haltOnFailure=True,
581 description='cmake stage 1',
582 workdir=stage1_build,
583 doStepIf=lambda step: step.build.getProperty("exists_ninja_1") != "OK",
584 env=env))
585
586 f.addStep(WarningCountingShellCommand(name='build stage 1',
587 command=ninja_cmd,
588 haltOnFailure=True,
589 description='ninja all',
590 workdir=stage1_build,
591 env=env))
592
593 if test and testStage1:
Renato Golincfbd5702014-09-06 19:09:16 +0000594 f.addStep(lit_test_command.LitTestCommand(name='ninja check 1',
595 command=ninja_check_cmd,
Renato Golin61aed7f2015-06-17 19:12:50 +0000596 haltOnFailure=not runTestSuite,
Renato Golincfbd5702014-09-06 19:09:16 +0000597 description=["checking stage 1"],
598 descriptionDone=["stage 1 checked"],
599 workdir=stage1_build,
600 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000601
Renato Golin61aed7f2015-06-17 19:12:50 +0000602 if useTwoStage or runTestSuite:
603 f.addStep(ShellCommand(name='install stage 1',
604 command=ninja_install_cmd,
605 description='ninja install',
606 workdir=stage1_build,
Renato Goline402f582014-09-04 19:25:24 +0000607 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000608
Reid Kleckner25a26b02015-03-09 22:30:25 +0000609 # Compute the cmake define flag to set the C and C++ compiler to clang. Use
610 # clang-cl if we used MSVC for stage1.
611 if not vs:
612 cc = 'clang'
613 cxx = 'clang++'
614 else:
615 cc = 'clang-cl.exe'
616 cxx = 'clang-cl.exe'
617
Reid Kleckner25a26b02015-03-09 22:30:25 +0000618
Renato Golin61aed7f2015-06-17 19:12:50 +0000619 ############# STAGE 2
620 if useTwoStage:
621 if clean:
622 f.addStep(ShellCommand(name='clean stage 2',
623 command=['rm','-rf',stage2_build],
624 warnOnFailure=True,
625 description='cleaning stage 2',
626 descriptionDone='clean',
627 workdir='.',
628 env=env))
629 else:
630 f.addStep(SetProperty(name="check ninja files 2",
631 workdir=stage2_build,
632 command=check_build_cmd,
633 flunkOnFailure=False,
634 property="exists_ninja_2"))
Reid Kleckner25a26b02015-03-09 22:30:25 +0000635
Renato Golin61aed7f2015-06-17 19:12:50 +0000636 # Set the compiler using the CC and CXX environment variables to work around
637 # backslash string escaping bugs somewhere between buildbot and cmake. The
638 # env.exe helper is required to run the tests, so hopefully it's already on
639 # PATH.
640 cmake_cmd2 = ['env',
641 WithProperties('CC=%(workdir)s/'+stage1_install+'/bin/'+cc),
642 WithProperties('CXX=%(workdir)s/'+stage1_install+'/bin/'+cxx),
643 cmake, "-G", "Ninja", "../llvm",
644 "-DCMAKE_BUILD_TYPE="+stage2_config,
645 "-DLLVM_ENABLE_ASSERTIONS=True",
646 "-DLLVM_LIT_ARGS="+lit_args,
647 "-DCMAKE_INSTALL_PREFIX=../"+stage2_install] + extra_cmake_args
Reid Kleckner25a26b02015-03-09 22:30:25 +0000648
Renato Golin61aed7f2015-06-17 19:12:50 +0000649 f.addStep(ShellCommand(name='cmake stage 2',
650 command=cmake_cmd2,
651 haltOnFailure=True,
652 description='cmake stage 2',
653 workdir=stage2_build,
654 doStepIf=lambda step: step.build.getProperty("exists_ninja_2") != "OK",
655 env=env))
656
657 f.addStep(WarningCountingShellCommand(name='build stage 2',
658 command=ninja_cmd,
659 haltOnFailure=True,
660 description='ninja all',
661 workdir=stage2_build,
662 env=env))
663
664 if test:
665 f.addStep(lit_test_command.LitTestCommand(name='ninja check 2',
666 command=ninja_check_cmd,
667 haltOnFailure=not runTestSuite,
668 description=["checking stage 2"],
669 descriptionDone=["stage 2 checked"],
670 workdir=stage2_build,
671 env=env))
672
673 ############# TEST SUITE
674 ## Test-Suite (stage 2 if built, stage 1 otherwise)
675 if runTestSuite:
676 compiler_path = stage1_install
677 if useTwoStage:
678 compiler_path=stage2_install
679 f.addStep(ShellCommand(name='install stage 2',
680 command=ninja_install_cmd,
681 description='ninja install 2',
Renato Golincfbd5702014-09-06 19:09:16 +0000682 workdir=stage2_build,
683 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000684
Renato Golin61aed7f2015-06-17 19:12:50 +0000685 # Get generated python, lnt
686 python = WithProperties('%(workdir)s/test/sandbox/bin/python')
687 lnt = WithProperties('%(workdir)s/test/sandbox/bin/lnt')
688 lnt_setup = WithProperties('%(workdir)s/test/lnt/setup.py')
689
690 # Paths
691 sandbox = WithProperties('%(workdir)s/test/sandbox')
692 test_suite_dir = WithProperties('%(workdir)s/test/test-suite')
693
694 # Get latest built Clang (stage1 or stage2)
695 cc = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cc)
696 cxx = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cxx)
697
698 # LNT Command line
699 if jobs is None:
700 jobs = 1
701 test_suite_cmd = [python, lnt, 'runtest', 'nt',
702 '-j'+str(jobs),
703 '--no-timestamp',
704 '--sandbox', sandbox,
705 '--test-suite', test_suite_dir,
706 '--cc', cc,
707 '--cxx', cxx]
708 # Append any option provided by the user
709 test_suite_cmd.extend(nt_flags)
710 # Only submit if a URL has been specified
711 if submitURL is not None:
712 if not isinstance(submitURL, list):
713 submitURL = [submitURL]
714 for url in submitURL:
715 test_suite_cmd.extend(['--submit', url])
716 if testerName:
717 test_suite_cmd.extend(['--no-machdep-info', testerName])
718 # CC and CXX are needed as env for build-tools
719 test_suite_env = env
720 test_suite_env['CC'] = cc
721 test_suite_env['CXX'] = cxx
722
723 # Steps to prepare, build and run LNT
724 f.addStep(ShellCommand(name='clean sandbox',
725 command=['rm', '-rf', 'sandbox'],
726 haltOnFailure=True,
727 description='removing sandbox directory',
728 workdir='test',
729 env=env))
730 f.addStep(ShellCommand(name='recreate sandbox',
731 command=['virtualenv', 'sandbox'],
732 haltOnFailure=True,
733 description='recreating sandbox',
734 workdir='test',
735 env=env))
736 f.addStep(ShellCommand(name='setup lit',
737 command=[python, lnt_setup, 'develop'],
738 haltOnFailure=True,
739 description='setting up LNT in sandbox',
740 workdir='test/sandbox',
741 env=env))
742 f.addStep(commands.LitTestCommand.LitTestCommand(
743 name='test-suite',
744 command=test_suite_cmd,
745 haltOnFailure=True,
746 description=['running the test suite'],
747 workdir='test/sandbox',
748 logfiles={'configure.log' : 'build/configure.log',
749 'build-tools.log' : 'build/build-tools.log',
750 'test.log' : 'build/test.log',
751 'report.json' : 'build/report.json'},
752 env=test_suite_env))
753
Renato Goline402f582014-09-04 19:25:24 +0000754 return f
755
Daniel Dunbarc51a59e2010-09-23 14:57:45 +0000756def getClangMSVCBuildFactory(update=True, clean=True, vcDrive='c', jobs=1, cmake=r"cmake"):
Daniel Dunbar44abe742009-07-19 01:59:03 +0000757 f = buildbot.process.factory.BuildFactory()
758
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000759 if update:
Daniel Dunbar44abe742009-07-19 01:59:03 +0000760 f.addStep(SVN(name='svn-llvm',
761 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
762 defaultBranch='trunk',
763 workdir='llvm'))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000764 f.addStep(SVN(name='svn-clang',
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000765 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
Daniel Dunbar44abe742009-07-19 01:59:03 +0000766 defaultBranch='trunk',
767 workdir='llvm/tools/clang'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000768 f.addStep(SVN(name='svn-clang-tools-extra',
769 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
770 defaultBranch='trunk',
771 workdir='llvm/tools/clang/tools/extra'))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000772
773 # Full & fast clean.
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000774 if clean:
Daniel Dunbar44abe742009-07-19 01:59:03 +0000775 f.addStep(ShellCommand(name='clean-1',
776 command=['del','/s/q','build'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000777 warnOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000778 description='cleaning',
779 descriptionDone='clean',
780 workdir='llvm'))
781 f.addStep(ShellCommand(name='clean-2',
782 command=['rmdir','/s/q','build'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000783 warnOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000784 description='cleaning',
785 descriptionDone='clean',
786 workdir='llvm'))
787
788 # Create the project files.
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000789
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000790 # Use batch files instead of ShellCommand directly, Windows quoting is
791 # borked. FIXME: See buildbot ticket #595 and buildbot ticket #377.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000792 f.addStep(batch_file_download.BatchFileDownload(name='cmakegen',
Daniel Dunbar06b20f12010-04-08 18:29:38 +0000793 command=[cmake,
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000794 "-DLLVM_TARGETS_TO_BUILD:=X86",
Daniel Dunbar1ddedce2010-09-24 19:57:34 +0000795 "-DLLVM_INCLUDE_EXAMPLES:=OFF",
796 "-DLLVM_INCLUDE_TESTS:=OFF",
797 "-DLLVM_TARGETS_TO_BUILD:=X86",
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000798 "-G",
799 "Visual Studio 9 2008",
800 ".."],
801 workdir="llvm\\build"))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000802 f.addStep(ShellCommand(name='cmake',
803 command=['cmakegen.bat'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000804 haltOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000805 description='cmake gen',
806 workdir='llvm\\build'))
807
808 # Build it.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000809 f.addStep(batch_file_download.BatchFileDownload(name='vcbuild',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000810 command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""",
811 "/M%d" % jobs,
812 "LLVM.sln",
813 "Debug|Win32"],
814 workdir="llvm\\build"))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000815 f.addStep(WarningCountingShellCommand(name='vcbuild',
816 command=['vcbuild.bat'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000817 haltOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000818 description='vcbuild',
819 workdir='llvm\\build',
820 warningPattern=" warning C.*:"))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000821
822 # Build clang-test project.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000823 f.addStep(batch_file_download.BatchFileDownload(name='vcbuild_test',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000824 command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""",
825 "clang-test.vcproj",
826 "Debug|Win32"],
827 workdir="llvm\\build\\tools\\clang\\test"))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000828 f.addStep(lit_test_command.LitTestCommand(name='test-clang',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000829 command=["vcbuild_test.bat"],
830 workdir="llvm\\build\\tools\\clang\\test"))
831
Daniel Dunbar44abe742009-07-19 01:59:03 +0000832 return f
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000833
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000834# Builds on Windows using CMake, MinGW(32|64), and no Microsoft tools.
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000835def getClangMinGWBuildFactory(update=True, clean=True, jobs=6, cmake=r"cmake"):
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000836 f = buildbot.process.factory.BuildFactory()
837
838 if update:
839 f.addStep(SVN(name='svn-llvm',
840 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
841 defaultBranch='trunk',
842 workdir='llvm'))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000843 f.addStep(SVN(name='svn-clang',
844 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
845 defaultBranch='trunk',
846 workdir='llvm/tools/clang'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000847 f.addStep(SVN(name='svn-clang-tools-extra',
848 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
849 defaultBranch='trunk',
850 workdir='llvm/tools/clang/tools/extra'))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000851
852 # Full & fast clean.
853 if clean:
854 # note: This command is redundant as the next command removes everything
855 f.addStep(ShellCommand(name='clean-1',
856 command=['del','/s/q','build'],
857 warnOnFailure=True,
858 description='cleaning',
859 descriptionDone='clean',
860 workdir='llvm'))
861 f.addStep(ShellCommand(name='clean-2',
862 command=['rmdir','/s/q','build'],
863 warnOnFailure=True,
864 description='cleaning',
865 descriptionDone='clean',
866 workdir='llvm'))
867
868 # Create the Makefiles.
869
870 # Use batch files instead of ShellCommand directly, Windows quoting is
871 # borked. FIXME: See buildbot ticket #595 and buildbot ticket #377.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000872 f.addStep(batch_file_download.BatchFileDownload(name='cmakegen',
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000873 command=[cmake,
874 "-DLLVM_TARGETS_TO_BUILD:=X86",
875 "-DLLVM_INCLUDE_EXAMPLES:=OFF",
876 "-DLLVM_INCLUDE_TESTS:=OFF",
877 "-DLLVM_TARGETS_TO_BUILD:=X86",
878 "-G",
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000879 "Ninja",
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000880 ".."],
881 workdir="llvm\\build"))
882 f.addStep(ShellCommand(name='cmake',
883 command=['cmakegen.bat'],
884 haltOnFailure=True,
885 description='cmake gen',
886 workdir='llvm\\build'))
887
888 # Build it.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000889 f.addStep(batch_file_download.BatchFileDownload(name='makeall',
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000890 command=["ninja", "-j", "%d" % jobs],
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000891 haltOnFailure=True,
892 workdir='llvm\\build'))
893
894 f.addStep(WarningCountingShellCommand(name='makeall',
895 command=['makeall.bat'],
896 haltOnFailure=True,
897 description='makeall',
898 workdir='llvm\\build'))
899
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000900 # Build global check project (make check) (sources not checked out...).
901 if 0:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000902 f.addStep(batch_file_download.BatchFileDownload(name='makecheck',
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000903 command=["ninja", "check"],
904 workdir='llvm\\build'))
905 f.addStep(WarningCountingShellCommand(name='check',
906 command=['makecheck.bat'],
907 description='make check',
908 workdir='llvm\\build'))
Galina Kistanova049d76c2012-06-09 00:56:05 +0000909
910 # Build clang-test project (make clang-test).
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000911 f.addStep(batch_file_download.BatchFileDownload(name='maketest',
912 command=["ninja", "clang-test"],
913 workdir="llvm\\build"))
914 f.addStep(lit_test_command.LitTestCommand(name='clang-test',
915 command=["maketest.bat"],
916 workdir="llvm\\build"))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000917 return f
918
Daniel Dunbar7363d032011-02-27 03:22:35 +0000919def addClangGCCTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install",
920 languages = ('gcc', 'g++', 'objc', 'obj-c++')):
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000921 make_vars = [WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000922 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000923 WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000924 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
David Blaikie05517332013-12-19 23:29:12 +0000925 f.addStep(SVN(name='svn-clang-gcc-tests', mode='update',
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000926 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
927 defaultBranch='trunk', workdir='clang-tests'))
928 gcc_dg_ignores = ignores.get('gcc-4_2-testsuite', {})
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000929 for lang in languages:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000930 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000931 name='test-gcc-4_2-testsuite-%s' % lang,
932 command=["make", "-k", "check-%s" % lang] + make_vars,
933 description="gcc-4_2-testsuite (%s)" % lang,
934 workdir='clang-tests/gcc-4_2-testsuite',
David Dean2bd0c3a2011-10-18 16:36:28 +0000935 logfiles={ 'dg.sum' : 'obj/%s/%s.sum' % (lang, lang),
936 '%s.log' % lang : 'obj/%s/%s.log' % (lang, lang)},
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000937 ignore=gcc_dg_ignores.get(lang, [])))
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000938
Daniel Dunbar7363d032011-02-27 03:22:35 +0000939def addClangGDBTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install"):
940 make_vars = [WithProperties(
941 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
942 WithProperties(
943 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
David Blaikie05517332013-12-19 23:29:12 +0000944 f.addStep(SVN(name='svn-clang-gdb-tests', mode='update',
Daniel Dunbar7363d032011-02-27 03:22:35 +0000945 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
946 defaultBranch='trunk', workdir='clang-tests'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000947 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar7363d032011-02-27 03:22:35 +0000948 name='test-gdb-1472-testsuite',
949 command=["make", "-k", "check"] + make_vars,
950 description="gdb-1472-testsuite",
951 workdir='clang-tests/gdb-1472-testsuite',
David Blaikie7ec695f2012-10-09 22:17:09 +0000952 logfiles={ 'dg.sum' : 'obj/filtered.gdb.sum',
David Blaikie624f4392012-11-05 22:34:35 +0000953 'gdb.log' : 'obj/gdb.log' }))
Daniel Dunbar7363d032011-02-27 03:22:35 +0000954
David Blaikie41d09c32013-01-02 21:11:09 +0000955def addModernClangGDBTests(f, jobs, install_prefix):
David Blaikie1bc5c372012-12-05 05:29:12 +0000956 make_vars = [WithProperties('RUNTESTFLAGS=CC_FOR_TARGET=\'{0}/bin/clang\' '
957 'CXX_FOR_TARGET=\'{0}/bin/clang++\' '
David Blaikie759bb752013-04-18 23:13:11 +0000958 'CFLAGS_FOR_TARGET=\'-w -fno-limit-debug-info\''
David Blaikief89877b2013-01-29 23:46:26 +0000959 .format(install_prefix))]
David Blaikie05517332013-12-19 23:29:12 +0000960 f.addStep(SVN(name='svn-clang-modern-gdb-tests', mode='update',
David Blaikief3f300b2012-11-17 01:13:41 +0000961 svnurl='http://llvm.org/svn/llvm-project/clang-tests-external/trunk/gdb/7.5',
David Blaikiedad03d52012-11-16 22:37:12 +0000962 workdir='clang-tests/src'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000963 f.addStep(Configure(command='../src/configure',
David Blaikief3f300b2012-11-17 01:13:41 +0000964 workdir='clang-tests/build/'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000965 f.addStep(WarningCountingShellCommand(name='gdb-75-build',
966 command=['make', WithProperties('-j%s' % jobs)],
967 haltOnFailure=True,
968 workdir='clang-tests/build'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000969 f.addStep(commands.DejaGNUCommand.DejaGNUCommand(
David Blaikiedad03d52012-11-16 22:37:12 +0000970 name='gdb-75-check',
David Blaikieb83bfdf2012-12-05 04:33:42 +0000971 command=['make', '-k', WithProperties('-j%s' % jobs), 'check'] + make_vars,
David Blaikiedad03d52012-11-16 22:37:12 +0000972 workdir='clang-tests/build',
David Blaikie1bc5c372012-12-05 05:29:12 +0000973 logfiles={'dg.sum':'gdb/testsuite/gdb.sum',
974 'gdb.log':'gdb/testsuite/gdb.log'}))
David Blaikiedad03d52012-11-16 22:37:12 +0000975
976
977
Daniel Dunbar7363d032011-02-27 03:22:35 +0000978# FIXME: Deprecated.
979addClangTests = addClangGCCTests
980
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000981def getClangTestsIgnoresFromPath(path, key):
982 def readList(path):
983 if not os.path.exists(path):
984 return []
985
986 f = open(path)
987 lines = [ln.strip() for ln in f]
988 f.close()
989 return lines
990
991 ignores = {}
992
993 gcc_dg_ignores = {}
994 for lang in ('gcc', 'g++', 'objc', 'obj-c++'):
995 lang_path = os.path.join(path, 'gcc-4_2-testsuite', 'expected_results',
996 key, lang)
997 gcc_dg_ignores[lang] = (
998 readList(os.path.join(lang_path, 'FAIL.txt')) +
999 readList(os.path.join(lang_path, 'UNRESOLVED.txt')) +
1000 readList(os.path.join(lang_path, 'XPASS.txt')))
1001 ignores['gcc-4_2-testsuite' ] = gcc_dg_ignores
1002
Daniel Dunbar7363d032011-02-27 03:22:35 +00001003 ignores_path = os.path.join(path, 'gdb-1472-testsuite', 'expected_results',
1004 key)
1005 gdb_dg_ignores = (
1006 readList(os.path.join(ignores_path, 'FAIL.txt')) +
1007 readList(os.path.join(ignores_path, 'UNRESOLVED.txt')) +
1008 readList(os.path.join(ignores_path, 'XPASS.txt')))
1009 ignores['gdb-1472-testsuite' ] = gdb_dg_ignores
1010
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +00001011 return ignores
David Deanf8b35442012-12-11 00:35:12 +00001012
Michael Gottesmandc771a02013-08-30 05:46:22 +00001013from zorg.buildbot.util.phasedbuilderutils import getBuildDir, setProperty
Michael Gottesman94e9ee42013-04-04 06:52:04 +00001014from zorg.buildbot.builders.Util import _did_last_build_fail
David Deanf8b35442012-12-11 00:35:12 +00001015from buildbot.steps.source.svn import SVN as HostSVN
1016
Michael Gottesman94e9ee42013-04-04 06:52:04 +00001017def phasedClang(config_options, is_bootstrap=True, use_lto=False,
Justin Bogner9605b3f2014-05-30 23:25:46 +00001018 incremental=False):
David Deanf8b35442012-12-11 00:35:12 +00001019 # Create an instance of the Builder.
1020 f = buildbot.process.factory.BuildFactory()
1021 # Determine the build directory.
1022 f = getBuildDir(f)
1023 # get rid of old archives from prior builds
1024 f.addStep(buildbot.steps.shell.ShellCommand(
Chris Matthews92ce8e22014-01-03 21:28:27 +00001025 name='rm.archives', command=['sh', '-c', 'sudo rm -rfv *gz'],
David Deanf8b35442012-12-11 00:35:12 +00001026 haltOnFailure=False, description=['rm archives'],
1027 workdir=WithProperties('%(builddir)s')))
1028 # Clean the build directory.
1029 clang_build_dir = 'clang-build'
Michael Gottesman94e9ee42013-04-04 06:52:04 +00001030 if incremental:
1031 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmand0ef7762013-10-01 20:50:35 +00001032 name='rm.clang-build', command=['sudo', 'rm', '-rfv',
1033 clang_build_dir],
Michael Gottesman94e9ee42013-04-04 06:52:04 +00001034 haltOnFailure=False, description=['rm dir', clang_build_dir],
1035 workdir=WithProperties('%(builddir)s'),
1036 doStepIf=_did_last_build_fail))
1037 else:
1038 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmand0ef7762013-10-01 20:50:35 +00001039 name='rm.clang-build', command=['sudo', 'rm', '-rfv',
1040 clang_build_dir],
Michael Gottesman94e9ee42013-04-04 06:52:04 +00001041 haltOnFailure=False, description=['rm dir', clang_build_dir],
1042 workdir=WithProperties('%(builddir)s')))
1043
David Deanf8b35442012-12-11 00:35:12 +00001044 # Cleanup the clang link, which buildbot's SVN always_purge does not know
1045 # (in 8.5 this changed to method='fresh')
1046 # how to remove correctly. If we don't do this, the LLVM update steps will
1047 # end up doing a clobber every time.
1048 #
1049 # FIXME: Should file a Trac for this, but I am lazy.
1050 f.addStep(buildbot.steps.shell.ShellCommand(
1051 name='rm.clang-sources-link',
Chris Matthews92ce8e22014-01-03 21:28:27 +00001052 command=['sudo', 'rm', '-rfv', 'llvm/tools/clang'],
David Deanf8b35442012-12-11 00:35:12 +00001053 haltOnFailure=False, description=['rm', 'clang sources link'],
1054 workdir=WithProperties('%(builddir)s')))
1055 f.addStep(buildbot.steps.shell.ShellCommand(
1056 name='rm.compiler-rt-sources-link',
Chris Matthews92ce8e22014-01-03 21:28:27 +00001057 command=['sudo', 'rm', '-rfv', 'llvm/projects/compiler-rt'],
David Deanf8b35442012-12-11 00:35:12 +00001058 haltOnFailure=False, description=['rm', 'compiler-rt sources link'],
1059 workdir=WithProperties('%(builddir)s')))
Michael Gottesman2db83142013-08-05 21:44:45 +00001060 # TODO: We used to use a symlink here but it seems to not work. I am trying
1061 # to get this builder to work so I am just going to copy it instead.
1062 f.addStep(buildbot.steps.shell.ShellCommand(
1063 name='rm.clang-tools-extra-source',
Chris Matthews92ce8e22014-01-03 21:28:27 +00001064 command=['sudo', 'rm', '-rfv', 'clang.src/tools/extra'],
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001065 haltOnFailure=True, workdir=WithProperties('%(builddir)s'),
Michael Gottesman2db83142013-08-05 21:44:45 +00001066 description=['rm', 'clang-tools-extra sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001067 f.addStep(buildbot.steps.shell.ShellCommand(
1068 name='rm.debuginfo-tests',
Chris Matthews92ce8e22014-01-03 21:28:27 +00001069 command=['sudo', 'rm', '-rfv', 'clang.src/test/debuginfo-tests'],
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001070 haltOnFailure=True, workdir=WithProperties('%(builddir)s'),
Michael Gottesmane92eb122013-09-08 01:58:27 +00001071 description=['rm', 'debuginfo-tests sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001072
David Deanf8b35442012-12-11 00:35:12 +00001073 # Pull sources.
Michael Gottesmandc771a02013-08-30 05:46:22 +00001074 f = phasedbuilderutils.SVNCleanupStep(f, 'llvm')
David Deanf8b35442012-12-11 00:35:12 +00001075 f.addStep(HostSVN(name='pull.llvm', mode='incremental', method='fresh',
1076 repourl='http://llvm.org/svn/llvm-project/llvm/trunk',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001077 retry=(60, 5), workdir='llvm', description='pull.llvm',
1078 alwaysUseLatest=False))
Michael Gottesmandc771a02013-08-30 05:46:22 +00001079 f = phasedbuilderutils.SVNCleanupStep(f, 'clang.src')
David Deanf8b35442012-12-11 00:35:12 +00001080 f.addStep(HostSVN(name='pull.clang', mode='incremental', method='fresh',
1081 repourl='http://llvm.org/svn/llvm-project/cfe/trunk',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001082 workdir='clang.src', retry=(60, 5),
David Deanf8b35442012-12-11 00:35:12 +00001083 description='pull.clang', alwaysUseLatest=False))
Michael Gottesmandc771a02013-08-30 05:46:22 +00001084 f = phasedbuilderutils.SVNCleanupStep(f, 'clang-tools-extra.src')
Michael Gottesman1dcf8f82013-03-28 06:20:57 +00001085 f.addStep(HostSVN(name='pull.clang-tools-extra', mode='incremental',
1086 method='fresh',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001087 repourl='http://llvm.org/svn/llvm-project/'
1088 'clang-tools-extra/trunk',
Michael Gottesman1dcf8f82013-03-28 06:20:57 +00001089 workdir='clang-tools-extra.src', alwaysUseLatest=False,
1090 retry=(60, 5), description='pull.clang-tools-extra'))
Michael Gottesmandc771a02013-08-30 05:46:22 +00001091 f = phasedbuilderutils.SVNCleanupStep(f, 'compiler-rt.src')
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001092 f.addStep(HostSVN(name='pull.compiler-rt', mode='incremental',
1093 method='fresh',
1094 repourl='http://llvm.org/svn/llvm-project/compiler-rt/'
1095 'trunk',
1096 workdir='compiler-rt.src', alwaysUseLatest=False,
1097 retry=(60, 5), description='pull.compiler-rt'))
Michael Gottesman13f82592013-09-08 01:54:43 +00001098 f = phasedbuilderutils.SVNCleanupStep(f, 'libcxx.src')
1099 f.addStep(HostSVN(name='pull.libcxx', mode='incremental',
1100 method='fresh',
1101 repourl='http://llvm.org/svn/llvm-project/libcxx/'
1102 'trunk',
1103 workdir='libcxx.src', alwaysUseLatest=False,
1104 retry=(60, 5), description='pull.libcxx'))
Michael Gottesmane92eb122013-09-08 01:58:27 +00001105 f = phasedbuilderutils.SVNCleanupStep(f, 'debuginfo-tests.src')
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001106 f.addStep(HostSVN(name='pull.debuginfo-tests', mode='incremental',
1107 method='fresh',
1108 repourl='http://llvm.org/svn/llvm-project/debuginfo-tests/'
1109 'trunk',
1110 workdir='debuginfo-tests.src', alwaysUseLatest=False,
1111 retry=(60, 5), description='pull.debuginfo-tests'))
1112
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001113 # Create symlinks to the clang compiler-rt sources inside the LLVM tree.
David Deanf8b35442012-12-11 00:35:12 +00001114 # We don't actually check out the sources there, because the SVN purge
1115 # would always remove them then.
1116 f.addStep(buildbot.steps.shell.ShellCommand(
1117 name='ln.clang-sources', haltOnFailure=True,
1118 command=['ln', '-sfv', '../../clang.src', 'clang'],
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001119 workdir='llvm/tools', description=['ln', 'clang sources']))
David Deanf8b35442012-12-11 00:35:12 +00001120 f.addStep(buildbot.steps.shell.ShellCommand(
1121 name='ln.compiler-rt-sources',
1122 command=['ln', '-sfv', '../../compiler-rt.src', 'compiler-rt'],
1123 haltOnFailure=True, workdir='llvm/projects',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001124 description=['ln', 'compiler-rt sources']))
Michael Gottesman4a68b872013-03-28 19:03:52 +00001125 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesman13f82592013-09-08 01:54:43 +00001126 name='ln.libcxx.sources',
1127 command=['ln', '-sfv', '../../libcxx.src', 'libcxx'],
1128 haltOnFailure=True, workdir='llvm/projects',
1129 description=['ln', 'libcxx sources']))
1130 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmanbcab1992013-03-28 18:37:21 +00001131 name='cp.clang-tools-extra-sources',
Michael Gottesman03495922013-03-28 18:40:44 +00001132 command=['cp', '-Rfv', '../../clang-tools-extra.src', 'extra'],
Michael Gottesman1dcf8f82013-03-28 06:20:57 +00001133 haltOnFailure=True, workdir='clang.src/tools',
Chris Matthewsecc0f442014-03-12 00:04:23 +00001134 description=['cp', 'clang-tools-extra sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001135 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmane92eb122013-09-08 01:58:27 +00001136 name='cp.debuginfo-tests.sources',
1137 command=['cp', '-Rfv', 'debuginfo-tests.src',
1138 'clang.src/test/debuginfo-tests'],
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001139 haltOnFailure=True, workdir=WithProperties('%(builddir)s'),
Michael Gottesmane92eb122013-09-08 01:58:27 +00001140 description=['cp', 'debuginfo-tests sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001141
David Deanf8b35442012-12-11 00:35:12 +00001142 # Clean the install directory.
1143 f.addStep(buildbot.steps.shell.ShellCommand(
Chris Matthews92ce8e22014-01-03 21:28:27 +00001144 name='rm.clang-install', command=['sudo', 'rm', '-rfv', 'clang-install'],
David Deanf8b35442012-12-11 00:35:12 +00001145 haltOnFailure=False, description=['rm dir', 'clang-install'],
1146 workdir=WithProperties('%(builddir)s')))
1147 # Construct the configure arguments.
1148 configure_args = ['../llvm/configure']
1149 configure_args.extend(config_options)
Galina Kistanova702eccb2013-08-22 00:09:17 +00001150 configure_args.extend(['--disable-bindings',
Michael Gottesman6f85f932014-06-27 23:49:58 +00001151 '--enable-keep-symbols',
Michael Gottesman0fd485a2014-08-02 01:42:51 +00001152 '--enable-targets=x86,x86_64,arm,aarch64'])
David Deanf8b35442012-12-11 00:35:12 +00001153 configure_args.append(
Michael Gottesman65d940f2013-03-13 21:51:16 +00001154 WithProperties('--prefix=%(builddir)s/clang-install'))
Michael Gottesmanca56e8f2013-03-06 22:27:38 +00001155
David Deanf8b35442012-12-11 00:35:12 +00001156 # If we are using a previously built compiler, download it and override CC
1157 # and CXX.
1158 if is_bootstrap:
Michael Gottesmana6b5be82013-06-28 21:57:20 +00001159 f = artifacts.GetCompilerArtifacts(f)
David Deanf8b35442012-12-11 00:35:12 +00001160 else:
Michael Gottesmandc771a02013-08-30 05:46:22 +00001161 f = phasedbuilderutils.GetLatestValidated(f)
David Deanf8b35442012-12-11 00:35:12 +00001162 cc_command = ['find', 'host-compiler', '-name', 'clang']
1163 f.addStep(buildbot.steps.shell.SetProperty(
1164 name='find.cc',
1165 command=cc_command,
Michael Gottesmandc771a02013-08-30 05:46:22 +00001166 extract_fn=phasedbuilderutils.find_cc,
David Deanf8b35442012-12-11 00:35:12 +00001167 workdir=WithProperties('%(builddir)s')))
1168 f.addStep(buildbot.steps.shell.ShellCommand(
1169 name='sanity.test', haltOnFailure=True,
1170 command=[WithProperties('%(builddir)s/%(cc_path)s'), '-v'],
1171 description=['sanity test']))
1172 configure_args.extend([
1173 WithProperties('CC=%(builddir)s/%(cc_path)s'),
1174 WithProperties('CXX=%(builddir)s/%(cc_path)s++')])
Michael Gottesman65d940f2013-03-13 21:51:16 +00001175
1176 # If we need to use lto, find liblto, add in proper flags here, etc.
1177 if use_lto:
Michael Gottesman01f0a622013-03-13 22:38:38 +00001178 liblto_command = ['find', WithProperties('%(builddir)s/host-compiler'),
1179 '-name', 'libLTO.dylib']
Michael Gottesman1da57ae2013-03-13 21:54:23 +00001180 f.addStep(buildbot.steps.shell.SetProperty(
Michael Gottesman65d940f2013-03-13 21:51:16 +00001181 name='find.liblto',
1182 command=liblto_command,
Michael Gottesmandc771a02013-08-30 05:46:22 +00001183 extract_fn=phasedbuilderutils.find_liblto,
Michael Gottesman65d940f2013-03-13 21:51:16 +00001184 workdir=WithProperties('%(builddir)s')))
1185 configure_args.append(
1186 '--with-extra-options=-flto -gline-tables-only')
1187
David Deanf8b35442012-12-11 00:35:12 +00001188 # Configure the LLVM build.
Michael Gottesmand97d8502013-04-04 07:57:31 +00001189 if incremental:
1190 # *NOTE* This is a temporary work around. I am eventually going to just
1191 # set up cmake/ninja but for now I am sticking with the make => I need
1192 # configure to run only after a failure so on success I have incremental
1193 # builds.
1194 f.addStep(buildbot.steps.shell.ShellCommand(
1195 name='configure.with.host', command=configure_args,
1196 haltOnFailure=True, description=['configure'],
1197 workdir=clang_build_dir,
1198 doStepIf=_did_last_build_fail))
1199 else:
1200 f.addStep(buildbot.steps.shell.ShellCommand(
1201 name='configure.with.host', command=configure_args,
1202 haltOnFailure=True, description=['configure'],
1203 workdir=clang_build_dir))
1204
David Deanf8b35442012-12-11 00:35:12 +00001205 # Build the compiler.
Michael Gottesman36778832013-09-08 01:37:35 +00001206 make_command = ['make', '-j', WithProperties('%(jobs)s'), 'VERBOSE=1']
Galina Kistanovabfb29d22013-05-09 23:53:24 +00001207 timeout = 40*60 # Normal timeout is 20 minutes.
Michael Gottesman65d940f2013-03-13 21:51:16 +00001208 if use_lto:
1209 make_command.append(WithProperties('DYLD_LIBRARY_PATH=%(liblto_path)s'))
Michael Gottesman2e7385c2013-08-12 17:57:27 +00001210 timeout = 240*60 # LTO timeout is 240 minutes.
Michael Gottesman65d940f2013-03-13 21:51:16 +00001211
David Deanf8b35442012-12-11 00:35:12 +00001212 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesman65d940f2013-03-13 21:51:16 +00001213 name='make', command=make_command,
Michael Gottesmanbab77ac2013-03-14 05:36:53 +00001214 haltOnFailure=True, description=['make'], workdir=clang_build_dir,
1215 timeout=timeout))
David Deanf8b35442012-12-11 00:35:12 +00001216 # Use make install-clang to produce minimal archive for use by downstream
1217 # builders.
1218 f.addStep(buildbot.steps.shell.ShellCommand(
1219 name='make.install-clang', haltOnFailure=True,
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001220 command=['make', 'install-clang', '-j',
1221 WithProperties('%(jobs)s'),
1222 'RC_SUPPORTED_ARCHS=armv7 i386 x86_64'],
David Deanf8b35442012-12-11 00:35:12 +00001223 description=['make install'], workdir=clang_build_dir))
1224 # Save artifacts of this build for use by other builders.
Michael Gottesmana6b5be82013-06-28 21:57:20 +00001225 f = artifacts.uploadArtifacts(f)
David Deanf8b35442012-12-11 00:35:12 +00001226 # Run the LLVM and Clang regression tests.
Michael Gottesmana9c32be2013-09-06 17:47:24 +00001227 cmd_str = r"""make VERBOSE=1 LIT_ARGS="-v --param run_long_tests=true --filter='^(?!.*debuginfo-tests)'" check-all"""
1228 f.addStep(lit_test_command.LitTestCommand(name='run.llvm.tests', haltOnFailure=True,
1229 command=cmd_str,
1230 description=['all', 'tests'],
1231 workdir=clang_build_dir))
1232 # Work around for lldb issue rdar://14929651
Chris Matthewsecc0f442014-03-12 00:04:23 +00001233 # The crazy filter regex is to remove static-member[2].cpp, which requires xcode5 or later.
1234 # radar://16295455 tracks the removal of this regex.
1235 cmd_str = r"""make VERBOSE=1 LIT_ARGS="-j 1 -v --param run_long_tests=true --filter='debuginfo-tests.(?!static-member)'" check-all"""
Michael Gottesman75382312013-09-08 02:15:08 +00001236 f.addStep(lit_test_command.LitTestCommand(name='run.llvm.debuginfo-tests', haltOnFailure=True,
Michael Gottesmane7dc31e2013-08-30 05:57:35 +00001237 command=cmd_str,
Michael Gottesmana6b5be82013-06-28 21:57:20 +00001238 description=['all', 'tests'],
1239 workdir=clang_build_dir))
David Deanf8b35442012-12-11 00:35:12 +00001240 return f