blob: 82f877045939a12655ff9e47ae70e0eaccc01b4e [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,
44 merge_functions=False):
Galina Kistanovaf4d79352011-10-20 20:46:52 +000045 # Prepare environmental variables. Set here all env we want everywhere.
46 merged_env = {
47 'TERM' : 'dumb' # Make sure Clang doesn't use color escape sequences.
48 }
49 if env is not None:
50 # Overwrite pre-set items with the given ones, so user can set anything.
51 merged_env.update(env)
David Blaikie2f7eb282012-08-24 18:37:00 +000052
David Blaikiedad03d52012-11-16 22:37:12 +000053 if run_gdb or run_gcc or run_modern_gdb:
David Blaikie88511c72012-08-24 23:14:06 +000054 outOfDir = True
Galina Kistanovaf4d79352011-10-20 20:46:52 +000055
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000056 # Don't use in-dir builds with a two stage build process.
Daniel Dunbar3efb7822010-02-26 19:20:00 +000057 inDir = not outOfDir and not useTwoStage
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000058 if inDir:
59 llvm_srcdir = "llvm"
60 llvm_1_objdir = "llvm"
David Blaikie88511c72012-08-24 23:14:06 +000061 llvm_1_installdir = None
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000062 else:
63 llvm_srcdir = "llvm.src"
64 llvm_1_objdir = "llvm.obj"
65 llvm_1_installdir = "llvm.install.1"
66 llvm_2_objdir = "llvm.obj.2"
Daniel Dunbar22d594a2010-07-31 05:29:16 +000067 llvm_2_installdir = "llvm.install"
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000068
Daniel Dunbar235aa412009-07-18 07:16:15 +000069 f = buildbot.process.factory.BuildFactory()
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000070
71 # Determine the build directory.
72 f.addStep(buildbot.steps.shell.SetProperty(name="get_builddir",
73 command=["pwd"],
74 property="builddir",
75 description="set build dir",
Galina Kistanovaf4d79352011-10-20 20:46:52 +000076 workdir=".",
77 env=merged_env))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000078
Daniel Dunbar06b20f12010-04-08 18:29:38 +000079 # Blow away completely, if requested.
80 if completely_clean:
81 f.addStep(ShellCommand(name="rm-llvm.src",
82 command=["rm", "-rf", llvm_srcdir],
83 haltOnFailure=True,
84 description=["rm src dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +000085 workdir=".",
86 env=merged_env))
Daniel Dunbar06b20f12010-04-08 18:29:38 +000087
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000088 # Checkout sources.
Peter Collingbourned49ac282011-10-25 14:38:45 +000089 if trunk_revision:
90 # The SVN build step provides no mechanism to check out a specific revision
91 # based on a property, so just run the commands directly here.
92 svn_co = ['svn', 'checkout']
93 if force_checkout:
94 svn_co += ['--force']
95 svn_co += ['--revision', WithProperties(trunk_revision)]
96
97 svn_co_llvm = svn_co + \
98 [WithProperties('http://llvm.org/svn/llvm-project/llvm/trunk@%s' %
99 trunk_revision),
100 llvm_srcdir]
101 svn_co_clang = svn_co + \
102 [WithProperties('http://llvm.org/svn/llvm-project/cfe/trunk@%s' %
103 trunk_revision),
104 '%s/tools/clang' % llvm_srcdir]
David Blaikie845ae0d2012-08-10 00:51:38 +0000105 svn_co_clang_tools_extra = svn_co + \
106 [WithProperties('http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@%s' %
107 trunk_revision),
108 '%s/tools/clang/tools/extra' % llvm_srcdir]
Peter Collingbourned49ac282011-10-25 14:38:45 +0000109
110 f.addStep(ShellCommand(name='svn-llvm',
111 command=svn_co_llvm,
112 haltOnFailure=True,
113 workdir='.'))
114 f.addStep(ShellCommand(name='svn-clang',
115 command=svn_co_clang,
116 haltOnFailure=True,
117 workdir='.'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000118 f.addStep(ShellCommand(name='svn-clang-tools-extra',
119 command=svn_co_clang_tools_extra,
120 haltOnFailure=True,
121 workdir='.'))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000122 else:
123 f.addStep(SVN(name='svn-llvm',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000124 mode='update',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000125 baseURL='http://llvm.org/svn/llvm-project/llvm/',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000126 defaultBranch='trunk',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000127 workdir=llvm_srcdir))
128 f.addStep(SVN(name='svn-clang',
129 mode='update',
130 baseURL='http://llvm.org/svn/llvm-project/cfe/',
131 defaultBranch='trunk',
132 workdir='%s/tools/clang' % llvm_srcdir))
David Blaikie845ae0d2012-08-10 00:51:38 +0000133 f.addStep(SVN(name='svn-clang-tools-extra',
134 mode='update',
135 baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
136 defaultBranch='trunk',
137 workdir='%s/tools/clang/tools/extra' % llvm_srcdir))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000138 if checkout_compiler_rt:
139 f.addStep(SVN(name='svn-compiler-rt',
140 mode='update',
141 baseURL='http://llvm.org/svn/llvm-project/compiler-rt/',
142 defaultBranch='trunk',
143 workdir='%s/projects/compiler-rt' % llvm_srcdir))
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000144
Galina Kistanova10836402013-09-26 20:42:52 +0000145 # Revert and apply patch mergeFunctions in required
146 if merge_functions:
147 f.addStep(ShellCommand(name="revert_patch_MergeFunctions",
148 command=["svn", "-R", "revert", '.'],
149 haltOnFailure=True,
150 description=["revert patch MergeFunctions"],
151 workdir='%s/tools/clang' % llvm_srcdir,
152 env=merged_env))
153
154 if merge_functions:
155 f.addStep(ShellCommand(name="patch_MergeFunctions",
156 command=["patch", "-Np0", "-i", '../../utils/Misc/mergefunctions.clang.svn.patch'],
157 haltOnFailure=True,
158 description=["patch MergeFunctions"],
159 workdir='%s/tools/clang' % llvm_srcdir,
160 env=merged_env))
161
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000162 # Clean up llvm (stage 1); unless in-dir.
163 if clean and llvm_srcdir != llvm_1_objdir:
164 f.addStep(ShellCommand(name="rm-llvm.obj.stage1",
165 command=["rm", "-rf", llvm_1_objdir],
166 haltOnFailure=True,
167 description=["rm build dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000168 workdir=".",
169 env=merged_env))
Andrew Trick70fa9d22011-08-25 23:38:51 +0000170
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000171 # Force without llvm-gcc so we don't run afoul of Frontend test failures.
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000172 base_configure_args = [WithProperties("%%(builddir)s/%s/configure" % llvm_srcdir),
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000173 '--disable-bindings']
174 base_configure_args += extra_configure_args
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000175 if triple:
Andrew Trick70fa9d22011-08-25 23:38:51 +0000176 base_configure_args += ['--build=%s' % triple,
Michael Gottesman6f85f932014-06-27 23:49:58 +0000177 '--host=%s' % triple]
Galina Kistanova702eccb2013-08-22 00:09:17 +0000178 args = base_configure_args + [WithProperties("--prefix=%%(builddir)s/%s" % llvm_1_installdir)]
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000179 args += builders_util.getConfigArgs(stage1_config)
David Blaikie8cbf62f2013-01-12 21:32:31 +0000180 if not clean:
181 f.addStep(SetProperty(name="Makefile_isready",
182 workdir=llvm_1_objdir,
183 command=["sh", "-c",
Galina Kistanovaf7275a42013-03-22 21:42:55 +0000184 "test -e Makefile.config && echo OK || echo Missing"],
David Blaikie8cbf62f2013-01-12 21:32:31 +0000185 flunkOnFailure=False,
186 property="exists_Makefile"))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000187 f.addStep(Configure(command=args,
188 workdir=llvm_1_objdir,
189 description=['configuring',stage1_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000190 descriptionDone=['configure',stage1_config],
David Blaikie8cbf62f2013-01-12 21:32:31 +0000191 env=merged_env,
192 doStepIf=lambda step: step.build.getProperty("exists_Makefile") != "OK"))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000193
194 # Make clean if using in-dir builds.
195 if clean and llvm_srcdir == llvm_1_objdir:
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000196 f.addStep(WarningCountingShellCommand(name="clean-llvm",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000197 command=[make, "clean"],
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000198 haltOnFailure=True,
199 description="cleaning llvm",
200 descriptionDone="clean llvm",
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000201 workdir=llvm_1_objdir,
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000202 doStepIf=clean,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000203 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000204
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000205 if extra_clean_step:
206 f.addStep(extra_clean_step)
207
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000208 f.addStep(WarningCountingShellCommand(name="compile",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000209 command=['nice', '-n', '10',
210 make, WithProperties("-j%s" % jobs)],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000211 haltOnFailure=True,
David Blaikie05517332013-12-19 23:29:12 +0000212 flunkOnFailure=not run_gdb,
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000213 description=["compiling", stage1_config],
214 descriptionDone=["compile", stage1_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000215 workdir=llvm_1_objdir,
216 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000217
218 if examples:
219 f.addStep(WarningCountingShellCommand(name="compile.examples",
220 command=['nice', '-n', '10',
221 make, WithProperties("-j%s" % jobs),
222 "BUILD_EXAMPLES=1"],
223 haltOnFailure=True,
Richard Smith65e6f5d2014-09-25 18:18:35 +0000224 description=["compiling", stage1_config, "examples"],
Daniel Dunbar256fed42009-11-25 21:11:08 +0000225 descriptionDone=["compile", stage1_config, "examples"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000226 workdir=llvm_1_objdir,
227 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000228
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000229 clangTestArgs = '-v -j %s' % jobs
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000230 if valgrind:
Daniel Dunbar89184b92010-04-18 19:09:32 +0000231 clangTestArgs += ' --vg'
Daniel Dunbara1bebce2010-03-21 01:24:00 +0000232 if valgrindLeakCheck:
233 clangTestArgs += ' --vg-leak'
Nick Lewycky8d26e472011-08-27 21:18:56 +0000234 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 +0000235 extraTestDirs = ''
236 if run_cxx_tests:
237 extraTestDirs += '%(builddir)s/llvm/tools/clang/utils/C++Tests'
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000238 if test:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000239 f.addStep(lit_test_command.LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000240 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000241 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000242 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie05517332013-12-19 23:29:12 +0000243 flunkOnFailure=not run_gdb,
David Blaikie7e6f8a12012-08-31 20:46:27 +0000244 description=["checking"],
245 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000246 workdir=llvm_1_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000247 usePTY=use_pty_in_tests,
248 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000249
250 # Install llvm and clang.
251 if llvm_1_installdir:
Daniel Dunbar9870de32010-03-28 22:25:31 +0000252 f.addStep(ShellCommand(name="rm-install.clang.stage1",
253 command=["rm", "-rf", llvm_1_installdir],
254 haltOnFailure=True,
255 description=["rm install dir", "clang"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000256 workdir=".",
257 env=merged_env))
Daniel Dunbar9870de32010-03-28 22:25:31 +0000258 f.addStep(WarningCountingShellCommand(name="install.clang.stage1",
259 command = ['nice', '-n', '10',
260 make, 'install-clang'],
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000261 haltOnFailure=True,
Daniel Dunbar9870de32010-03-28 22:25:31 +0000262 description=["install", "clang",
263 stage1_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000264 workdir=llvm_1_objdir,
265 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000266
David Blaikiedad03d52012-11-16 22:37:12 +0000267 if run_gdb or run_gcc or run_modern_gdb:
David Blaikiea76da842012-08-13 22:24:46 +0000268 ignores = getClangTestsIgnoresFromPath(os.path.expanduser('~/public/clang-tests'), 'clang-x86_64-darwin10')
269 install_prefix = "%%(builddir)s/%s" % llvm_1_installdir
270 if run_gdb:
271 addClangGDBTests(f, ignores, install_prefix)
David Blaikiedad03d52012-11-16 22:37:12 +0000272 if run_modern_gdb:
David Blaikie41d09c32013-01-02 21:11:09 +0000273 addModernClangGDBTests(f, jobs, install_prefix)
David Blaikiea76da842012-08-13 22:24:46 +0000274 if run_gcc:
275 addClangGCCTests(f, ignores, install_prefix)
276
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000277 if not useTwoStage:
Daniel Dunbardedf6572010-11-13 00:23:34 +0000278 if package_dst:
279 name = WithProperties(
280 "%(builddir)s/" + llvm_1_objdir +
281 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
282 f.addStep(ShellCommand(name='pkg.tar',
283 description="tar root",
284 command=["tar", "zcvf", name, "./"],
285 workdir=llvm_1_installdir,
286 warnOnFailure=True,
287 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000288 haltOnFailure=False,
289 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000290 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000291 description="upload root",
Daniel Dunbardedf6572010-11-13 00:23:34 +0000292 command=["scp", name,
293 WithProperties(
294 package_dst + "/%(buildername)s")],
295 workdir=".",
296 warnOnFailure=True,
297 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000298 haltOnFailure=False,
299 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000300
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000301 return f
302
303 # Clean up llvm (stage 2).
304 if clean:
305 f.addStep(ShellCommand(name="rm-llvm.obj.stage2",
306 command=["rm", "-rf", llvm_2_objdir],
307 haltOnFailure=True,
308 description=["rm build dir", "llvm", "(stage 2)"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000309 workdir=".",
310 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000311
312 # Configure llvm (stage 2).
Galina Kistanova702eccb2013-08-22 00:09:17 +0000313 args = base_configure_args + [WithProperties("--prefix=%(builddir)s/" + llvm_2_installdir)]
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000314 args += builders_util.getConfigArgs(stage2_config)
Benjamin Kramer9c6fed72012-07-20 10:18:32 +0000315 local_env = dict(merged_env)
316 local_env.update({
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000317 'CC' : WithProperties("%%(builddir)s/%s/bin/clang" % llvm_1_installdir),
318 'CXX' : WithProperties("%%(builddir)s/%s/bin/clang++" % llvm_1_installdir)})
319
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000320 f.addStep(Configure(name="configure.llvm.stage2",
321 command=args,
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000322 haltOnFailure=True,
323 workdir=llvm_2_objdir,
324 description=["configure", "llvm", "(stage 2)",
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000325 stage2_config],
326 env=local_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000327
328 # Build llvm (stage 2).
329 f.addStep(WarningCountingShellCommand(name="compile.llvm.stage2",
330 command=['nice', '-n', '10',
331 make, WithProperties("-j%s" % jobs)],
332 haltOnFailure=True,
333 description=["compiling", "(stage 2)",
334 stage2_config],
335 descriptionDone=["compile", "(stage 2)",
336 stage2_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000337 workdir=llvm_2_objdir,
338 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000339
340 if test:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000341 f.addStep(lit_test_command.LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000342 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000343 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000344 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie7e6f8a12012-08-31 20:46:27 +0000345 description=["checking"],
346 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000347 workdir=llvm_2_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000348 usePTY=use_pty_in_tests,
349 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000350
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000351 # Install clang (stage 2).
Daniel Dunbar9870de32010-03-28 22:25:31 +0000352 f.addStep(ShellCommand(name="rm-install.clang.stage2",
353 command=["rm", "-rf", llvm_2_installdir],
354 haltOnFailure=True,
355 description=["rm install dir", "clang"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000356 workdir=".",
357 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000358 f.addStep(WarningCountingShellCommand(name="install.clang.stage2",
359 command = ['nice', '-n', '10',
360 make, 'install-clang'],
361 haltOnFailure=True,
362 description=["install", "clang",
363 "(stage 2)"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000364 workdir=llvm_2_objdir,
365 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000366
367 if package_dst:
368 name = WithProperties(
369 "%(builddir)s/" + llvm_2_objdir +
370 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
371 f.addStep(ShellCommand(name='pkg.tar',
372 description="tar root",
373 command=["tar", "zcvf", name, "./"],
374 workdir=llvm_2_installdir,
375 warnOnFailure=True,
376 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000377 haltOnFailure=False,
378 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000379 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000380 description="upload root",
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000381 command=["scp", name,
382 WithProperties(
383 package_dst + "/%(buildername)s")],
384 workdir=".",
385 warnOnFailure=True,
386 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000387 haltOnFailure=False,
388 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000389
Daniel Dunbar235aa412009-07-18 07:16:15 +0000390 return f
Daniel Dunbar44abe742009-07-19 01:59:03 +0000391
Renato Goline402f582014-09-04 19:25:24 +0000392# CMake Linux builds
393def getClangCMakeBuildFactory(
394 clean=True,
395 test=True,
396 cmake='cmake',
397 jobs=None,
398
399 # Multi-stage compilation
400 useTwoStage=False,
401 testStage1=True,
402 stage1_config='Release',
403 stage2_config='Release',
404
405 # Environmental variables for all steps.
406 env={},
407 extra_cmake_args=[],
408
409 # Extra repositories
410 checkout_clang_tools_extra=True,
411 checkout_compiler_rt=True):
412
413 ############# PREPARING
414 f = buildbot.process.factory.BuildFactory()
415
416 # We *must* checkout at least Clang+LLVM
417 f.addStep(SVN(name='svn-llvm',
418 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
419 defaultBranch='trunk',
420 workdir='llvm'))
421 f.addStep(SVN(name='svn-clang',
422 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
423 defaultBranch='trunk',
424 workdir='llvm/tools/clang'))
425
426 # Extra stuff that will be built/tested
427 if checkout_clang_tools_extra:
428 f.addStep(SVN(name='svn-clang-tools-extra',
429 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
430 defaultBranch='trunk',
431 workdir='llvm/tools/clang/tools/extra'))
432 if checkout_compiler_rt:
433 f.addStep(SVN(name='svn-compiler-rt',
434 mode='update', baseURL='http://llvm.org/svn/llvm-project/compiler-rt/',
435 defaultBranch='trunk',
436 workdir='llvm/projects/compiler-rt'))
437
438 # If jobs not defined, Ninja will choose a suitable value
439 jobs_cmd=[]
440 lit_args="'-v"
441 if jobs is not None:
442 jobs_cmd=["-j"+str(jobs)]
443 lit_args+=" -j"+str(jobs)+"'"
444 else:
445 lit_args+="'"
446 ninja_cmd=['ninja'] + jobs_cmd
447 ninja_install_cmd=['ninja', 'install'] + jobs_cmd
448 ninja_check_cmd=['ninja', 'check-all'] + jobs_cmd
449
450 # Global configurations
451 stage1_build='stage1'
452 stage1_install='stage1.install'
453 stage2_build='stage2'
454
455 ############# CLEANING
456 if clean:
457 f.addStep(ShellCommand(name='clean stage 1',
458 command=['rm','-rf',stage1_build],
459 warnOnFailure=True,
460 description='cleaning stage 1',
461 descriptionDone='clean',
462 workdir='.',
463 env=env))
464 else:
465 f.addStep(SetProperty(name="check ninja files 1",
466 workdir=stage1_build,
467 command=["sh", "-c",
468 "test -e build.ninja && echo OK || echo Missing"],
469 flunkOnFailure=False,
470 property="exists_ninja_1"))
471
472
473 ############# STAGE 1
474 f.addStep(ShellCommand(name='cmake stage 1',
475 command=[cmake, "-G", "Ninja", "../llvm",
476 "-DCMAKE_BUILD_TYPE="+stage1_config,
477 "-DLLVM_ENABLE_ASSERTIONS=True",
478 "-DLLVM_LIT_ARGS="+lit_args,
479 "-DCMAKE_INSTALL_PREFIX=../"+stage1_install]
480 + extra_cmake_args,
481 haltOnFailure=True,
482 description='cmake stage 1',
483 workdir=stage1_build,
484 doStepIf=lambda step: step.build.getProperty("exists_ninja_1") != "OK",
485 env=env))
486
487 f.addStep(WarningCountingShellCommand(name='build stage 1',
488 command=ninja_cmd,
489 haltOnFailure=True,
490 description='ninja all',
491 workdir=stage1_build,
492 env=env))
493
494 if test and testStage1:
Renato Golincfbd5702014-09-06 19:09:16 +0000495 f.addStep(lit_test_command.LitTestCommand(name='ninja check 1',
496 command=ninja_check_cmd,
497 description=["checking stage 1"],
498 descriptionDone=["stage 1 checked"],
499 workdir=stage1_build,
500 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000501
502 if not useTwoStage:
503 return f
504
505 ############# STAGE 2
506 f.addStep(ShellCommand(name='install stage 1',
507 command=ninja_install_cmd,
508 description='ninja install',
509 workdir=stage1_build,
510 env=env))
511
512 if clean:
513 f.addStep(ShellCommand(name='clean stage 2',
514 command=['rm','-rf',stage2_build],
515 warnOnFailure=True,
516 description='cleaning stage 2',
517 descriptionDone='clean',
518 workdir='.',
519 env=env))
520 else:
521 f.addStep(SetProperty(name="check ninja files 2",
522 workdir=stage2_build,
523 command=["sh", "-c",
524 "test -e build.ninja && echo OK || echo Missing"],
525 flunkOnFailure=False,
526 property="exists_ninja_2"))
527
528
529 f.addStep(ShellCommand(name='cmake stage 2',
530 command=[cmake, "-G", "Ninja", "../llvm",
531 "-DCMAKE_BUILD_TYPE="+stage2_config,
532 "-DLLVM_ENABLE_ASSERTIONS=True",
533 WithProperties("-DCMAKE_C_COMPILER=%(workdir)s/"+stage1_install+"/bin/clang"),
534 WithProperties("-DCMAKE_CXX_COMPILER=%(workdir)s/"+stage1_install+"/bin/clang++"),
535 "-DLLVM_LIT_ARGS="+lit_args]
536 + extra_cmake_args,
537 haltOnFailure=True,
538 description='cmake stage 2',
539 workdir=stage2_build,
540 doStepIf=lambda step: step.build.getProperty("exists_ninja_2") != "OK",
541 env=env))
542
543 f.addStep(WarningCountingShellCommand(name='build stage 2',
544 command=ninja_cmd,
545 haltOnFailure=True,
546 description='ninja all',
547 workdir=stage2_build,
548 env=env))
549
550 if test:
Renato Golincfbd5702014-09-06 19:09:16 +0000551 f.addStep(lit_test_command.LitTestCommand(name='ninja check 2',
552 command=ninja_check_cmd,
553 description=["checking stage 2"],
554 descriptionDone=["stage 2 checked"],
555 workdir=stage2_build,
556 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000557
558 return f
559
Daniel Dunbarc51a59e2010-09-23 14:57:45 +0000560def getClangMSVCBuildFactory(update=True, clean=True, vcDrive='c', jobs=1, cmake=r"cmake"):
Daniel Dunbar44abe742009-07-19 01:59:03 +0000561 f = buildbot.process.factory.BuildFactory()
562
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000563 if update:
Daniel Dunbar44abe742009-07-19 01:59:03 +0000564 f.addStep(SVN(name='svn-llvm',
565 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
566 defaultBranch='trunk',
567 workdir='llvm'))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000568 f.addStep(SVN(name='svn-clang',
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000569 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
Daniel Dunbar44abe742009-07-19 01:59:03 +0000570 defaultBranch='trunk',
571 workdir='llvm/tools/clang'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000572 f.addStep(SVN(name='svn-clang-tools-extra',
573 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
574 defaultBranch='trunk',
575 workdir='llvm/tools/clang/tools/extra'))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000576
577 # Full & fast clean.
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000578 if clean:
Daniel Dunbar44abe742009-07-19 01:59:03 +0000579 f.addStep(ShellCommand(name='clean-1',
580 command=['del','/s/q','build'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000581 warnOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000582 description='cleaning',
583 descriptionDone='clean',
584 workdir='llvm'))
585 f.addStep(ShellCommand(name='clean-2',
586 command=['rmdir','/s/q','build'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000587 warnOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000588 description='cleaning',
589 descriptionDone='clean',
590 workdir='llvm'))
591
592 # Create the project files.
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000593
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000594 # Use batch files instead of ShellCommand directly, Windows quoting is
595 # borked. FIXME: See buildbot ticket #595 and buildbot ticket #377.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000596 f.addStep(batch_file_download.BatchFileDownload(name='cmakegen',
Daniel Dunbar06b20f12010-04-08 18:29:38 +0000597 command=[cmake,
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000598 "-DLLVM_TARGETS_TO_BUILD:=X86",
Daniel Dunbar1ddedce2010-09-24 19:57:34 +0000599 "-DLLVM_INCLUDE_EXAMPLES:=OFF",
600 "-DLLVM_INCLUDE_TESTS:=OFF",
601 "-DLLVM_TARGETS_TO_BUILD:=X86",
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000602 "-G",
603 "Visual Studio 9 2008",
604 ".."],
605 workdir="llvm\\build"))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000606 f.addStep(ShellCommand(name='cmake',
607 command=['cmakegen.bat'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000608 haltOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000609 description='cmake gen',
610 workdir='llvm\\build'))
611
612 # Build it.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000613 f.addStep(batch_file_download.BatchFileDownload(name='vcbuild',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000614 command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""",
615 "/M%d" % jobs,
616 "LLVM.sln",
617 "Debug|Win32"],
618 workdir="llvm\\build"))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000619 f.addStep(WarningCountingShellCommand(name='vcbuild',
620 command=['vcbuild.bat'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000621 haltOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000622 description='vcbuild',
623 workdir='llvm\\build',
624 warningPattern=" warning C.*:"))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000625
626 # Build clang-test project.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000627 f.addStep(batch_file_download.BatchFileDownload(name='vcbuild_test',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000628 command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""",
629 "clang-test.vcproj",
630 "Debug|Win32"],
631 workdir="llvm\\build\\tools\\clang\\test"))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000632 f.addStep(lit_test_command.LitTestCommand(name='test-clang',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000633 command=["vcbuild_test.bat"],
634 workdir="llvm\\build\\tools\\clang\\test"))
635
Daniel Dunbar44abe742009-07-19 01:59:03 +0000636 return f
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000637
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000638# Builds on Windows using CMake, MinGW(32|64), and no Microsoft tools.
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000639def getClangMinGWBuildFactory(update=True, clean=True, jobs=6, cmake=r"cmake"):
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000640 f = buildbot.process.factory.BuildFactory()
641
642 if update:
643 f.addStep(SVN(name='svn-llvm',
644 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
645 defaultBranch='trunk',
646 workdir='llvm'))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000647 f.addStep(SVN(name='svn-clang',
648 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
649 defaultBranch='trunk',
650 workdir='llvm/tools/clang'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000651 f.addStep(SVN(name='svn-clang-tools-extra',
652 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
653 defaultBranch='trunk',
654 workdir='llvm/tools/clang/tools/extra'))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000655
656 # Full & fast clean.
657 if clean:
658 # note: This command is redundant as the next command removes everything
659 f.addStep(ShellCommand(name='clean-1',
660 command=['del','/s/q','build'],
661 warnOnFailure=True,
662 description='cleaning',
663 descriptionDone='clean',
664 workdir='llvm'))
665 f.addStep(ShellCommand(name='clean-2',
666 command=['rmdir','/s/q','build'],
667 warnOnFailure=True,
668 description='cleaning',
669 descriptionDone='clean',
670 workdir='llvm'))
671
672 # Create the Makefiles.
673
674 # Use batch files instead of ShellCommand directly, Windows quoting is
675 # borked. FIXME: See buildbot ticket #595 and buildbot ticket #377.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000676 f.addStep(batch_file_download.BatchFileDownload(name='cmakegen',
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000677 command=[cmake,
678 "-DLLVM_TARGETS_TO_BUILD:=X86",
679 "-DLLVM_INCLUDE_EXAMPLES:=OFF",
680 "-DLLVM_INCLUDE_TESTS:=OFF",
681 "-DLLVM_TARGETS_TO_BUILD:=X86",
682 "-G",
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000683 "Ninja",
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000684 ".."],
685 workdir="llvm\\build"))
686 f.addStep(ShellCommand(name='cmake',
687 command=['cmakegen.bat'],
688 haltOnFailure=True,
689 description='cmake gen',
690 workdir='llvm\\build'))
691
692 # Build it.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000693 f.addStep(batch_file_download.BatchFileDownload(name='makeall',
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000694 command=["ninja", "-j", "%d" % jobs],
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000695 haltOnFailure=True,
696 workdir='llvm\\build'))
697
698 f.addStep(WarningCountingShellCommand(name='makeall',
699 command=['makeall.bat'],
700 haltOnFailure=True,
701 description='makeall',
702 workdir='llvm\\build'))
703
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000704 # Build global check project (make check) (sources not checked out...).
705 if 0:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000706 f.addStep(batch_file_download.BatchFileDownload(name='makecheck',
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000707 command=["ninja", "check"],
708 workdir='llvm\\build'))
709 f.addStep(WarningCountingShellCommand(name='check',
710 command=['makecheck.bat'],
711 description='make check',
712 workdir='llvm\\build'))
Galina Kistanova049d76c2012-06-09 00:56:05 +0000713
714 # Build clang-test project (make clang-test).
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000715 f.addStep(batch_file_download.BatchFileDownload(name='maketest',
716 command=["ninja", "clang-test"],
717 workdir="llvm\\build"))
718 f.addStep(lit_test_command.LitTestCommand(name='clang-test',
719 command=["maketest.bat"],
720 workdir="llvm\\build"))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000721 return f
722
Daniel Dunbar7363d032011-02-27 03:22:35 +0000723def addClangGCCTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install",
724 languages = ('gcc', 'g++', 'objc', 'obj-c++')):
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000725 make_vars = [WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000726 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000727 WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000728 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
David Blaikie05517332013-12-19 23:29:12 +0000729 f.addStep(SVN(name='svn-clang-gcc-tests', mode='update',
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000730 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
731 defaultBranch='trunk', workdir='clang-tests'))
732 gcc_dg_ignores = ignores.get('gcc-4_2-testsuite', {})
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000733 for lang in languages:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000734 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000735 name='test-gcc-4_2-testsuite-%s' % lang,
736 command=["make", "-k", "check-%s" % lang] + make_vars,
737 description="gcc-4_2-testsuite (%s)" % lang,
738 workdir='clang-tests/gcc-4_2-testsuite',
David Dean2bd0c3a2011-10-18 16:36:28 +0000739 logfiles={ 'dg.sum' : 'obj/%s/%s.sum' % (lang, lang),
740 '%s.log' % lang : 'obj/%s/%s.log' % (lang, lang)},
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000741 ignore=gcc_dg_ignores.get(lang, [])))
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000742
Daniel Dunbar7363d032011-02-27 03:22:35 +0000743def addClangGDBTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install"):
744 make_vars = [WithProperties(
745 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
746 WithProperties(
747 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
David Blaikie05517332013-12-19 23:29:12 +0000748 f.addStep(SVN(name='svn-clang-gdb-tests', mode='update',
Daniel Dunbar7363d032011-02-27 03:22:35 +0000749 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
750 defaultBranch='trunk', workdir='clang-tests'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000751 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar7363d032011-02-27 03:22:35 +0000752 name='test-gdb-1472-testsuite',
753 command=["make", "-k", "check"] + make_vars,
754 description="gdb-1472-testsuite",
755 workdir='clang-tests/gdb-1472-testsuite',
David Blaikie7ec695f2012-10-09 22:17:09 +0000756 logfiles={ 'dg.sum' : 'obj/filtered.gdb.sum',
David Blaikie624f4392012-11-05 22:34:35 +0000757 'gdb.log' : 'obj/gdb.log' }))
Daniel Dunbar7363d032011-02-27 03:22:35 +0000758
David Blaikie41d09c32013-01-02 21:11:09 +0000759def addModernClangGDBTests(f, jobs, install_prefix):
David Blaikie1bc5c372012-12-05 05:29:12 +0000760 make_vars = [WithProperties('RUNTESTFLAGS=CC_FOR_TARGET=\'{0}/bin/clang\' '
761 'CXX_FOR_TARGET=\'{0}/bin/clang++\' '
David Blaikie759bb752013-04-18 23:13:11 +0000762 'CFLAGS_FOR_TARGET=\'-w -fno-limit-debug-info\''
David Blaikief89877b2013-01-29 23:46:26 +0000763 .format(install_prefix))]
David Blaikie05517332013-12-19 23:29:12 +0000764 f.addStep(SVN(name='svn-clang-modern-gdb-tests', mode='update',
David Blaikief3f300b2012-11-17 01:13:41 +0000765 svnurl='http://llvm.org/svn/llvm-project/clang-tests-external/trunk/gdb/7.5',
David Blaikiedad03d52012-11-16 22:37:12 +0000766 workdir='clang-tests/src'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000767 f.addStep(Configure(command='../src/configure',
David Blaikief3f300b2012-11-17 01:13:41 +0000768 workdir='clang-tests/build/'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000769 f.addStep(WarningCountingShellCommand(name='gdb-75-build',
770 command=['make', WithProperties('-j%s' % jobs)],
771 haltOnFailure=True,
772 workdir='clang-tests/build'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000773 f.addStep(commands.DejaGNUCommand.DejaGNUCommand(
David Blaikiedad03d52012-11-16 22:37:12 +0000774 name='gdb-75-check',
David Blaikieb83bfdf2012-12-05 04:33:42 +0000775 command=['make', '-k', WithProperties('-j%s' % jobs), 'check'] + make_vars,
David Blaikiedad03d52012-11-16 22:37:12 +0000776 workdir='clang-tests/build',
David Blaikie1bc5c372012-12-05 05:29:12 +0000777 logfiles={'dg.sum':'gdb/testsuite/gdb.sum',
778 'gdb.log':'gdb/testsuite/gdb.log'}))
David Blaikiedad03d52012-11-16 22:37:12 +0000779
780
781
Daniel Dunbar7363d032011-02-27 03:22:35 +0000782# FIXME: Deprecated.
783addClangTests = addClangGCCTests
784
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000785def getClangTestsIgnoresFromPath(path, key):
786 def readList(path):
787 if not os.path.exists(path):
788 return []
789
790 f = open(path)
791 lines = [ln.strip() for ln in f]
792 f.close()
793 return lines
794
795 ignores = {}
796
797 gcc_dg_ignores = {}
798 for lang in ('gcc', 'g++', 'objc', 'obj-c++'):
799 lang_path = os.path.join(path, 'gcc-4_2-testsuite', 'expected_results',
800 key, lang)
801 gcc_dg_ignores[lang] = (
802 readList(os.path.join(lang_path, 'FAIL.txt')) +
803 readList(os.path.join(lang_path, 'UNRESOLVED.txt')) +
804 readList(os.path.join(lang_path, 'XPASS.txt')))
805 ignores['gcc-4_2-testsuite' ] = gcc_dg_ignores
806
Daniel Dunbar7363d032011-02-27 03:22:35 +0000807 ignores_path = os.path.join(path, 'gdb-1472-testsuite', 'expected_results',
808 key)
809 gdb_dg_ignores = (
810 readList(os.path.join(ignores_path, 'FAIL.txt')) +
811 readList(os.path.join(ignores_path, 'UNRESOLVED.txt')) +
812 readList(os.path.join(ignores_path, 'XPASS.txt')))
813 ignores['gdb-1472-testsuite' ] = gdb_dg_ignores
814
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000815 return ignores
David Deanf8b35442012-12-11 00:35:12 +0000816
Michael Gottesmandc771a02013-08-30 05:46:22 +0000817from zorg.buildbot.util.phasedbuilderutils import getBuildDir, setProperty
Michael Gottesman94e9ee42013-04-04 06:52:04 +0000818from zorg.buildbot.builders.Util import _did_last_build_fail
David Deanf8b35442012-12-11 00:35:12 +0000819from buildbot.steps.source.svn import SVN as HostSVN
820
Michael Gottesman94e9ee42013-04-04 06:52:04 +0000821def phasedClang(config_options, is_bootstrap=True, use_lto=False,
Justin Bogner9605b3f2014-05-30 23:25:46 +0000822 incremental=False):
David Deanf8b35442012-12-11 00:35:12 +0000823 # Create an instance of the Builder.
824 f = buildbot.process.factory.BuildFactory()
825 # Determine the build directory.
826 f = getBuildDir(f)
827 # get rid of old archives from prior builds
828 f.addStep(buildbot.steps.shell.ShellCommand(
Chris Matthews92ce8e22014-01-03 21:28:27 +0000829 name='rm.archives', command=['sh', '-c', 'sudo rm -rfv *gz'],
David Deanf8b35442012-12-11 00:35:12 +0000830 haltOnFailure=False, description=['rm archives'],
831 workdir=WithProperties('%(builddir)s')))
832 # Clean the build directory.
833 clang_build_dir = 'clang-build'
Michael Gottesman94e9ee42013-04-04 06:52:04 +0000834 if incremental:
835 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmand0ef7762013-10-01 20:50:35 +0000836 name='rm.clang-build', command=['sudo', 'rm', '-rfv',
837 clang_build_dir],
Michael Gottesman94e9ee42013-04-04 06:52:04 +0000838 haltOnFailure=False, description=['rm dir', clang_build_dir],
839 workdir=WithProperties('%(builddir)s'),
840 doStepIf=_did_last_build_fail))
841 else:
842 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmand0ef7762013-10-01 20:50:35 +0000843 name='rm.clang-build', command=['sudo', 'rm', '-rfv',
844 clang_build_dir],
Michael Gottesman94e9ee42013-04-04 06:52:04 +0000845 haltOnFailure=False, description=['rm dir', clang_build_dir],
846 workdir=WithProperties('%(builddir)s')))
847
David Deanf8b35442012-12-11 00:35:12 +0000848 # Cleanup the clang link, which buildbot's SVN always_purge does not know
849 # (in 8.5 this changed to method='fresh')
850 # how to remove correctly. If we don't do this, the LLVM update steps will
851 # end up doing a clobber every time.
852 #
853 # FIXME: Should file a Trac for this, but I am lazy.
854 f.addStep(buildbot.steps.shell.ShellCommand(
855 name='rm.clang-sources-link',
Chris Matthews92ce8e22014-01-03 21:28:27 +0000856 command=['sudo', 'rm', '-rfv', 'llvm/tools/clang'],
David Deanf8b35442012-12-11 00:35:12 +0000857 haltOnFailure=False, description=['rm', 'clang sources link'],
858 workdir=WithProperties('%(builddir)s')))
859 f.addStep(buildbot.steps.shell.ShellCommand(
860 name='rm.compiler-rt-sources-link',
Chris Matthews92ce8e22014-01-03 21:28:27 +0000861 command=['sudo', 'rm', '-rfv', 'llvm/projects/compiler-rt'],
David Deanf8b35442012-12-11 00:35:12 +0000862 haltOnFailure=False, description=['rm', 'compiler-rt sources link'],
863 workdir=WithProperties('%(builddir)s')))
Michael Gottesman2db83142013-08-05 21:44:45 +0000864 # TODO: We used to use a symlink here but it seems to not work. I am trying
865 # to get this builder to work so I am just going to copy it instead.
866 f.addStep(buildbot.steps.shell.ShellCommand(
867 name='rm.clang-tools-extra-source',
Chris Matthews92ce8e22014-01-03 21:28:27 +0000868 command=['sudo', 'rm', '-rfv', 'clang.src/tools/extra'],
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +0000869 haltOnFailure=True, workdir=WithProperties('%(builddir)s'),
Michael Gottesman2db83142013-08-05 21:44:45 +0000870 description=['rm', 'clang-tools-extra sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +0000871 f.addStep(buildbot.steps.shell.ShellCommand(
872 name='rm.debuginfo-tests',
Chris Matthews92ce8e22014-01-03 21:28:27 +0000873 command=['sudo', 'rm', '-rfv', 'clang.src/test/debuginfo-tests'],
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +0000874 haltOnFailure=True, workdir=WithProperties('%(builddir)s'),
Michael Gottesmane92eb122013-09-08 01:58:27 +0000875 description=['rm', 'debuginfo-tests sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +0000876
David Deanf8b35442012-12-11 00:35:12 +0000877 # Pull sources.
Michael Gottesmandc771a02013-08-30 05:46:22 +0000878 f = phasedbuilderutils.SVNCleanupStep(f, 'llvm')
David Deanf8b35442012-12-11 00:35:12 +0000879 f.addStep(HostSVN(name='pull.llvm', mode='incremental', method='fresh',
880 repourl='http://llvm.org/svn/llvm-project/llvm/trunk',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000881 retry=(60, 5), workdir='llvm', description='pull.llvm',
882 alwaysUseLatest=False))
Michael Gottesmandc771a02013-08-30 05:46:22 +0000883 f = phasedbuilderutils.SVNCleanupStep(f, 'clang.src')
David Deanf8b35442012-12-11 00:35:12 +0000884 f.addStep(HostSVN(name='pull.clang', mode='incremental', method='fresh',
885 repourl='http://llvm.org/svn/llvm-project/cfe/trunk',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000886 workdir='clang.src', retry=(60, 5),
David Deanf8b35442012-12-11 00:35:12 +0000887 description='pull.clang', alwaysUseLatest=False))
Michael Gottesmandc771a02013-08-30 05:46:22 +0000888 f = phasedbuilderutils.SVNCleanupStep(f, 'clang-tools-extra.src')
Michael Gottesman1dcf8f82013-03-28 06:20:57 +0000889 f.addStep(HostSVN(name='pull.clang-tools-extra', mode='incremental',
890 method='fresh',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000891 repourl='http://llvm.org/svn/llvm-project/'
892 'clang-tools-extra/trunk',
Michael Gottesman1dcf8f82013-03-28 06:20:57 +0000893 workdir='clang-tools-extra.src', alwaysUseLatest=False,
894 retry=(60, 5), description='pull.clang-tools-extra'))
Michael Gottesmandc771a02013-08-30 05:46:22 +0000895 f = phasedbuilderutils.SVNCleanupStep(f, 'compiler-rt.src')
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000896 f.addStep(HostSVN(name='pull.compiler-rt', mode='incremental',
897 method='fresh',
898 repourl='http://llvm.org/svn/llvm-project/compiler-rt/'
899 'trunk',
900 workdir='compiler-rt.src', alwaysUseLatest=False,
901 retry=(60, 5), description='pull.compiler-rt'))
Michael Gottesman13f82592013-09-08 01:54:43 +0000902 f = phasedbuilderutils.SVNCleanupStep(f, 'libcxx.src')
903 f.addStep(HostSVN(name='pull.libcxx', mode='incremental',
904 method='fresh',
905 repourl='http://llvm.org/svn/llvm-project/libcxx/'
906 'trunk',
907 workdir='libcxx.src', alwaysUseLatest=False,
908 retry=(60, 5), description='pull.libcxx'))
Michael Gottesmane92eb122013-09-08 01:58:27 +0000909 f = phasedbuilderutils.SVNCleanupStep(f, 'debuginfo-tests.src')
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +0000910 f.addStep(HostSVN(name='pull.debuginfo-tests', mode='incremental',
911 method='fresh',
912 repourl='http://llvm.org/svn/llvm-project/debuginfo-tests/'
913 'trunk',
914 workdir='debuginfo-tests.src', alwaysUseLatest=False,
915 retry=(60, 5), description='pull.debuginfo-tests'))
916
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000917 # Create symlinks to the clang compiler-rt sources inside the LLVM tree.
David Deanf8b35442012-12-11 00:35:12 +0000918 # We don't actually check out the sources there, because the SVN purge
919 # would always remove them then.
920 f.addStep(buildbot.steps.shell.ShellCommand(
921 name='ln.clang-sources', haltOnFailure=True,
922 command=['ln', '-sfv', '../../clang.src', 'clang'],
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000923 workdir='llvm/tools', description=['ln', 'clang sources']))
David Deanf8b35442012-12-11 00:35:12 +0000924 f.addStep(buildbot.steps.shell.ShellCommand(
925 name='ln.compiler-rt-sources',
926 command=['ln', '-sfv', '../../compiler-rt.src', 'compiler-rt'],
927 haltOnFailure=True, workdir='llvm/projects',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000928 description=['ln', 'compiler-rt sources']))
Michael Gottesman4a68b872013-03-28 19:03:52 +0000929 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesman13f82592013-09-08 01:54:43 +0000930 name='ln.libcxx.sources',
931 command=['ln', '-sfv', '../../libcxx.src', 'libcxx'],
932 haltOnFailure=True, workdir='llvm/projects',
933 description=['ln', 'libcxx sources']))
934 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmanbcab1992013-03-28 18:37:21 +0000935 name='cp.clang-tools-extra-sources',
Michael Gottesman03495922013-03-28 18:40:44 +0000936 command=['cp', '-Rfv', '../../clang-tools-extra.src', 'extra'],
Michael Gottesman1dcf8f82013-03-28 06:20:57 +0000937 haltOnFailure=True, workdir='clang.src/tools',
Chris Matthewsecc0f442014-03-12 00:04:23 +0000938 description=['cp', 'clang-tools-extra sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +0000939 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmane92eb122013-09-08 01:58:27 +0000940 name='cp.debuginfo-tests.sources',
941 command=['cp', '-Rfv', 'debuginfo-tests.src',
942 'clang.src/test/debuginfo-tests'],
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +0000943 haltOnFailure=True, workdir=WithProperties('%(builddir)s'),
Michael Gottesmane92eb122013-09-08 01:58:27 +0000944 description=['cp', 'debuginfo-tests sources']))
Michael Gottesman6ba2d2a2013-09-08 01:54:45 +0000945
David Deanf8b35442012-12-11 00:35:12 +0000946 # Clean the install directory.
947 f.addStep(buildbot.steps.shell.ShellCommand(
Chris Matthews92ce8e22014-01-03 21:28:27 +0000948 name='rm.clang-install', command=['sudo', 'rm', '-rfv', 'clang-install'],
David Deanf8b35442012-12-11 00:35:12 +0000949 haltOnFailure=False, description=['rm dir', 'clang-install'],
950 workdir=WithProperties('%(builddir)s')))
951 # Construct the configure arguments.
952 configure_args = ['../llvm/configure']
953 configure_args.extend(config_options)
Galina Kistanova702eccb2013-08-22 00:09:17 +0000954 configure_args.extend(['--disable-bindings',
Michael Gottesman6f85f932014-06-27 23:49:58 +0000955 '--enable-keep-symbols',
Michael Gottesman0fd485a2014-08-02 01:42:51 +0000956 '--enable-targets=x86,x86_64,arm,aarch64'])
David Deanf8b35442012-12-11 00:35:12 +0000957 configure_args.append(
Michael Gottesman65d940f2013-03-13 21:51:16 +0000958 WithProperties('--prefix=%(builddir)s/clang-install'))
Michael Gottesmanca56e8f2013-03-06 22:27:38 +0000959
David Deanf8b35442012-12-11 00:35:12 +0000960 # If we are using a previously built compiler, download it and override CC
961 # and CXX.
962 if is_bootstrap:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000963 f = artifacts.GetCompilerArtifacts(f)
David Deanf8b35442012-12-11 00:35:12 +0000964 else:
Michael Gottesmandc771a02013-08-30 05:46:22 +0000965 f = phasedbuilderutils.GetLatestValidated(f)
David Deanf8b35442012-12-11 00:35:12 +0000966 cc_command = ['find', 'host-compiler', '-name', 'clang']
967 f.addStep(buildbot.steps.shell.SetProperty(
968 name='find.cc',
969 command=cc_command,
Michael Gottesmandc771a02013-08-30 05:46:22 +0000970 extract_fn=phasedbuilderutils.find_cc,
David Deanf8b35442012-12-11 00:35:12 +0000971 workdir=WithProperties('%(builddir)s')))
972 f.addStep(buildbot.steps.shell.ShellCommand(
973 name='sanity.test', haltOnFailure=True,
974 command=[WithProperties('%(builddir)s/%(cc_path)s'), '-v'],
975 description=['sanity test']))
976 configure_args.extend([
977 WithProperties('CC=%(builddir)s/%(cc_path)s'),
978 WithProperties('CXX=%(builddir)s/%(cc_path)s++')])
Michael Gottesman65d940f2013-03-13 21:51:16 +0000979
980 # If we need to use lto, find liblto, add in proper flags here, etc.
981 if use_lto:
Michael Gottesman01f0a622013-03-13 22:38:38 +0000982 liblto_command = ['find', WithProperties('%(builddir)s/host-compiler'),
983 '-name', 'libLTO.dylib']
Michael Gottesman1da57ae2013-03-13 21:54:23 +0000984 f.addStep(buildbot.steps.shell.SetProperty(
Michael Gottesman65d940f2013-03-13 21:51:16 +0000985 name='find.liblto',
986 command=liblto_command,
Michael Gottesmandc771a02013-08-30 05:46:22 +0000987 extract_fn=phasedbuilderutils.find_liblto,
Michael Gottesman65d940f2013-03-13 21:51:16 +0000988 workdir=WithProperties('%(builddir)s')))
989 configure_args.append(
990 '--with-extra-options=-flto -gline-tables-only')
991
David Deanf8b35442012-12-11 00:35:12 +0000992 # Configure the LLVM build.
Michael Gottesmand97d8502013-04-04 07:57:31 +0000993 if incremental:
994 # *NOTE* This is a temporary work around. I am eventually going to just
995 # set up cmake/ninja but for now I am sticking with the make => I need
996 # configure to run only after a failure so on success I have incremental
997 # builds.
998 f.addStep(buildbot.steps.shell.ShellCommand(
999 name='configure.with.host', command=configure_args,
1000 haltOnFailure=True, description=['configure'],
1001 workdir=clang_build_dir,
1002 doStepIf=_did_last_build_fail))
1003 else:
1004 f.addStep(buildbot.steps.shell.ShellCommand(
1005 name='configure.with.host', command=configure_args,
1006 haltOnFailure=True, description=['configure'],
1007 workdir=clang_build_dir))
1008
David Deanf8b35442012-12-11 00:35:12 +00001009 # Build the compiler.
Michael Gottesman36778832013-09-08 01:37:35 +00001010 make_command = ['make', '-j', WithProperties('%(jobs)s'), 'VERBOSE=1']
Galina Kistanovabfb29d22013-05-09 23:53:24 +00001011 timeout = 40*60 # Normal timeout is 20 minutes.
Michael Gottesman65d940f2013-03-13 21:51:16 +00001012 if use_lto:
1013 make_command.append(WithProperties('DYLD_LIBRARY_PATH=%(liblto_path)s'))
Michael Gottesman2e7385c2013-08-12 17:57:27 +00001014 timeout = 240*60 # LTO timeout is 240 minutes.
Michael Gottesman65d940f2013-03-13 21:51:16 +00001015
David Deanf8b35442012-12-11 00:35:12 +00001016 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesman65d940f2013-03-13 21:51:16 +00001017 name='make', command=make_command,
Michael Gottesmanbab77ac2013-03-14 05:36:53 +00001018 haltOnFailure=True, description=['make'], workdir=clang_build_dir,
1019 timeout=timeout))
David Deanf8b35442012-12-11 00:35:12 +00001020 # Use make install-clang to produce minimal archive for use by downstream
1021 # builders.
1022 f.addStep(buildbot.steps.shell.ShellCommand(
1023 name='make.install-clang', haltOnFailure=True,
Michael Gottesmanf8748fb2013-03-28 06:21:03 +00001024 command=['make', 'install-clang', '-j',
1025 WithProperties('%(jobs)s'),
1026 'RC_SUPPORTED_ARCHS=armv7 i386 x86_64'],
David Deanf8b35442012-12-11 00:35:12 +00001027 description=['make install'], workdir=clang_build_dir))
1028 # Save artifacts of this build for use by other builders.
Michael Gottesmana6b5be82013-06-28 21:57:20 +00001029 f = artifacts.uploadArtifacts(f)
David Deanf8b35442012-12-11 00:35:12 +00001030 # Run the LLVM and Clang regression tests.
Michael Gottesmana9c32be2013-09-06 17:47:24 +00001031 cmd_str = r"""make VERBOSE=1 LIT_ARGS="-v --param run_long_tests=true --filter='^(?!.*debuginfo-tests)'" check-all"""
1032 f.addStep(lit_test_command.LitTestCommand(name='run.llvm.tests', haltOnFailure=True,
1033 command=cmd_str,
1034 description=['all', 'tests'],
1035 workdir=clang_build_dir))
1036 # Work around for lldb issue rdar://14929651
Chris Matthewsecc0f442014-03-12 00:04:23 +00001037 # The crazy filter regex is to remove static-member[2].cpp, which requires xcode5 or later.
1038 # radar://16295455 tracks the removal of this regex.
1039 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 +00001040 f.addStep(lit_test_command.LitTestCommand(name='run.llvm.debuginfo-tests', haltOnFailure=True,
Michael Gottesmane7dc31e2013-08-30 05:57:35 +00001041 command=cmd_str,
Michael Gottesmana6b5be82013-06-28 21:57:20 +00001042 description=['all', 'tests'],
1043 workdir=clang_build_dir))
David Deanf8b35442012-12-11 00:35:12 +00001044 return f