blob: 50eac87a974ae386920f6b6d5f29ded4f839a2a0 [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 Golind1c46742015-08-06 18:05:34 +0000595 haltOnStage1Check = not useTwoStage and not runTestSuite
Renato Golincfbd5702014-09-06 19:09:16 +0000596 f.addStep(lit_test_command.LitTestCommand(name='ninja check 1',
597 command=ninja_check_cmd,
Renato Golind1c46742015-08-06 18:05:34 +0000598 haltOnFailure=haltOnStage1Check,
Renato Golincfbd5702014-09-06 19:09:16 +0000599 description=["checking stage 1"],
600 descriptionDone=["stage 1 checked"],
601 workdir=stage1_build,
602 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000603
Renato Golin61aed7f2015-06-17 19:12:50 +0000604 if useTwoStage or runTestSuite:
605 f.addStep(ShellCommand(name='install stage 1',
606 command=ninja_install_cmd,
607 description='ninja install',
608 workdir=stage1_build,
Renato Goline402f582014-09-04 19:25:24 +0000609 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000610
Reid Kleckner25a26b02015-03-09 22:30:25 +0000611 # Compute the cmake define flag to set the C and C++ compiler to clang. Use
612 # clang-cl if we used MSVC for stage1.
613 if not vs:
614 cc = 'clang'
615 cxx = 'clang++'
616 else:
617 cc = 'clang-cl.exe'
618 cxx = 'clang-cl.exe'
619
Reid Kleckner25a26b02015-03-09 22:30:25 +0000620
Renato Golin61aed7f2015-06-17 19:12:50 +0000621 ############# STAGE 2
622 if useTwoStage:
623 if clean:
624 f.addStep(ShellCommand(name='clean stage 2',
625 command=['rm','-rf',stage2_build],
626 warnOnFailure=True,
627 description='cleaning stage 2',
628 descriptionDone='clean',
629 workdir='.',
630 env=env))
631 else:
632 f.addStep(SetProperty(name="check ninja files 2",
633 workdir=stage2_build,
634 command=check_build_cmd,
635 flunkOnFailure=False,
636 property="exists_ninja_2"))
Reid Kleckner25a26b02015-03-09 22:30:25 +0000637
Renato Golin61aed7f2015-06-17 19:12:50 +0000638 # Set the compiler using the CC and CXX environment variables to work around
639 # backslash string escaping bugs somewhere between buildbot and cmake. The
640 # env.exe helper is required to run the tests, so hopefully it's already on
641 # PATH.
642 cmake_cmd2 = ['env',
643 WithProperties('CC=%(workdir)s/'+stage1_install+'/bin/'+cc),
644 WithProperties('CXX=%(workdir)s/'+stage1_install+'/bin/'+cxx),
645 cmake, "-G", "Ninja", "../llvm",
646 "-DCMAKE_BUILD_TYPE="+stage2_config,
647 "-DLLVM_ENABLE_ASSERTIONS=True",
648 "-DLLVM_LIT_ARGS="+lit_args,
649 "-DCMAKE_INSTALL_PREFIX=../"+stage2_install] + extra_cmake_args
Reid Kleckner25a26b02015-03-09 22:30:25 +0000650
Renato Golin61aed7f2015-06-17 19:12:50 +0000651 f.addStep(ShellCommand(name='cmake stage 2',
652 command=cmake_cmd2,
653 haltOnFailure=True,
654 description='cmake stage 2',
655 workdir=stage2_build,
656 doStepIf=lambda step: step.build.getProperty("exists_ninja_2") != "OK",
657 env=env))
658
659 f.addStep(WarningCountingShellCommand(name='build stage 2',
660 command=ninja_cmd,
661 haltOnFailure=True,
662 description='ninja all',
663 workdir=stage2_build,
664 env=env))
665
666 if test:
667 f.addStep(lit_test_command.LitTestCommand(name='ninja check 2',
668 command=ninja_check_cmd,
669 haltOnFailure=not runTestSuite,
670 description=["checking stage 2"],
671 descriptionDone=["stage 2 checked"],
672 workdir=stage2_build,
673 env=env))
674
675 ############# TEST SUITE
676 ## Test-Suite (stage 2 if built, stage 1 otherwise)
677 if runTestSuite:
678 compiler_path = stage1_install
679 if useTwoStage:
680 compiler_path=stage2_install
681 f.addStep(ShellCommand(name='install stage 2',
682 command=ninja_install_cmd,
683 description='ninja install 2',
Renato Golincfbd5702014-09-06 19:09:16 +0000684 workdir=stage2_build,
685 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000686
Renato Golin61aed7f2015-06-17 19:12:50 +0000687 # Get generated python, lnt
688 python = WithProperties('%(workdir)s/test/sandbox/bin/python')
689 lnt = WithProperties('%(workdir)s/test/sandbox/bin/lnt')
690 lnt_setup = WithProperties('%(workdir)s/test/lnt/setup.py')
691
692 # Paths
693 sandbox = WithProperties('%(workdir)s/test/sandbox')
694 test_suite_dir = WithProperties('%(workdir)s/test/test-suite')
695
696 # Get latest built Clang (stage1 or stage2)
697 cc = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cc)
698 cxx = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cxx)
699
700 # LNT Command line
701 if jobs is None:
702 jobs = 1
703 test_suite_cmd = [python, lnt, 'runtest', 'nt',
704 '-j'+str(jobs),
705 '--no-timestamp',
706 '--sandbox', sandbox,
707 '--test-suite', test_suite_dir,
708 '--cc', cc,
709 '--cxx', cxx]
710 # Append any option provided by the user
711 test_suite_cmd.extend(nt_flags)
712 # Only submit if a URL has been specified
713 if submitURL is not None:
714 if not isinstance(submitURL, list):
715 submitURL = [submitURL]
716 for url in submitURL:
717 test_suite_cmd.extend(['--submit', url])
718 if testerName:
719 test_suite_cmd.extend(['--no-machdep-info', testerName])
720 # CC and CXX are needed as env for build-tools
Renato Goline6c1b3b2015-07-01 15:52:22 +0000721 test_suite_env = copy.deepcopy(env)
Renato Golin61aed7f2015-06-17 19:12:50 +0000722 test_suite_env['CC'] = cc
723 test_suite_env['CXX'] = cxx
724
725 # Steps to prepare, build and run LNT
726 f.addStep(ShellCommand(name='clean sandbox',
727 command=['rm', '-rf', 'sandbox'],
728 haltOnFailure=True,
729 description='removing sandbox directory',
730 workdir='test',
731 env=env))
732 f.addStep(ShellCommand(name='recreate sandbox',
733 command=['virtualenv', 'sandbox'],
734 haltOnFailure=True,
735 description='recreating sandbox',
736 workdir='test',
737 env=env))
738 f.addStep(ShellCommand(name='setup lit',
739 command=[python, lnt_setup, 'develop'],
740 haltOnFailure=True,
741 description='setting up LNT in sandbox',
742 workdir='test/sandbox',
743 env=env))
744 f.addStep(commands.LitTestCommand.LitTestCommand(
745 name='test-suite',
746 command=test_suite_cmd,
747 haltOnFailure=True,
748 description=['running the test suite'],
749 workdir='test/sandbox',
750 logfiles={'configure.log' : 'build/configure.log',
751 'build-tools.log' : 'build/build-tools.log',
752 'test.log' : 'build/test.log',
753 'report.json' : 'build/report.json'},
754 env=test_suite_env))
755
Renato Goline402f582014-09-04 19:25:24 +0000756 return f
757
Daniel Dunbarc51a59e2010-09-23 14:57:45 +0000758def getClangMSVCBuildFactory(update=True, clean=True, vcDrive='c', jobs=1, cmake=r"cmake"):
Daniel Dunbar44abe742009-07-19 01:59:03 +0000759 f = buildbot.process.factory.BuildFactory()
760
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000761 if update:
Daniel Dunbar44abe742009-07-19 01:59:03 +0000762 f.addStep(SVN(name='svn-llvm',
763 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
764 defaultBranch='trunk',
765 workdir='llvm'))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000766 f.addStep(SVN(name='svn-clang',
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000767 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
Daniel Dunbar44abe742009-07-19 01:59:03 +0000768 defaultBranch='trunk',
769 workdir='llvm/tools/clang'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000770 f.addStep(SVN(name='svn-clang-tools-extra',
771 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
772 defaultBranch='trunk',
773 workdir='llvm/tools/clang/tools/extra'))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000774
775 # Full & fast clean.
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000776 if clean:
Daniel Dunbar44abe742009-07-19 01:59:03 +0000777 f.addStep(ShellCommand(name='clean-1',
778 command=['del','/s/q','build'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000779 warnOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000780 description='cleaning',
781 descriptionDone='clean',
782 workdir='llvm'))
783 f.addStep(ShellCommand(name='clean-2',
784 command=['rmdir','/s/q','build'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000785 warnOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000786 description='cleaning',
787 descriptionDone='clean',
788 workdir='llvm'))
789
790 # Create the project files.
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000791
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000792 # Use batch files instead of ShellCommand directly, Windows quoting is
793 # borked. FIXME: See buildbot ticket #595 and buildbot ticket #377.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000794 f.addStep(batch_file_download.BatchFileDownload(name='cmakegen',
Daniel Dunbar06b20f12010-04-08 18:29:38 +0000795 command=[cmake,
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000796 "-DLLVM_TARGETS_TO_BUILD:=X86",
Daniel Dunbar1ddedce2010-09-24 19:57:34 +0000797 "-DLLVM_INCLUDE_EXAMPLES:=OFF",
798 "-DLLVM_INCLUDE_TESTS:=OFF",
799 "-DLLVM_TARGETS_TO_BUILD:=X86",
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000800 "-G",
801 "Visual Studio 9 2008",
802 ".."],
803 workdir="llvm\\build"))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000804 f.addStep(ShellCommand(name='cmake',
805 command=['cmakegen.bat'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000806 haltOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000807 description='cmake gen',
808 workdir='llvm\\build'))
809
810 # Build it.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000811 f.addStep(batch_file_download.BatchFileDownload(name='vcbuild',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000812 command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""",
813 "/M%d" % jobs,
814 "LLVM.sln",
815 "Debug|Win32"],
816 workdir="llvm\\build"))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000817 f.addStep(WarningCountingShellCommand(name='vcbuild',
818 command=['vcbuild.bat'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000819 haltOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000820 description='vcbuild',
821 workdir='llvm\\build',
822 warningPattern=" warning C.*:"))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000823
824 # Build clang-test project.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000825 f.addStep(batch_file_download.BatchFileDownload(name='vcbuild_test',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000826 command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""",
827 "clang-test.vcproj",
828 "Debug|Win32"],
829 workdir="llvm\\build\\tools\\clang\\test"))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000830 f.addStep(lit_test_command.LitTestCommand(name='test-clang',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000831 command=["vcbuild_test.bat"],
832 workdir="llvm\\build\\tools\\clang\\test"))
833
Daniel Dunbar44abe742009-07-19 01:59:03 +0000834 return f
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000835
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000836# Builds on Windows using CMake, MinGW(32|64), and no Microsoft tools.
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000837def getClangMinGWBuildFactory(update=True, clean=True, jobs=6, cmake=r"cmake"):
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000838 f = buildbot.process.factory.BuildFactory()
839
840 if update:
841 f.addStep(SVN(name='svn-llvm',
842 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
843 defaultBranch='trunk',
844 workdir='llvm'))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000845 f.addStep(SVN(name='svn-clang',
846 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
847 defaultBranch='trunk',
848 workdir='llvm/tools/clang'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000849 f.addStep(SVN(name='svn-clang-tools-extra',
850 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
851 defaultBranch='trunk',
852 workdir='llvm/tools/clang/tools/extra'))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000853
854 # Full & fast clean.
855 if clean:
856 # note: This command is redundant as the next command removes everything
857 f.addStep(ShellCommand(name='clean-1',
858 command=['del','/s/q','build'],
859 warnOnFailure=True,
860 description='cleaning',
861 descriptionDone='clean',
862 workdir='llvm'))
863 f.addStep(ShellCommand(name='clean-2',
864 command=['rmdir','/s/q','build'],
865 warnOnFailure=True,
866 description='cleaning',
867 descriptionDone='clean',
868 workdir='llvm'))
869
870 # Create the Makefiles.
871
872 # Use batch files instead of ShellCommand directly, Windows quoting is
873 # borked. FIXME: See buildbot ticket #595 and buildbot ticket #377.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000874 f.addStep(batch_file_download.BatchFileDownload(name='cmakegen',
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000875 command=[cmake,
876 "-DLLVM_TARGETS_TO_BUILD:=X86",
877 "-DLLVM_INCLUDE_EXAMPLES:=OFF",
878 "-DLLVM_INCLUDE_TESTS:=OFF",
879 "-DLLVM_TARGETS_TO_BUILD:=X86",
880 "-G",
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000881 "Ninja",
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000882 ".."],
883 workdir="llvm\\build"))
884 f.addStep(ShellCommand(name='cmake',
885 command=['cmakegen.bat'],
886 haltOnFailure=True,
887 description='cmake gen',
888 workdir='llvm\\build'))
889
890 # Build it.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000891 f.addStep(batch_file_download.BatchFileDownload(name='makeall',
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000892 command=["ninja", "-j", "%d" % jobs],
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000893 haltOnFailure=True,
894 workdir='llvm\\build'))
895
896 f.addStep(WarningCountingShellCommand(name='makeall',
897 command=['makeall.bat'],
898 haltOnFailure=True,
899 description='makeall',
900 workdir='llvm\\build'))
901
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000902 # Build global check project (make check) (sources not checked out...).
903 if 0:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000904 f.addStep(batch_file_download.BatchFileDownload(name='makecheck',
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000905 command=["ninja", "check"],
906 workdir='llvm\\build'))
907 f.addStep(WarningCountingShellCommand(name='check',
908 command=['makecheck.bat'],
909 description='make check',
910 workdir='llvm\\build'))
Galina Kistanova049d76c2012-06-09 00:56:05 +0000911
912 # Build clang-test project (make clang-test).
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000913 f.addStep(batch_file_download.BatchFileDownload(name='maketest',
914 command=["ninja", "clang-test"],
915 workdir="llvm\\build"))
916 f.addStep(lit_test_command.LitTestCommand(name='clang-test',
917 command=["maketest.bat"],
918 workdir="llvm\\build"))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000919 return f
920
Daniel Dunbar7363d032011-02-27 03:22:35 +0000921def addClangGCCTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install",
922 languages = ('gcc', 'g++', 'objc', 'obj-c++')):
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000923 make_vars = [WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000924 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000925 WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000926 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
David Blaikie05517332013-12-19 23:29:12 +0000927 f.addStep(SVN(name='svn-clang-gcc-tests', mode='update',
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000928 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
929 defaultBranch='trunk', workdir='clang-tests'))
930 gcc_dg_ignores = ignores.get('gcc-4_2-testsuite', {})
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000931 for lang in languages:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000932 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000933 name='test-gcc-4_2-testsuite-%s' % lang,
934 command=["make", "-k", "check-%s" % lang] + make_vars,
935 description="gcc-4_2-testsuite (%s)" % lang,
936 workdir='clang-tests/gcc-4_2-testsuite',
David Dean2bd0c3a2011-10-18 16:36:28 +0000937 logfiles={ 'dg.sum' : 'obj/%s/%s.sum' % (lang, lang),
938 '%s.log' % lang : 'obj/%s/%s.log' % (lang, lang)},
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000939 ignore=gcc_dg_ignores.get(lang, [])))
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000940
Daniel Dunbar7363d032011-02-27 03:22:35 +0000941def addClangGDBTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install"):
942 make_vars = [WithProperties(
943 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
944 WithProperties(
945 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
David Blaikie05517332013-12-19 23:29:12 +0000946 f.addStep(SVN(name='svn-clang-gdb-tests', mode='update',
Daniel Dunbar7363d032011-02-27 03:22:35 +0000947 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
948 defaultBranch='trunk', workdir='clang-tests'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000949 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar7363d032011-02-27 03:22:35 +0000950 name='test-gdb-1472-testsuite',
951 command=["make", "-k", "check"] + make_vars,
952 description="gdb-1472-testsuite",
953 workdir='clang-tests/gdb-1472-testsuite',
David Blaikie7ec695f2012-10-09 22:17:09 +0000954 logfiles={ 'dg.sum' : 'obj/filtered.gdb.sum',
David Blaikie624f4392012-11-05 22:34:35 +0000955 'gdb.log' : 'obj/gdb.log' }))
Daniel Dunbar7363d032011-02-27 03:22:35 +0000956
David Blaikie41d09c32013-01-02 21:11:09 +0000957def addModernClangGDBTests(f, jobs, install_prefix):
David Blaikie1bc5c372012-12-05 05:29:12 +0000958 make_vars = [WithProperties('RUNTESTFLAGS=CC_FOR_TARGET=\'{0}/bin/clang\' '
959 'CXX_FOR_TARGET=\'{0}/bin/clang++\' '
David Blaikie759bb752013-04-18 23:13:11 +0000960 'CFLAGS_FOR_TARGET=\'-w -fno-limit-debug-info\''
David Blaikief89877b2013-01-29 23:46:26 +0000961 .format(install_prefix))]
David Blaikie05517332013-12-19 23:29:12 +0000962 f.addStep(SVN(name='svn-clang-modern-gdb-tests', mode='update',
David Blaikief3f300b2012-11-17 01:13:41 +0000963 svnurl='http://llvm.org/svn/llvm-project/clang-tests-external/trunk/gdb/7.5',
David Blaikiedad03d52012-11-16 22:37:12 +0000964 workdir='clang-tests/src'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000965 f.addStep(Configure(command='../src/configure',
David Blaikief3f300b2012-11-17 01:13:41 +0000966 workdir='clang-tests/build/'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000967 f.addStep(WarningCountingShellCommand(name='gdb-75-build',
968 command=['make', WithProperties('-j%s' % jobs)],
969 haltOnFailure=True,
970 workdir='clang-tests/build'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000971 f.addStep(commands.DejaGNUCommand.DejaGNUCommand(
David Blaikiedad03d52012-11-16 22:37:12 +0000972 name='gdb-75-check',
David Blaikieb83bfdf2012-12-05 04:33:42 +0000973 command=['make', '-k', WithProperties('-j%s' % jobs), 'check'] + make_vars,
David Blaikiedad03d52012-11-16 22:37:12 +0000974 workdir='clang-tests/build',
David Blaikie1bc5c372012-12-05 05:29:12 +0000975 logfiles={'dg.sum':'gdb/testsuite/gdb.sum',
976 'gdb.log':'gdb/testsuite/gdb.log'}))
David Blaikiedad03d52012-11-16 22:37:12 +0000977
978
979
Daniel Dunbar7363d032011-02-27 03:22:35 +0000980# FIXME: Deprecated.
981addClangTests = addClangGCCTests
982
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000983def getClangTestsIgnoresFromPath(path, key):
984 def readList(path):
985 if not os.path.exists(path):
986 return []
987
988 f = open(path)
989 lines = [ln.strip() for ln in f]
990 f.close()
991 return lines
992
993 ignores = {}
994
995 gcc_dg_ignores = {}
996 for lang in ('gcc', 'g++', 'objc', 'obj-c++'):
997 lang_path = os.path.join(path, 'gcc-4_2-testsuite', 'expected_results',
998 key, lang)
999 gcc_dg_ignores[lang] = (
1000 readList(os.path.join(lang_path, 'FAIL.txt')) +
1001 readList(os.path.join(lang_path, 'UNRESOLVED.txt')) +
1002 readList(os.path.join(lang_path, 'XPASS.txt')))
1003 ignores['gcc-4_2-testsuite' ] = gcc_dg_ignores
1004
Daniel Dunbar7363d032011-02-27 03:22:35 +00001005 ignores_path = os.path.join(path, 'gdb-1472-testsuite', 'expected_results',
1006 key)
1007 gdb_dg_ignores = (
1008 readList(os.path.join(ignores_path, 'FAIL.txt')) +
1009 readList(os.path.join(ignores_path, 'UNRESOLVED.txt')) +
1010 readList(os.path.join(ignores_path, 'XPASS.txt')))
1011 ignores['gdb-1472-testsuite' ] = gdb_dg_ignores
1012
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +00001013 return ignores
David Deanf8b35442012-12-11 00:35:12 +00001014
Michael Gottesmandc771a02013-08-30 05:46:22 +00001015from zorg.buildbot.util.phasedbuilderutils import getBuildDir, setProperty
Michael Gottesman94e9ee42013-04-04 06:52:04 +00001016from zorg.buildbot.builders.Util import _did_last_build_fail
David Deanf8b35442012-12-11 00:35:12 +00001017from buildbot.steps.source.svn import SVN as HostSVN
1018
Michael Gottesman94e9ee42013-04-04 06:52:04 +00001019def phasedClang(config_options, is_bootstrap=True, use_lto=False,
Justin Bogner9605b3f2014-05-30 23:25:46 +00001020 incremental=False):
David Deanf8b35442012-12-11 00:35:12 +00001021 # Create an instance of the Builder.
1022 f = buildbot.process.factory.BuildFactory()
1023 # Determine the build directory.
1024 f = getBuildDir(f)
1025 # get rid of old archives from prior builds
1026 f.addStep(buildbot.steps.shell.ShellCommand(
Chris Matthews92ce8e22014-01-03 21:28:27 +00001027 name='rm.archives', command=['sh', '-c', 'sudo rm -rfv *gz'],
David Deanf8b35442012-12-11 00:35:12 +00001028 haltOnFailure=False, description=['rm archives'],
1029 workdir=WithProperties('%(builddir)s')))
1030 # Clean the build directory.
1031 clang_build_dir = 'clang-build'
Michael Gottesman94e9ee42013-04-04 06:52:04 +00001032 if incremental:
1033 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmand0ef7762013-10-01 20:50:35 +00001034 name='rm.clang-build', command=['sudo', 'rm', '-rfv',
1035 clang_build_dir],
Michael Gottesman94e9ee42013-04-04 06:52:04 +00001036 haltOnFailure=False, description=['rm dir', clang_build_dir],
1037 workdir=WithProperties('%(builddir)s'),
1038 doStepIf=_did_last_build_fail))
1039 else:
1040 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmand0ef7762013-10-01 20:50:35 +00001041 name='rm.clang-build', command=['sudo', 'rm', '-rfv',
1042 clang_build_dir],
Michael Gottesman94e9ee42013-04-04 06:52:04 +00001043 haltOnFailure=False, description=['rm dir', clang_build_dir],
1044 workdir=WithProperties('%(builddir)s')))
1045
David Deanf8b35442012-12-11 00:35:12 +00001046 # Cleanup the clang link, which buildbot's SVN always_purge does not know
1047 # (in 8.5 this changed to method='fresh')
1048 # how to remove correctly. If we don't do this, the LLVM update steps will
1049 # end up doing a clobber every time.
1050 #
1051 # FIXME: Should file a Trac for this, but I am lazy.
1052 f.addStep(buildbot.steps.shell.ShellCommand(
1053 name='rm.clang-sources-link',
Chris Matthews92ce8e22014-01-03 21:28:27 +00001054 command=['sudo', 'rm', '-rfv', 'llvm/tools/clang'],
David Deanf8b35442012-12-11 00:35:12 +00001055 haltOnFailure=False, description=['rm', 'clang sources link'],
1056 workdir=WithProperties('%(builddir)s')))
1057 f.addStep(buildbot.steps.shell.ShellCommand(
1058 name='rm.compiler-rt-sources-link',
Chris Matthews92ce8e22014-01-03 21:28:27 +00001059 command=['sudo', 'rm', '-rfv', 'llvm/projects/compiler-rt'],
David Deanf8b35442012-12-11 00:35:12 +00001060 haltOnFailure=False, description=['rm', 'compiler-rt sources link'],
1061 workdir=WithProperties('%(builddir)s')))
Michael Gottesman2db83142013-08-05 21:44:45 +00001062 # TODO: We used to use a symlink here but it seems to not work. I am trying
1063 # to get this builder to work so I am just going to copy it instead.
1064 f.addStep(buildbot.steps.shell.ShellCommand(
1065 name='rm.clang-tools-extra-source',
Chris Matthews92ce8e22014-01-03 21:28:27 +00001066 command=['sudo', 'rm', '-rfv', 'clang.src/tools/extra'],
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001067 haltOnFailure=True, workdir=WithProperties('%(builddir)s'),
Michael Gottesman2db83142013-08-05 21:44:45 +00001068 description=['rm', 'clang-tools-extra sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001069 f.addStep(buildbot.steps.shell.ShellCommand(
1070 name='rm.debuginfo-tests',
Chris Matthews92ce8e22014-01-03 21:28:27 +00001071 command=['sudo', 'rm', '-rfv', 'clang.src/test/debuginfo-tests'],
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001072 haltOnFailure=True, workdir=WithProperties('%(builddir)s'),
Michael Gottesmane92eb122013-09-08 01:58:27 +00001073 description=['rm', 'debuginfo-tests sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001074
David Deanf8b35442012-12-11 00:35:12 +00001075 # Pull sources.
Michael Gottesmandc771a02013-08-30 05:46:22 +00001076 f = phasedbuilderutils.SVNCleanupStep(f, 'llvm')
David Deanf8b35442012-12-11 00:35:12 +00001077 f.addStep(HostSVN(name='pull.llvm', mode='incremental', method='fresh',
1078 repourl='http://llvm.org/svn/llvm-project/llvm/trunk',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001079 retry=(60, 5), workdir='llvm', description='pull.llvm',
1080 alwaysUseLatest=False))
Michael Gottesmandc771a02013-08-30 05:46:22 +00001081 f = phasedbuilderutils.SVNCleanupStep(f, 'clang.src')
David Deanf8b35442012-12-11 00:35:12 +00001082 f.addStep(HostSVN(name='pull.clang', mode='incremental', method='fresh',
1083 repourl='http://llvm.org/svn/llvm-project/cfe/trunk',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001084 workdir='clang.src', retry=(60, 5),
David Deanf8b35442012-12-11 00:35:12 +00001085 description='pull.clang', alwaysUseLatest=False))
Michael Gottesmandc771a02013-08-30 05:46:22 +00001086 f = phasedbuilderutils.SVNCleanupStep(f, 'clang-tools-extra.src')
Michael Gottesman1dcf8f82013-03-28 06:20:57 +00001087 f.addStep(HostSVN(name='pull.clang-tools-extra', mode='incremental',
1088 method='fresh',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001089 repourl='http://llvm.org/svn/llvm-project/'
1090 'clang-tools-extra/trunk',
Michael Gottesman1dcf8f82013-03-28 06:20:57 +00001091 workdir='clang-tools-extra.src', alwaysUseLatest=False,
1092 retry=(60, 5), description='pull.clang-tools-extra'))
Michael Gottesmandc771a02013-08-30 05:46:22 +00001093 f = phasedbuilderutils.SVNCleanupStep(f, 'compiler-rt.src')
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001094 f.addStep(HostSVN(name='pull.compiler-rt', mode='incremental',
1095 method='fresh',
1096 repourl='http://llvm.org/svn/llvm-project/compiler-rt/'
1097 'trunk',
1098 workdir='compiler-rt.src', alwaysUseLatest=False,
1099 retry=(60, 5), description='pull.compiler-rt'))
Michael Gottesman13f82592013-09-08 01:54:43 +00001100 f = phasedbuilderutils.SVNCleanupStep(f, 'libcxx.src')
1101 f.addStep(HostSVN(name='pull.libcxx', mode='incremental',
1102 method='fresh',
1103 repourl='http://llvm.org/svn/llvm-project/libcxx/'
1104 'trunk',
1105 workdir='libcxx.src', alwaysUseLatest=False,
1106 retry=(60, 5), description='pull.libcxx'))
Michael Gottesmane92eb122013-09-08 01:58:27 +00001107 f = phasedbuilderutils.SVNCleanupStep(f, 'debuginfo-tests.src')
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001108 f.addStep(HostSVN(name='pull.debuginfo-tests', mode='incremental',
1109 method='fresh',
1110 repourl='http://llvm.org/svn/llvm-project/debuginfo-tests/'
1111 'trunk',
1112 workdir='debuginfo-tests.src', alwaysUseLatest=False,
1113 retry=(60, 5), description='pull.debuginfo-tests'))
1114
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001115 # Create symlinks to the clang compiler-rt sources inside the LLVM tree.
David Deanf8b35442012-12-11 00:35:12 +00001116 # We don't actually check out the sources there, because the SVN purge
1117 # would always remove them then.
1118 f.addStep(buildbot.steps.shell.ShellCommand(
1119 name='ln.clang-sources', haltOnFailure=True,
1120 command=['ln', '-sfv', '../../clang.src', 'clang'],
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001121 workdir='llvm/tools', description=['ln', 'clang sources']))
David Deanf8b35442012-12-11 00:35:12 +00001122 f.addStep(buildbot.steps.shell.ShellCommand(
1123 name='ln.compiler-rt-sources',
1124 command=['ln', '-sfv', '../../compiler-rt.src', 'compiler-rt'],
1125 haltOnFailure=True, workdir='llvm/projects',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001126 description=['ln', 'compiler-rt sources']))
Michael Gottesman4a68b872013-03-28 19:03:52 +00001127 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesman13f82592013-09-08 01:54:43 +00001128 name='ln.libcxx.sources',
1129 command=['ln', '-sfv', '../../libcxx.src', 'libcxx'],
1130 haltOnFailure=True, workdir='llvm/projects',
1131 description=['ln', 'libcxx sources']))
1132 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmanbcab1992013-03-28 18:37:21 +00001133 name='cp.clang-tools-extra-sources',
Michael Gottesman03495922013-03-28 18:40:44 +00001134 command=['cp', '-Rfv', '../../clang-tools-extra.src', 'extra'],
Michael Gottesman1dcf8f82013-03-28 06:20:57 +00001135 haltOnFailure=True, workdir='clang.src/tools',
Chris Matthewsecc0f442014-03-12 00:04:23 +00001136 description=['cp', 'clang-tools-extra sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001137 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmane92eb122013-09-08 01:58:27 +00001138 name='cp.debuginfo-tests.sources',
1139 command=['cp', '-Rfv', 'debuginfo-tests.src',
1140 'clang.src/test/debuginfo-tests'],
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001141 haltOnFailure=True, workdir=WithProperties('%(builddir)s'),
Michael Gottesmane92eb122013-09-08 01:58:27 +00001142 description=['cp', 'debuginfo-tests sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001143
David Deanf8b35442012-12-11 00:35:12 +00001144 # Clean the install directory.
1145 f.addStep(buildbot.steps.shell.ShellCommand(
Chris Matthews92ce8e22014-01-03 21:28:27 +00001146 name='rm.clang-install', command=['sudo', 'rm', '-rfv', 'clang-install'],
David Deanf8b35442012-12-11 00:35:12 +00001147 haltOnFailure=False, description=['rm dir', 'clang-install'],
1148 workdir=WithProperties('%(builddir)s')))
1149 # Construct the configure arguments.
1150 configure_args = ['../llvm/configure']
1151 configure_args.extend(config_options)
Galina Kistanova702eccb2013-08-22 00:09:17 +00001152 configure_args.extend(['--disable-bindings',
Michael Gottesman6f85f932014-06-27 23:49:58 +00001153 '--enable-keep-symbols',
Michael Gottesman0fd485a2014-08-02 01:42:51 +00001154 '--enable-targets=x86,x86_64,arm,aarch64'])
David Deanf8b35442012-12-11 00:35:12 +00001155 configure_args.append(
Michael Gottesman65d940f2013-03-13 21:51:16 +00001156 WithProperties('--prefix=%(builddir)s/clang-install'))
Michael Gottesmanca56e8f2013-03-06 22:27:38 +00001157
David Deanf8b35442012-12-11 00:35:12 +00001158 # If we are using a previously built compiler, download it and override CC
1159 # and CXX.
1160 if is_bootstrap:
Michael Gottesmana6b5be82013-06-28 21:57:20 +00001161 f = artifacts.GetCompilerArtifacts(f)
David Deanf8b35442012-12-11 00:35:12 +00001162 else:
Michael Gottesmandc771a02013-08-30 05:46:22 +00001163 f = phasedbuilderutils.GetLatestValidated(f)
David Deanf8b35442012-12-11 00:35:12 +00001164 cc_command = ['find', 'host-compiler', '-name', 'clang']
1165 f.addStep(buildbot.steps.shell.SetProperty(
1166 name='find.cc',
1167 command=cc_command,
Michael Gottesmandc771a02013-08-30 05:46:22 +00001168 extract_fn=phasedbuilderutils.find_cc,
David Deanf8b35442012-12-11 00:35:12 +00001169 workdir=WithProperties('%(builddir)s')))
1170 f.addStep(buildbot.steps.shell.ShellCommand(
1171 name='sanity.test', haltOnFailure=True,
1172 command=[WithProperties('%(builddir)s/%(cc_path)s'), '-v'],
1173 description=['sanity test']))
1174 configure_args.extend([
1175 WithProperties('CC=%(builddir)s/%(cc_path)s'),
1176 WithProperties('CXX=%(builddir)s/%(cc_path)s++')])
Michael Gottesman65d940f2013-03-13 21:51:16 +00001177
1178 # If we need to use lto, find liblto, add in proper flags here, etc.
1179 if use_lto:
Michael Gottesman01f0a622013-03-13 22:38:38 +00001180 liblto_command = ['find', WithProperties('%(builddir)s/host-compiler'),
1181 '-name', 'libLTO.dylib']
Michael Gottesman1da57ae2013-03-13 21:54:23 +00001182 f.addStep(buildbot.steps.shell.SetProperty(
Michael Gottesman65d940f2013-03-13 21:51:16 +00001183 name='find.liblto',
1184 command=liblto_command,
Michael Gottesmandc771a02013-08-30 05:46:22 +00001185 extract_fn=phasedbuilderutils.find_liblto,
Michael Gottesman65d940f2013-03-13 21:51:16 +00001186 workdir=WithProperties('%(builddir)s')))
1187 configure_args.append(
1188 '--with-extra-options=-flto -gline-tables-only')
1189
David Deanf8b35442012-12-11 00:35:12 +00001190 # Configure the LLVM build.
Michael Gottesmand97d8502013-04-04 07:57:31 +00001191 if incremental:
1192 # *NOTE* This is a temporary work around. I am eventually going to just
1193 # set up cmake/ninja but for now I am sticking with the make => I need
1194 # configure to run only after a failure so on success I have incremental
1195 # builds.
1196 f.addStep(buildbot.steps.shell.ShellCommand(
1197 name='configure.with.host', command=configure_args,
1198 haltOnFailure=True, description=['configure'],
1199 workdir=clang_build_dir,
1200 doStepIf=_did_last_build_fail))
1201 else:
1202 f.addStep(buildbot.steps.shell.ShellCommand(
1203 name='configure.with.host', command=configure_args,
1204 haltOnFailure=True, description=['configure'],
1205 workdir=clang_build_dir))
1206
David Deanf8b35442012-12-11 00:35:12 +00001207 # Build the compiler.
Michael Gottesman36778832013-09-08 01:37:35 +00001208 make_command = ['make', '-j', WithProperties('%(jobs)s'), 'VERBOSE=1']
Galina Kistanovabfb29d22013-05-09 23:53:24 +00001209 timeout = 40*60 # Normal timeout is 20 minutes.
Michael Gottesman65d940f2013-03-13 21:51:16 +00001210 if use_lto:
1211 make_command.append(WithProperties('DYLD_LIBRARY_PATH=%(liblto_path)s'))
Michael Gottesman2e7385c2013-08-12 17:57:27 +00001212 timeout = 240*60 # LTO timeout is 240 minutes.
Michael Gottesman65d940f2013-03-13 21:51:16 +00001213
David Deanf8b35442012-12-11 00:35:12 +00001214 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesman65d940f2013-03-13 21:51:16 +00001215 name='make', command=make_command,
Michael Gottesmanbab77ac2013-03-14 05:36:53 +00001216 haltOnFailure=True, description=['make'], workdir=clang_build_dir,
1217 timeout=timeout))
David Deanf8b35442012-12-11 00:35:12 +00001218 # Use make install-clang to produce minimal archive for use by downstream
1219 # builders.
1220 f.addStep(buildbot.steps.shell.ShellCommand(
1221 name='make.install-clang', haltOnFailure=True,
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001222 command=['make', 'install-clang', '-j',
1223 WithProperties('%(jobs)s'),
1224 'RC_SUPPORTED_ARCHS=armv7 i386 x86_64'],
David Deanf8b35442012-12-11 00:35:12 +00001225 description=['make install'], workdir=clang_build_dir))
1226 # Save artifacts of this build for use by other builders.
Michael Gottesmana6b5be82013-06-28 21:57:20 +00001227 f = artifacts.uploadArtifacts(f)
David Deanf8b35442012-12-11 00:35:12 +00001228 # Run the LLVM and Clang regression tests.
Michael Gottesmana9c32be2013-09-06 17:47:24 +00001229 cmd_str = r"""make VERBOSE=1 LIT_ARGS="-v --param run_long_tests=true --filter='^(?!.*debuginfo-tests)'" check-all"""
1230 f.addStep(lit_test_command.LitTestCommand(name='run.llvm.tests', haltOnFailure=True,
1231 command=cmd_str,
1232 description=['all', 'tests'],
1233 workdir=clang_build_dir))
1234 # Work around for lldb issue rdar://14929651
Chris Matthewsecc0f442014-03-12 00:04:23 +00001235 # The crazy filter regex is to remove static-member[2].cpp, which requires xcode5 or later.
1236 # radar://16295455 tracks the removal of this regex.
1237 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 +00001238 f.addStep(lit_test_command.LitTestCommand(name='run.llvm.debuginfo-tests', haltOnFailure=True,
Michael Gottesmane7dc31e2013-08-30 05:57:35 +00001239 command=cmd_str,
Michael Gottesmana6b5be82013-06-28 21:57:20 +00001240 description=['all', 'tests'],
1241 workdir=clang_build_dir))
David Deanf8b35442012-12-11 00:35:12 +00001242 return f