blob: 6262da4687c0e19e18fd08b963521d1efca5884a [file] [log] [blame]
Daniel Dunbar235aa412009-07-18 07:16:15 +00001import buildbot
2import buildbot.process.factory
David Deanf8b35442012-12-11 00:35:12 +00003import os
4
5from buildbot.process.properties import WithProperties
David Blaikie8cbf62f2013-01-12 21:32:31 +00006from buildbot.steps.shell import Configure, ShellCommand, SetProperty
Daniel Dunbar44abe742009-07-19 01:59:03 +00007from buildbot.steps.shell import WarningCountingShellCommand
David Deanf8b35442012-12-11 00:35:12 +00008from buildbot.steps.source import SVN
Daniel Dunbar44abe742009-07-19 01:59:03 +00009from buildbot.steps.transfer import FileDownload
Michael Gottesmana6b5be82013-06-28 21:57:20 +000010
Michael Gottesman960bcfa2013-08-30 05:46:15 +000011import zorg.buildbot.util.artifacts as artifacts
Michael Gottesmana6b5be82013-06-28 21:57:20 +000012import zorg.buildbot.builders.Util as builders_util
Michael Gottesmandc771a02013-08-30 05:46:22 +000013import zorg.buildbot.util.phasedbuilderutils as phasedbuilderutils
Michael Gottesmana6b5be82013-06-28 21:57:20 +000014import zorg.buildbot.commands as commands
15import zorg.buildbot.commands.BatchFileDownload as batch_file_download
16import zorg.buildbot.commands.LitTestCommand as lit_test_command
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000017
Galina Kistanovaf4d79352011-10-20 20:46:52 +000018def getClangBuildFactory(
19 triple=None,
20 clean=True,
21 test=True,
22 package_dst=None,
23 run_cxx_tests=False,
24 examples=False,
25 valgrind=False,
26 valgrindLeakCheck=False,
27 outOfDir=False,
28 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
David Blaikiedad03d52012-11-16 22:37:12 +000058 if run_gdb or run_gcc or run_modern_gdb:
David Blaikie88511c72012-08-24 23:14:06 +000059 outOfDir = True
Galina Kistanovaf4d79352011-10-20 20:46:52 +000060
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000061 # Don't use in-dir builds with a two stage build process.
Daniel Dunbar3efb7822010-02-26 19:20:00 +000062 inDir = not outOfDir and not useTwoStage
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000063 if inDir:
64 llvm_srcdir = "llvm"
65 llvm_1_objdir = "llvm"
David Blaikie88511c72012-08-24 23:14:06 +000066 llvm_1_installdir = None
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000067 else:
68 llvm_srcdir = "llvm.src"
69 llvm_1_objdir = "llvm.obj"
70 llvm_1_installdir = "llvm.install.1"
71 llvm_2_objdir = "llvm.obj.2"
Daniel Dunbar22d594a2010-07-31 05:29:16 +000072 llvm_2_installdir = "llvm.install"
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000073
Daniel Dunbar235aa412009-07-18 07:16:15 +000074 f = buildbot.process.factory.BuildFactory()
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000075
76 # Determine the build directory.
77 f.addStep(buildbot.steps.shell.SetProperty(name="get_builddir",
78 command=["pwd"],
79 property="builddir",
80 description="set build dir",
Galina Kistanovaf4d79352011-10-20 20:46:52 +000081 workdir=".",
82 env=merged_env))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000083
Daniel Dunbar06b20f12010-04-08 18:29:38 +000084 # Blow away completely, if requested.
85 if completely_clean:
86 f.addStep(ShellCommand(name="rm-llvm.src",
87 command=["rm", "-rf", llvm_srcdir],
88 haltOnFailure=True,
89 description=["rm src dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +000090 workdir=".",
91 env=merged_env))
Daniel Dunbar06b20f12010-04-08 18:29:38 +000092
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000093 # Checkout sources.
Peter Collingbourned49ac282011-10-25 14:38:45 +000094 if trunk_revision:
95 # The SVN build step provides no mechanism to check out a specific revision
96 # based on a property, so just run the commands directly here.
97 svn_co = ['svn', 'checkout']
98 if force_checkout:
99 svn_co += ['--force']
100 svn_co += ['--revision', WithProperties(trunk_revision)]
101
102 svn_co_llvm = svn_co + \
103 [WithProperties('http://llvm.org/svn/llvm-project/llvm/trunk@%s' %
104 trunk_revision),
105 llvm_srcdir]
106 svn_co_clang = svn_co + \
107 [WithProperties('http://llvm.org/svn/llvm-project/cfe/trunk@%s' %
108 trunk_revision),
109 '%s/tools/clang' % llvm_srcdir]
David Blaikie845ae0d2012-08-10 00:51:38 +0000110 svn_co_clang_tools_extra = svn_co + \
111 [WithProperties('http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@%s' %
112 trunk_revision),
113 '%s/tools/clang/tools/extra' % llvm_srcdir]
Peter Collingbourned49ac282011-10-25 14:38:45 +0000114
115 f.addStep(ShellCommand(name='svn-llvm',
116 command=svn_co_llvm,
117 haltOnFailure=True,
118 workdir='.'))
119 f.addStep(ShellCommand(name='svn-clang',
120 command=svn_co_clang,
121 haltOnFailure=True,
122 workdir='.'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000123 f.addStep(ShellCommand(name='svn-clang-tools-extra',
124 command=svn_co_clang_tools_extra,
125 haltOnFailure=True,
126 workdir='.'))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000127 else:
128 f.addStep(SVN(name='svn-llvm',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000129 mode='update',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000130 baseURL='http://llvm.org/svn/llvm-project/llvm/',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000131 defaultBranch='trunk',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000132 workdir=llvm_srcdir))
133 f.addStep(SVN(name='svn-clang',
134 mode='update',
135 baseURL='http://llvm.org/svn/llvm-project/cfe/',
136 defaultBranch='trunk',
137 workdir='%s/tools/clang' % llvm_srcdir))
David Blaikie845ae0d2012-08-10 00:51:38 +0000138 f.addStep(SVN(name='svn-clang-tools-extra',
139 mode='update',
140 baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
141 defaultBranch='trunk',
142 workdir='%s/tools/clang/tools/extra' % llvm_srcdir))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000143 if checkout_compiler_rt:
144 f.addStep(SVN(name='svn-compiler-rt',
145 mode='update',
146 baseURL='http://llvm.org/svn/llvm-project/compiler-rt/',
147 defaultBranch='trunk',
148 workdir='%s/projects/compiler-rt' % llvm_srcdir))
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000149
Galina Kistanova10836402013-09-26 20:42:52 +0000150 # Revert and apply patch mergeFunctions in required
151 if merge_functions:
152 f.addStep(ShellCommand(name="revert_patch_MergeFunctions",
153 command=["svn", "-R", "revert", '.'],
154 haltOnFailure=True,
155 description=["revert patch MergeFunctions"],
156 workdir='%s/tools/clang' % llvm_srcdir,
157 env=merged_env))
158
159 if merge_functions:
160 f.addStep(ShellCommand(name="patch_MergeFunctions",
161 command=["patch", "-Np0", "-i", '../../utils/Misc/mergefunctions.clang.svn.patch'],
162 haltOnFailure=True,
163 description=["patch MergeFunctions"],
164 workdir='%s/tools/clang' % llvm_srcdir,
165 env=merged_env))
166
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000167 # Clean up llvm (stage 1); unless in-dir.
168 if clean and llvm_srcdir != llvm_1_objdir:
169 f.addStep(ShellCommand(name="rm-llvm.obj.stage1",
170 command=["rm", "-rf", llvm_1_objdir],
171 haltOnFailure=True,
172 description=["rm build dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000173 workdir=".",
174 env=merged_env))
Andrew Trick70fa9d22011-08-25 23:38:51 +0000175
David Blaikie8cbf62f2013-01-12 21:32:31 +0000176 if not clean:
Richard Smith02389162014-09-26 23:53:06 +0000177 if cmake:
178 expected_makefile = 'Makefile'
179 else:
180 expected_makefile = 'Makefile.config'
David Blaikie8cbf62f2013-01-12 21:32:31 +0000181 f.addStep(SetProperty(name="Makefile_isready",
182 workdir=llvm_1_objdir,
183 command=["sh", "-c",
Richard Smith02389162014-09-26 23:53:06 +0000184 "test -e %s && echo OK || echo Missing" % expected_makefile],
David Blaikie8cbf62f2013-01-12 21:32:31 +0000185 flunkOnFailure=False,
186 property="exists_Makefile"))
Richard Smith02389162014-09-26 23:53:06 +0000187
188 if not cmake:
189 # Force without llvm-gcc so we don't run afoul of Frontend test failures.
190 base_configure_args = [WithProperties("%%(builddir)s/%s/configure" % llvm_srcdir),
191 '--disable-bindings']
192 base_configure_args += extra_configure_args
193 if triple:
194 base_configure_args += ['--build=%s' % triple,
195 '--host=%s' % triple]
196 args = base_configure_args + [WithProperties("--prefix=%%(builddir)s/%s" % llvm_1_installdir)]
197 args += builders_util.getConfigArgs(stage1_config)
198
199 f.addStep(Configure(command=args,
200 workdir=llvm_1_objdir,
201 description=['configuring',stage1_config],
202 descriptionDone=['configure',stage1_config],
203 env=merged_env,
204 doStepIf=lambda step: step.build.getProperty("exists_Makefile") != "OK"))
205 else:
206 cmake_triple_arg = []
207 if triple:
208 cmake_triple_arg = ['-DLLVM_HOST_TRIPLE=%s' % triple]
209 f.addStep(ShellCommand(name='cmake',
210 command=[cmake,
211 '-DLLVM_BUILD_TESTS=ON',
212 '-DCMAKE_BUILD_TYPE=%s' % stage1_config] +
213 cmake_triple_arg +
214 extra_configure_args +
215 ["../" + llvm_srcdir],
216 description='cmake stage1',
217 workdir=llvm_1_objdir,
218 env=merged_env,
219 doStepIf=lambda step: step.build.getProperty("exists_Makefile") != "OK"))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000220
221 # Make clean if using in-dir builds.
222 if clean and llvm_srcdir == llvm_1_objdir:
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000223 f.addStep(WarningCountingShellCommand(name="clean-llvm",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000224 command=[make, "clean"],
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000225 haltOnFailure=True,
226 description="cleaning llvm",
227 descriptionDone="clean llvm",
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000228 workdir=llvm_1_objdir,
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000229 doStepIf=clean,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000230 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000231
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000232 if extra_clean_step:
233 f.addStep(extra_clean_step)
234
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000235 f.addStep(WarningCountingShellCommand(name="compile",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000236 command=['nice', '-n', '10',
237 make, WithProperties("-j%s" % jobs)],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000238 haltOnFailure=True,
David Blaikie05517332013-12-19 23:29:12 +0000239 flunkOnFailure=not run_gdb,
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000240 description=["compiling", stage1_config],
241 descriptionDone=["compile", stage1_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000242 workdir=llvm_1_objdir,
243 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000244
245 if examples:
246 f.addStep(WarningCountingShellCommand(name="compile.examples",
247 command=['nice', '-n', '10',
248 make, WithProperties("-j%s" % jobs),
249 "BUILD_EXAMPLES=1"],
250 haltOnFailure=True,
Richard Smith65e6f5d2014-09-25 18:18:35 +0000251 description=["compiling", stage1_config, "examples"],
Daniel Dunbar256fed42009-11-25 21:11:08 +0000252 descriptionDone=["compile", stage1_config, "examples"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000253 workdir=llvm_1_objdir,
254 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000255
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000256 clangTestArgs = '-v -j %s' % jobs
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000257 if valgrind:
Daniel Dunbar89184b92010-04-18 19:09:32 +0000258 clangTestArgs += ' --vg'
Daniel Dunbara1bebce2010-03-21 01:24:00 +0000259 if valgrindLeakCheck:
260 clangTestArgs += ' --vg-leak'
Nick Lewycky8d26e472011-08-27 21:18:56 +0000261 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 +0000262 extraTestDirs = ''
263 if run_cxx_tests:
264 extraTestDirs += '%(builddir)s/llvm/tools/clang/utils/C++Tests'
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000265 if test:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000266 f.addStep(lit_test_command.LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000267 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000268 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000269 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie05517332013-12-19 23:29:12 +0000270 flunkOnFailure=not run_gdb,
David Blaikie7e6f8a12012-08-31 20:46:27 +0000271 description=["checking"],
272 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000273 workdir=llvm_1_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000274 usePTY=use_pty_in_tests,
275 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000276
277 # Install llvm and clang.
Richard Smith02389162014-09-26 23:53:06 +0000278 if llvm_1_installdir and not cmake: # FIXME: install for cmake build
Daniel Dunbar9870de32010-03-28 22:25:31 +0000279 f.addStep(ShellCommand(name="rm-install.clang.stage1",
280 command=["rm", "-rf", llvm_1_installdir],
281 haltOnFailure=True,
282 description=["rm install dir", "clang"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000283 workdir=".",
284 env=merged_env))
Daniel Dunbar9870de32010-03-28 22:25:31 +0000285 f.addStep(WarningCountingShellCommand(name="install.clang.stage1",
286 command = ['nice', '-n', '10',
287 make, 'install-clang'],
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000288 haltOnFailure=True,
Daniel Dunbar9870de32010-03-28 22:25:31 +0000289 description=["install", "clang",
290 stage1_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000291 workdir=llvm_1_objdir,
292 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000293
David Blaikiedad03d52012-11-16 22:37:12 +0000294 if run_gdb or run_gcc or run_modern_gdb:
David Blaikiea76da842012-08-13 22:24:46 +0000295 ignores = getClangTestsIgnoresFromPath(os.path.expanduser('~/public/clang-tests'), 'clang-x86_64-darwin10')
296 install_prefix = "%%(builddir)s/%s" % llvm_1_installdir
297 if run_gdb:
298 addClangGDBTests(f, ignores, install_prefix)
David Blaikiedad03d52012-11-16 22:37:12 +0000299 if run_modern_gdb:
David Blaikie41d09c32013-01-02 21:11:09 +0000300 addModernClangGDBTests(f, jobs, install_prefix)
David Blaikiea76da842012-08-13 22:24:46 +0000301 if run_gcc:
302 addClangGCCTests(f, ignores, install_prefix)
303
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000304 if not useTwoStage:
Daniel Dunbardedf6572010-11-13 00:23:34 +0000305 if package_dst:
306 name = WithProperties(
307 "%(builddir)s/" + llvm_1_objdir +
308 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
309 f.addStep(ShellCommand(name='pkg.tar',
310 description="tar root",
311 command=["tar", "zcvf", name, "./"],
312 workdir=llvm_1_installdir,
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 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000318 description="upload root",
Daniel Dunbardedf6572010-11-13 00:23:34 +0000319 command=["scp", name,
320 WithProperties(
321 package_dst + "/%(buildername)s")],
322 workdir=".",
323 warnOnFailure=True,
324 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000325 haltOnFailure=False,
326 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000327
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000328 return f
329
330 # Clean up llvm (stage 2).
Richard Smith02389162014-09-26 23:53:06 +0000331 #
332 # FIXME: It does not make much sense to skip this for a bootstrap builder.
333 # Check whether there is any reason to skip cleaning here and if not, remove
334 # this condition.
335 if clean or cmake:
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000336 f.addStep(ShellCommand(name="rm-llvm.obj.stage2",
337 command=["rm", "-rf", llvm_2_objdir],
338 haltOnFailure=True,
339 description=["rm build dir", "llvm", "(stage 2)"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000340 workdir=".",
341 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000342
343 # Configure llvm (stage 2).
Richard Smith02389162014-09-26 23:53:06 +0000344 if not cmake:
345 args = base_configure_args + [WithProperties("--prefix=%(builddir)s/" + llvm_2_installdir)]
346 args += builders_util.getConfigArgs(stage2_config)
347 local_env = dict(merged_env)
348 local_env.update({
349 'CC' : WithProperties("%%(builddir)s/%s/bin/clang" % llvm_1_installdir),
350 'CXX' : WithProperties("%%(builddir)s/%s/bin/clang++" % llvm_1_installdir)})
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000351
Richard Smith02389162014-09-26 23:53:06 +0000352 f.addStep(Configure(name="configure.llvm.stage2",
353 command=args,
354 haltOnFailure=True,
355 workdir=llvm_2_objdir,
356 description=["configure", "llvm", "(stage 2)",
357 stage2_config],
358 env=local_env))
359 else:
360 c_flags = ''
361 cxx_flags = ''
362 extra_args = []
363 if modules:
364 c_flags += '-fmodules-cache-path=%%(builddir)s/%s/module-cache' % llvm_2_objdir
365 # Modules requires libc++ for now (we don't have a module map for libstdc++ yet).
366 cxx_flags += '-stdlib=libc++'
367 extra_args = ['-DLLVM_ENABLE_MODULES=1']
368
369 f.addStep(ShellCommand(name='cmake',
370 command=[cmake] + extra_args + [
371 '-DLLVM_BUILD_TESTS=ON',
372 WithProperties('-DCMAKE_C_COMPILER=%%(builddir)s/%s/bin/clang' % llvm_1_objdir), # FIXME use installdir
373 WithProperties('-DCMAKE_CXX_COMPILER=%%(builddir)s/%s/bin/clang++' % llvm_1_objdir),
374 '-DCMAKE_BUILD_TYPE=%s' % stage2_config,
375 WithProperties('-DCMAKE_C_FLAGS=%s' % c_flags),
376 WithProperties('-DCMAKE_CXX_FLAGS=%s %s' % (c_flags, cxx_flags)),
377 "../" + llvm_srcdir],
378 description='cmake stage2',
379 workdir=llvm_2_objdir,
380 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000381
382 # Build llvm (stage 2).
383 f.addStep(WarningCountingShellCommand(name="compile.llvm.stage2",
384 command=['nice', '-n', '10',
385 make, WithProperties("-j%s" % jobs)],
386 haltOnFailure=True,
387 description=["compiling", "(stage 2)",
388 stage2_config],
389 descriptionDone=["compile", "(stage 2)",
390 stage2_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000391 workdir=llvm_2_objdir,
392 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000393
394 if test:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000395 f.addStep(lit_test_command.LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000396 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000397 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000398 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie7e6f8a12012-08-31 20:46:27 +0000399 description=["checking"],
400 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000401 workdir=llvm_2_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000402 usePTY=use_pty_in_tests,
403 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000404
Richard Smith02389162014-09-26 23:53:06 +0000405 if llvm_2_installdir and not cmake: # FIXME: install for cmake build
406 # Install clang (stage 2).
407 f.addStep(ShellCommand(name="rm-install.clang.stage2",
408 command=["rm", "-rf", llvm_2_installdir],
409 haltOnFailure=True,
410 description=["rm install dir", "clang"],
411 workdir=".",
412 env=merged_env))
413 f.addStep(WarningCountingShellCommand(name="install.clang.stage2",
414 command = ['nice', '-n', '10',
415 make, 'install-clang'],
416 haltOnFailure=True,
417 description=["install", "clang",
418 "(stage 2)"],
419 workdir=llvm_2_objdir,
420 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000421
422 if package_dst:
423 name = WithProperties(
424 "%(builddir)s/" + llvm_2_objdir +
425 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
426 f.addStep(ShellCommand(name='pkg.tar',
427 description="tar root",
428 command=["tar", "zcvf", name, "./"],
429 workdir=llvm_2_installdir,
430 warnOnFailure=True,
431 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000432 haltOnFailure=False,
433 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000434 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000435 description="upload root",
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000436 command=["scp", name,
437 WithProperties(
438 package_dst + "/%(buildername)s")],
439 workdir=".",
440 warnOnFailure=True,
441 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000442 haltOnFailure=False,
443 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000444
Daniel Dunbar235aa412009-07-18 07:16:15 +0000445 return f
Daniel Dunbar44abe742009-07-19 01:59:03 +0000446
Renato Goline402f582014-09-04 19:25:24 +0000447# CMake Linux builds
448def getClangCMakeBuildFactory(
449 clean=True,
450 test=True,
451 cmake='cmake',
452 jobs=None,
453
454 # Multi-stage compilation
455 useTwoStage=False,
456 testStage1=True,
457 stage1_config='Release',
458 stage2_config='Release',
459
460 # Environmental variables for all steps.
461 env={},
462 extra_cmake_args=[],
463
464 # Extra repositories
465 checkout_clang_tools_extra=True,
466 checkout_compiler_rt=True):
467
468 ############# PREPARING
469 f = buildbot.process.factory.BuildFactory()
470
471 # We *must* checkout at least Clang+LLVM
472 f.addStep(SVN(name='svn-llvm',
473 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
474 defaultBranch='trunk',
475 workdir='llvm'))
476 f.addStep(SVN(name='svn-clang',
477 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
478 defaultBranch='trunk',
479 workdir='llvm/tools/clang'))
480
481 # Extra stuff that will be built/tested
482 if checkout_clang_tools_extra:
483 f.addStep(SVN(name='svn-clang-tools-extra',
484 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
485 defaultBranch='trunk',
486 workdir='llvm/tools/clang/tools/extra'))
487 if checkout_compiler_rt:
488 f.addStep(SVN(name='svn-compiler-rt',
489 mode='update', baseURL='http://llvm.org/svn/llvm-project/compiler-rt/',
490 defaultBranch='trunk',
491 workdir='llvm/projects/compiler-rt'))
492
493 # If jobs not defined, Ninja will choose a suitable value
494 jobs_cmd=[]
495 lit_args="'-v"
496 if jobs is not None:
497 jobs_cmd=["-j"+str(jobs)]
498 lit_args+=" -j"+str(jobs)+"'"
499 else:
500 lit_args+="'"
501 ninja_cmd=['ninja'] + jobs_cmd
502 ninja_install_cmd=['ninja', 'install'] + jobs_cmd
503 ninja_check_cmd=['ninja', 'check-all'] + jobs_cmd
504
505 # Global configurations
506 stage1_build='stage1'
507 stage1_install='stage1.install'
508 stage2_build='stage2'
509
510 ############# CLEANING
511 if clean:
512 f.addStep(ShellCommand(name='clean stage 1',
513 command=['rm','-rf',stage1_build],
514 warnOnFailure=True,
515 description='cleaning stage 1',
516 descriptionDone='clean',
517 workdir='.',
518 env=env))
519 else:
520 f.addStep(SetProperty(name="check ninja files 1",
521 workdir=stage1_build,
522 command=["sh", "-c",
523 "test -e build.ninja && echo OK || echo Missing"],
524 flunkOnFailure=False,
525 property="exists_ninja_1"))
526
527
528 ############# STAGE 1
529 f.addStep(ShellCommand(name='cmake stage 1',
530 command=[cmake, "-G", "Ninja", "../llvm",
531 "-DCMAKE_BUILD_TYPE="+stage1_config,
532 "-DLLVM_ENABLE_ASSERTIONS=True",
533 "-DLLVM_LIT_ARGS="+lit_args,
534 "-DCMAKE_INSTALL_PREFIX=../"+stage1_install]
535 + extra_cmake_args,
536 haltOnFailure=True,
537 description='cmake stage 1',
538 workdir=stage1_build,
539 doStepIf=lambda step: step.build.getProperty("exists_ninja_1") != "OK",
540 env=env))
541
542 f.addStep(WarningCountingShellCommand(name='build stage 1',
543 command=ninja_cmd,
544 haltOnFailure=True,
545 description='ninja all',
546 workdir=stage1_build,
547 env=env))
548
549 if test and testStage1:
Renato Golincfbd5702014-09-06 19:09:16 +0000550 f.addStep(lit_test_command.LitTestCommand(name='ninja check 1',
551 command=ninja_check_cmd,
552 description=["checking stage 1"],
553 descriptionDone=["stage 1 checked"],
554 workdir=stage1_build,
555 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000556
557 if not useTwoStage:
558 return f
559
560 ############# STAGE 2
561 f.addStep(ShellCommand(name='install stage 1',
562 command=ninja_install_cmd,
563 description='ninja install',
564 workdir=stage1_build,
565 env=env))
566
567 if clean:
568 f.addStep(ShellCommand(name='clean stage 2',
569 command=['rm','-rf',stage2_build],
570 warnOnFailure=True,
571 description='cleaning stage 2',
572 descriptionDone='clean',
573 workdir='.',
574 env=env))
575 else:
576 f.addStep(SetProperty(name="check ninja files 2",
577 workdir=stage2_build,
578 command=["sh", "-c",
579 "test -e build.ninja && echo OK || echo Missing"],
580 flunkOnFailure=False,
581 property="exists_ninja_2"))
582
583
584 f.addStep(ShellCommand(name='cmake stage 2',
585 command=[cmake, "-G", "Ninja", "../llvm",
586 "-DCMAKE_BUILD_TYPE="+stage2_config,
587 "-DLLVM_ENABLE_ASSERTIONS=True",
588 WithProperties("-DCMAKE_C_COMPILER=%(workdir)s/"+stage1_install+"/bin/clang"),
589 WithProperties("-DCMAKE_CXX_COMPILER=%(workdir)s/"+stage1_install+"/bin/clang++"),
590 "-DLLVM_LIT_ARGS="+lit_args]
591 + extra_cmake_args,
592 haltOnFailure=True,
593 description='cmake stage 2',
594 workdir=stage2_build,
595 doStepIf=lambda step: step.build.getProperty("exists_ninja_2") != "OK",
596 env=env))
597
598 f.addStep(WarningCountingShellCommand(name='build stage 2',
599 command=ninja_cmd,
600 haltOnFailure=True,
601 description='ninja all',
602 workdir=stage2_build,
603 env=env))
604
605 if test:
Renato Golincfbd5702014-09-06 19:09:16 +0000606 f.addStep(lit_test_command.LitTestCommand(name='ninja check 2',
607 command=ninja_check_cmd,
608 description=["checking stage 2"],
609 descriptionDone=["stage 2 checked"],
610 workdir=stage2_build,
611 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000612
613 return f
614
Daniel Dunbarc51a59e2010-09-23 14:57:45 +0000615def getClangMSVCBuildFactory(update=True, clean=True, vcDrive='c', jobs=1, cmake=r"cmake"):
Daniel Dunbar44abe742009-07-19 01:59:03 +0000616 f = buildbot.process.factory.BuildFactory()
617
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000618 if update:
Daniel Dunbar44abe742009-07-19 01:59:03 +0000619 f.addStep(SVN(name='svn-llvm',
620 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
621 defaultBranch='trunk',
622 workdir='llvm'))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000623 f.addStep(SVN(name='svn-clang',
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000624 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
Daniel Dunbar44abe742009-07-19 01:59:03 +0000625 defaultBranch='trunk',
626 workdir='llvm/tools/clang'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000627 f.addStep(SVN(name='svn-clang-tools-extra',
628 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
629 defaultBranch='trunk',
630 workdir='llvm/tools/clang/tools/extra'))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000631
632 # Full & fast clean.
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000633 if clean:
Daniel Dunbar44abe742009-07-19 01:59:03 +0000634 f.addStep(ShellCommand(name='clean-1',
635 command=['del','/s/q','build'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000636 warnOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000637 description='cleaning',
638 descriptionDone='clean',
639 workdir='llvm'))
640 f.addStep(ShellCommand(name='clean-2',
641 command=['rmdir','/s/q','build'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000642 warnOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000643 description='cleaning',
644 descriptionDone='clean',
645 workdir='llvm'))
646
647 # Create the project files.
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000648
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000649 # Use batch files instead of ShellCommand directly, Windows quoting is
650 # borked. FIXME: See buildbot ticket #595 and buildbot ticket #377.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000651 f.addStep(batch_file_download.BatchFileDownload(name='cmakegen',
Daniel Dunbar06b20f12010-04-08 18:29:38 +0000652 command=[cmake,
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000653 "-DLLVM_TARGETS_TO_BUILD:=X86",
Daniel Dunbar1ddedce2010-09-24 19:57:34 +0000654 "-DLLVM_INCLUDE_EXAMPLES:=OFF",
655 "-DLLVM_INCLUDE_TESTS:=OFF",
656 "-DLLVM_TARGETS_TO_BUILD:=X86",
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000657 "-G",
658 "Visual Studio 9 2008",
659 ".."],
660 workdir="llvm\\build"))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000661 f.addStep(ShellCommand(name='cmake',
662 command=['cmakegen.bat'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000663 haltOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000664 description='cmake gen',
665 workdir='llvm\\build'))
666
667 # Build it.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000668 f.addStep(batch_file_download.BatchFileDownload(name='vcbuild',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000669 command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""",
670 "/M%d" % jobs,
671 "LLVM.sln",
672 "Debug|Win32"],
673 workdir="llvm\\build"))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000674 f.addStep(WarningCountingShellCommand(name='vcbuild',
675 command=['vcbuild.bat'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000676 haltOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000677 description='vcbuild',
678 workdir='llvm\\build',
679 warningPattern=" warning C.*:"))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000680
681 # Build clang-test project.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000682 f.addStep(batch_file_download.BatchFileDownload(name='vcbuild_test',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000683 command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""",
684 "clang-test.vcproj",
685 "Debug|Win32"],
686 workdir="llvm\\build\\tools\\clang\\test"))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000687 f.addStep(lit_test_command.LitTestCommand(name='test-clang',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000688 command=["vcbuild_test.bat"],
689 workdir="llvm\\build\\tools\\clang\\test"))
690
Daniel Dunbar44abe742009-07-19 01:59:03 +0000691 return f
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000692
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000693# Builds on Windows using CMake, MinGW(32|64), and no Microsoft tools.
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000694def getClangMinGWBuildFactory(update=True, clean=True, jobs=6, cmake=r"cmake"):
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000695 f = buildbot.process.factory.BuildFactory()
696
697 if update:
698 f.addStep(SVN(name='svn-llvm',
699 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
700 defaultBranch='trunk',
701 workdir='llvm'))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000702 f.addStep(SVN(name='svn-clang',
703 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
704 defaultBranch='trunk',
705 workdir='llvm/tools/clang'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000706 f.addStep(SVN(name='svn-clang-tools-extra',
707 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
708 defaultBranch='trunk',
709 workdir='llvm/tools/clang/tools/extra'))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000710
711 # Full & fast clean.
712 if clean:
713 # note: This command is redundant as the next command removes everything
714 f.addStep(ShellCommand(name='clean-1',
715 command=['del','/s/q','build'],
716 warnOnFailure=True,
717 description='cleaning',
718 descriptionDone='clean',
719 workdir='llvm'))
720 f.addStep(ShellCommand(name='clean-2',
721 command=['rmdir','/s/q','build'],
722 warnOnFailure=True,
723 description='cleaning',
724 descriptionDone='clean',
725 workdir='llvm'))
726
727 # Create the Makefiles.
728
729 # Use batch files instead of ShellCommand directly, Windows quoting is
730 # borked. FIXME: See buildbot ticket #595 and buildbot ticket #377.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000731 f.addStep(batch_file_download.BatchFileDownload(name='cmakegen',
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000732 command=[cmake,
733 "-DLLVM_TARGETS_TO_BUILD:=X86",
734 "-DLLVM_INCLUDE_EXAMPLES:=OFF",
735 "-DLLVM_INCLUDE_TESTS:=OFF",
736 "-DLLVM_TARGETS_TO_BUILD:=X86",
737 "-G",
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000738 "Ninja",
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000739 ".."],
740 workdir="llvm\\build"))
741 f.addStep(ShellCommand(name='cmake',
742 command=['cmakegen.bat'],
743 haltOnFailure=True,
744 description='cmake gen',
745 workdir='llvm\\build'))
746
747 # Build it.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000748 f.addStep(batch_file_download.BatchFileDownload(name='makeall',
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000749 command=["ninja", "-j", "%d" % jobs],
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000750 haltOnFailure=True,
751 workdir='llvm\\build'))
752
753 f.addStep(WarningCountingShellCommand(name='makeall',
754 command=['makeall.bat'],
755 haltOnFailure=True,
756 description='makeall',
757 workdir='llvm\\build'))
758
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000759 # Build global check project (make check) (sources not checked out...).
760 if 0:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000761 f.addStep(batch_file_download.BatchFileDownload(name='makecheck',
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000762 command=["ninja", "check"],
763 workdir='llvm\\build'))
764 f.addStep(WarningCountingShellCommand(name='check',
765 command=['makecheck.bat'],
766 description='make check',
767 workdir='llvm\\build'))
Galina Kistanova049d76c2012-06-09 00:56:05 +0000768
769 # Build clang-test project (make clang-test).
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000770 f.addStep(batch_file_download.BatchFileDownload(name='maketest',
771 command=["ninja", "clang-test"],
772 workdir="llvm\\build"))
773 f.addStep(lit_test_command.LitTestCommand(name='clang-test',
774 command=["maketest.bat"],
775 workdir="llvm\\build"))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000776 return f
777
Daniel Dunbar7363d032011-02-27 03:22:35 +0000778def addClangGCCTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install",
779 languages = ('gcc', 'g++', 'objc', 'obj-c++')):
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000780 make_vars = [WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000781 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000782 WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000783 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
David Blaikie05517332013-12-19 23:29:12 +0000784 f.addStep(SVN(name='svn-clang-gcc-tests', mode='update',
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000785 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
786 defaultBranch='trunk', workdir='clang-tests'))
787 gcc_dg_ignores = ignores.get('gcc-4_2-testsuite', {})
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000788 for lang in languages:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000789 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000790 name='test-gcc-4_2-testsuite-%s' % lang,
791 command=["make", "-k", "check-%s" % lang] + make_vars,
792 description="gcc-4_2-testsuite (%s)" % lang,
793 workdir='clang-tests/gcc-4_2-testsuite',
David Dean2bd0c3a2011-10-18 16:36:28 +0000794 logfiles={ 'dg.sum' : 'obj/%s/%s.sum' % (lang, lang),
795 '%s.log' % lang : 'obj/%s/%s.log' % (lang, lang)},
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000796 ignore=gcc_dg_ignores.get(lang, [])))
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000797
Daniel Dunbar7363d032011-02-27 03:22:35 +0000798def addClangGDBTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install"):
799 make_vars = [WithProperties(
800 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
801 WithProperties(
802 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
David Blaikie05517332013-12-19 23:29:12 +0000803 f.addStep(SVN(name='svn-clang-gdb-tests', mode='update',
Daniel Dunbar7363d032011-02-27 03:22:35 +0000804 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
805 defaultBranch='trunk', workdir='clang-tests'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000806 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar7363d032011-02-27 03:22:35 +0000807 name='test-gdb-1472-testsuite',
808 command=["make", "-k", "check"] + make_vars,
809 description="gdb-1472-testsuite",
810 workdir='clang-tests/gdb-1472-testsuite',
David Blaikie7ec695f2012-10-09 22:17:09 +0000811 logfiles={ 'dg.sum' : 'obj/filtered.gdb.sum',
David Blaikie624f4392012-11-05 22:34:35 +0000812 'gdb.log' : 'obj/gdb.log' }))
Daniel Dunbar7363d032011-02-27 03:22:35 +0000813
David Blaikie41d09c32013-01-02 21:11:09 +0000814def addModernClangGDBTests(f, jobs, install_prefix):
David Blaikie1bc5c372012-12-05 05:29:12 +0000815 make_vars = [WithProperties('RUNTESTFLAGS=CC_FOR_TARGET=\'{0}/bin/clang\' '
816 'CXX_FOR_TARGET=\'{0}/bin/clang++\' '
David Blaikie759bb752013-04-18 23:13:11 +0000817 'CFLAGS_FOR_TARGET=\'-w -fno-limit-debug-info\''
David Blaikief89877b2013-01-29 23:46:26 +0000818 .format(install_prefix))]
David Blaikie05517332013-12-19 23:29:12 +0000819 f.addStep(SVN(name='svn-clang-modern-gdb-tests', mode='update',
David Blaikief3f300b2012-11-17 01:13:41 +0000820 svnurl='http://llvm.org/svn/llvm-project/clang-tests-external/trunk/gdb/7.5',
David Blaikiedad03d52012-11-16 22:37:12 +0000821 workdir='clang-tests/src'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000822 f.addStep(Configure(command='../src/configure',
David Blaikief3f300b2012-11-17 01:13:41 +0000823 workdir='clang-tests/build/'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000824 f.addStep(WarningCountingShellCommand(name='gdb-75-build',
825 command=['make', WithProperties('-j%s' % jobs)],
826 haltOnFailure=True,
827 workdir='clang-tests/build'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000828 f.addStep(commands.DejaGNUCommand.DejaGNUCommand(
David Blaikiedad03d52012-11-16 22:37:12 +0000829 name='gdb-75-check',
David Blaikieb83bfdf2012-12-05 04:33:42 +0000830 command=['make', '-k', WithProperties('-j%s' % jobs), 'check'] + make_vars,
David Blaikiedad03d52012-11-16 22:37:12 +0000831 workdir='clang-tests/build',
David Blaikie1bc5c372012-12-05 05:29:12 +0000832 logfiles={'dg.sum':'gdb/testsuite/gdb.sum',
833 'gdb.log':'gdb/testsuite/gdb.log'}))
David Blaikiedad03d52012-11-16 22:37:12 +0000834
835
836
Daniel Dunbar7363d032011-02-27 03:22:35 +0000837# FIXME: Deprecated.
838addClangTests = addClangGCCTests
839
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000840def getClangTestsIgnoresFromPath(path, key):
841 def readList(path):
842 if not os.path.exists(path):
843 return []
844
845 f = open(path)
846 lines = [ln.strip() for ln in f]
847 f.close()
848 return lines
849
850 ignores = {}
851
852 gcc_dg_ignores = {}
853 for lang in ('gcc', 'g++', 'objc', 'obj-c++'):
854 lang_path = os.path.join(path, 'gcc-4_2-testsuite', 'expected_results',
855 key, lang)
856 gcc_dg_ignores[lang] = (
857 readList(os.path.join(lang_path, 'FAIL.txt')) +
858 readList(os.path.join(lang_path, 'UNRESOLVED.txt')) +
859 readList(os.path.join(lang_path, 'XPASS.txt')))
860 ignores['gcc-4_2-testsuite' ] = gcc_dg_ignores
861
Daniel Dunbar7363d032011-02-27 03:22:35 +0000862 ignores_path = os.path.join(path, 'gdb-1472-testsuite', 'expected_results',
863 key)
864 gdb_dg_ignores = (
865 readList(os.path.join(ignores_path, 'FAIL.txt')) +
866 readList(os.path.join(ignores_path, 'UNRESOLVED.txt')) +
867 readList(os.path.join(ignores_path, 'XPASS.txt')))
868 ignores['gdb-1472-testsuite' ] = gdb_dg_ignores
869
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000870 return ignores
David Deanf8b35442012-12-11 00:35:12 +0000871
Michael Gottesmandc771a02013-08-30 05:46:22 +0000872from zorg.buildbot.util.phasedbuilderutils import getBuildDir, setProperty
Michael Gottesman94e9ee42013-04-04 06:52:04 +0000873from zorg.buildbot.builders.Util import _did_last_build_fail
David Deanf8b35442012-12-11 00:35:12 +0000874from buildbot.steps.source.svn import SVN as HostSVN
875
Michael Gottesman94e9ee42013-04-04 06:52:04 +0000876def phasedClang(config_options, is_bootstrap=True, use_lto=False,
Justin Bogner9605b3f2014-05-30 23:25:46 +0000877 incremental=False):
David Deanf8b35442012-12-11 00:35:12 +0000878 # Create an instance of the Builder.
879 f = buildbot.process.factory.BuildFactory()
880 # Determine the build directory.
881 f = getBuildDir(f)
882 # get rid of old archives from prior builds
883 f.addStep(buildbot.steps.shell.ShellCommand(
Chris Matthews92ce8e22014-01-03 21:28:27 +0000884 name='rm.archives', command=['sh', '-c', 'sudo rm -rfv *gz'],
David Deanf8b35442012-12-11 00:35:12 +0000885 haltOnFailure=False, description=['rm archives'],
886 workdir=WithProperties('%(builddir)s')))
887 # Clean the build directory.
888 clang_build_dir = 'clang-build'
Michael Gottesman94e9ee42013-04-04 06:52:04 +0000889 if incremental:
890 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmand0ef7762013-10-01 20:50:35 +0000891 name='rm.clang-build', command=['sudo', 'rm', '-rfv',
892 clang_build_dir],
Michael Gottesman94e9ee42013-04-04 06:52:04 +0000893 haltOnFailure=False, description=['rm dir', clang_build_dir],
894 workdir=WithProperties('%(builddir)s'),
895 doStepIf=_did_last_build_fail))
896 else:
897 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmand0ef7762013-10-01 20:50:35 +0000898 name='rm.clang-build', command=['sudo', 'rm', '-rfv',
899 clang_build_dir],
Michael Gottesman94e9ee42013-04-04 06:52:04 +0000900 haltOnFailure=False, description=['rm dir', clang_build_dir],
901 workdir=WithProperties('%(builddir)s')))
902
David Deanf8b35442012-12-11 00:35:12 +0000903 # Cleanup the clang link, which buildbot's SVN always_purge does not know
904 # (in 8.5 this changed to method='fresh')
905 # how to remove correctly. If we don't do this, the LLVM update steps will
906 # end up doing a clobber every time.
907 #
908 # FIXME: Should file a Trac for this, but I am lazy.
909 f.addStep(buildbot.steps.shell.ShellCommand(
910 name='rm.clang-sources-link',
Chris Matthews92ce8e22014-01-03 21:28:27 +0000911 command=['sudo', 'rm', '-rfv', 'llvm/tools/clang'],
David Deanf8b35442012-12-11 00:35:12 +0000912 haltOnFailure=False, description=['rm', 'clang sources link'],
913 workdir=WithProperties('%(builddir)s')))
914 f.addStep(buildbot.steps.shell.ShellCommand(
915 name='rm.compiler-rt-sources-link',
Chris Matthews92ce8e22014-01-03 21:28:27 +0000916 command=['sudo', 'rm', '-rfv', 'llvm/projects/compiler-rt'],
David Deanf8b35442012-12-11 00:35:12 +0000917 haltOnFailure=False, description=['rm', 'compiler-rt sources link'],
918 workdir=WithProperties('%(builddir)s')))
Michael Gottesman2db83142013-08-05 21:44:45 +0000919 # TODO: We used to use a symlink here but it seems to not work. I am trying
920 # to get this builder to work so I am just going to copy it instead.
921 f.addStep(buildbot.steps.shell.ShellCommand(
922 name='rm.clang-tools-extra-source',
Chris Matthews92ce8e22014-01-03 21:28:27 +0000923 command=['sudo', 'rm', '-rfv', 'clang.src/tools/extra'],
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +0000924 haltOnFailure=True, workdir=WithProperties('%(builddir)s'),
Michael Gottesman2db83142013-08-05 21:44:45 +0000925 description=['rm', 'clang-tools-extra sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +0000926 f.addStep(buildbot.steps.shell.ShellCommand(
927 name='rm.debuginfo-tests',
Chris Matthews92ce8e22014-01-03 21:28:27 +0000928 command=['sudo', 'rm', '-rfv', 'clang.src/test/debuginfo-tests'],
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +0000929 haltOnFailure=True, workdir=WithProperties('%(builddir)s'),
Michael Gottesmane92eb122013-09-08 01:58:27 +0000930 description=['rm', 'debuginfo-tests sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +0000931
David Deanf8b35442012-12-11 00:35:12 +0000932 # Pull sources.
Michael Gottesmandc771a02013-08-30 05:46:22 +0000933 f = phasedbuilderutils.SVNCleanupStep(f, 'llvm')
David Deanf8b35442012-12-11 00:35:12 +0000934 f.addStep(HostSVN(name='pull.llvm', mode='incremental', method='fresh',
935 repourl='http://llvm.org/svn/llvm-project/llvm/trunk',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000936 retry=(60, 5), workdir='llvm', description='pull.llvm',
937 alwaysUseLatest=False))
Michael Gottesmandc771a02013-08-30 05:46:22 +0000938 f = phasedbuilderutils.SVNCleanupStep(f, 'clang.src')
David Deanf8b35442012-12-11 00:35:12 +0000939 f.addStep(HostSVN(name='pull.clang', mode='incremental', method='fresh',
940 repourl='http://llvm.org/svn/llvm-project/cfe/trunk',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000941 workdir='clang.src', retry=(60, 5),
David Deanf8b35442012-12-11 00:35:12 +0000942 description='pull.clang', alwaysUseLatest=False))
Michael Gottesmandc771a02013-08-30 05:46:22 +0000943 f = phasedbuilderutils.SVNCleanupStep(f, 'clang-tools-extra.src')
Michael Gottesman1dcf8f82013-03-28 06:20:57 +0000944 f.addStep(HostSVN(name='pull.clang-tools-extra', mode='incremental',
945 method='fresh',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000946 repourl='http://llvm.org/svn/llvm-project/'
947 'clang-tools-extra/trunk',
Michael Gottesman1dcf8f82013-03-28 06:20:57 +0000948 workdir='clang-tools-extra.src', alwaysUseLatest=False,
949 retry=(60, 5), description='pull.clang-tools-extra'))
Michael Gottesmandc771a02013-08-30 05:46:22 +0000950 f = phasedbuilderutils.SVNCleanupStep(f, 'compiler-rt.src')
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000951 f.addStep(HostSVN(name='pull.compiler-rt', mode='incremental',
952 method='fresh',
953 repourl='http://llvm.org/svn/llvm-project/compiler-rt/'
954 'trunk',
955 workdir='compiler-rt.src', alwaysUseLatest=False,
956 retry=(60, 5), description='pull.compiler-rt'))
Michael Gottesman13f82592013-09-08 01:54:43 +0000957 f = phasedbuilderutils.SVNCleanupStep(f, 'libcxx.src')
958 f.addStep(HostSVN(name='pull.libcxx', mode='incremental',
959 method='fresh',
960 repourl='http://llvm.org/svn/llvm-project/libcxx/'
961 'trunk',
962 workdir='libcxx.src', alwaysUseLatest=False,
963 retry=(60, 5), description='pull.libcxx'))
Michael Gottesmane92eb122013-09-08 01:58:27 +0000964 f = phasedbuilderutils.SVNCleanupStep(f, 'debuginfo-tests.src')
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +0000965 f.addStep(HostSVN(name='pull.debuginfo-tests', mode='incremental',
966 method='fresh',
967 repourl='http://llvm.org/svn/llvm-project/debuginfo-tests/'
968 'trunk',
969 workdir='debuginfo-tests.src', alwaysUseLatest=False,
970 retry=(60, 5), description='pull.debuginfo-tests'))
971
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000972 # Create symlinks to the clang compiler-rt sources inside the LLVM tree.
David Deanf8b35442012-12-11 00:35:12 +0000973 # We don't actually check out the sources there, because the SVN purge
974 # would always remove them then.
975 f.addStep(buildbot.steps.shell.ShellCommand(
976 name='ln.clang-sources', haltOnFailure=True,
977 command=['ln', '-sfv', '../../clang.src', 'clang'],
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000978 workdir='llvm/tools', description=['ln', 'clang sources']))
David Deanf8b35442012-12-11 00:35:12 +0000979 f.addStep(buildbot.steps.shell.ShellCommand(
980 name='ln.compiler-rt-sources',
981 command=['ln', '-sfv', '../../compiler-rt.src', 'compiler-rt'],
982 haltOnFailure=True, workdir='llvm/projects',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000983 description=['ln', 'compiler-rt sources']))
Michael Gottesman4a68b872013-03-28 19:03:52 +0000984 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesman13f82592013-09-08 01:54:43 +0000985 name='ln.libcxx.sources',
986 command=['ln', '-sfv', '../../libcxx.src', 'libcxx'],
987 haltOnFailure=True, workdir='llvm/projects',
988 description=['ln', 'libcxx sources']))
989 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmanbcab1992013-03-28 18:37:21 +0000990 name='cp.clang-tools-extra-sources',
Michael Gottesman03495922013-03-28 18:40:44 +0000991 command=['cp', '-Rfv', '../../clang-tools-extra.src', 'extra'],
Michael Gottesman1dcf8f82013-03-28 06:20:57 +0000992 haltOnFailure=True, workdir='clang.src/tools',
Chris Matthewsecc0f442014-03-12 00:04:23 +0000993 description=['cp', 'clang-tools-extra sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +0000994 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmane92eb122013-09-08 01:58:27 +0000995 name='cp.debuginfo-tests.sources',
996 command=['cp', '-Rfv', 'debuginfo-tests.src',
997 'clang.src/test/debuginfo-tests'],
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +0000998 haltOnFailure=True, workdir=WithProperties('%(builddir)s'),
Michael Gottesmane92eb122013-09-08 01:58:27 +0000999 description=['cp', 'debuginfo-tests sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +00001000
David Deanf8b35442012-12-11 00:35:12 +00001001 # Clean the install directory.
1002 f.addStep(buildbot.steps.shell.ShellCommand(
Chris Matthews92ce8e22014-01-03 21:28:27 +00001003 name='rm.clang-install', command=['sudo', 'rm', '-rfv', 'clang-install'],
David Deanf8b35442012-12-11 00:35:12 +00001004 haltOnFailure=False, description=['rm dir', 'clang-install'],
1005 workdir=WithProperties('%(builddir)s')))
1006 # Construct the configure arguments.
1007 configure_args = ['../llvm/configure']
1008 configure_args.extend(config_options)
Galina Kistanova702eccb2013-08-22 00:09:17 +00001009 configure_args.extend(['--disable-bindings',
Michael Gottesman6f85f932014-06-27 23:49:58 +00001010 '--enable-keep-symbols',
Michael Gottesman0fd485a2014-08-02 01:42:51 +00001011 '--enable-targets=x86,x86_64,arm,aarch64'])
David Deanf8b35442012-12-11 00:35:12 +00001012 configure_args.append(
Michael Gottesman65d940f2013-03-13 21:51:16 +00001013 WithProperties('--prefix=%(builddir)s/clang-install'))
Michael Gottesmanca56e8f2013-03-06 22:27:38 +00001014
David Deanf8b35442012-12-11 00:35:12 +00001015 # If we are using a previously built compiler, download it and override CC
1016 # and CXX.
1017 if is_bootstrap:
Michael Gottesmana6b5be82013-06-28 21:57:20 +00001018 f = artifacts.GetCompilerArtifacts(f)
David Deanf8b35442012-12-11 00:35:12 +00001019 else:
Michael Gottesmandc771a02013-08-30 05:46:22 +00001020 f = phasedbuilderutils.GetLatestValidated(f)
David Deanf8b35442012-12-11 00:35:12 +00001021 cc_command = ['find', 'host-compiler', '-name', 'clang']
1022 f.addStep(buildbot.steps.shell.SetProperty(
1023 name='find.cc',
1024 command=cc_command,
Michael Gottesmandc771a02013-08-30 05:46:22 +00001025 extract_fn=phasedbuilderutils.find_cc,
David Deanf8b35442012-12-11 00:35:12 +00001026 workdir=WithProperties('%(builddir)s')))
1027 f.addStep(buildbot.steps.shell.ShellCommand(
1028 name='sanity.test', haltOnFailure=True,
1029 command=[WithProperties('%(builddir)s/%(cc_path)s'), '-v'],
1030 description=['sanity test']))
1031 configure_args.extend([
1032 WithProperties('CC=%(builddir)s/%(cc_path)s'),
1033 WithProperties('CXX=%(builddir)s/%(cc_path)s++')])
Michael Gottesman65d940f2013-03-13 21:51:16 +00001034
1035 # If we need to use lto, find liblto, add in proper flags here, etc.
1036 if use_lto:
Michael Gottesman01f0a622013-03-13 22:38:38 +00001037 liblto_command = ['find', WithProperties('%(builddir)s/host-compiler'),
1038 '-name', 'libLTO.dylib']
Michael Gottesman1da57ae2013-03-13 21:54:23 +00001039 f.addStep(buildbot.steps.shell.SetProperty(
Michael Gottesman65d940f2013-03-13 21:51:16 +00001040 name='find.liblto',
1041 command=liblto_command,
Michael Gottesmandc771a02013-08-30 05:46:22 +00001042 extract_fn=phasedbuilderutils.find_liblto,
Michael Gottesman65d940f2013-03-13 21:51:16 +00001043 workdir=WithProperties('%(builddir)s')))
1044 configure_args.append(
1045 '--with-extra-options=-flto -gline-tables-only')
1046
David Deanf8b35442012-12-11 00:35:12 +00001047 # Configure the LLVM build.
Michael Gottesmand97d8502013-04-04 07:57:31 +00001048 if incremental:
1049 # *NOTE* This is a temporary work around. I am eventually going to just
1050 # set up cmake/ninja but for now I am sticking with the make => I need
1051 # configure to run only after a failure so on success I have incremental
1052 # builds.
1053 f.addStep(buildbot.steps.shell.ShellCommand(
1054 name='configure.with.host', command=configure_args,
1055 haltOnFailure=True, description=['configure'],
1056 workdir=clang_build_dir,
1057 doStepIf=_did_last_build_fail))
1058 else:
1059 f.addStep(buildbot.steps.shell.ShellCommand(
1060 name='configure.with.host', command=configure_args,
1061 haltOnFailure=True, description=['configure'],
1062 workdir=clang_build_dir))
1063
David Deanf8b35442012-12-11 00:35:12 +00001064 # Build the compiler.
Michael Gottesman36778832013-09-08 01:37:35 +00001065 make_command = ['make', '-j', WithProperties('%(jobs)s'), 'VERBOSE=1']
Galina Kistanovabfb29d22013-05-09 23:53:24 +00001066 timeout = 40*60 # Normal timeout is 20 minutes.
Michael Gottesman65d940f2013-03-13 21:51:16 +00001067 if use_lto:
1068 make_command.append(WithProperties('DYLD_LIBRARY_PATH=%(liblto_path)s'))
Michael Gottesman2e7385c2013-08-12 17:57:27 +00001069 timeout = 240*60 # LTO timeout is 240 minutes.
Michael Gottesman65d940f2013-03-13 21:51:16 +00001070
David Deanf8b35442012-12-11 00:35:12 +00001071 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesman65d940f2013-03-13 21:51:16 +00001072 name='make', command=make_command,
Michael Gottesmanbab77ac2013-03-14 05:36:53 +00001073 haltOnFailure=True, description=['make'], workdir=clang_build_dir,
1074 timeout=timeout))
David Deanf8b35442012-12-11 00:35:12 +00001075 # Use make install-clang to produce minimal archive for use by downstream
1076 # builders.
1077 f.addStep(buildbot.steps.shell.ShellCommand(
1078 name='make.install-clang', haltOnFailure=True,
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001079 command=['make', 'install-clang', '-j',
1080 WithProperties('%(jobs)s'),
1081 'RC_SUPPORTED_ARCHS=armv7 i386 x86_64'],
David Deanf8b35442012-12-11 00:35:12 +00001082 description=['make install'], workdir=clang_build_dir))
1083 # Save artifacts of this build for use by other builders.
Michael Gottesmana6b5be82013-06-28 21:57:20 +00001084 f = artifacts.uploadArtifacts(f)
David Deanf8b35442012-12-11 00:35:12 +00001085 # Run the LLVM and Clang regression tests.
Michael Gottesmana9c32be2013-09-06 17:47:24 +00001086 cmd_str = r"""make VERBOSE=1 LIT_ARGS="-v --param run_long_tests=true --filter='^(?!.*debuginfo-tests)'" check-all"""
1087 f.addStep(lit_test_command.LitTestCommand(name='run.llvm.tests', haltOnFailure=True,
1088 command=cmd_str,
1089 description=['all', 'tests'],
1090 workdir=clang_build_dir))
1091 # Work around for lldb issue rdar://14929651
Chris Matthewsecc0f442014-03-12 00:04:23 +00001092 # The crazy filter regex is to remove static-member[2].cpp, which requires xcode5 or later.
1093 # radar://16295455 tracks the removal of this regex.
1094 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 +00001095 f.addStep(lit_test_command.LitTestCommand(name='run.llvm.debuginfo-tests', haltOnFailure=True,
Michael Gottesmane7dc31e2013-08-30 05:57:35 +00001096 command=cmd_str,
Michael Gottesmana6b5be82013-06-28 21:57:20 +00001097 description=['all', 'tests'],
1098 workdir=clang_build_dir))
David Deanf8b35442012-12-11 00:35:12 +00001099 return f