blob: d0da8db913ec6e7176331f154d23d5b19eab8bc7 [file] [log] [blame]
Daniel Dunbar235aa412009-07-18 07:16:15 +00001import buildbot
2import buildbot.process.factory
Renato Goline6c1b3b2015-07-01 15:52:22 +00003import copy
David Deanf8b35442012-12-11 00:35:12 +00004import os
5
Reid Kleckner25a26b02015-03-09 22:30:25 +00006from buildbot.process.properties import WithProperties, Property
David Blaikie8cbf62f2013-01-12 21:32:31 +00007from buildbot.steps.shell import Configure, ShellCommand, SetProperty
Daniel Dunbar44abe742009-07-19 01:59:03 +00008from buildbot.steps.shell import WarningCountingShellCommand
David Deanf8b35442012-12-11 00:35:12 +00009from buildbot.steps.source import SVN
Daniel Dunbar44abe742009-07-19 01:59:03 +000010from buildbot.steps.transfer import FileDownload
Michael Gottesmana6b5be82013-06-28 21:57:20 +000011
Michael Gottesman960bcfa2013-08-30 05:46:15 +000012import zorg.buildbot.util.artifacts as artifacts
Michael Gottesmana6b5be82013-06-28 21:57:20 +000013import zorg.buildbot.builders.Util as builders_util
Michael Gottesmandc771a02013-08-30 05:46:22 +000014import zorg.buildbot.util.phasedbuilderutils as phasedbuilderutils
Michael Gottesmana6b5be82013-06-28 21:57:20 +000015import zorg.buildbot.commands as commands
16import zorg.buildbot.commands.BatchFileDownload as batch_file_download
17import zorg.buildbot.commands.LitTestCommand as lit_test_command
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,
Galina Kistanovaf4d79352011-10-20 20:46:52 +000028 useTwoStage=False,
29 completely_clean=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +000030 make='make',
31 jobs="%(jobs)s",
32 stage1_config='Debug+Asserts',
33 stage2_config='Release+Asserts',
34 env={}, # Environmental variables for all steps.
35 extra_configure_args=[],
36 use_pty_in_tests=False,
Peter Collingbourned49ac282011-10-25 14:38:45 +000037 trunk_revision=None,
38 force_checkout=False,
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +000039 extra_clean_step=None,
David Blaikiea76da842012-08-13 22:24:46 +000040 checkout_compiler_rt=False,
41 run_gdb=False,
David Blaikiedad03d52012-11-16 22:37:12 +000042 run_modern_gdb=False,
Galina Kistanova10836402013-09-26 20:42:52 +000043 run_gcc=False,
Richard Smith02389162014-09-26 23:53:06 +000044 merge_functions=False,
45 cmake=None,
46 modules=False):
47 assert not modules or (cmake and useTwoStage), \
48 "modules build requires 2 stage cmake build for now"
49
Galina Kistanovaf4d79352011-10-20 20:46:52 +000050 # Prepare environmental variables. Set here all env we want everywhere.
51 merged_env = {
52 'TERM' : 'dumb' # Make sure Clang doesn't use color escape sequences.
53 }
54 if env is not None:
55 # Overwrite pre-set items with the given ones, so user can set anything.
56 merged_env.update(env)
David Blaikie2f7eb282012-08-24 18:37:00 +000057
Jonathan Roelofs62415e52015-02-28 00:03:17 +000058 llvm_srcdir = "llvm.src"
59 llvm_1_objdir = "llvm.obj"
60 llvm_1_installdir = "llvm.install.1"
61 llvm_2_objdir = "llvm.obj.2"
62 llvm_2_installdir = "llvm.install"
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000063
Daniel Dunbar235aa412009-07-18 07:16:15 +000064 f = buildbot.process.factory.BuildFactory()
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000065
66 # Determine the build directory.
67 f.addStep(buildbot.steps.shell.SetProperty(name="get_builddir",
68 command=["pwd"],
69 property="builddir",
70 description="set build dir",
Galina Kistanovaf4d79352011-10-20 20:46:52 +000071 workdir=".",
72 env=merged_env))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000073
Daniel Dunbar06b20f12010-04-08 18:29:38 +000074 # Blow away completely, if requested.
75 if completely_clean:
76 f.addStep(ShellCommand(name="rm-llvm.src",
77 command=["rm", "-rf", llvm_srcdir],
78 haltOnFailure=True,
79 description=["rm src dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +000080 workdir=".",
81 env=merged_env))
Daniel Dunbar06b20f12010-04-08 18:29:38 +000082
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000083 # Checkout sources.
Peter Collingbourned49ac282011-10-25 14:38:45 +000084 if trunk_revision:
85 # The SVN build step provides no mechanism to check out a specific revision
86 # based on a property, so just run the commands directly here.
87 svn_co = ['svn', 'checkout']
88 if force_checkout:
89 svn_co += ['--force']
90 svn_co += ['--revision', WithProperties(trunk_revision)]
91
92 svn_co_llvm = svn_co + \
93 [WithProperties('http://llvm.org/svn/llvm-project/llvm/trunk@%s' %
94 trunk_revision),
95 llvm_srcdir]
96 svn_co_clang = svn_co + \
97 [WithProperties('http://llvm.org/svn/llvm-project/cfe/trunk@%s' %
98 trunk_revision),
99 '%s/tools/clang' % llvm_srcdir]
David Blaikie845ae0d2012-08-10 00:51:38 +0000100 svn_co_clang_tools_extra = svn_co + \
101 [WithProperties('http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@%s' %
102 trunk_revision),
103 '%s/tools/clang/tools/extra' % llvm_srcdir]
Peter Collingbourned49ac282011-10-25 14:38:45 +0000104
105 f.addStep(ShellCommand(name='svn-llvm',
106 command=svn_co_llvm,
107 haltOnFailure=True,
108 workdir='.'))
109 f.addStep(ShellCommand(name='svn-clang',
110 command=svn_co_clang,
111 haltOnFailure=True,
112 workdir='.'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000113 f.addStep(ShellCommand(name='svn-clang-tools-extra',
114 command=svn_co_clang_tools_extra,
115 haltOnFailure=True,
116 workdir='.'))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000117 else:
118 f.addStep(SVN(name='svn-llvm',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000119 mode='update',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000120 baseURL='http://llvm.org/svn/llvm-project/llvm/',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000121 defaultBranch='trunk',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000122 workdir=llvm_srcdir))
123 f.addStep(SVN(name='svn-clang',
124 mode='update',
125 baseURL='http://llvm.org/svn/llvm-project/cfe/',
126 defaultBranch='trunk',
127 workdir='%s/tools/clang' % llvm_srcdir))
David Blaikie845ae0d2012-08-10 00:51:38 +0000128 f.addStep(SVN(name='svn-clang-tools-extra',
129 mode='update',
130 baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
131 defaultBranch='trunk',
132 workdir='%s/tools/clang/tools/extra' % llvm_srcdir))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000133 if checkout_compiler_rt:
134 f.addStep(SVN(name='svn-compiler-rt',
135 mode='update',
136 baseURL='http://llvm.org/svn/llvm-project/compiler-rt/',
137 defaultBranch='trunk',
138 workdir='%s/projects/compiler-rt' % llvm_srcdir))
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000139
Galina Kistanova10836402013-09-26 20:42:52 +0000140 # Revert and apply patch mergeFunctions in required
141 if merge_functions:
142 f.addStep(ShellCommand(name="revert_patch_MergeFunctions",
143 command=["svn", "-R", "revert", '.'],
144 haltOnFailure=True,
145 description=["revert patch MergeFunctions"],
146 workdir='%s/tools/clang' % llvm_srcdir,
147 env=merged_env))
148
149 if merge_functions:
150 f.addStep(ShellCommand(name="patch_MergeFunctions",
151 command=["patch", "-Np0", "-i", '../../utils/Misc/mergefunctions.clang.svn.patch'],
152 haltOnFailure=True,
153 description=["patch MergeFunctions"],
154 workdir='%s/tools/clang' % llvm_srcdir,
155 env=merged_env))
156
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000157 # Clean up llvm (stage 1); unless in-dir.
158 if clean and llvm_srcdir != llvm_1_objdir:
159 f.addStep(ShellCommand(name="rm-llvm.obj.stage1",
160 command=["rm", "-rf", llvm_1_objdir],
161 haltOnFailure=True,
162 description=["rm build dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000163 workdir=".",
164 env=merged_env))
Andrew Trick70fa9d22011-08-25 23:38:51 +0000165
David Blaikie8cbf62f2013-01-12 21:32:31 +0000166 if not clean:
Richard Smith02389162014-09-26 23:53:06 +0000167 if cmake:
168 expected_makefile = 'Makefile'
169 else:
170 expected_makefile = 'Makefile.config'
David Blaikie8cbf62f2013-01-12 21:32:31 +0000171 f.addStep(SetProperty(name="Makefile_isready",
172 workdir=llvm_1_objdir,
173 command=["sh", "-c",
Richard Smith02389162014-09-26 23:53:06 +0000174 "test -e %s && echo OK || echo Missing" % expected_makefile],
David Blaikie8cbf62f2013-01-12 21:32:31 +0000175 flunkOnFailure=False,
176 property="exists_Makefile"))
Richard Smith02389162014-09-26 23:53:06 +0000177
178 if not cmake:
179 # Force without llvm-gcc so we don't run afoul of Frontend test failures.
180 base_configure_args = [WithProperties("%%(builddir)s/%s/configure" % llvm_srcdir),
181 '--disable-bindings']
182 base_configure_args += extra_configure_args
183 if triple:
184 base_configure_args += ['--build=%s' % triple,
185 '--host=%s' % triple]
186 args = base_configure_args + [WithProperties("--prefix=%%(builddir)s/%s" % llvm_1_installdir)]
187 args += builders_util.getConfigArgs(stage1_config)
188
189 f.addStep(Configure(command=args,
190 workdir=llvm_1_objdir,
191 description=['configuring',stage1_config],
192 descriptionDone=['configure',stage1_config],
193 env=merged_env,
194 doStepIf=lambda step: step.build.getProperty("exists_Makefile") != "OK"))
195 else:
196 cmake_triple_arg = []
197 if triple:
198 cmake_triple_arg = ['-DLLVM_HOST_TRIPLE=%s' % triple]
199 f.addStep(ShellCommand(name='cmake',
200 command=[cmake,
201 '-DLLVM_BUILD_TESTS=ON',
202 '-DCMAKE_BUILD_TYPE=%s' % stage1_config] +
203 cmake_triple_arg +
204 extra_configure_args +
205 ["../" + llvm_srcdir],
206 description='cmake stage1',
207 workdir=llvm_1_objdir,
208 env=merged_env,
209 doStepIf=lambda step: step.build.getProperty("exists_Makefile") != "OK"))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000210
211 # Make clean if using in-dir builds.
212 if clean and llvm_srcdir == llvm_1_objdir:
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000213 f.addStep(WarningCountingShellCommand(name="clean-llvm",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000214 command=[make, "clean"],
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000215 haltOnFailure=True,
216 description="cleaning llvm",
217 descriptionDone="clean llvm",
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000218 workdir=llvm_1_objdir,
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000219 doStepIf=clean,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000220 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000221
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000222 if extra_clean_step:
223 f.addStep(extra_clean_step)
224
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000225 f.addStep(WarningCountingShellCommand(name="compile",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000226 command=['nice', '-n', '10',
227 make, WithProperties("-j%s" % jobs)],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000228 haltOnFailure=True,
David Blaikie05517332013-12-19 23:29:12 +0000229 flunkOnFailure=not run_gdb,
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000230 description=["compiling", stage1_config],
231 descriptionDone=["compile", stage1_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000232 workdir=llvm_1_objdir,
233 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000234
235 if examples:
236 f.addStep(WarningCountingShellCommand(name="compile.examples",
237 command=['nice', '-n', '10',
238 make, WithProperties("-j%s" % jobs),
239 "BUILD_EXAMPLES=1"],
240 haltOnFailure=True,
Richard Smith65e6f5d2014-09-25 18:18:35 +0000241 description=["compiling", stage1_config, "examples"],
Daniel Dunbar256fed42009-11-25 21:11:08 +0000242 descriptionDone=["compile", stage1_config, "examples"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000243 workdir=llvm_1_objdir,
244 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000245
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000246 clangTestArgs = '-v -j %s' % jobs
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000247 if valgrind:
Daniel Dunbar89184b92010-04-18 19:09:32 +0000248 clangTestArgs += ' --vg'
Daniel Dunbara1bebce2010-03-21 01:24:00 +0000249 if valgrindLeakCheck:
250 clangTestArgs += ' --vg-leak'
Nick Lewycky8d26e472011-08-27 21:18:56 +0000251 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 +0000252 extraTestDirs = ''
253 if run_cxx_tests:
254 extraTestDirs += '%(builddir)s/llvm/tools/clang/utils/C++Tests'
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000255 if test:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000256 f.addStep(lit_test_command.LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000257 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000258 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000259 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie05517332013-12-19 23:29:12 +0000260 flunkOnFailure=not run_gdb,
David Blaikie7e6f8a12012-08-31 20:46:27 +0000261 description=["checking"],
262 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000263 workdir=llvm_1_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000264 usePTY=use_pty_in_tests,
265 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000266
267 # Install llvm and clang.
Richard Smith02389162014-09-26 23:53:06 +0000268 if llvm_1_installdir and not cmake: # FIXME: install for cmake build
Daniel Dunbar9870de32010-03-28 22:25:31 +0000269 f.addStep(ShellCommand(name="rm-install.clang.stage1",
270 command=["rm", "-rf", llvm_1_installdir],
271 haltOnFailure=True,
272 description=["rm install dir", "clang"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000273 workdir=".",
274 env=merged_env))
Daniel Dunbar9870de32010-03-28 22:25:31 +0000275 f.addStep(WarningCountingShellCommand(name="install.clang.stage1",
276 command = ['nice', '-n', '10',
277 make, 'install-clang'],
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000278 haltOnFailure=True,
Daniel Dunbar9870de32010-03-28 22:25:31 +0000279 description=["install", "clang",
280 stage1_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000281 workdir=llvm_1_objdir,
282 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000283
David Blaikiedad03d52012-11-16 22:37:12 +0000284 if run_gdb or run_gcc or run_modern_gdb:
David Blaikiea76da842012-08-13 22:24:46 +0000285 ignores = getClangTestsIgnoresFromPath(os.path.expanduser('~/public/clang-tests'), 'clang-x86_64-darwin10')
286 install_prefix = "%%(builddir)s/%s" % llvm_1_installdir
287 if run_gdb:
288 addClangGDBTests(f, ignores, install_prefix)
David Blaikiedad03d52012-11-16 22:37:12 +0000289 if run_modern_gdb:
David Blaikie41d09c32013-01-02 21:11:09 +0000290 addModernClangGDBTests(f, jobs, install_prefix)
David Blaikiea76da842012-08-13 22:24:46 +0000291 if run_gcc:
292 addClangGCCTests(f, ignores, install_prefix)
293
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000294 if not useTwoStage:
Daniel Dunbardedf6572010-11-13 00:23:34 +0000295 if package_dst:
296 name = WithProperties(
297 "%(builddir)s/" + llvm_1_objdir +
298 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
299 f.addStep(ShellCommand(name='pkg.tar',
300 description="tar root",
301 command=["tar", "zcvf", name, "./"],
302 workdir=llvm_1_installdir,
303 warnOnFailure=True,
304 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000305 haltOnFailure=False,
306 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000307 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000308 description="upload root",
Daniel Dunbardedf6572010-11-13 00:23:34 +0000309 command=["scp", name,
310 WithProperties(
311 package_dst + "/%(buildername)s")],
312 workdir=".",
313 warnOnFailure=True,
314 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000315 haltOnFailure=False,
316 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000317
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000318 return f
319
320 # Clean up llvm (stage 2).
Richard Smith02389162014-09-26 23:53:06 +0000321 #
322 # FIXME: It does not make much sense to skip this for a bootstrap builder.
323 # Check whether there is any reason to skip cleaning here and if not, remove
324 # this condition.
325 if clean or cmake:
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000326 f.addStep(ShellCommand(name="rm-llvm.obj.stage2",
327 command=["rm", "-rf", llvm_2_objdir],
328 haltOnFailure=True,
329 description=["rm build dir", "llvm", "(stage 2)"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000330 workdir=".",
331 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000332
333 # Configure llvm (stage 2).
Richard Smith02389162014-09-26 23:53:06 +0000334 if not cmake:
335 args = base_configure_args + [WithProperties("--prefix=%(builddir)s/" + llvm_2_installdir)]
336 args += builders_util.getConfigArgs(stage2_config)
337 local_env = dict(merged_env)
338 local_env.update({
339 'CC' : WithProperties("%%(builddir)s/%s/bin/clang" % llvm_1_installdir),
340 'CXX' : WithProperties("%%(builddir)s/%s/bin/clang++" % llvm_1_installdir)})
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000341
Richard Smith02389162014-09-26 23:53:06 +0000342 f.addStep(Configure(name="configure.llvm.stage2",
343 command=args,
344 haltOnFailure=True,
345 workdir=llvm_2_objdir,
346 description=["configure", "llvm", "(stage 2)",
347 stage2_config],
348 env=local_env))
349 else:
350 c_flags = ''
351 cxx_flags = ''
352 extra_args = []
353 if modules:
354 c_flags += '-fmodules-cache-path=%%(builddir)s/%s/module-cache' % llvm_2_objdir
355 # Modules requires libc++ for now (we don't have a module map for libstdc++ yet).
356 cxx_flags += '-stdlib=libc++'
357 extra_args = ['-DLLVM_ENABLE_MODULES=1']
358
359 f.addStep(ShellCommand(name='cmake',
360 command=[cmake] + extra_args + [
361 '-DLLVM_BUILD_TESTS=ON',
362 WithProperties('-DCMAKE_C_COMPILER=%%(builddir)s/%s/bin/clang' % llvm_1_objdir), # FIXME use installdir
363 WithProperties('-DCMAKE_CXX_COMPILER=%%(builddir)s/%s/bin/clang++' % llvm_1_objdir),
364 '-DCMAKE_BUILD_TYPE=%s' % stage2_config,
365 WithProperties('-DCMAKE_C_FLAGS=%s' % c_flags),
366 WithProperties('-DCMAKE_CXX_FLAGS=%s %s' % (c_flags, cxx_flags)),
367 "../" + llvm_srcdir],
368 description='cmake stage2',
369 workdir=llvm_2_objdir,
370 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000371
Richard Smith35c28622015-03-26 00:18:15 +0000372 if modules:
373 f.addStep(WarningCountingShellCommand(name="compile.llvm.stage2.intrinsics_gen",
374 command=['nice', '-n', '10',
375 make, "intrinsics_gen", WithProperties("-j%s" % jobs)],
376 haltOnFailure=True,
377 description=["compiling", "(stage 2 intrinsics.gen)",
378 stage2_config],
379 descriptionDone=["compile", "(stage 2 intrinsics.gen)",
380 stage2_config],
381 workdir=llvm_2_objdir,
382 env=merged_env))
383
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000384 # Build llvm (stage 2).
385 f.addStep(WarningCountingShellCommand(name="compile.llvm.stage2",
386 command=['nice', '-n', '10',
387 make, WithProperties("-j%s" % jobs)],
388 haltOnFailure=True,
389 description=["compiling", "(stage 2)",
390 stage2_config],
391 descriptionDone=["compile", "(stage 2)",
392 stage2_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000393 workdir=llvm_2_objdir,
394 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000395
396 if test:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000397 f.addStep(lit_test_command.LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000398 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000399 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000400 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie7e6f8a12012-08-31 20:46:27 +0000401 description=["checking"],
402 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000403 workdir=llvm_2_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000404 usePTY=use_pty_in_tests,
405 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000406
Richard Smith02389162014-09-26 23:53:06 +0000407 if llvm_2_installdir and not cmake: # FIXME: install for cmake build
408 # Install clang (stage 2).
409 f.addStep(ShellCommand(name="rm-install.clang.stage2",
410 command=["rm", "-rf", llvm_2_installdir],
411 haltOnFailure=True,
412 description=["rm install dir", "clang"],
413 workdir=".",
414 env=merged_env))
415 f.addStep(WarningCountingShellCommand(name="install.clang.stage2",
416 command = ['nice', '-n', '10',
417 make, 'install-clang'],
418 haltOnFailure=True,
419 description=["install", "clang",
420 "(stage 2)"],
421 workdir=llvm_2_objdir,
422 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000423
424 if package_dst:
425 name = WithProperties(
426 "%(builddir)s/" + llvm_2_objdir +
427 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
428 f.addStep(ShellCommand(name='pkg.tar',
429 description="tar root",
430 command=["tar", "zcvf", name, "./"],
431 workdir=llvm_2_installdir,
432 warnOnFailure=True,
433 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000434 haltOnFailure=False,
435 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000436 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000437 description="upload root",
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000438 command=["scp", name,
439 WithProperties(
440 package_dst + "/%(buildername)s")],
441 workdir=".",
442 warnOnFailure=True,
443 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000444 haltOnFailure=False,
445 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000446
Daniel Dunbar235aa412009-07-18 07:16:15 +0000447 return f
Daniel Dunbar44abe742009-07-19 01:59:03 +0000448
Renato Golin61aed7f2015-06-17 19:12:50 +0000449def addSVNUpdateSteps(f,
450 checkout_clang_tools_extra,
451 checkout_compiler_rt,
452 checkout_test_suite):
Renato Goline402f582014-09-04 19:25:24 +0000453 # We *must* checkout at least Clang+LLVM
454 f.addStep(SVN(name='svn-llvm',
455 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
456 defaultBranch='trunk',
457 workdir='llvm'))
458 f.addStep(SVN(name='svn-clang',
459 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
460 defaultBranch='trunk',
461 workdir='llvm/tools/clang'))
462
463 # Extra stuff that will be built/tested
464 if checkout_clang_tools_extra:
465 f.addStep(SVN(name='svn-clang-tools-extra',
466 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
467 defaultBranch='trunk',
468 workdir='llvm/tools/clang/tools/extra'))
469 if checkout_compiler_rt:
470 f.addStep(SVN(name='svn-compiler-rt',
471 mode='update', baseURL='http://llvm.org/svn/llvm-project/compiler-rt/',
472 defaultBranch='trunk',
473 workdir='llvm/projects/compiler-rt'))
Renato Golin61aed7f2015-06-17 19:12:50 +0000474 if checkout_test_suite:
475 f.addStep(SVN(name='svn-lnt',
476 mode='update', baseURL='http://llvm.org/svn/llvm-project/lnt/',
477 defaultBranch='trunk',
478 workdir='test/lnt'))
479 f.addStep(SVN(name='svn-test-suite',
480 mode='update', baseURL='http://llvm.org/svn/llvm-project/test-suite/',
481 defaultBranch='trunk',
482 workdir='test/test-suite'))
Renato Goline402f582014-09-04 19:25:24 +0000483
Reid Kleckner25a26b02015-03-09 22:30:25 +0000484
485def getClangCMakeBuildFactory(
486 clean=True,
487 test=True,
488 cmake='cmake',
489 jobs=None,
490
491 # VS tools environment variable if using MSVC. For example,
492 # %VS120COMNTOOLS% selects the 2013 toolchain.
493 vs=None,
494 vs_target_arch='x86',
495
496 # Multi-stage compilation
497 useTwoStage=False,
498 testStage1=True,
499 stage1_config='Release',
500 stage2_config='Release',
501
Renato Golin61aed7f2015-06-17 19:12:50 +0000502 # Test-suite
503 runTestSuite=False,
504 nt_flags=[],
505 submitURL=None,
506 testerName=None,
507
Reid Kleckner25a26b02015-03-09 22:30:25 +0000508 # Environmental variables for all steps.
509 env={},
510 extra_cmake_args=[],
511
512 # Extra repositories
513 checkout_clang_tools_extra=True,
514 checkout_compiler_rt=True):
515
516 ############# PREPARING
517 f = buildbot.process.factory.BuildFactory()
518
Renato Golin61aed7f2015-06-17 19:12:50 +0000519 addSVNUpdateSteps(f,
520 checkout_clang_tools_extra=checkout_clang_tools_extra,
521 checkout_compiler_rt=checkout_compiler_rt,
522 checkout_test_suite=runTestSuite)
Reid Kleckner25a26b02015-03-09 22:30:25 +0000523
Renato Goline402f582014-09-04 19:25:24 +0000524 # If jobs not defined, Ninja will choose a suitable value
Renato Golincc83db32015-06-17 19:23:40 +0000525 jobs_cmd = []
526 lit_args = "'-v"
Renato Goline402f582014-09-04 19:25:24 +0000527 if jobs is not None:
Renato Golincc83db32015-06-17 19:23:40 +0000528 jobs_cmd = ["-j"+str(jobs)]
529 lit_args += " -j"+str(jobs)+"'"
Renato Goline402f582014-09-04 19:25:24 +0000530 else:
Renato Golincc83db32015-06-17 19:23:40 +0000531 lit_args += "'"
532 ninja_cmd = ['ninja'] + jobs_cmd
533 ninja_install_cmd = ['ninja', 'install'] + jobs_cmd
534 ninja_check_cmd = ['ninja', 'check-all'] + jobs_cmd
Reid Kleckner25a26b02015-03-09 22:30:25 +0000535 check_build_cmd = ["sh", "-c",
536 "test -e build.ninja && echo OK || echo Missing"]
537 if vs:
538 check_build_cmd = ["cmd", "/c", "if exist build.ninja (echo OK) " +
539 " else (echo Missing & exit 1)"]
Renato Goline402f582014-09-04 19:25:24 +0000540
541 # Global configurations
Renato Golincc83db32015-06-17 19:23:40 +0000542 stage1_build = 'stage1'
543 stage1_install = 'stage1.install'
544 stage2_build = 'stage2'
545 stage2_install = 'stage2.install'
Renato Goline402f582014-09-04 19:25:24 +0000546
Reid Kleckner25a26b02015-03-09 22:30:25 +0000547 # Set up VS environment, if appropriate.
548 if vs:
549 f.addStep(SetProperty(
550 command=builders_util.getVisualStudioEnvironment(vs, vs_target_arch),
551 extract_fn=builders_util.extractSlaveEnvironment))
552 assert not env, "Can't have custom builder env vars with VS"
553 env = Property('slave_env')
554
555
Renato Goline402f582014-09-04 19:25:24 +0000556 ############# CLEANING
557 if clean:
558 f.addStep(ShellCommand(name='clean stage 1',
559 command=['rm','-rf',stage1_build],
560 warnOnFailure=True,
561 description='cleaning stage 1',
562 descriptionDone='clean',
563 workdir='.',
564 env=env))
565 else:
566 f.addStep(SetProperty(name="check ninja files 1",
567 workdir=stage1_build,
Reid Kleckner25a26b02015-03-09 22:30:25 +0000568 command=check_build_cmd,
Renato Goline402f582014-09-04 19:25:24 +0000569 flunkOnFailure=False,
570 property="exists_ninja_1"))
571
572
573 ############# STAGE 1
574 f.addStep(ShellCommand(name='cmake stage 1',
575 command=[cmake, "-G", "Ninja", "../llvm",
576 "-DCMAKE_BUILD_TYPE="+stage1_config,
577 "-DLLVM_ENABLE_ASSERTIONS=True",
578 "-DLLVM_LIT_ARGS="+lit_args,
579 "-DCMAKE_INSTALL_PREFIX=../"+stage1_install]
580 + extra_cmake_args,
581 haltOnFailure=True,
582 description='cmake stage 1',
583 workdir=stage1_build,
584 doStepIf=lambda step: step.build.getProperty("exists_ninja_1") != "OK",
585 env=env))
586
587 f.addStep(WarningCountingShellCommand(name='build stage 1',
588 command=ninja_cmd,
589 haltOnFailure=True,
590 description='ninja all',
591 workdir=stage1_build,
592 env=env))
593
594 if test and testStage1:
Renato Golincfbd5702014-09-06 19:09:16 +0000595 f.addStep(lit_test_command.LitTestCommand(name='ninja check 1',
596 command=ninja_check_cmd,
Renato Golin61aed7f2015-06-17 19:12:50 +0000597 haltOnFailure=not runTestSuite,
Renato Golincfbd5702014-09-06 19:09:16 +0000598 description=["checking stage 1"],
599 descriptionDone=["stage 1 checked"],
600 workdir=stage1_build,
601 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000602
Renato Golin61aed7f2015-06-17 19:12:50 +0000603 if useTwoStage or runTestSuite:
604 f.addStep(ShellCommand(name='install stage 1',
605 command=ninja_install_cmd,
606 description='ninja install',
607 workdir=stage1_build,
Renato Goline402f582014-09-04 19:25:24 +0000608 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000609
Reid Kleckner25a26b02015-03-09 22:30:25 +0000610 # Compute the cmake define flag to set the C and C++ compiler to clang. Use
611 # clang-cl if we used MSVC for stage1.
612 if not vs:
613 cc = 'clang'
614 cxx = 'clang++'
615 else:
616 cc = 'clang-cl.exe'
617 cxx = 'clang-cl.exe'
618
Reid Kleckner25a26b02015-03-09 22:30:25 +0000619
Renato Golin61aed7f2015-06-17 19:12:50 +0000620 ############# STAGE 2
621 if useTwoStage:
622 if clean:
623 f.addStep(ShellCommand(name='clean stage 2',
624 command=['rm','-rf',stage2_build],
625 warnOnFailure=True,
626 description='cleaning stage 2',
627 descriptionDone='clean',
628 workdir='.',
629 env=env))
630 else:
631 f.addStep(SetProperty(name="check ninja files 2",
632 workdir=stage2_build,
633 command=check_build_cmd,
634 flunkOnFailure=False,
635 property="exists_ninja_2"))
Reid Kleckner25a26b02015-03-09 22:30:25 +0000636
Renato Golin61aed7f2015-06-17 19:12:50 +0000637 # Set the compiler using the CC and CXX environment variables to work around
638 # backslash string escaping bugs somewhere between buildbot and cmake. The
639 # env.exe helper is required to run the tests, so hopefully it's already on
640 # PATH.
641 cmake_cmd2 = ['env',
642 WithProperties('CC=%(workdir)s/'+stage1_install+'/bin/'+cc),
643 WithProperties('CXX=%(workdir)s/'+stage1_install+'/bin/'+cxx),
644 cmake, "-G", "Ninja", "../llvm",
645 "-DCMAKE_BUILD_TYPE="+stage2_config,
646 "-DLLVM_ENABLE_ASSERTIONS=True",
647 "-DLLVM_LIT_ARGS="+lit_args,
648 "-DCMAKE_INSTALL_PREFIX=../"+stage2_install] + extra_cmake_args
Reid Kleckner25a26b02015-03-09 22:30:25 +0000649
Renato Golin61aed7f2015-06-17 19:12:50 +0000650 f.addStep(ShellCommand(name='cmake stage 2',
651 command=cmake_cmd2,
652 haltOnFailure=True,
653 description='cmake stage 2',
654 workdir=stage2_build,
655 doStepIf=lambda step: step.build.getProperty("exists_ninja_2") != "OK",
656 env=env))
657
658 f.addStep(WarningCountingShellCommand(name='build stage 2',
659 command=ninja_cmd,
660 haltOnFailure=True,
661 description='ninja all',
662 workdir=stage2_build,
663 env=env))
664
665 if test:
666 f.addStep(lit_test_command.LitTestCommand(name='ninja check 2',
667 command=ninja_check_cmd,
668 haltOnFailure=not runTestSuite,
669 description=["checking stage 2"],
670 descriptionDone=["stage 2 checked"],
671 workdir=stage2_build,
672 env=env))
673
674 ############# TEST SUITE
675 ## Test-Suite (stage 2 if built, stage 1 otherwise)
676 if runTestSuite:
677 compiler_path = stage1_install
678 if useTwoStage:
679 compiler_path=stage2_install
680 f.addStep(ShellCommand(name='install stage 2',
681 command=ninja_install_cmd,
682 description='ninja install 2',
Renato Golincfbd5702014-09-06 19:09:16 +0000683 workdir=stage2_build,
684 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000685
Renato Golin61aed7f2015-06-17 19:12:50 +0000686 # Get generated python, lnt
687 python = WithProperties('%(workdir)s/test/sandbox/bin/python')
688 lnt = WithProperties('%(workdir)s/test/sandbox/bin/lnt')
689 lnt_setup = WithProperties('%(workdir)s/test/lnt/setup.py')
690
691 # Paths
692 sandbox = WithProperties('%(workdir)s/test/sandbox')
693 test_suite_dir = WithProperties('%(workdir)s/test/test-suite')
694
695 # Get latest built Clang (stage1 or stage2)
696 cc = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cc)
697 cxx = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cxx)
698
699 # LNT Command line
700 if jobs is None:
701 jobs = 1
702 test_suite_cmd = [python, lnt, 'runtest', 'nt',
703 '-j'+str(jobs),
704 '--no-timestamp',
705 '--sandbox', sandbox,
706 '--test-suite', test_suite_dir,
707 '--cc', cc,
708 '--cxx', cxx]
709 # Append any option provided by the user
710 test_suite_cmd.extend(nt_flags)
711 # Only submit if a URL has been specified
712 if submitURL is not None:
713 if not isinstance(submitURL, list):
714 submitURL = [submitURL]
715 for url in submitURL:
716 test_suite_cmd.extend(['--submit', url])
717 if testerName:
718 test_suite_cmd.extend(['--no-machdep-info', testerName])
719 # CC and CXX are needed as env for build-tools
Renato Goline6c1b3b2015-07-01 15:52:22 +0000720 test_suite_env = copy.deepcopy(env)
Renato Golin61aed7f2015-06-17 19:12:50 +0000721 test_suite_env['CC'] = cc
722 test_suite_env['CXX'] = cxx
723
724 # Steps to prepare, build and run LNT
725 f.addStep(ShellCommand(name='clean sandbox',
726 command=['rm', '-rf', 'sandbox'],
727 haltOnFailure=True,
728 description='removing sandbox directory',
729 workdir='test',
730 env=env))
731 f.addStep(ShellCommand(name='recreate sandbox',
732 command=['virtualenv', 'sandbox'],
733 haltOnFailure=True,
734 description='recreating sandbox',
735 workdir='test',
736 env=env))
737 f.addStep(ShellCommand(name='setup lit',
738 command=[python, lnt_setup, 'develop'],
739 haltOnFailure=True,
740 description='setting up LNT in sandbox',
741 workdir='test/sandbox',
742 env=env))
743 f.addStep(commands.LitTestCommand.LitTestCommand(
744 name='test-suite',
745 command=test_suite_cmd,
746 haltOnFailure=True,
747 description=['running the test suite'],
748 workdir='test/sandbox',
749 logfiles={'configure.log' : 'build/configure.log',
750 'build-tools.log' : 'build/build-tools.log',
751 'test.log' : 'build/test.log',
752 'report.json' : 'build/report.json'},
753 env=test_suite_env))
754
Renato Goline402f582014-09-04 19:25:24 +0000755 return f
756
Daniel Dunbarc51a59e2010-09-23 14:57:45 +0000757def getClangMSVCBuildFactory(update=True, clean=True, vcDrive='c', jobs=1, cmake=r"cmake"):
Daniel Dunbar44abe742009-07-19 01:59:03 +0000758 f = buildbot.process.factory.BuildFactory()
759
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000760 if update:
Daniel Dunbar44abe742009-07-19 01:59:03 +0000761 f.addStep(SVN(name='svn-llvm',
762 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
763 defaultBranch='trunk',
764 workdir='llvm'))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000765 f.addStep(SVN(name='svn-clang',
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000766 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
Daniel Dunbar44abe742009-07-19 01:59:03 +0000767 defaultBranch='trunk',
768 workdir='llvm/tools/clang'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000769 f.addStep(SVN(name='svn-clang-tools-extra',
770 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
771 defaultBranch='trunk',
772 workdir='llvm/tools/clang/tools/extra'))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000773
774 # Full & fast clean.
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000775 if clean:
Daniel Dunbar44abe742009-07-19 01:59:03 +0000776 f.addStep(ShellCommand(name='clean-1',
777 command=['del','/s/q','build'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000778 warnOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000779 description='cleaning',
780 descriptionDone='clean',
781 workdir='llvm'))
782 f.addStep(ShellCommand(name='clean-2',
783 command=['rmdir','/s/q','build'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000784 warnOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000785 description='cleaning',
786 descriptionDone='clean',
787 workdir='llvm'))
788
789 # Create the project files.
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000790
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000791 # Use batch files instead of ShellCommand directly, Windows quoting is
792 # borked. FIXME: See buildbot ticket #595 and buildbot ticket #377.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000793 f.addStep(batch_file_download.BatchFileDownload(name='cmakegen',
Daniel Dunbar06b20f12010-04-08 18:29:38 +0000794 command=[cmake,
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000795 "-DLLVM_TARGETS_TO_BUILD:=X86",
Daniel Dunbar1ddedce2010-09-24 19:57:34 +0000796 "-DLLVM_INCLUDE_EXAMPLES:=OFF",
797 "-DLLVM_INCLUDE_TESTS:=OFF",
798 "-DLLVM_TARGETS_TO_BUILD:=X86",
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000799 "-G",
800 "Visual Studio 9 2008",
801 ".."],
802 workdir="llvm\\build"))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000803 f.addStep(ShellCommand(name='cmake',
804 command=['cmakegen.bat'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000805 haltOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000806 description='cmake gen',
807 workdir='llvm\\build'))
808
809 # Build it.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000810 f.addStep(batch_file_download.BatchFileDownload(name='vcbuild',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000811 command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""",
812 "/M%d" % jobs,
813 "LLVM.sln",
814 "Debug|Win32"],
815 workdir="llvm\\build"))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000816 f.addStep(WarningCountingShellCommand(name='vcbuild',
817 command=['vcbuild.bat'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000818 haltOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000819 description='vcbuild',
820 workdir='llvm\\build',
821 warningPattern=" warning C.*:"))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000822
823 # Build clang-test project.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000824 f.addStep(batch_file_download.BatchFileDownload(name='vcbuild_test',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000825 command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""",
826 "clang-test.vcproj",
827 "Debug|Win32"],
828 workdir="llvm\\build\\tools\\clang\\test"))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000829 f.addStep(lit_test_command.LitTestCommand(name='test-clang',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000830 command=["vcbuild_test.bat"],
831 workdir="llvm\\build\\tools\\clang\\test"))
832
Daniel Dunbar44abe742009-07-19 01:59:03 +0000833 return f
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000834
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000835# Builds on Windows using CMake, MinGW(32|64), and no Microsoft tools.
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000836def getClangMinGWBuildFactory(update=True, clean=True, jobs=6, cmake=r"cmake"):
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000837 f = buildbot.process.factory.BuildFactory()
838
839 if update:
840 f.addStep(SVN(name='svn-llvm',
841 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
842 defaultBranch='trunk',
843 workdir='llvm'))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000844 f.addStep(SVN(name='svn-clang',
845 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
846 defaultBranch='trunk',
847 workdir='llvm/tools/clang'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000848 f.addStep(SVN(name='svn-clang-tools-extra',
849 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
850 defaultBranch='trunk',
851 workdir='llvm/tools/clang/tools/extra'))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000852
853 # Full & fast clean.
854 if clean:
855 # note: This command is redundant as the next command removes everything
856 f.addStep(ShellCommand(name='clean-1',
857 command=['del','/s/q','build'],
858 warnOnFailure=True,
859 description='cleaning',
860 descriptionDone='clean',
861 workdir='llvm'))
862 f.addStep(ShellCommand(name='clean-2',
863 command=['rmdir','/s/q','build'],
864 warnOnFailure=True,
865 description='cleaning',
866 descriptionDone='clean',
867 workdir='llvm'))
868
869 # Create the Makefiles.
870
871 # Use batch files instead of ShellCommand directly, Windows quoting is
872 # borked. FIXME: See buildbot ticket #595 and buildbot ticket #377.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000873 f.addStep(batch_file_download.BatchFileDownload(name='cmakegen',
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000874 command=[cmake,
875 "-DLLVM_TARGETS_TO_BUILD:=X86",
876 "-DLLVM_INCLUDE_EXAMPLES:=OFF",
877 "-DLLVM_INCLUDE_TESTS:=OFF",
878 "-DLLVM_TARGETS_TO_BUILD:=X86",
879 "-G",
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000880 "Ninja",
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000881 ".."],
882 workdir="llvm\\build"))
883 f.addStep(ShellCommand(name='cmake',
884 command=['cmakegen.bat'],
885 haltOnFailure=True,
886 description='cmake gen',
887 workdir='llvm\\build'))
888
889 # Build it.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000890 f.addStep(batch_file_download.BatchFileDownload(name='makeall',
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000891 command=["ninja", "-j", "%d" % jobs],
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000892 haltOnFailure=True,
893 workdir='llvm\\build'))
894
895 f.addStep(WarningCountingShellCommand(name='makeall',
896 command=['makeall.bat'],
897 haltOnFailure=True,
898 description='makeall',
899 workdir='llvm\\build'))
900
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000901 # Build global check project (make check) (sources not checked out...).
902 if 0:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000903 f.addStep(batch_file_download.BatchFileDownload(name='makecheck',
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000904 command=["ninja", "check"],
905 workdir='llvm\\build'))
906 f.addStep(WarningCountingShellCommand(name='check',
907 command=['makecheck.bat'],
908 description='make check',
909 workdir='llvm\\build'))
Galina Kistanova049d76c2012-06-09 00:56:05 +0000910
911 # Build clang-test project (make clang-test).
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000912 f.addStep(batch_file_download.BatchFileDownload(name='maketest',
913 command=["ninja", "clang-test"],
914 workdir="llvm\\build"))
915 f.addStep(lit_test_command.LitTestCommand(name='clang-test',
916 command=["maketest.bat"],
917 workdir="llvm\\build"))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000918 return f
919
Daniel Dunbar7363d032011-02-27 03:22:35 +0000920def addClangGCCTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install",
921 languages = ('gcc', 'g++', 'objc', 'obj-c++')):
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000922 make_vars = [WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000923 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000924 WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000925 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
David Blaikie05517332013-12-19 23:29:12 +0000926 f.addStep(SVN(name='svn-clang-gcc-tests', mode='update',
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000927 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
928 defaultBranch='trunk', workdir='clang-tests'))
929 gcc_dg_ignores = ignores.get('gcc-4_2-testsuite', {})
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000930 for lang in languages:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000931 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000932 name='test-gcc-4_2-testsuite-%s' % lang,
933 command=["make", "-k", "check-%s" % lang] + make_vars,
934 description="gcc-4_2-testsuite (%s)" % lang,
935 workdir='clang-tests/gcc-4_2-testsuite',
David Dean2bd0c3a2011-10-18 16:36:28 +0000936 logfiles={ 'dg.sum' : 'obj/%s/%s.sum' % (lang, lang),
937 '%s.log' % lang : 'obj/%s/%s.log' % (lang, lang)},
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000938 ignore=gcc_dg_ignores.get(lang, [])))
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000939
Daniel Dunbar7363d032011-02-27 03:22:35 +0000940def addClangGDBTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install"):
941 make_vars = [WithProperties(
942 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
943 WithProperties(
944 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
David Blaikie05517332013-12-19 23:29:12 +0000945 f.addStep(SVN(name='svn-clang-gdb-tests', mode='update',
Daniel Dunbar7363d032011-02-27 03:22:35 +0000946 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
947 defaultBranch='trunk', workdir='clang-tests'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000948 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar7363d032011-02-27 03:22:35 +0000949 name='test-gdb-1472-testsuite',
950 command=["make", "-k", "check"] + make_vars,
951 description="gdb-1472-testsuite",
952 workdir='clang-tests/gdb-1472-testsuite',
David Blaikie7ec695f2012-10-09 22:17:09 +0000953 logfiles={ 'dg.sum' : 'obj/filtered.gdb.sum',
David Blaikie624f4392012-11-05 22:34:35 +0000954 'gdb.log' : 'obj/gdb.log' }))
Daniel Dunbar7363d032011-02-27 03:22:35 +0000955
David Blaikie41d09c32013-01-02 21:11:09 +0000956def addModernClangGDBTests(f, jobs, install_prefix):
David Blaikie1bc5c372012-12-05 05:29:12 +0000957 make_vars = [WithProperties('RUNTESTFLAGS=CC_FOR_TARGET=\'{0}/bin/clang\' '
958 'CXX_FOR_TARGET=\'{0}/bin/clang++\' '
David Blaikie759bb752013-04-18 23:13:11 +0000959 'CFLAGS_FOR_TARGET=\'-w -fno-limit-debug-info\''
David Blaikief89877b2013-01-29 23:46:26 +0000960 .format(install_prefix))]
David Blaikie05517332013-12-19 23:29:12 +0000961 f.addStep(SVN(name='svn-clang-modern-gdb-tests', mode='update',
David Blaikief3f300b2012-11-17 01:13:41 +0000962 svnurl='http://llvm.org/svn/llvm-project/clang-tests-external/trunk/gdb/7.5',
David Blaikiedad03d52012-11-16 22:37:12 +0000963 workdir='clang-tests/src'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000964 f.addStep(Configure(command='../src/configure',
David Blaikief3f300b2012-11-17 01:13:41 +0000965 workdir='clang-tests/build/'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000966 f.addStep(WarningCountingShellCommand(name='gdb-75-build',
967 command=['make', WithProperties('-j%s' % jobs)],
968 haltOnFailure=True,
969 workdir='clang-tests/build'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000970 f.addStep(commands.DejaGNUCommand.DejaGNUCommand(
David Blaikiedad03d52012-11-16 22:37:12 +0000971 name='gdb-75-check',
David Blaikieb83bfdf2012-12-05 04:33:42 +0000972 command=['make', '-k', WithProperties('-j%s' % jobs), 'check'] + make_vars,
David Blaikiedad03d52012-11-16 22:37:12 +0000973 workdir='clang-tests/build',
David Blaikie1bc5c372012-12-05 05:29:12 +0000974 logfiles={'dg.sum':'gdb/testsuite/gdb.sum',
975 'gdb.log':'gdb/testsuite/gdb.log'}))
David Blaikiedad03d52012-11-16 22:37:12 +0000976
977
978
Daniel Dunbar7363d032011-02-27 03:22:35 +0000979# FIXME: Deprecated.
980addClangTests = addClangGCCTests
981
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000982def getClangTestsIgnoresFromPath(path, key):
983 def readList(path):
984 if not os.path.exists(path):
985 return []
986
987 f = open(path)
988 lines = [ln.strip() for ln in f]
989 f.close()
990 return lines
991
992 ignores = {}
993
994 gcc_dg_ignores = {}
995 for lang in ('gcc', 'g++', 'objc', 'obj-c++'):
996 lang_path = os.path.join(path, 'gcc-4_2-testsuite', 'expected_results',
997 key, lang)
998 gcc_dg_ignores[lang] = (
999 readList(os.path.join(lang_path, 'FAIL.txt')) +
1000 readList(os.path.join(lang_path, 'UNRESOLVED.txt')) +
1001 readList(os.path.join(lang_path, 'XPASS.txt')))
1002 ignores['gcc-4_2-testsuite' ] = gcc_dg_ignores
1003
Daniel Dunbar7363d032011-02-27 03:22:35 +00001004 ignores_path = os.path.join(path, 'gdb-1472-testsuite', 'expected_results',
1005 key)
1006 gdb_dg_ignores = (
1007 readList(os.path.join(ignores_path, 'FAIL.txt')) +
1008 readList(os.path.join(ignores_path, 'UNRESOLVED.txt')) +
1009 readList(os.path.join(ignores_path, 'XPASS.txt')))
1010 ignores['gdb-1472-testsuite' ] = gdb_dg_ignores
1011
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +00001012 return ignores
David Deanf8b35442012-12-11 00:35:12 +00001013
Michael Gottesmandc771a02013-08-30 05:46:22 +00001014from zorg.buildbot.util.phasedbuilderutils import getBuildDir, setProperty
Michael Gottesman94e9ee42013-04-04 06:52:04 +00001015from zorg.buildbot.builders.Util import _did_last_build_fail
David Deanf8b35442012-12-11 00:35:12 +00001016from buildbot.steps.source.svn import SVN as HostSVN
1017
Michael Gottesman94e9ee42013-04-04 06:52:04 +00001018def phasedClang(config_options, is_bootstrap=True, use_lto=False,
Justin Bogner9605b3f2014-05-30 23:25:46 +00001019 incremental=False):
David Deanf8b35442012-12-11 00:35:12 +00001020 # Create an instance of the Builder.
1021 f = buildbot.process.factory.BuildFactory()
1022 # Determine the build directory.
1023 f = getBuildDir(f)
1024 # get rid of old archives from prior builds
1025 f.addStep(buildbot.steps.shell.ShellCommand(
Chris Matthews92ce8e22014-01-03 21:28:27 +00001026 name='rm.archives', command=['sh', '-c', 'sudo rm -rfv *gz'],
David Deanf8b35442012-12-11 00:35:12 +00001027 haltOnFailure=False, description=['rm archives'],
1028 workdir=WithProperties('%(builddir)s')))
1029 # Clean the build directory.
1030 clang_build_dir = 'clang-build'
Michael Gottesman94e9ee42013-04-04 06:52:04 +00001031 if incremental:
1032 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmand0ef7762013-10-01 20:50:35 +00001033 name='rm.clang-build', command=['sudo', 'rm', '-rfv',
1034 clang_build_dir],
Michael Gottesman94e9ee42013-04-04 06:52:04 +00001035 haltOnFailure=False, description=['rm dir', clang_build_dir],
1036 workdir=WithProperties('%(builddir)s'),
1037 doStepIf=_did_last_build_fail))
1038 else:
1039 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmand0ef7762013-10-01 20:50:35 +00001040 name='rm.clang-build', command=['sudo', 'rm', '-rfv',
1041 clang_build_dir],
Michael Gottesman94e9ee42013-04-04 06:52:04 +00001042 haltOnFailure=False, description=['rm dir', clang_build_dir],
1043 workdir=WithProperties('%(builddir)s')))
1044
David Deanf8b35442012-12-11 00:35:12 +00001045 # Cleanup the clang link, which buildbot's SVN always_purge does not know
1046 # (in 8.5 this changed to method='fresh')
1047 # how to remove correctly. If we don't do this, the LLVM update steps will
1048 # end up doing a clobber every time.
1049 #
1050 # FIXME: Should file a Trac for this, but I am lazy.
1051 f.addStep(buildbot.steps.shell.ShellCommand(
1052 name='rm.clang-sources-link',
Chris Matthews92ce8e22014-01-03 21:28:27 +00001053 command=['sudo', 'rm', '-rfv', 'llvm/tools/clang'],
David Deanf8b35442012-12-11 00:35:12 +00001054 haltOnFailure=False, description=['rm', 'clang sources link'],
1055 workdir=WithProperties('%(builddir)s')))
1056 f.addStep(buildbot.steps.shell.ShellCommand(
1057 name='rm.compiler-rt-sources-link',
Chris Matthews92ce8e22014-01-03 21:28:27 +00001058 command=['sudo', 'rm', '-rfv', 'llvm/projects/compiler-rt'],
David Deanf8b35442012-12-11 00:35:12 +00001059 haltOnFailure=False, description=['rm', 'compiler-rt sources link'],
1060 workdir=WithProperties('%(builddir)s')))
Michael Gottesman2db83142013-08-05 21:44:45 +00001061 # TODO: We used to use a symlink here but it seems to not work. I am trying
1062 # to get this builder to work so I am just going to copy it instead.
1063 f.addStep(buildbot.steps.shell.ShellCommand(
1064 name='rm.clang-tools-extra-source',
Chris Matthews92ce8e22014-01-03 21:28:27 +00001065 command=['sudo', 'rm', '-rfv', 'clang.src/tools/extra'],
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001066 haltOnFailure=True, workdir=WithProperties('%(builddir)s'),
Michael Gottesman2db83142013-08-05 21:44:45 +00001067 description=['rm', 'clang-tools-extra sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001068 f.addStep(buildbot.steps.shell.ShellCommand(
1069 name='rm.debuginfo-tests',
Chris Matthews92ce8e22014-01-03 21:28:27 +00001070 command=['sudo', 'rm', '-rfv', 'clang.src/test/debuginfo-tests'],
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001071 haltOnFailure=True, workdir=WithProperties('%(builddir)s'),
Michael Gottesmane92eb122013-09-08 01:58:27 +00001072 description=['rm', 'debuginfo-tests sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001073
David Deanf8b35442012-12-11 00:35:12 +00001074 # Pull sources.
Michael Gottesmandc771a02013-08-30 05:46:22 +00001075 f = phasedbuilderutils.SVNCleanupStep(f, 'llvm')
David Deanf8b35442012-12-11 00:35:12 +00001076 f.addStep(HostSVN(name='pull.llvm', mode='incremental', method='fresh',
1077 repourl='http://llvm.org/svn/llvm-project/llvm/trunk',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001078 retry=(60, 5), workdir='llvm', description='pull.llvm',
1079 alwaysUseLatest=False))
Michael Gottesmandc771a02013-08-30 05:46:22 +00001080 f = phasedbuilderutils.SVNCleanupStep(f, 'clang.src')
David Deanf8b35442012-12-11 00:35:12 +00001081 f.addStep(HostSVN(name='pull.clang', mode='incremental', method='fresh',
1082 repourl='http://llvm.org/svn/llvm-project/cfe/trunk',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001083 workdir='clang.src', retry=(60, 5),
David Deanf8b35442012-12-11 00:35:12 +00001084 description='pull.clang', alwaysUseLatest=False))
Michael Gottesmandc771a02013-08-30 05:46:22 +00001085 f = phasedbuilderutils.SVNCleanupStep(f, 'clang-tools-extra.src')
Michael Gottesman1dcf8f82013-03-28 06:20:57 +00001086 f.addStep(HostSVN(name='pull.clang-tools-extra', mode='incremental',
1087 method='fresh',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001088 repourl='http://llvm.org/svn/llvm-project/'
1089 'clang-tools-extra/trunk',
Michael Gottesman1dcf8f82013-03-28 06:20:57 +00001090 workdir='clang-tools-extra.src', alwaysUseLatest=False,
1091 retry=(60, 5), description='pull.clang-tools-extra'))
Michael Gottesmandc771a02013-08-30 05:46:22 +00001092 f = phasedbuilderutils.SVNCleanupStep(f, 'compiler-rt.src')
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001093 f.addStep(HostSVN(name='pull.compiler-rt', mode='incremental',
1094 method='fresh',
1095 repourl='http://llvm.org/svn/llvm-project/compiler-rt/'
1096 'trunk',
1097 workdir='compiler-rt.src', alwaysUseLatest=False,
1098 retry=(60, 5), description='pull.compiler-rt'))
Michael Gottesman13f82592013-09-08 01:54:43 +00001099 f = phasedbuilderutils.SVNCleanupStep(f, 'libcxx.src')
1100 f.addStep(HostSVN(name='pull.libcxx', mode='incremental',
1101 method='fresh',
1102 repourl='http://llvm.org/svn/llvm-project/libcxx/'
1103 'trunk',
1104 workdir='libcxx.src', alwaysUseLatest=False,
1105 retry=(60, 5), description='pull.libcxx'))
Michael Gottesmane92eb122013-09-08 01:58:27 +00001106 f = phasedbuilderutils.SVNCleanupStep(f, 'debuginfo-tests.src')
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001107 f.addStep(HostSVN(name='pull.debuginfo-tests', mode='incremental',
1108 method='fresh',
1109 repourl='http://llvm.org/svn/llvm-project/debuginfo-tests/'
1110 'trunk',
1111 workdir='debuginfo-tests.src', alwaysUseLatest=False,
1112 retry=(60, 5), description='pull.debuginfo-tests'))
1113
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001114 # Create symlinks to the clang compiler-rt sources inside the LLVM tree.
David Deanf8b35442012-12-11 00:35:12 +00001115 # We don't actually check out the sources there, because the SVN purge
1116 # would always remove them then.
1117 f.addStep(buildbot.steps.shell.ShellCommand(
1118 name='ln.clang-sources', haltOnFailure=True,
1119 command=['ln', '-sfv', '../../clang.src', 'clang'],
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001120 workdir='llvm/tools', description=['ln', 'clang sources']))
David Deanf8b35442012-12-11 00:35:12 +00001121 f.addStep(buildbot.steps.shell.ShellCommand(
1122 name='ln.compiler-rt-sources',
1123 command=['ln', '-sfv', '../../compiler-rt.src', 'compiler-rt'],
1124 haltOnFailure=True, workdir='llvm/projects',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001125 description=['ln', 'compiler-rt sources']))
Michael Gottesman4a68b872013-03-28 19:03:52 +00001126 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesman13f82592013-09-08 01:54:43 +00001127 name='ln.libcxx.sources',
1128 command=['ln', '-sfv', '../../libcxx.src', 'libcxx'],
1129 haltOnFailure=True, workdir='llvm/projects',
1130 description=['ln', 'libcxx sources']))
1131 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmanbcab1992013-03-28 18:37:21 +00001132 name='cp.clang-tools-extra-sources',
Michael Gottesman03495922013-03-28 18:40:44 +00001133 command=['cp', '-Rfv', '../../clang-tools-extra.src', 'extra'],
Michael Gottesman1dcf8f82013-03-28 06:20:57 +00001134 haltOnFailure=True, workdir='clang.src/tools',
Chris Matthewsecc0f442014-03-12 00:04:23 +00001135 description=['cp', 'clang-tools-extra sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001136 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmane92eb122013-09-08 01:58:27 +00001137 name='cp.debuginfo-tests.sources',
1138 command=['cp', '-Rfv', 'debuginfo-tests.src',
1139 'clang.src/test/debuginfo-tests'],
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001140 haltOnFailure=True, workdir=WithProperties('%(builddir)s'),
Michael Gottesmane92eb122013-09-08 01:58:27 +00001141 description=['cp', 'debuginfo-tests sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001142
David Deanf8b35442012-12-11 00:35:12 +00001143 # Clean the install directory.
1144 f.addStep(buildbot.steps.shell.ShellCommand(
Chris Matthews92ce8e22014-01-03 21:28:27 +00001145 name='rm.clang-install', command=['sudo', 'rm', '-rfv', 'clang-install'],
David Deanf8b35442012-12-11 00:35:12 +00001146 haltOnFailure=False, description=['rm dir', 'clang-install'],
1147 workdir=WithProperties('%(builddir)s')))
1148 # Construct the configure arguments.
1149 configure_args = ['../llvm/configure']
1150 configure_args.extend(config_options)
Galina Kistanova702eccb2013-08-22 00:09:17 +00001151 configure_args.extend(['--disable-bindings',
Michael Gottesman6f85f932014-06-27 23:49:58 +00001152 '--enable-keep-symbols',
Michael Gottesman0fd485a2014-08-02 01:42:51 +00001153 '--enable-targets=x86,x86_64,arm,aarch64'])
David Deanf8b35442012-12-11 00:35:12 +00001154 configure_args.append(
Michael Gottesman65d940f2013-03-13 21:51:16 +00001155 WithProperties('--prefix=%(builddir)s/clang-install'))
Michael Gottesmanca56e8f2013-03-06 22:27:38 +00001156
David Deanf8b35442012-12-11 00:35:12 +00001157 # If we are using a previously built compiler, download it and override CC
1158 # and CXX.
1159 if is_bootstrap:
Michael Gottesmana6b5be82013-06-28 21:57:20 +00001160 f = artifacts.GetCompilerArtifacts(f)
David Deanf8b35442012-12-11 00:35:12 +00001161 else:
Michael Gottesmandc771a02013-08-30 05:46:22 +00001162 f = phasedbuilderutils.GetLatestValidated(f)
David Deanf8b35442012-12-11 00:35:12 +00001163 cc_command = ['find', 'host-compiler', '-name', 'clang']
1164 f.addStep(buildbot.steps.shell.SetProperty(
1165 name='find.cc',
1166 command=cc_command,
Michael Gottesmandc771a02013-08-30 05:46:22 +00001167 extract_fn=phasedbuilderutils.find_cc,
David Deanf8b35442012-12-11 00:35:12 +00001168 workdir=WithProperties('%(builddir)s')))
1169 f.addStep(buildbot.steps.shell.ShellCommand(
1170 name='sanity.test', haltOnFailure=True,
1171 command=[WithProperties('%(builddir)s/%(cc_path)s'), '-v'],
1172 description=['sanity test']))
1173 configure_args.extend([
1174 WithProperties('CC=%(builddir)s/%(cc_path)s'),
1175 WithProperties('CXX=%(builddir)s/%(cc_path)s++')])
Michael Gottesman65d940f2013-03-13 21:51:16 +00001176
1177 # If we need to use lto, find liblto, add in proper flags here, etc.
1178 if use_lto:
Michael Gottesman01f0a622013-03-13 22:38:38 +00001179 liblto_command = ['find', WithProperties('%(builddir)s/host-compiler'),
1180 '-name', 'libLTO.dylib']
Michael Gottesman1da57ae2013-03-13 21:54:23 +00001181 f.addStep(buildbot.steps.shell.SetProperty(
Michael Gottesman65d940f2013-03-13 21:51:16 +00001182 name='find.liblto',
1183 command=liblto_command,
Michael Gottesmandc771a02013-08-30 05:46:22 +00001184 extract_fn=phasedbuilderutils.find_liblto,
Michael Gottesman65d940f2013-03-13 21:51:16 +00001185 workdir=WithProperties('%(builddir)s')))
1186 configure_args.append(
1187 '--with-extra-options=-flto -gline-tables-only')
1188
David Deanf8b35442012-12-11 00:35:12 +00001189 # Configure the LLVM build.
Michael Gottesmand97d8502013-04-04 07:57:31 +00001190 if incremental:
1191 # *NOTE* This is a temporary work around. I am eventually going to just
1192 # set up cmake/ninja but for now I am sticking with the make => I need
1193 # configure to run only after a failure so on success I have incremental
1194 # builds.
1195 f.addStep(buildbot.steps.shell.ShellCommand(
1196 name='configure.with.host', command=configure_args,
1197 haltOnFailure=True, description=['configure'],
1198 workdir=clang_build_dir,
1199 doStepIf=_did_last_build_fail))
1200 else:
1201 f.addStep(buildbot.steps.shell.ShellCommand(
1202 name='configure.with.host', command=configure_args,
1203 haltOnFailure=True, description=['configure'],
1204 workdir=clang_build_dir))
1205
David Deanf8b35442012-12-11 00:35:12 +00001206 # Build the compiler.
Michael Gottesman36778832013-09-08 01:37:35 +00001207 make_command = ['make', '-j', WithProperties('%(jobs)s'), 'VERBOSE=1']
Galina Kistanovabfb29d22013-05-09 23:53:24 +00001208 timeout = 40*60 # Normal timeout is 20 minutes.
Michael Gottesman65d940f2013-03-13 21:51:16 +00001209 if use_lto:
1210 make_command.append(WithProperties('DYLD_LIBRARY_PATH=%(liblto_path)s'))
Michael Gottesman2e7385c2013-08-12 17:57:27 +00001211 timeout = 240*60 # LTO timeout is 240 minutes.
Michael Gottesman65d940f2013-03-13 21:51:16 +00001212
David Deanf8b35442012-12-11 00:35:12 +00001213 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesman65d940f2013-03-13 21:51:16 +00001214 name='make', command=make_command,
Michael Gottesmanbab77ac2013-03-14 05:36:53 +00001215 haltOnFailure=True, description=['make'], workdir=clang_build_dir,
1216 timeout=timeout))
David Deanf8b35442012-12-11 00:35:12 +00001217 # Use make install-clang to produce minimal archive for use by downstream
1218 # builders.
1219 f.addStep(buildbot.steps.shell.ShellCommand(
1220 name='make.install-clang', haltOnFailure=True,
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001221 command=['make', 'install-clang', '-j',
1222 WithProperties('%(jobs)s'),
1223 'RC_SUPPORTED_ARCHS=armv7 i386 x86_64'],
David Deanf8b35442012-12-11 00:35:12 +00001224 description=['make install'], workdir=clang_build_dir))
1225 # Save artifacts of this build for use by other builders.
Michael Gottesmana6b5be82013-06-28 21:57:20 +00001226 f = artifacts.uploadArtifacts(f)
David Deanf8b35442012-12-11 00:35:12 +00001227 # Run the LLVM and Clang regression tests.
Michael Gottesmana9c32be2013-09-06 17:47:24 +00001228 cmd_str = r"""make VERBOSE=1 LIT_ARGS="-v --param run_long_tests=true --filter='^(?!.*debuginfo-tests)'" check-all"""
1229 f.addStep(lit_test_command.LitTestCommand(name='run.llvm.tests', haltOnFailure=True,
1230 command=cmd_str,
1231 description=['all', 'tests'],
1232 workdir=clang_build_dir))
1233 # Work around for lldb issue rdar://14929651
Chris Matthewsecc0f442014-03-12 00:04:23 +00001234 # The crazy filter regex is to remove static-member[2].cpp, which requires xcode5 or later.
1235 # radar://16295455 tracks the removal of this regex.
1236 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 +00001237 f.addStep(lit_test_command.LitTestCommand(name='run.llvm.debuginfo-tests', haltOnFailure=True,
Michael Gottesmane7dc31e2013-08-30 05:57:35 +00001238 command=cmd_str,
Michael Gottesmana6b5be82013-06-28 21:57:20 +00001239 description=['all', 'tests'],
1240 workdir=clang_build_dir))
David Deanf8b35442012-12-11 00:35:12 +00001241 return f