blob: 83a77fa675059c2b3f62ab28e1413d5fe9ca0b08 [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
Daniel Sandersfa222332015-12-04 14:30:39 +00005from datetime import datetime
David Deanf8b35442012-12-11 00:35:12 +00006
Reid Kleckner25a26b02015-03-09 22:30:25 +00007from buildbot.process.properties import WithProperties, Property
David Blaikie8cbf62f2013-01-12 21:32:31 +00008from buildbot.steps.shell import Configure, ShellCommand, SetProperty
Daniel Dunbar44abe742009-07-19 01:59:03 +00009from buildbot.steps.shell import WarningCountingShellCommand
David Deanf8b35442012-12-11 00:35:12 +000010from buildbot.steps.source import SVN
Daniel Dunbar44abe742009-07-19 01:59:03 +000011from buildbot.steps.transfer import FileDownload
Michael Gottesmana6b5be82013-06-28 21:57:20 +000012
Michael Gottesman960bcfa2013-08-30 05:46:15 +000013import zorg.buildbot.util.artifacts as artifacts
Michael Gottesmana6b5be82013-06-28 21:57:20 +000014import zorg.buildbot.builders.Util as builders_util
Michael Gottesmandc771a02013-08-30 05:46:22 +000015import zorg.buildbot.util.phasedbuilderutils as phasedbuilderutils
Michael Gottesmana6b5be82013-06-28 21:57:20 +000016import zorg.buildbot.commands as commands
17import zorg.buildbot.commands.BatchFileDownload as batch_file_download
18import zorg.buildbot.commands.LitTestCommand as lit_test_command
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000019
Galina Kistanovaf4d79352011-10-20 20:46:52 +000020def getClangBuildFactory(
21 triple=None,
22 clean=True,
23 test=True,
24 package_dst=None,
25 run_cxx_tests=False,
26 examples=False,
27 valgrind=False,
28 valgrindLeakCheck=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +000029 useTwoStage=False,
30 completely_clean=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +000031 make='make',
32 jobs="%(jobs)s",
33 stage1_config='Debug+Asserts',
34 stage2_config='Release+Asserts',
35 env={}, # Environmental variables for all steps.
36 extra_configure_args=[],
Vassil Vassilev5a9b9ed2016-05-25 17:10:03 +000037 stage2_extra_configure_args=[],
Galina Kistanovaf4d79352011-10-20 20:46:52 +000038 use_pty_in_tests=False,
Peter Collingbourned49ac282011-10-25 14:38:45 +000039 trunk_revision=None,
40 force_checkout=False,
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +000041 extra_clean_step=None,
David Blaikiea76da842012-08-13 22:24:46 +000042 checkout_compiler_rt=False,
43 run_gdb=False,
David Blaikiedad03d52012-11-16 22:37:12 +000044 run_modern_gdb=False,
Vassil Vassilev0c647ef2016-06-30 21:16:45 +000045 run_gcc=False):
Galina Kistanovaf4d79352011-10-20 20:46:52 +000046 # Prepare environmental variables. Set here all env we want everywhere.
47 merged_env = {
48 'TERM' : 'dumb' # Make sure Clang doesn't use color escape sequences.
49 }
50 if env is not None:
51 # Overwrite pre-set items with the given ones, so user can set anything.
52 merged_env.update(env)
David Blaikie2f7eb282012-08-24 18:37:00 +000053
Jonathan Roelofs62415e52015-02-28 00:03:17 +000054 llvm_srcdir = "llvm.src"
55 llvm_1_objdir = "llvm.obj"
56 llvm_1_installdir = "llvm.install.1"
57 llvm_2_objdir = "llvm.obj.2"
58 llvm_2_installdir = "llvm.install"
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000059
Daniel Dunbar235aa412009-07-18 07:16:15 +000060 f = buildbot.process.factory.BuildFactory()
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000061
62 # Determine the build directory.
63 f.addStep(buildbot.steps.shell.SetProperty(name="get_builddir",
64 command=["pwd"],
65 property="builddir",
66 description="set build dir",
Galina Kistanovaf4d79352011-10-20 20:46:52 +000067 workdir=".",
68 env=merged_env))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000069
Daniel Dunbar06b20f12010-04-08 18:29:38 +000070 # Blow away completely, if requested.
71 if completely_clean:
72 f.addStep(ShellCommand(name="rm-llvm.src",
73 command=["rm", "-rf", llvm_srcdir],
74 haltOnFailure=True,
75 description=["rm src dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +000076 workdir=".",
77 env=merged_env))
Daniel Dunbar06b20f12010-04-08 18:29:38 +000078
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000079 # Checkout sources.
Peter Collingbourned49ac282011-10-25 14:38:45 +000080 if trunk_revision:
81 # The SVN build step provides no mechanism to check out a specific revision
82 # based on a property, so just run the commands directly here.
83 svn_co = ['svn', 'checkout']
84 if force_checkout:
85 svn_co += ['--force']
86 svn_co += ['--revision', WithProperties(trunk_revision)]
87
88 svn_co_llvm = svn_co + \
89 [WithProperties('http://llvm.org/svn/llvm-project/llvm/trunk@%s' %
90 trunk_revision),
91 llvm_srcdir]
92 svn_co_clang = svn_co + \
93 [WithProperties('http://llvm.org/svn/llvm-project/cfe/trunk@%s' %
94 trunk_revision),
95 '%s/tools/clang' % llvm_srcdir]
David Blaikie845ae0d2012-08-10 00:51:38 +000096 svn_co_clang_tools_extra = svn_co + \
97 [WithProperties('http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@%s' %
98 trunk_revision),
99 '%s/tools/clang/tools/extra' % llvm_srcdir]
Peter Collingbourned49ac282011-10-25 14:38:45 +0000100
101 f.addStep(ShellCommand(name='svn-llvm',
102 command=svn_co_llvm,
103 haltOnFailure=True,
104 workdir='.'))
105 f.addStep(ShellCommand(name='svn-clang',
106 command=svn_co_clang,
107 haltOnFailure=True,
108 workdir='.'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000109 f.addStep(ShellCommand(name='svn-clang-tools-extra',
110 command=svn_co_clang_tools_extra,
111 haltOnFailure=True,
112 workdir='.'))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000113 else:
114 f.addStep(SVN(name='svn-llvm',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000115 mode='update',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000116 baseURL='http://llvm.org/svn/llvm-project/llvm/',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000117 defaultBranch='trunk',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000118 workdir=llvm_srcdir))
119 f.addStep(SVN(name='svn-clang',
120 mode='update',
121 baseURL='http://llvm.org/svn/llvm-project/cfe/',
122 defaultBranch='trunk',
123 workdir='%s/tools/clang' % llvm_srcdir))
David Blaikie845ae0d2012-08-10 00:51:38 +0000124 f.addStep(SVN(name='svn-clang-tools-extra',
125 mode='update',
126 baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
127 defaultBranch='trunk',
128 workdir='%s/tools/clang/tools/extra' % llvm_srcdir))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000129 if checkout_compiler_rt:
130 f.addStep(SVN(name='svn-compiler-rt',
131 mode='update',
132 baseURL='http://llvm.org/svn/llvm-project/compiler-rt/',
133 defaultBranch='trunk',
134 workdir='%s/projects/compiler-rt' % llvm_srcdir))
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000135
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000136 # Clean up llvm (stage 1); unless in-dir.
137 if clean and llvm_srcdir != llvm_1_objdir:
138 f.addStep(ShellCommand(name="rm-llvm.obj.stage1",
139 command=["rm", "-rf", llvm_1_objdir],
140 haltOnFailure=True,
141 description=["rm build dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000142 workdir=".",
143 env=merged_env))
Andrew Trick70fa9d22011-08-25 23:38:51 +0000144
David Blaikie8cbf62f2013-01-12 21:32:31 +0000145 if not clean:
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000146 expected_makefile = 'Makefile'
David Blaikie8cbf62f2013-01-12 21:32:31 +0000147 f.addStep(SetProperty(name="Makefile_isready",
148 workdir=llvm_1_objdir,
149 command=["sh", "-c",
Richard Smith02389162014-09-26 23:53:06 +0000150 "test -e %s && echo OK || echo Missing" % expected_makefile],
David Blaikie8cbf62f2013-01-12 21:32:31 +0000151 flunkOnFailure=False,
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000152 property="exists_Makefile"))
Richard Smith02389162014-09-26 23:53:06 +0000153
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000154 cmake_triple_arg = []
155 if triple:
156 cmake_triple_arg = ['-DLLVM_HOST_TRIPLE=%s' % triple]
157 f.addStep(ShellCommand(name='cmake',
158 command=['cmake',
159 '-DLLVM_BUILD_TESTS=ON',
160 '-DCMAKE_BUILD_TYPE=%s' % stage1_config] +
161 cmake_triple_arg +
162 extra_configure_args +
163 ["../" + llvm_srcdir],
164 description='cmake stage1',
165 workdir=llvm_1_objdir,
166 env=merged_env,
167 doStepIf=lambda step: step.build.getProperty("exists_Makefile") != "OK"))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000168
169 # Make clean if using in-dir builds.
170 if clean and llvm_srcdir == llvm_1_objdir:
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000171 f.addStep(WarningCountingShellCommand(name="clean-llvm",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000172 command=[make, "clean"],
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000173 haltOnFailure=True,
174 description="cleaning llvm",
175 descriptionDone="clean llvm",
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000176 workdir=llvm_1_objdir,
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000177 doStepIf=clean,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000178 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000179
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000180 if extra_clean_step:
181 f.addStep(extra_clean_step)
182
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000183 f.addStep(WarningCountingShellCommand(name="compile",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000184 command=['nice', '-n', '10',
185 make, WithProperties("-j%s" % jobs)],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000186 haltOnFailure=True,
David Blaikie05517332013-12-19 23:29:12 +0000187 flunkOnFailure=not run_gdb,
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000188 description=["compiling", stage1_config],
189 descriptionDone=["compile", stage1_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000190 workdir=llvm_1_objdir,
191 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000192
193 if examples:
194 f.addStep(WarningCountingShellCommand(name="compile.examples",
195 command=['nice', '-n', '10',
196 make, WithProperties("-j%s" % jobs),
197 "BUILD_EXAMPLES=1"],
198 haltOnFailure=True,
Richard Smith65e6f5d2014-09-25 18:18:35 +0000199 description=["compiling", stage1_config, "examples"],
Daniel Dunbar256fed42009-11-25 21:11:08 +0000200 descriptionDone=["compile", stage1_config, "examples"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000201 workdir=llvm_1_objdir,
202 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000203
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000204 clangTestArgs = '-v -j %s' % jobs
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000205 if valgrind:
Daniel Dunbar89184b92010-04-18 19:09:32 +0000206 clangTestArgs += ' --vg'
Daniel Dunbara1bebce2010-03-21 01:24:00 +0000207 if valgrindLeakCheck:
208 clangTestArgs += ' --vg-leak'
Nick Lewycky8d26e472011-08-27 21:18:56 +0000209 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 +0000210 extraTestDirs = ''
211 if run_cxx_tests:
212 extraTestDirs += '%(builddir)s/llvm/tools/clang/utils/C++Tests'
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000213 if test:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000214 f.addStep(lit_test_command.LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000215 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000216 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000217 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie05517332013-12-19 23:29:12 +0000218 flunkOnFailure=not run_gdb,
David Blaikie7e6f8a12012-08-31 20:46:27 +0000219 description=["checking"],
220 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000221 workdir=llvm_1_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000222 usePTY=use_pty_in_tests,
223 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000224
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000225 # TODO: Install llvm and clang for stage1.
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000226
David Blaikiedad03d52012-11-16 22:37:12 +0000227 if run_gdb or run_gcc or run_modern_gdb:
David Blaikiea76da842012-08-13 22:24:46 +0000228 ignores = getClangTestsIgnoresFromPath(os.path.expanduser('~/public/clang-tests'), 'clang-x86_64-darwin10')
229 install_prefix = "%%(builddir)s/%s" % llvm_1_installdir
230 if run_gdb:
231 addClangGDBTests(f, ignores, install_prefix)
David Blaikiedad03d52012-11-16 22:37:12 +0000232 if run_modern_gdb:
David Blaikie41d09c32013-01-02 21:11:09 +0000233 addModernClangGDBTests(f, jobs, install_prefix)
David Blaikiea76da842012-08-13 22:24:46 +0000234 if run_gcc:
235 addClangGCCTests(f, ignores, install_prefix)
236
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000237 if not useTwoStage:
Daniel Dunbardedf6572010-11-13 00:23:34 +0000238 if package_dst:
239 name = WithProperties(
240 "%(builddir)s/" + llvm_1_objdir +
241 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
242 f.addStep(ShellCommand(name='pkg.tar',
243 description="tar root",
244 command=["tar", "zcvf", name, "./"],
245 workdir=llvm_1_installdir,
246 warnOnFailure=True,
247 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000248 haltOnFailure=False,
249 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000250 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000251 description="upload root",
Daniel Dunbardedf6572010-11-13 00:23:34 +0000252 command=["scp", name,
253 WithProperties(
254 package_dst + "/%(buildername)s")],
255 workdir=".",
256 warnOnFailure=True,
257 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000258 haltOnFailure=False,
259 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000260
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000261 return f
262
263 # Clean up llvm (stage 2).
Richard Smith02389162014-09-26 23:53:06 +0000264 #
Galina Kistanova79900972015-11-16 17:30:42 +0000265 # We always cleanly build the stage 2. If the compiler has been
266 # changed on the stage 1, we cannot trust any of the intermediate file
267 # from the old compiler. And if the stage 1 compiler is the same, we should
268 # not build in the first place.
269 f.addStep(ShellCommand(name="rm-llvm.obj.stage2",
270 command=["rm", "-rf", llvm_2_objdir],
271 haltOnFailure=True,
272 description=["rm build dir", "llvm", "(stage 2)"],
273 workdir=".",
274 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000275
276 # Configure llvm (stage 2).
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000277 f.addStep(ShellCommand(name='cmake',
Vassil Vassilev5a9b9ed2016-05-25 17:10:03 +0000278 command=['cmake'] + stage2_extra_configure_args + [
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000279 '-DLLVM_BUILD_TESTS=ON',
280 WithProperties('-DCMAKE_C_COMPILER=%%(builddir)s/%s/bin/clang' % llvm_1_objdir), # FIXME use installdir
281 WithProperties('-DCMAKE_CXX_COMPILER=%%(builddir)s/%s/bin/clang++' % llvm_1_objdir),
282 '-DCMAKE_BUILD_TYPE=%s' % stage2_config,
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000283 "../" + llvm_srcdir],
284 description='cmake stage2',
285 workdir=llvm_2_objdir,
286 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000287
288 # Build llvm (stage 2).
289 f.addStep(WarningCountingShellCommand(name="compile.llvm.stage2",
290 command=['nice', '-n', '10',
291 make, WithProperties("-j%s" % jobs)],
292 haltOnFailure=True,
293 description=["compiling", "(stage 2)",
294 stage2_config],
295 descriptionDone=["compile", "(stage 2)",
296 stage2_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000297 workdir=llvm_2_objdir,
298 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000299
300 if test:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000301 f.addStep(lit_test_command.LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000302 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000303 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000304 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie7e6f8a12012-08-31 20:46:27 +0000305 description=["checking"],
306 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000307 workdir=llvm_2_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000308 usePTY=use_pty_in_tests,
309 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000310
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000311 # TODO: Install llvm and clang for stage2.
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000312
313 if package_dst:
314 name = WithProperties(
315 "%(builddir)s/" + llvm_2_objdir +
316 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
317 f.addStep(ShellCommand(name='pkg.tar',
318 description="tar root",
319 command=["tar", "zcvf", name, "./"],
320 workdir=llvm_2_installdir,
321 warnOnFailure=True,
322 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000323 haltOnFailure=False,
324 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000325 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000326 description="upload root",
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000327 command=["scp", name,
328 WithProperties(
329 package_dst + "/%(buildername)s")],
330 workdir=".",
331 warnOnFailure=True,
332 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000333 haltOnFailure=False,
334 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000335
Daniel Dunbar235aa412009-07-18 07:16:15 +0000336 return f
Daniel Dunbar44abe742009-07-19 01:59:03 +0000337
Renato Golin61aed7f2015-06-17 19:12:50 +0000338def addSVNUpdateSteps(f,
339 checkout_clang_tools_extra,
340 checkout_compiler_rt,
341 checkout_test_suite):
Renato Goline402f582014-09-04 19:25:24 +0000342 # We *must* checkout at least Clang+LLVM
343 f.addStep(SVN(name='svn-llvm',
344 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
345 defaultBranch='trunk',
346 workdir='llvm'))
347 f.addStep(SVN(name='svn-clang',
348 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
349 defaultBranch='trunk',
350 workdir='llvm/tools/clang'))
351
352 # Extra stuff that will be built/tested
353 if checkout_clang_tools_extra:
354 f.addStep(SVN(name='svn-clang-tools-extra',
355 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
356 defaultBranch='trunk',
357 workdir='llvm/tools/clang/tools/extra'))
358 if checkout_compiler_rt:
359 f.addStep(SVN(name='svn-compiler-rt',
360 mode='update', baseURL='http://llvm.org/svn/llvm-project/compiler-rt/',
361 defaultBranch='trunk',
362 workdir='llvm/projects/compiler-rt'))
Renato Golin61aed7f2015-06-17 19:12:50 +0000363 if checkout_test_suite:
364 f.addStep(SVN(name='svn-lnt',
365 mode='update', baseURL='http://llvm.org/svn/llvm-project/lnt/',
366 defaultBranch='trunk',
367 workdir='test/lnt'))
368 f.addStep(SVN(name='svn-test-suite',
369 mode='update', baseURL='http://llvm.org/svn/llvm-project/test-suite/',
370 defaultBranch='trunk',
371 workdir='test/test-suite'))
Renato Goline402f582014-09-04 19:25:24 +0000372
Daniel Sandersfa222332015-12-04 14:30:39 +0000373def addGCSUploadSteps(f, package_name, install_prefix, gcs_directory, env,
374 gcs_url_property=None):
375 """
376 Add steps to upload to the Google Cloud Storage bucket.
377
378 f - The BuildFactory to modify.
379 package_name - The name of this package for the descriptions (e.g.
380 'stage 1')
381 install_prefix - The directory the build has been installed to.
382 gcs_directory - The subdirectory of the bucket root to upload to. This
383 should match the builder name.
384 env - The environment to use. Set BOTO_CONFIG to use a configuration file
385 in a non-standard location, and BUCKET to use a different GCS bucket.
386 gcs_url_property - Property to assign the GCS url to.
387 """
388
389 gcs_url_fmt = ('gs://%(gcs_bucket)s/%(gcs_directory)s/'
390 'clang-r%(got_revision)s-t%(now)s-b%(buildnumber)s.tar.xz')
391 time_fmt = '%Y-%m-%d_%H-%M-%S'
392 gcs_url = \
393 WithProperties(
394 gcs_url_fmt,
395 gcs_bucket=lambda _: env.get('BUCKET', 'llvm-build-artifacts'),
396 gcs_directory=lambda _: gcs_directory,
397 now=lambda _: datetime.utcnow().strftime(time_fmt))
398
399 if gcs_url_property:
400 f.addStep(SetProperty(
401 name="record GCS url for " + package_name,
402 command=['echo', gcs_url],
403 property=gcs_url_property))
404
405 f.addStep(ShellCommand(name='package ' + package_name,
406 command=['tar', 'cvfJ', '../install.tar.xz', '.'],
407 description='packaging ' + package_name + '...',
408 workdir=install_prefix,
409 env=env))
410
411 f.addStep(ShellCommand(
412 name='upload ' + package_name + ' to storage bucket',
413 command=['gsutil', 'cp', '../install.tar.xz', gcs_url],
414 description=('uploading ' + package_name +
415 'to storage bucket ...'),
416 workdir=install_prefix,
417 env=env))
418
419def getClangCMakeGCSBuildFactory(
420 clean=True,
421 test=True,
422 cmake='cmake',
423 jobs=None,
424
425 # VS tools environment variable if using MSVC. For example,
426 # %VS120COMNTOOLS% selects the 2013 toolchain.
427 vs=None,
428 vs_target_arch='x86',
429
430 # Multi-stage compilation
431 useTwoStage=False,
432 testStage1=True,
433 stage1_config='Release',
434 stage2_config='Release',
435
436 # Test-suite
437 runTestSuite=False,
438 nt_flags=[],
439 submitURL=None,
440 testerName=None,
441
442 # Environmental variables for all steps.
443 env={},
444 extra_cmake_args=[],
445
446 # Extra repositories
447 checkout_clang_tools_extra=True,
448 checkout_compiler_rt=True,
449
450 # Upload artifacts to Google Cloud Storage (for the llvmbisect tool)
451 stage1_upload_directory=None,
452
453 # Triggers
454 trigger_after_stage1=[]):
455 return _getClangCMakeBuildFactory(
456 clean=clean, test=test, cmake=cmake, jobs=jobs, vs=vs,
457 vs_target_arch=vs_target_arch, useTwoStage=useTwoStage,
458 testStage1=testStage1, stage1_config=stage1_config,
459 stage2_config=stage2_config, runTestSuite=runTestSuite,
460 nt_flags=nt_flags, submitURL=submitURL, testerName=testerName,
461 env=env, extra_cmake_args=extra_cmake_args,
462 checkout_clang_tools_extra=checkout_clang_tools_extra,
463 checkout_compiler_rt=checkout_compiler_rt,
464 stage1_upload_directory=stage1_upload_directory,
465 trigger_after_stage1=trigger_after_stage1)
Reid Kleckner25a26b02015-03-09 22:30:25 +0000466
467def getClangCMakeBuildFactory(
468 clean=True,
469 test=True,
470 cmake='cmake',
471 jobs=None,
472
473 # VS tools environment variable if using MSVC. For example,
474 # %VS120COMNTOOLS% selects the 2013 toolchain.
475 vs=None,
476 vs_target_arch='x86',
477
478 # Multi-stage compilation
479 useTwoStage=False,
480 testStage1=True,
481 stage1_config='Release',
482 stage2_config='Release',
483
Renato Golin61aed7f2015-06-17 19:12:50 +0000484 # Test-suite
485 runTestSuite=False,
486 nt_flags=[],
487 submitURL=None,
488 testerName=None,
489
Reid Kleckner25a26b02015-03-09 22:30:25 +0000490 # Environmental variables for all steps.
491 env={},
492 extra_cmake_args=[],
493
494 # Extra repositories
495 checkout_clang_tools_extra=True,
496 checkout_compiler_rt=True):
Daniel Sandersfa222332015-12-04 14:30:39 +0000497 return _getClangCMakeBuildFactory(
498 clean=clean, test=test, cmake=cmake, jobs=jobs, vs=vs,
499 vs_target_arch=vs_target_arch, useTwoStage=useTwoStage,
500 testStage1=testStage1, stage1_config=stage1_config,
501 stage2_config=stage2_config, runTestSuite=runTestSuite,
502 nt_flags=nt_flags, submitURL=submitURL, testerName=testerName,
503 env=env, extra_cmake_args=extra_cmake_args,
504 checkout_clang_tools_extra=checkout_clang_tools_extra,
505 checkout_compiler_rt=checkout_compiler_rt)
506
507def _getClangCMakeBuildFactory(
508 clean=True,
509 test=True,
510 cmake='cmake',
511 jobs=None,
512
513 # VS tools environment variable if using MSVC. For example,
514 # %VS120COMNTOOLS% selects the 2013 toolchain.
515 vs=None,
516 vs_target_arch='x86',
517
518 # Multi-stage compilation
519 useTwoStage=False,
520 testStage1=True,
521 stage1_config='Release',
522 stage2_config='Release',
523
524 # Test-suite
525 runTestSuite=False,
526 nt_flags=[],
527 submitURL=None,
528 testerName=None,
529
530 # Environmental variables for all steps.
531 env={},
532 extra_cmake_args=[],
533
534 # Extra repositories
535 checkout_clang_tools_extra=True,
536 checkout_compiler_rt=True,
537
538 # Upload artifacts to Google Cloud Storage (for the llvmbisect tool)
539 stage1_upload_directory=None,
540
541 # Triggers
542 trigger_after_stage1=[]):
Reid Kleckner25a26b02015-03-09 22:30:25 +0000543
544 ############# PREPARING
545 f = buildbot.process.factory.BuildFactory()
546
Renato Golin61aed7f2015-06-17 19:12:50 +0000547 addSVNUpdateSteps(f,
548 checkout_clang_tools_extra=checkout_clang_tools_extra,
549 checkout_compiler_rt=checkout_compiler_rt,
550 checkout_test_suite=runTestSuite)
Reid Kleckner25a26b02015-03-09 22:30:25 +0000551
Renato Goline402f582014-09-04 19:25:24 +0000552 # If jobs not defined, Ninja will choose a suitable value
Renato Golincc83db32015-06-17 19:23:40 +0000553 jobs_cmd = []
554 lit_args = "'-v"
Renato Goline402f582014-09-04 19:25:24 +0000555 if jobs is not None:
Renato Golincc83db32015-06-17 19:23:40 +0000556 jobs_cmd = ["-j"+str(jobs)]
557 lit_args += " -j"+str(jobs)+"'"
Renato Goline402f582014-09-04 19:25:24 +0000558 else:
Renato Golincc83db32015-06-17 19:23:40 +0000559 lit_args += "'"
560 ninja_cmd = ['ninja'] + jobs_cmd
561 ninja_install_cmd = ['ninja', 'install'] + jobs_cmd
562 ninja_check_cmd = ['ninja', 'check-all'] + jobs_cmd
Reid Kleckner25a26b02015-03-09 22:30:25 +0000563 check_build_cmd = ["sh", "-c",
564 "test -e build.ninja && echo OK || echo Missing"]
565 if vs:
566 check_build_cmd = ["cmd", "/c", "if exist build.ninja (echo OK) " +
567 " else (echo Missing & exit 1)"]
Renato Goline402f582014-09-04 19:25:24 +0000568
569 # Global configurations
Renato Golincc83db32015-06-17 19:23:40 +0000570 stage1_build = 'stage1'
571 stage1_install = 'stage1.install'
572 stage2_build = 'stage2'
573 stage2_install = 'stage2.install'
Renato Goline402f582014-09-04 19:25:24 +0000574
Reid Kleckner25a26b02015-03-09 22:30:25 +0000575 # Set up VS environment, if appropriate.
576 if vs:
577 f.addStep(SetProperty(
578 command=builders_util.getVisualStudioEnvironment(vs, vs_target_arch),
579 extract_fn=builders_util.extractSlaveEnvironment))
580 assert not env, "Can't have custom builder env vars with VS"
581 env = Property('slave_env')
582
583
Renato Goline402f582014-09-04 19:25:24 +0000584 ############# CLEANING
585 if clean:
586 f.addStep(ShellCommand(name='clean stage 1',
587 command=['rm','-rf',stage1_build],
588 warnOnFailure=True,
589 description='cleaning stage 1',
590 descriptionDone='clean',
591 workdir='.',
592 env=env))
593 else:
594 f.addStep(SetProperty(name="check ninja files 1",
595 workdir=stage1_build,
Reid Kleckner25a26b02015-03-09 22:30:25 +0000596 command=check_build_cmd,
Renato Goline402f582014-09-04 19:25:24 +0000597 flunkOnFailure=False,
598 property="exists_ninja_1"))
599
600
601 ############# STAGE 1
602 f.addStep(ShellCommand(name='cmake stage 1',
603 command=[cmake, "-G", "Ninja", "../llvm",
604 "-DCMAKE_BUILD_TYPE="+stage1_config,
605 "-DLLVM_ENABLE_ASSERTIONS=True",
606 "-DLLVM_LIT_ARGS="+lit_args,
607 "-DCMAKE_INSTALL_PREFIX=../"+stage1_install]
608 + extra_cmake_args,
609 haltOnFailure=True,
610 description='cmake stage 1',
611 workdir=stage1_build,
612 doStepIf=lambda step: step.build.getProperty("exists_ninja_1") != "OK",
613 env=env))
614
615 f.addStep(WarningCountingShellCommand(name='build stage 1',
616 command=ninja_cmd,
617 haltOnFailure=True,
618 description='ninja all',
619 workdir=stage1_build,
620 env=env))
621
622 if test and testStage1:
Renato Golind1c46742015-08-06 18:05:34 +0000623 haltOnStage1Check = not useTwoStage and not runTestSuite
Renato Golincfbd5702014-09-06 19:09:16 +0000624 f.addStep(lit_test_command.LitTestCommand(name='ninja check 1',
625 command=ninja_check_cmd,
Renato Golind1c46742015-08-06 18:05:34 +0000626 haltOnFailure=haltOnStage1Check,
Renato Golincfbd5702014-09-06 19:09:16 +0000627 description=["checking stage 1"],
628 descriptionDone=["stage 1 checked"],
629 workdir=stage1_build,
630 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000631
Daniel Sandersfa222332015-12-04 14:30:39 +0000632 if useTwoStage or runTestSuite or stage1_upload_directory:
Renato Golin61aed7f2015-06-17 19:12:50 +0000633 f.addStep(ShellCommand(name='install stage 1',
634 command=ninja_install_cmd,
635 description='ninja install',
636 workdir=stage1_build,
Renato Goline402f582014-09-04 19:25:24 +0000637 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000638
Daniel Sandersfa222332015-12-04 14:30:39 +0000639 if stage1_upload_directory:
640 addGCSUploadSteps(f, 'stage 1', stage1_install, stage1_upload_directory,
641 env, gcs_url_property='stage1_package_gcs_url')
642
Reid Kleckner25a26b02015-03-09 22:30:25 +0000643 # Compute the cmake define flag to set the C and C++ compiler to clang. Use
644 # clang-cl if we used MSVC for stage1.
645 if not vs:
646 cc = 'clang'
647 cxx = 'clang++'
648 else:
649 cc = 'clang-cl.exe'
650 cxx = 'clang-cl.exe'
651
Reid Kleckner25a26b02015-03-09 22:30:25 +0000652
Renato Golin61aed7f2015-06-17 19:12:50 +0000653 ############# STAGE 2
654 if useTwoStage:
Galina Kistanova79900972015-11-16 17:30:42 +0000655 # We always cleanly build the stage 2. If the compiler has been
656 # changed on the stage 1, we cannot trust any of the intermediate file
657 # from the old compiler. And if the stage 1 compiler is the same, we
658 # should not build in the first place.
659 f.addStep(ShellCommand(name='clean stage 2',
660 command=['rm','-rf',stage2_build],
661 warnOnFailure=True,
662 description='cleaning stage 2',
663 descriptionDone='clean',
664 workdir='.',
665 env=env))
Reid Kleckner25a26b02015-03-09 22:30:25 +0000666
Renato Golin61aed7f2015-06-17 19:12:50 +0000667 # Set the compiler using the CC and CXX environment variables to work around
668 # backslash string escaping bugs somewhere between buildbot and cmake. The
669 # env.exe helper is required to run the tests, so hopefully it's already on
670 # PATH.
671 cmake_cmd2 = ['env',
672 WithProperties('CC=%(workdir)s/'+stage1_install+'/bin/'+cc),
673 WithProperties('CXX=%(workdir)s/'+stage1_install+'/bin/'+cxx),
674 cmake, "-G", "Ninja", "../llvm",
675 "-DCMAKE_BUILD_TYPE="+stage2_config,
676 "-DLLVM_ENABLE_ASSERTIONS=True",
677 "-DLLVM_LIT_ARGS="+lit_args,
678 "-DCMAKE_INSTALL_PREFIX=../"+stage2_install] + extra_cmake_args
Reid Kleckner25a26b02015-03-09 22:30:25 +0000679
Renato Golin61aed7f2015-06-17 19:12:50 +0000680 f.addStep(ShellCommand(name='cmake stage 2',
681 command=cmake_cmd2,
682 haltOnFailure=True,
683 description='cmake stage 2',
684 workdir=stage2_build,
685 doStepIf=lambda step: step.build.getProperty("exists_ninja_2") != "OK",
686 env=env))
687
688 f.addStep(WarningCountingShellCommand(name='build stage 2',
689 command=ninja_cmd,
690 haltOnFailure=True,
691 description='ninja all',
692 workdir=stage2_build,
693 env=env))
694
695 if test:
696 f.addStep(lit_test_command.LitTestCommand(name='ninja check 2',
697 command=ninja_check_cmd,
698 haltOnFailure=not runTestSuite,
699 description=["checking stage 2"],
700 descriptionDone=["stage 2 checked"],
701 workdir=stage2_build,
702 env=env))
703
704 ############# TEST SUITE
705 ## Test-Suite (stage 2 if built, stage 1 otherwise)
706 if runTestSuite:
707 compiler_path = stage1_install
708 if useTwoStage:
709 compiler_path=stage2_install
710 f.addStep(ShellCommand(name='install stage 2',
711 command=ninja_install_cmd,
712 description='ninja install 2',
Renato Golincfbd5702014-09-06 19:09:16 +0000713 workdir=stage2_build,
714 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000715
Renato Golin61aed7f2015-06-17 19:12:50 +0000716 # Get generated python, lnt
717 python = WithProperties('%(workdir)s/test/sandbox/bin/python')
718 lnt = WithProperties('%(workdir)s/test/sandbox/bin/lnt')
719 lnt_setup = WithProperties('%(workdir)s/test/lnt/setup.py')
720
721 # Paths
722 sandbox = WithProperties('%(workdir)s/test/sandbox')
723 test_suite_dir = WithProperties('%(workdir)s/test/test-suite')
724
725 # Get latest built Clang (stage1 or stage2)
726 cc = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cc)
727 cxx = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cxx)
728
729 # LNT Command line
730 if jobs is None:
731 jobs = 1
732 test_suite_cmd = [python, lnt, 'runtest', 'nt',
733 '-j'+str(jobs),
734 '--no-timestamp',
735 '--sandbox', sandbox,
736 '--test-suite', test_suite_dir,
737 '--cc', cc,
738 '--cxx', cxx]
739 # Append any option provided by the user
740 test_suite_cmd.extend(nt_flags)
741 # Only submit if a URL has been specified
742 if submitURL is not None:
743 if not isinstance(submitURL, list):
744 submitURL = [submitURL]
745 for url in submitURL:
746 test_suite_cmd.extend(['--submit', url])
747 if testerName:
748 test_suite_cmd.extend(['--no-machdep-info', testerName])
749 # CC and CXX are needed as env for build-tools
Renato Goline6c1b3b2015-07-01 15:52:22 +0000750 test_suite_env = copy.deepcopy(env)
Renato Golin61aed7f2015-06-17 19:12:50 +0000751 test_suite_env['CC'] = cc
752 test_suite_env['CXX'] = cxx
753
754 # Steps to prepare, build and run LNT
755 f.addStep(ShellCommand(name='clean sandbox',
756 command=['rm', '-rf', 'sandbox'],
757 haltOnFailure=True,
758 description='removing sandbox directory',
759 workdir='test',
760 env=env))
761 f.addStep(ShellCommand(name='recreate sandbox',
762 command=['virtualenv', 'sandbox'],
763 haltOnFailure=True,
764 description='recreating sandbox',
765 workdir='test',
766 env=env))
767 f.addStep(ShellCommand(name='setup lit',
768 command=[python, lnt_setup, 'develop'],
769 haltOnFailure=True,
770 description='setting up LNT in sandbox',
771 workdir='test/sandbox',
772 env=env))
773 f.addStep(commands.LitTestCommand.LitTestCommand(
774 name='test-suite',
775 command=test_suite_cmd,
776 haltOnFailure=True,
777 description=['running the test suite'],
778 workdir='test/sandbox',
779 logfiles={'configure.log' : 'build/configure.log',
780 'build-tools.log' : 'build/build-tools.log',
781 'test.log' : 'build/test.log',
782 'report.json' : 'build/report.json'},
783 env=test_suite_env))
784
Renato Goline402f582014-09-04 19:25:24 +0000785 return f
786
Daniel Dunbarc51a59e2010-09-23 14:57:45 +0000787def getClangMSVCBuildFactory(update=True, clean=True, vcDrive='c', jobs=1, cmake=r"cmake"):
Daniel Dunbar44abe742009-07-19 01:59:03 +0000788 f = buildbot.process.factory.BuildFactory()
789
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000790 if update:
Daniel Dunbar44abe742009-07-19 01:59:03 +0000791 f.addStep(SVN(name='svn-llvm',
792 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
793 defaultBranch='trunk',
794 workdir='llvm'))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000795 f.addStep(SVN(name='svn-clang',
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000796 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
Daniel Dunbar44abe742009-07-19 01:59:03 +0000797 defaultBranch='trunk',
798 workdir='llvm/tools/clang'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000799 f.addStep(SVN(name='svn-clang-tools-extra',
800 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
801 defaultBranch='trunk',
802 workdir='llvm/tools/clang/tools/extra'))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000803
804 # Full & fast clean.
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000805 if clean:
Daniel Dunbar44abe742009-07-19 01:59:03 +0000806 f.addStep(ShellCommand(name='clean-1',
807 command=['del','/s/q','build'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000808 warnOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000809 description='cleaning',
810 descriptionDone='clean',
811 workdir='llvm'))
812 f.addStep(ShellCommand(name='clean-2',
813 command=['rmdir','/s/q','build'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000814 warnOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000815 description='cleaning',
816 descriptionDone='clean',
817 workdir='llvm'))
818
819 # Create the project files.
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000820
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000821 # Use batch files instead of ShellCommand directly, Windows quoting is
822 # borked. FIXME: See buildbot ticket #595 and buildbot ticket #377.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000823 f.addStep(batch_file_download.BatchFileDownload(name='cmakegen',
Daniel Dunbar06b20f12010-04-08 18:29:38 +0000824 command=[cmake,
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000825 "-DLLVM_TARGETS_TO_BUILD:=X86",
Daniel Dunbar1ddedce2010-09-24 19:57:34 +0000826 "-DLLVM_INCLUDE_EXAMPLES:=OFF",
827 "-DLLVM_INCLUDE_TESTS:=OFF",
828 "-DLLVM_TARGETS_TO_BUILD:=X86",
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000829 "-G",
830 "Visual Studio 9 2008",
831 ".."],
832 workdir="llvm\\build"))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000833 f.addStep(ShellCommand(name='cmake',
834 command=['cmakegen.bat'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000835 haltOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000836 description='cmake gen',
837 workdir='llvm\\build'))
838
839 # Build it.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000840 f.addStep(batch_file_download.BatchFileDownload(name='vcbuild',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000841 command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""",
842 "/M%d" % jobs,
843 "LLVM.sln",
844 "Debug|Win32"],
845 workdir="llvm\\build"))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000846 f.addStep(WarningCountingShellCommand(name='vcbuild',
847 command=['vcbuild.bat'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000848 haltOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000849 description='vcbuild',
850 workdir='llvm\\build',
851 warningPattern=" warning C.*:"))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000852
853 # Build clang-test project.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000854 f.addStep(batch_file_download.BatchFileDownload(name='vcbuild_test',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000855 command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""",
856 "clang-test.vcproj",
857 "Debug|Win32"],
858 workdir="llvm\\build\\tools\\clang\\test"))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000859 f.addStep(lit_test_command.LitTestCommand(name='test-clang',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000860 command=["vcbuild_test.bat"],
861 workdir="llvm\\build\\tools\\clang\\test"))
862
Daniel Dunbar44abe742009-07-19 01:59:03 +0000863 return f
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000864
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000865# Builds on Windows using CMake, MinGW(32|64), and no Microsoft tools.
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000866def getClangMinGWBuildFactory(update=True, clean=True, jobs=6, cmake=r"cmake"):
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000867 f = buildbot.process.factory.BuildFactory()
868
869 if update:
870 f.addStep(SVN(name='svn-llvm',
871 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
872 defaultBranch='trunk',
873 workdir='llvm'))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000874 f.addStep(SVN(name='svn-clang',
875 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
876 defaultBranch='trunk',
877 workdir='llvm/tools/clang'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000878 f.addStep(SVN(name='svn-clang-tools-extra',
879 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
880 defaultBranch='trunk',
881 workdir='llvm/tools/clang/tools/extra'))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000882
883 # Full & fast clean.
884 if clean:
885 # note: This command is redundant as the next command removes everything
886 f.addStep(ShellCommand(name='clean-1',
887 command=['del','/s/q','build'],
888 warnOnFailure=True,
889 description='cleaning',
890 descriptionDone='clean',
891 workdir='llvm'))
892 f.addStep(ShellCommand(name='clean-2',
893 command=['rmdir','/s/q','build'],
894 warnOnFailure=True,
895 description='cleaning',
896 descriptionDone='clean',
897 workdir='llvm'))
898
899 # Create the Makefiles.
900
901 # Use batch files instead of ShellCommand directly, Windows quoting is
902 # borked. FIXME: See buildbot ticket #595 and buildbot ticket #377.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000903 f.addStep(batch_file_download.BatchFileDownload(name='cmakegen',
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000904 command=[cmake,
905 "-DLLVM_TARGETS_TO_BUILD:=X86",
906 "-DLLVM_INCLUDE_EXAMPLES:=OFF",
907 "-DLLVM_INCLUDE_TESTS:=OFF",
908 "-DLLVM_TARGETS_TO_BUILD:=X86",
909 "-G",
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000910 "Ninja",
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000911 ".."],
912 workdir="llvm\\build"))
913 f.addStep(ShellCommand(name='cmake',
914 command=['cmakegen.bat'],
915 haltOnFailure=True,
916 description='cmake gen',
917 workdir='llvm\\build'))
918
919 # Build it.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000920 f.addStep(batch_file_download.BatchFileDownload(name='makeall',
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000921 command=["ninja", "-j", "%d" % jobs],
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000922 haltOnFailure=True,
923 workdir='llvm\\build'))
924
925 f.addStep(WarningCountingShellCommand(name='makeall',
926 command=['makeall.bat'],
927 haltOnFailure=True,
928 description='makeall',
929 workdir='llvm\\build'))
930
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000931 # Build global check project (make check) (sources not checked out...).
932 if 0:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000933 f.addStep(batch_file_download.BatchFileDownload(name='makecheck',
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000934 command=["ninja", "check"],
935 workdir='llvm\\build'))
936 f.addStep(WarningCountingShellCommand(name='check',
937 command=['makecheck.bat'],
938 description='make check',
939 workdir='llvm\\build'))
Galina Kistanova049d76c2012-06-09 00:56:05 +0000940
941 # Build clang-test project (make clang-test).
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000942 f.addStep(batch_file_download.BatchFileDownload(name='maketest',
943 command=["ninja", "clang-test"],
944 workdir="llvm\\build"))
945 f.addStep(lit_test_command.LitTestCommand(name='clang-test',
946 command=["maketest.bat"],
947 workdir="llvm\\build"))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000948 return f
949
Daniel Dunbar7363d032011-02-27 03:22:35 +0000950def addClangGCCTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install",
951 languages = ('gcc', 'g++', 'objc', 'obj-c++')):
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000952 make_vars = [WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000953 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000954 WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000955 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
David Blaikie05517332013-12-19 23:29:12 +0000956 f.addStep(SVN(name='svn-clang-gcc-tests', mode='update',
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000957 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
958 defaultBranch='trunk', workdir='clang-tests'))
959 gcc_dg_ignores = ignores.get('gcc-4_2-testsuite', {})
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000960 for lang in languages:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000961 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000962 name='test-gcc-4_2-testsuite-%s' % lang,
963 command=["make", "-k", "check-%s" % lang] + make_vars,
964 description="gcc-4_2-testsuite (%s)" % lang,
965 workdir='clang-tests/gcc-4_2-testsuite',
David Dean2bd0c3a2011-10-18 16:36:28 +0000966 logfiles={ 'dg.sum' : 'obj/%s/%s.sum' % (lang, lang),
967 '%s.log' % lang : 'obj/%s/%s.log' % (lang, lang)},
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000968 ignore=gcc_dg_ignores.get(lang, [])))
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000969
Daniel Dunbar7363d032011-02-27 03:22:35 +0000970def addClangGDBTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install"):
971 make_vars = [WithProperties(
972 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
973 WithProperties(
974 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
David Blaikie05517332013-12-19 23:29:12 +0000975 f.addStep(SVN(name='svn-clang-gdb-tests', mode='update',
Daniel Dunbar7363d032011-02-27 03:22:35 +0000976 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
977 defaultBranch='trunk', workdir='clang-tests'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000978 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar7363d032011-02-27 03:22:35 +0000979 name='test-gdb-1472-testsuite',
980 command=["make", "-k", "check"] + make_vars,
981 description="gdb-1472-testsuite",
982 workdir='clang-tests/gdb-1472-testsuite',
David Blaikie7ec695f2012-10-09 22:17:09 +0000983 logfiles={ 'dg.sum' : 'obj/filtered.gdb.sum',
David Blaikie624f4392012-11-05 22:34:35 +0000984 'gdb.log' : 'obj/gdb.log' }))
Daniel Dunbar7363d032011-02-27 03:22:35 +0000985
David Blaikie41d09c32013-01-02 21:11:09 +0000986def addModernClangGDBTests(f, jobs, install_prefix):
David Blaikie1bc5c372012-12-05 05:29:12 +0000987 make_vars = [WithProperties('RUNTESTFLAGS=CC_FOR_TARGET=\'{0}/bin/clang\' '
988 'CXX_FOR_TARGET=\'{0}/bin/clang++\' '
David Blaikie759bb752013-04-18 23:13:11 +0000989 'CFLAGS_FOR_TARGET=\'-w -fno-limit-debug-info\''
David Blaikief89877b2013-01-29 23:46:26 +0000990 .format(install_prefix))]
David Blaikie05517332013-12-19 23:29:12 +0000991 f.addStep(SVN(name='svn-clang-modern-gdb-tests', mode='update',
David Blaikief3f300b2012-11-17 01:13:41 +0000992 svnurl='http://llvm.org/svn/llvm-project/clang-tests-external/trunk/gdb/7.5',
David Blaikiedad03d52012-11-16 22:37:12 +0000993 workdir='clang-tests/src'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000994 f.addStep(Configure(command='../src/configure',
David Blaikief3f300b2012-11-17 01:13:41 +0000995 workdir='clang-tests/build/'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000996 f.addStep(WarningCountingShellCommand(name='gdb-75-build',
997 command=['make', WithProperties('-j%s' % jobs)],
998 haltOnFailure=True,
999 workdir='clang-tests/build'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +00001000 f.addStep(commands.DejaGNUCommand.DejaGNUCommand(
David Blaikiedad03d52012-11-16 22:37:12 +00001001 name='gdb-75-check',
David Blaikieb83bfdf2012-12-05 04:33:42 +00001002 command=['make', '-k', WithProperties('-j%s' % jobs), 'check'] + make_vars,
David Blaikiedad03d52012-11-16 22:37:12 +00001003 workdir='clang-tests/build',
David Blaikie1bc5c372012-12-05 05:29:12 +00001004 logfiles={'dg.sum':'gdb/testsuite/gdb.sum',
1005 'gdb.log':'gdb/testsuite/gdb.log'}))
David Blaikiedad03d52012-11-16 22:37:12 +00001006
1007
1008
Daniel Dunbar7363d032011-02-27 03:22:35 +00001009# FIXME: Deprecated.
1010addClangTests = addClangGCCTests
1011
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +00001012def getClangTestsIgnoresFromPath(path, key):
1013 def readList(path):
1014 if not os.path.exists(path):
1015 return []
1016
1017 f = open(path)
1018 lines = [ln.strip() for ln in f]
1019 f.close()
1020 return lines
1021
1022 ignores = {}
1023
1024 gcc_dg_ignores = {}
1025 for lang in ('gcc', 'g++', 'objc', 'obj-c++'):
1026 lang_path = os.path.join(path, 'gcc-4_2-testsuite', 'expected_results',
1027 key, lang)
1028 gcc_dg_ignores[lang] = (
1029 readList(os.path.join(lang_path, 'FAIL.txt')) +
1030 readList(os.path.join(lang_path, 'UNRESOLVED.txt')) +
1031 readList(os.path.join(lang_path, 'XPASS.txt')))
1032 ignores['gcc-4_2-testsuite' ] = gcc_dg_ignores
1033
Daniel Dunbar7363d032011-02-27 03:22:35 +00001034 ignores_path = os.path.join(path, 'gdb-1472-testsuite', 'expected_results',
1035 key)
1036 gdb_dg_ignores = (
1037 readList(os.path.join(ignores_path, 'FAIL.txt')) +
1038 readList(os.path.join(ignores_path, 'UNRESOLVED.txt')) +
1039 readList(os.path.join(ignores_path, 'XPASS.txt')))
1040 ignores['gdb-1472-testsuite' ] = gdb_dg_ignores
1041
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +00001042 return ignores
David Deanf8b35442012-12-11 00:35:12 +00001043
Michael Gottesmandc771a02013-08-30 05:46:22 +00001044from zorg.buildbot.util.phasedbuilderutils import getBuildDir, setProperty
Michael Gottesman94e9ee42013-04-04 06:52:04 +00001045from zorg.buildbot.builders.Util import _did_last_build_fail
David Deanf8b35442012-12-11 00:35:12 +00001046from buildbot.steps.source.svn import SVN as HostSVN
1047
Michael Gottesman94e9ee42013-04-04 06:52:04 +00001048def phasedClang(config_options, is_bootstrap=True, use_lto=False,
Justin Bogner9605b3f2014-05-30 23:25:46 +00001049 incremental=False):
David Deanf8b35442012-12-11 00:35:12 +00001050 # Create an instance of the Builder.
1051 f = buildbot.process.factory.BuildFactory()
1052 # Determine the build directory.
1053 f = getBuildDir(f)
1054 # get rid of old archives from prior builds
1055 f.addStep(buildbot.steps.shell.ShellCommand(
Chris Matthews92ce8e22014-01-03 21:28:27 +00001056 name='rm.archives', command=['sh', '-c', 'sudo rm -rfv *gz'],
David Deanf8b35442012-12-11 00:35:12 +00001057 haltOnFailure=False, description=['rm archives'],
1058 workdir=WithProperties('%(builddir)s')))
1059 # Clean the build directory.
1060 clang_build_dir = 'clang-build'
Michael Gottesman94e9ee42013-04-04 06:52:04 +00001061 if incremental:
1062 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmand0ef7762013-10-01 20:50:35 +00001063 name='rm.clang-build', command=['sudo', 'rm', '-rfv',
1064 clang_build_dir],
Michael Gottesman94e9ee42013-04-04 06:52:04 +00001065 haltOnFailure=False, description=['rm dir', clang_build_dir],
1066 workdir=WithProperties('%(builddir)s'),
1067 doStepIf=_did_last_build_fail))
1068 else:
1069 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmand0ef7762013-10-01 20:50:35 +00001070 name='rm.clang-build', command=['sudo', 'rm', '-rfv',
1071 clang_build_dir],
Michael Gottesman94e9ee42013-04-04 06:52:04 +00001072 haltOnFailure=False, description=['rm dir', clang_build_dir],
1073 workdir=WithProperties('%(builddir)s')))
1074
David Deanf8b35442012-12-11 00:35:12 +00001075 # Cleanup the clang link, which buildbot's SVN always_purge does not know
1076 # (in 8.5 this changed to method='fresh')
1077 # how to remove correctly. If we don't do this, the LLVM update steps will
1078 # end up doing a clobber every time.
1079 #
1080 # FIXME: Should file a Trac for this, but I am lazy.
1081 f.addStep(buildbot.steps.shell.ShellCommand(
1082 name='rm.clang-sources-link',
Chris Matthews92ce8e22014-01-03 21:28:27 +00001083 command=['sudo', 'rm', '-rfv', 'llvm/tools/clang'],
David Deanf8b35442012-12-11 00:35:12 +00001084 haltOnFailure=False, description=['rm', 'clang sources link'],
1085 workdir=WithProperties('%(builddir)s')))
1086 f.addStep(buildbot.steps.shell.ShellCommand(
1087 name='rm.compiler-rt-sources-link',
Chris Matthews92ce8e22014-01-03 21:28:27 +00001088 command=['sudo', 'rm', '-rfv', 'llvm/projects/compiler-rt'],
David Deanf8b35442012-12-11 00:35:12 +00001089 haltOnFailure=False, description=['rm', 'compiler-rt sources link'],
1090 workdir=WithProperties('%(builddir)s')))
Michael Gottesman2db83142013-08-05 21:44:45 +00001091 # TODO: We used to use a symlink here but it seems to not work. I am trying
1092 # to get this builder to work so I am just going to copy it instead.
1093 f.addStep(buildbot.steps.shell.ShellCommand(
1094 name='rm.clang-tools-extra-source',
Chris Matthews92ce8e22014-01-03 21:28:27 +00001095 command=['sudo', 'rm', '-rfv', 'clang.src/tools/extra'],
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001096 haltOnFailure=True, workdir=WithProperties('%(builddir)s'),
Michael Gottesman2db83142013-08-05 21:44:45 +00001097 description=['rm', 'clang-tools-extra sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001098 f.addStep(buildbot.steps.shell.ShellCommand(
1099 name='rm.debuginfo-tests',
Chris Matthews92ce8e22014-01-03 21:28:27 +00001100 command=['sudo', 'rm', '-rfv', 'clang.src/test/debuginfo-tests'],
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001101 haltOnFailure=True, workdir=WithProperties('%(builddir)s'),
Michael Gottesmane92eb122013-09-08 01:58:27 +00001102 description=['rm', 'debuginfo-tests sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001103
David Deanf8b35442012-12-11 00:35:12 +00001104 # Pull sources.
Michael Gottesmandc771a02013-08-30 05:46:22 +00001105 f = phasedbuilderutils.SVNCleanupStep(f, 'llvm')
David Deanf8b35442012-12-11 00:35:12 +00001106 f.addStep(HostSVN(name='pull.llvm', mode='incremental', method='fresh',
1107 repourl='http://llvm.org/svn/llvm-project/llvm/trunk',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001108 retry=(60, 5), workdir='llvm', description='pull.llvm',
1109 alwaysUseLatest=False))
Michael Gottesmandc771a02013-08-30 05:46:22 +00001110 f = phasedbuilderutils.SVNCleanupStep(f, 'clang.src')
David Deanf8b35442012-12-11 00:35:12 +00001111 f.addStep(HostSVN(name='pull.clang', mode='incremental', method='fresh',
1112 repourl='http://llvm.org/svn/llvm-project/cfe/trunk',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001113 workdir='clang.src', retry=(60, 5),
David Deanf8b35442012-12-11 00:35:12 +00001114 description='pull.clang', alwaysUseLatest=False))
Michael Gottesmandc771a02013-08-30 05:46:22 +00001115 f = phasedbuilderutils.SVNCleanupStep(f, 'clang-tools-extra.src')
Michael Gottesman1dcf8f82013-03-28 06:20:57 +00001116 f.addStep(HostSVN(name='pull.clang-tools-extra', mode='incremental',
1117 method='fresh',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001118 repourl='http://llvm.org/svn/llvm-project/'
1119 'clang-tools-extra/trunk',
Michael Gottesman1dcf8f82013-03-28 06:20:57 +00001120 workdir='clang-tools-extra.src', alwaysUseLatest=False,
1121 retry=(60, 5), description='pull.clang-tools-extra'))
Michael Gottesmandc771a02013-08-30 05:46:22 +00001122 f = phasedbuilderutils.SVNCleanupStep(f, 'compiler-rt.src')
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001123 f.addStep(HostSVN(name='pull.compiler-rt', mode='incremental',
1124 method='fresh',
1125 repourl='http://llvm.org/svn/llvm-project/compiler-rt/'
1126 'trunk',
1127 workdir='compiler-rt.src', alwaysUseLatest=False,
1128 retry=(60, 5), description='pull.compiler-rt'))
Michael Gottesman13f82592013-09-08 01:54:43 +00001129 f = phasedbuilderutils.SVNCleanupStep(f, 'libcxx.src')
1130 f.addStep(HostSVN(name='pull.libcxx', mode='incremental',
1131 method='fresh',
1132 repourl='http://llvm.org/svn/llvm-project/libcxx/'
1133 'trunk',
1134 workdir='libcxx.src', alwaysUseLatest=False,
1135 retry=(60, 5), description='pull.libcxx'))
Michael Gottesmane92eb122013-09-08 01:58:27 +00001136 f = phasedbuilderutils.SVNCleanupStep(f, 'debuginfo-tests.src')
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001137 f.addStep(HostSVN(name='pull.debuginfo-tests', mode='incremental',
1138 method='fresh',
1139 repourl='http://llvm.org/svn/llvm-project/debuginfo-tests/'
1140 'trunk',
1141 workdir='debuginfo-tests.src', alwaysUseLatest=False,
1142 retry=(60, 5), description='pull.debuginfo-tests'))
1143
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001144 # Create symlinks to the clang compiler-rt sources inside the LLVM tree.
David Deanf8b35442012-12-11 00:35:12 +00001145 # We don't actually check out the sources there, because the SVN purge
1146 # would always remove them then.
1147 f.addStep(buildbot.steps.shell.ShellCommand(
1148 name='ln.clang-sources', haltOnFailure=True,
1149 command=['ln', '-sfv', '../../clang.src', 'clang'],
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001150 workdir='llvm/tools', description=['ln', 'clang sources']))
David Deanf8b35442012-12-11 00:35:12 +00001151 f.addStep(buildbot.steps.shell.ShellCommand(
1152 name='ln.compiler-rt-sources',
1153 command=['ln', '-sfv', '../../compiler-rt.src', 'compiler-rt'],
1154 haltOnFailure=True, workdir='llvm/projects',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001155 description=['ln', 'compiler-rt sources']))
Michael Gottesman4a68b872013-03-28 19:03:52 +00001156 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesman13f82592013-09-08 01:54:43 +00001157 name='ln.libcxx.sources',
1158 command=['ln', '-sfv', '../../libcxx.src', 'libcxx'],
1159 haltOnFailure=True, workdir='llvm/projects',
1160 description=['ln', 'libcxx sources']))
1161 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmanbcab1992013-03-28 18:37:21 +00001162 name='cp.clang-tools-extra-sources',
Michael Gottesman03495922013-03-28 18:40:44 +00001163 command=['cp', '-Rfv', '../../clang-tools-extra.src', 'extra'],
Michael Gottesman1dcf8f82013-03-28 06:20:57 +00001164 haltOnFailure=True, workdir='clang.src/tools',
Chris Matthewsecc0f442014-03-12 00:04:23 +00001165 description=['cp', 'clang-tools-extra sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001166 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmane92eb122013-09-08 01:58:27 +00001167 name='cp.debuginfo-tests.sources',
1168 command=['cp', '-Rfv', 'debuginfo-tests.src',
1169 'clang.src/test/debuginfo-tests'],
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001170 haltOnFailure=True, workdir=WithProperties('%(builddir)s'),
Michael Gottesmane92eb122013-09-08 01:58:27 +00001171 description=['cp', 'debuginfo-tests sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001172
David Deanf8b35442012-12-11 00:35:12 +00001173 # Clean the install directory.
1174 f.addStep(buildbot.steps.shell.ShellCommand(
Chris Matthews92ce8e22014-01-03 21:28:27 +00001175 name='rm.clang-install', command=['sudo', 'rm', '-rfv', 'clang-install'],
David Deanf8b35442012-12-11 00:35:12 +00001176 haltOnFailure=False, description=['rm dir', 'clang-install'],
1177 workdir=WithProperties('%(builddir)s')))
1178 # Construct the configure arguments.
1179 configure_args = ['../llvm/configure']
1180 configure_args.extend(config_options)
Galina Kistanova702eccb2013-08-22 00:09:17 +00001181 configure_args.extend(['--disable-bindings',
Michael Gottesman6f85f932014-06-27 23:49:58 +00001182 '--enable-keep-symbols',
Michael Gottesman0fd485a2014-08-02 01:42:51 +00001183 '--enable-targets=x86,x86_64,arm,aarch64'])
David Deanf8b35442012-12-11 00:35:12 +00001184 configure_args.append(
Michael Gottesman65d940f2013-03-13 21:51:16 +00001185 WithProperties('--prefix=%(builddir)s/clang-install'))
Michael Gottesmanca56e8f2013-03-06 22:27:38 +00001186
David Deanf8b35442012-12-11 00:35:12 +00001187 # If we are using a previously built compiler, download it and override CC
1188 # and CXX.
1189 if is_bootstrap:
Michael Gottesmana6b5be82013-06-28 21:57:20 +00001190 f = artifacts.GetCompilerArtifacts(f)
David Deanf8b35442012-12-11 00:35:12 +00001191 else:
Michael Gottesmandc771a02013-08-30 05:46:22 +00001192 f = phasedbuilderutils.GetLatestValidated(f)
David Deanf8b35442012-12-11 00:35:12 +00001193 cc_command = ['find', 'host-compiler', '-name', 'clang']
1194 f.addStep(buildbot.steps.shell.SetProperty(
1195 name='find.cc',
1196 command=cc_command,
Michael Gottesmandc771a02013-08-30 05:46:22 +00001197 extract_fn=phasedbuilderutils.find_cc,
David Deanf8b35442012-12-11 00:35:12 +00001198 workdir=WithProperties('%(builddir)s')))
1199 f.addStep(buildbot.steps.shell.ShellCommand(
1200 name='sanity.test', haltOnFailure=True,
1201 command=[WithProperties('%(builddir)s/%(cc_path)s'), '-v'],
1202 description=['sanity test']))
1203 configure_args.extend([
1204 WithProperties('CC=%(builddir)s/%(cc_path)s'),
1205 WithProperties('CXX=%(builddir)s/%(cc_path)s++')])
Michael Gottesman65d940f2013-03-13 21:51:16 +00001206
1207 # If we need to use lto, find liblto, add in proper flags here, etc.
1208 if use_lto:
Michael Gottesman01f0a622013-03-13 22:38:38 +00001209 liblto_command = ['find', WithProperties('%(builddir)s/host-compiler'),
1210 '-name', 'libLTO.dylib']
Michael Gottesman1da57ae2013-03-13 21:54:23 +00001211 f.addStep(buildbot.steps.shell.SetProperty(
Michael Gottesman65d940f2013-03-13 21:51:16 +00001212 name='find.liblto',
1213 command=liblto_command,
Michael Gottesmandc771a02013-08-30 05:46:22 +00001214 extract_fn=phasedbuilderutils.find_liblto,
Michael Gottesman65d940f2013-03-13 21:51:16 +00001215 workdir=WithProperties('%(builddir)s')))
1216 configure_args.append(
1217 '--with-extra-options=-flto -gline-tables-only')
1218
David Deanf8b35442012-12-11 00:35:12 +00001219 # Configure the LLVM build.
Michael Gottesmand97d8502013-04-04 07:57:31 +00001220 if incremental:
1221 # *NOTE* This is a temporary work around. I am eventually going to just
1222 # set up cmake/ninja but for now I am sticking with the make => I need
1223 # configure to run only after a failure so on success I have incremental
1224 # builds.
1225 f.addStep(buildbot.steps.shell.ShellCommand(
1226 name='configure.with.host', command=configure_args,
1227 haltOnFailure=True, description=['configure'],
1228 workdir=clang_build_dir,
1229 doStepIf=_did_last_build_fail))
1230 else:
1231 f.addStep(buildbot.steps.shell.ShellCommand(
1232 name='configure.with.host', command=configure_args,
1233 haltOnFailure=True, description=['configure'],
1234 workdir=clang_build_dir))
1235
David Deanf8b35442012-12-11 00:35:12 +00001236 # Build the compiler.
Michael Gottesman36778832013-09-08 01:37:35 +00001237 make_command = ['make', '-j', WithProperties('%(jobs)s'), 'VERBOSE=1']
Galina Kistanovabfb29d22013-05-09 23:53:24 +00001238 timeout = 40*60 # Normal timeout is 20 minutes.
Michael Gottesman65d940f2013-03-13 21:51:16 +00001239 if use_lto:
1240 make_command.append(WithProperties('DYLD_LIBRARY_PATH=%(liblto_path)s'))
Michael Gottesman2e7385c2013-08-12 17:57:27 +00001241 timeout = 240*60 # LTO timeout is 240 minutes.
Michael Gottesman65d940f2013-03-13 21:51:16 +00001242
David Deanf8b35442012-12-11 00:35:12 +00001243 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesman65d940f2013-03-13 21:51:16 +00001244 name='make', command=make_command,
Michael Gottesmanbab77ac2013-03-14 05:36:53 +00001245 haltOnFailure=True, description=['make'], workdir=clang_build_dir,
1246 timeout=timeout))
David Deanf8b35442012-12-11 00:35:12 +00001247 # Use make install-clang to produce minimal archive for use by downstream
1248 # builders.
1249 f.addStep(buildbot.steps.shell.ShellCommand(
1250 name='make.install-clang', haltOnFailure=True,
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001251 command=['make', 'install-clang', '-j',
1252 WithProperties('%(jobs)s'),
1253 'RC_SUPPORTED_ARCHS=armv7 i386 x86_64'],
David Deanf8b35442012-12-11 00:35:12 +00001254 description=['make install'], workdir=clang_build_dir))
1255 # Save artifacts of this build for use by other builders.
Michael Gottesmana6b5be82013-06-28 21:57:20 +00001256 f = artifacts.uploadArtifacts(f)
David Deanf8b35442012-12-11 00:35:12 +00001257 # Run the LLVM and Clang regression tests.
Yunzhong Gao3dd8d8b2016-01-29 22:03:54 +00001258 cmd_str = r"""make VERBOSE=1 LIT_ARGS="-v --param run_long_tests=true --param enable_console=1 --filter='^(?!.*debuginfo-tests)'" check-all"""
Michael Gottesmana9c32be2013-09-06 17:47:24 +00001259 f.addStep(lit_test_command.LitTestCommand(name='run.llvm.tests', haltOnFailure=True,
1260 command=cmd_str,
1261 description=['all', 'tests'],
1262 workdir=clang_build_dir))
1263 # Work around for lldb issue rdar://14929651
Chris Matthewsecc0f442014-03-12 00:04:23 +00001264 # The crazy filter regex is to remove static-member[2].cpp, which requires xcode5 or later.
1265 # radar://16295455 tracks the removal of this regex.
Yunzhong Gao3dd8d8b2016-01-29 22:03:54 +00001266 cmd_str = r"""make VERBOSE=1 LIT_ARGS="-j 1 -v --param run_long_tests=true --param enable_console=1 --filter='debuginfo-tests.(?!static-member)'" check-all"""
Michael Gottesman75382312013-09-08 02:15:08 +00001267 f.addStep(lit_test_command.LitTestCommand(name='run.llvm.debuginfo-tests', haltOnFailure=True,
Michael Gottesmane7dc31e2013-08-30 05:57:35 +00001268 command=cmd_str,
Michael Gottesmana6b5be82013-06-28 21:57:20 +00001269 description=['all', 'tests'],
1270 workdir=clang_build_dir))
David Deanf8b35442012-12-11 00:35:12 +00001271 return f