blob: bb60f252e1eab6ca28d725896aadd12ed3db96ae [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
13import zorg.buildbot.PhasedBuilderUtils as phased_builder_utils
14import 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,
David Blaikie41d09c32013-01-02 21:11:09 +000043 run_gcc=False):
Galina Kistanovaf4d79352011-10-20 20:46:52 +000044 # Prepare environmental variables. Set here all env we want everywhere.
45 merged_env = {
46 'TERM' : 'dumb' # Make sure Clang doesn't use color escape sequences.
47 }
48 if env is not None:
49 # Overwrite pre-set items with the given ones, so user can set anything.
50 merged_env.update(env)
David Blaikie2f7eb282012-08-24 18:37:00 +000051
David Blaikiedad03d52012-11-16 22:37:12 +000052 if run_gdb or run_gcc or run_modern_gdb:
David Blaikie88511c72012-08-24 23:14:06 +000053 outOfDir = True
Galina Kistanovaf4d79352011-10-20 20:46:52 +000054
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000055 # Don't use in-dir builds with a two stage build process.
Daniel Dunbar3efb7822010-02-26 19:20:00 +000056 inDir = not outOfDir and not useTwoStage
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000057 if inDir:
58 llvm_srcdir = "llvm"
59 llvm_1_objdir = "llvm"
David Blaikie88511c72012-08-24 23:14:06 +000060 llvm_1_installdir = None
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000061 else:
62 llvm_srcdir = "llvm.src"
63 llvm_1_objdir = "llvm.obj"
64 llvm_1_installdir = "llvm.install.1"
65 llvm_2_objdir = "llvm.obj.2"
Daniel Dunbar22d594a2010-07-31 05:29:16 +000066 llvm_2_installdir = "llvm.install"
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000067
Daniel Dunbar235aa412009-07-18 07:16:15 +000068 f = buildbot.process.factory.BuildFactory()
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000069
70 # Determine the build directory.
71 f.addStep(buildbot.steps.shell.SetProperty(name="get_builddir",
72 command=["pwd"],
73 property="builddir",
74 description="set build dir",
Galina Kistanovaf4d79352011-10-20 20:46:52 +000075 workdir=".",
76 env=merged_env))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000077
Daniel Dunbar06b20f12010-04-08 18:29:38 +000078 # Blow away completely, if requested.
79 if completely_clean:
80 f.addStep(ShellCommand(name="rm-llvm.src",
81 command=["rm", "-rf", llvm_srcdir],
82 haltOnFailure=True,
83 description=["rm src dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +000084 workdir=".",
85 env=merged_env))
Daniel Dunbar06b20f12010-04-08 18:29:38 +000086
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000087 # Checkout sources.
Peter Collingbourned49ac282011-10-25 14:38:45 +000088 if trunk_revision:
89 # The SVN build step provides no mechanism to check out a specific revision
90 # based on a property, so just run the commands directly here.
91 svn_co = ['svn', 'checkout']
92 if force_checkout:
93 svn_co += ['--force']
94 svn_co += ['--revision', WithProperties(trunk_revision)]
95
96 svn_co_llvm = svn_co + \
97 [WithProperties('http://llvm.org/svn/llvm-project/llvm/trunk@%s' %
98 trunk_revision),
99 llvm_srcdir]
100 svn_co_clang = svn_co + \
101 [WithProperties('http://llvm.org/svn/llvm-project/cfe/trunk@%s' %
102 trunk_revision),
103 '%s/tools/clang' % llvm_srcdir]
David Blaikie845ae0d2012-08-10 00:51:38 +0000104 svn_co_clang_tools_extra = svn_co + \
105 [WithProperties('http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@%s' %
106 trunk_revision),
107 '%s/tools/clang/tools/extra' % llvm_srcdir]
Peter Collingbourned49ac282011-10-25 14:38:45 +0000108
109 f.addStep(ShellCommand(name='svn-llvm',
110 command=svn_co_llvm,
111 haltOnFailure=True,
112 workdir='.'))
113 f.addStep(ShellCommand(name='svn-clang',
114 command=svn_co_clang,
115 haltOnFailure=True,
116 workdir='.'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000117 f.addStep(ShellCommand(name='svn-clang-tools-extra',
118 command=svn_co_clang_tools_extra,
119 haltOnFailure=True,
120 workdir='.'))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000121 else:
122 f.addStep(SVN(name='svn-llvm',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000123 mode='update',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000124 baseURL='http://llvm.org/svn/llvm-project/llvm/',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000125 defaultBranch='trunk',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000126 workdir=llvm_srcdir))
127 f.addStep(SVN(name='svn-clang',
128 mode='update',
129 baseURL='http://llvm.org/svn/llvm-project/cfe/',
130 defaultBranch='trunk',
131 workdir='%s/tools/clang' % llvm_srcdir))
David Blaikie845ae0d2012-08-10 00:51:38 +0000132 f.addStep(SVN(name='svn-clang-tools-extra',
133 mode='update',
134 baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
135 defaultBranch='trunk',
136 workdir='%s/tools/clang/tools/extra' % llvm_srcdir))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000137 if checkout_compiler_rt:
138 f.addStep(SVN(name='svn-compiler-rt',
139 mode='update',
140 baseURL='http://llvm.org/svn/llvm-project/compiler-rt/',
141 defaultBranch='trunk',
142 workdir='%s/projects/compiler-rt' % llvm_srcdir))
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000143
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000144 # Clean up llvm (stage 1); unless in-dir.
145 if clean and llvm_srcdir != llvm_1_objdir:
146 f.addStep(ShellCommand(name="rm-llvm.obj.stage1",
147 command=["rm", "-rf", llvm_1_objdir],
148 haltOnFailure=True,
149 description=["rm build dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000150 workdir=".",
151 env=merged_env))
Andrew Trick70fa9d22011-08-25 23:38:51 +0000152
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000153 # Force without llvm-gcc so we don't run afoul of Frontend test failures.
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000154 base_configure_args = [WithProperties("%%(builddir)s/%s/configure" % llvm_srcdir),
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000155 '--disable-bindings']
156 base_configure_args += extra_configure_args
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000157 if triple:
Andrew Trick70fa9d22011-08-25 23:38:51 +0000158 base_configure_args += ['--build=%s' % triple,
David Dean7da22862012-10-01 19:57:30 +0000159 '--host=%s' % triple]
Galina Kistanova702eccb2013-08-22 00:09:17 +0000160 args = base_configure_args + [WithProperties("--prefix=%%(builddir)s/%s" % llvm_1_installdir)]
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000161 args += builders_util.getConfigArgs(stage1_config)
David Blaikie8cbf62f2013-01-12 21:32:31 +0000162 if not clean:
163 f.addStep(SetProperty(name="Makefile_isready",
164 workdir=llvm_1_objdir,
165 command=["sh", "-c",
Galina Kistanovaf7275a42013-03-22 21:42:55 +0000166 "test -e Makefile.config && echo OK || echo Missing"],
David Blaikie8cbf62f2013-01-12 21:32:31 +0000167 flunkOnFailure=False,
168 property="exists_Makefile"))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000169 f.addStep(Configure(command=args,
170 workdir=llvm_1_objdir,
171 description=['configuring',stage1_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000172 descriptionDone=['configure',stage1_config],
David Blaikie8cbf62f2013-01-12 21:32:31 +0000173 env=merged_env,
174 doStepIf=lambda step: step.build.getProperty("exists_Makefile") != "OK"))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000175
176 # Make clean if using in-dir builds.
177 if clean and llvm_srcdir == llvm_1_objdir:
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000178 f.addStep(WarningCountingShellCommand(name="clean-llvm",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000179 command=[make, "clean"],
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000180 haltOnFailure=True,
181 description="cleaning llvm",
182 descriptionDone="clean llvm",
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000183 workdir=llvm_1_objdir,
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000184 doStepIf=clean,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000185 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000186
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000187 if extra_clean_step:
188 f.addStep(extra_clean_step)
189
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000190 f.addStep(WarningCountingShellCommand(name="compile",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000191 command=['nice', '-n', '10',
192 make, WithProperties("-j%s" % jobs)],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000193 haltOnFailure=True,
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000194 description=["compiling", stage1_config],
195 descriptionDone=["compile", stage1_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000196 workdir=llvm_1_objdir,
197 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000198
199 if examples:
200 f.addStep(WarningCountingShellCommand(name="compile.examples",
201 command=['nice', '-n', '10',
202 make, WithProperties("-j%s" % jobs),
203 "BUILD_EXAMPLES=1"],
204 haltOnFailure=True,
205 description=["compilinge", stage1_config, "examples"],
206 descriptionDone=["compile", stage1_config, "examples"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000207 workdir=llvm_1_objdir,
208 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000209
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000210 clangTestArgs = '-v -j %s' % jobs
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000211 if valgrind:
Daniel Dunbar89184b92010-04-18 19:09:32 +0000212 clangTestArgs += ' --vg'
Daniel Dunbara1bebce2010-03-21 01:24:00 +0000213 if valgrindLeakCheck:
214 clangTestArgs += ' --vg-leak'
Nick Lewycky8d26e472011-08-27 21:18:56 +0000215 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 +0000216 extraTestDirs = ''
217 if run_cxx_tests:
218 extraTestDirs += '%(builddir)s/llvm/tools/clang/utils/C++Tests'
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000219 if test:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000220 f.addStep(lit_test_command.LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000221 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000222 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000223 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie7e6f8a12012-08-31 20:46:27 +0000224 description=["checking"],
225 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000226 workdir=llvm_1_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000227 usePTY=use_pty_in_tests,
228 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000229
230 # Install llvm and clang.
231 if llvm_1_installdir:
Daniel Dunbar9870de32010-03-28 22:25:31 +0000232 f.addStep(ShellCommand(name="rm-install.clang.stage1",
233 command=["rm", "-rf", llvm_1_installdir],
234 haltOnFailure=True,
235 description=["rm install dir", "clang"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000236 workdir=".",
237 env=merged_env))
Daniel Dunbar9870de32010-03-28 22:25:31 +0000238 f.addStep(WarningCountingShellCommand(name="install.clang.stage1",
239 command = ['nice', '-n', '10',
240 make, 'install-clang'],
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000241 haltOnFailure=True,
Daniel Dunbar9870de32010-03-28 22:25:31 +0000242 description=["install", "clang",
243 stage1_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000244 workdir=llvm_1_objdir,
245 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000246
David Blaikiedad03d52012-11-16 22:37:12 +0000247 if run_gdb or run_gcc or run_modern_gdb:
David Blaikiea76da842012-08-13 22:24:46 +0000248 ignores = getClangTestsIgnoresFromPath(os.path.expanduser('~/public/clang-tests'), 'clang-x86_64-darwin10')
249 install_prefix = "%%(builddir)s/%s" % llvm_1_installdir
250 if run_gdb:
251 addClangGDBTests(f, ignores, install_prefix)
David Blaikiedad03d52012-11-16 22:37:12 +0000252 if run_modern_gdb:
David Blaikie41d09c32013-01-02 21:11:09 +0000253 addModernClangGDBTests(f, jobs, install_prefix)
David Blaikiea76da842012-08-13 22:24:46 +0000254 if run_gcc:
255 addClangGCCTests(f, ignores, install_prefix)
256
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000257 if not useTwoStage:
Daniel Dunbardedf6572010-11-13 00:23:34 +0000258 if package_dst:
259 name = WithProperties(
260 "%(builddir)s/" + llvm_1_objdir +
261 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
262 f.addStep(ShellCommand(name='pkg.tar',
263 description="tar root",
264 command=["tar", "zcvf", name, "./"],
265 workdir=llvm_1_installdir,
266 warnOnFailure=True,
267 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000268 haltOnFailure=False,
269 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000270 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000271 description="upload root",
Daniel Dunbardedf6572010-11-13 00:23:34 +0000272 command=["scp", name,
273 WithProperties(
274 package_dst + "/%(buildername)s")],
275 workdir=".",
276 warnOnFailure=True,
277 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000278 haltOnFailure=False,
279 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000280
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000281 return f
282
283 # Clean up llvm (stage 2).
284 if clean:
285 f.addStep(ShellCommand(name="rm-llvm.obj.stage2",
286 command=["rm", "-rf", llvm_2_objdir],
287 haltOnFailure=True,
288 description=["rm build dir", "llvm", "(stage 2)"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000289 workdir=".",
290 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000291
292 # Configure llvm (stage 2).
Galina Kistanova702eccb2013-08-22 00:09:17 +0000293 args = base_configure_args + [WithProperties("--prefix=%(builddir)s/" + llvm_2_installdir)]
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000294 args += builders_util.getConfigArgs(stage2_config)
Benjamin Kramer9c6fed72012-07-20 10:18:32 +0000295 local_env = dict(merged_env)
296 local_env.update({
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000297 'CC' : WithProperties("%%(builddir)s/%s/bin/clang" % llvm_1_installdir),
298 'CXX' : WithProperties("%%(builddir)s/%s/bin/clang++" % llvm_1_installdir)})
299
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000300 f.addStep(Configure(name="configure.llvm.stage2",
301 command=args,
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000302 haltOnFailure=True,
303 workdir=llvm_2_objdir,
304 description=["configure", "llvm", "(stage 2)",
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000305 stage2_config],
306 env=local_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000307
308 # Build llvm (stage 2).
309 f.addStep(WarningCountingShellCommand(name="compile.llvm.stage2",
310 command=['nice', '-n', '10',
311 make, WithProperties("-j%s" % jobs)],
312 haltOnFailure=True,
313 description=["compiling", "(stage 2)",
314 stage2_config],
315 descriptionDone=["compile", "(stage 2)",
316 stage2_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000317 workdir=llvm_2_objdir,
318 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000319
320 if test:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000321 f.addStep(lit_test_command.LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000322 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000323 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000324 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie7e6f8a12012-08-31 20:46:27 +0000325 description=["checking"],
326 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000327 workdir=llvm_2_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000328 usePTY=use_pty_in_tests,
329 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000330
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000331 # Install clang (stage 2).
Daniel Dunbar9870de32010-03-28 22:25:31 +0000332 f.addStep(ShellCommand(name="rm-install.clang.stage2",
333 command=["rm", "-rf", llvm_2_installdir],
334 haltOnFailure=True,
335 description=["rm install dir", "clang"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000336 workdir=".",
337 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000338 f.addStep(WarningCountingShellCommand(name="install.clang.stage2",
339 command = ['nice', '-n', '10',
340 make, 'install-clang'],
341 haltOnFailure=True,
342 description=["install", "clang",
343 "(stage 2)"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000344 workdir=llvm_2_objdir,
345 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000346
347 if package_dst:
348 name = WithProperties(
349 "%(builddir)s/" + llvm_2_objdir +
350 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
351 f.addStep(ShellCommand(name='pkg.tar',
352 description="tar root",
353 command=["tar", "zcvf", name, "./"],
354 workdir=llvm_2_installdir,
355 warnOnFailure=True,
356 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000357 haltOnFailure=False,
358 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000359 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000360 description="upload root",
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000361 command=["scp", name,
362 WithProperties(
363 package_dst + "/%(buildername)s")],
364 workdir=".",
365 warnOnFailure=True,
366 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000367 haltOnFailure=False,
368 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000369
Daniel Dunbar235aa412009-07-18 07:16:15 +0000370 return f
Daniel Dunbar44abe742009-07-19 01:59:03 +0000371
Daniel Dunbarc51a59e2010-09-23 14:57:45 +0000372def getClangMSVCBuildFactory(update=True, clean=True, vcDrive='c', jobs=1, cmake=r"cmake"):
Daniel Dunbar44abe742009-07-19 01:59:03 +0000373 f = buildbot.process.factory.BuildFactory()
374
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000375 if update:
Daniel Dunbar44abe742009-07-19 01:59:03 +0000376 f.addStep(SVN(name='svn-llvm',
377 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
378 defaultBranch='trunk',
379 workdir='llvm'))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000380 f.addStep(SVN(name='svn-clang',
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000381 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
Daniel Dunbar44abe742009-07-19 01:59:03 +0000382 defaultBranch='trunk',
383 workdir='llvm/tools/clang'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000384 f.addStep(SVN(name='svn-clang-tools-extra',
385 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
386 defaultBranch='trunk',
387 workdir='llvm/tools/clang/tools/extra'))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000388
389 # Full & fast clean.
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000390 if clean:
Daniel Dunbar44abe742009-07-19 01:59:03 +0000391 f.addStep(ShellCommand(name='clean-1',
392 command=['del','/s/q','build'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000393 warnOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000394 description='cleaning',
395 descriptionDone='clean',
396 workdir='llvm'))
397 f.addStep(ShellCommand(name='clean-2',
398 command=['rmdir','/s/q','build'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000399 warnOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000400 description='cleaning',
401 descriptionDone='clean',
402 workdir='llvm'))
403
404 # Create the project files.
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000405
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000406 # Use batch files instead of ShellCommand directly, Windows quoting is
407 # borked. FIXME: See buildbot ticket #595 and buildbot ticket #377.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000408 f.addStep(batch_file_download.BatchFileDownload(name='cmakegen',
Daniel Dunbar06b20f12010-04-08 18:29:38 +0000409 command=[cmake,
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000410 "-DLLVM_TARGETS_TO_BUILD:=X86",
Daniel Dunbar1ddedce2010-09-24 19:57:34 +0000411 "-DLLVM_INCLUDE_EXAMPLES:=OFF",
412 "-DLLVM_INCLUDE_TESTS:=OFF",
413 "-DLLVM_TARGETS_TO_BUILD:=X86",
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000414 "-G",
415 "Visual Studio 9 2008",
416 ".."],
417 workdir="llvm\\build"))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000418 f.addStep(ShellCommand(name='cmake',
419 command=['cmakegen.bat'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000420 haltOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000421 description='cmake gen',
422 workdir='llvm\\build'))
423
424 # Build it.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000425 f.addStep(batch_file_download.BatchFileDownload(name='vcbuild',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000426 command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""",
427 "/M%d" % jobs,
428 "LLVM.sln",
429 "Debug|Win32"],
430 workdir="llvm\\build"))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000431 f.addStep(WarningCountingShellCommand(name='vcbuild',
432 command=['vcbuild.bat'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000433 haltOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000434 description='vcbuild',
435 workdir='llvm\\build',
436 warningPattern=" warning C.*:"))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000437
438 # Build clang-test project.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000439 f.addStep(batch_file_download.BatchFileDownload(name='vcbuild_test',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000440 command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""",
441 "clang-test.vcproj",
442 "Debug|Win32"],
443 workdir="llvm\\build\\tools\\clang\\test"))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000444 f.addStep(lit_test_command.LitTestCommand(name='test-clang',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000445 command=["vcbuild_test.bat"],
446 workdir="llvm\\build\\tools\\clang\\test"))
447
Daniel Dunbar44abe742009-07-19 01:59:03 +0000448 return f
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000449
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000450# Builds on Windows using CMake, MinGW(32|64), and no Microsoft tools.
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000451def getClangMinGWBuildFactory(update=True, clean=True, jobs=6, cmake=r"cmake"):
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000452 f = buildbot.process.factory.BuildFactory()
453
454 if update:
455 f.addStep(SVN(name='svn-llvm',
456 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
457 defaultBranch='trunk',
458 workdir='llvm'))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000459 f.addStep(SVN(name='svn-clang',
460 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
461 defaultBranch='trunk',
462 workdir='llvm/tools/clang'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000463 f.addStep(SVN(name='svn-clang-tools-extra',
464 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
465 defaultBranch='trunk',
466 workdir='llvm/tools/clang/tools/extra'))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000467
468 # Full & fast clean.
469 if clean:
470 # note: This command is redundant as the next command removes everything
471 f.addStep(ShellCommand(name='clean-1',
472 command=['del','/s/q','build'],
473 warnOnFailure=True,
474 description='cleaning',
475 descriptionDone='clean',
476 workdir='llvm'))
477 f.addStep(ShellCommand(name='clean-2',
478 command=['rmdir','/s/q','build'],
479 warnOnFailure=True,
480 description='cleaning',
481 descriptionDone='clean',
482 workdir='llvm'))
483
484 # Create the Makefiles.
485
486 # Use batch files instead of ShellCommand directly, Windows quoting is
487 # borked. FIXME: See buildbot ticket #595 and buildbot ticket #377.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000488 f.addStep(batch_file_download.BatchFileDownload(name='cmakegen',
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000489 command=[cmake,
490 "-DLLVM_TARGETS_TO_BUILD:=X86",
491 "-DLLVM_INCLUDE_EXAMPLES:=OFF",
492 "-DLLVM_INCLUDE_TESTS:=OFF",
493 "-DLLVM_TARGETS_TO_BUILD:=X86",
494 "-G",
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000495 "Ninja",
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000496 ".."],
497 workdir="llvm\\build"))
498 f.addStep(ShellCommand(name='cmake',
499 command=['cmakegen.bat'],
500 haltOnFailure=True,
501 description='cmake gen',
502 workdir='llvm\\build'))
503
504 # Build it.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000505 f.addStep(batch_file_download.BatchFileDownload(name='makeall',
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000506 command=["ninja", "-j", "%d" % jobs],
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000507 haltOnFailure=True,
508 workdir='llvm\\build'))
509
510 f.addStep(WarningCountingShellCommand(name='makeall',
511 command=['makeall.bat'],
512 haltOnFailure=True,
513 description='makeall',
514 workdir='llvm\\build'))
515
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000516 # Build global check project (make check) (sources not checked out...).
517 if 0:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000518 f.addStep(batch_file_download.BatchFileDownload(name='makecheck',
Galina Kistanova5e97edf2012-06-19 20:10:21 +0000519 command=["ninja", "check"],
520 workdir='llvm\\build'))
521 f.addStep(WarningCountingShellCommand(name='check',
522 command=['makecheck.bat'],
523 description='make check',
524 workdir='llvm\\build'))
Galina Kistanova049d76c2012-06-09 00:56:05 +0000525
526 # Build clang-test project (make clang-test).
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000527 f.addStep(batch_file_download.BatchFileDownload(name='maketest',
528 command=["ninja", "clang-test"],
529 workdir="llvm\\build"))
530 f.addStep(lit_test_command.LitTestCommand(name='clang-test',
531 command=["maketest.bat"],
532 workdir="llvm\\build"))
Galina Kistanova2a97a3b2012-06-06 20:50:33 +0000533 return f
534
Daniel Dunbar7363d032011-02-27 03:22:35 +0000535def addClangGCCTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install",
536 languages = ('gcc', 'g++', 'objc', 'obj-c++')):
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000537 make_vars = [WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000538 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000539 WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000540 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000541 f.addStep(SVN(name='svn-clang-tests', mode='update',
542 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
543 defaultBranch='trunk', workdir='clang-tests'))
544 gcc_dg_ignores = ignores.get('gcc-4_2-testsuite', {})
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000545 for lang in languages:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000546 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000547 name='test-gcc-4_2-testsuite-%s' % lang,
548 command=["make", "-k", "check-%s" % lang] + make_vars,
549 description="gcc-4_2-testsuite (%s)" % lang,
550 workdir='clang-tests/gcc-4_2-testsuite',
David Dean2bd0c3a2011-10-18 16:36:28 +0000551 logfiles={ 'dg.sum' : 'obj/%s/%s.sum' % (lang, lang),
552 '%s.log' % lang : 'obj/%s/%s.log' % (lang, lang)},
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000553 ignore=gcc_dg_ignores.get(lang, [])))
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000554
Daniel Dunbar7363d032011-02-27 03:22:35 +0000555def addClangGDBTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install"):
556 make_vars = [WithProperties(
557 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
558 WithProperties(
559 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
560 f.addStep(SVN(name='svn-clang-tests', mode='update',
561 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
562 defaultBranch='trunk', workdir='clang-tests'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000563 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar7363d032011-02-27 03:22:35 +0000564 name='test-gdb-1472-testsuite',
565 command=["make", "-k", "check"] + make_vars,
566 description="gdb-1472-testsuite",
567 workdir='clang-tests/gdb-1472-testsuite',
David Blaikie7ec695f2012-10-09 22:17:09 +0000568 logfiles={ 'dg.sum' : 'obj/filtered.gdb.sum',
David Blaikie624f4392012-11-05 22:34:35 +0000569 'gdb.log' : 'obj/gdb.log' }))
Daniel Dunbar7363d032011-02-27 03:22:35 +0000570
David Blaikie41d09c32013-01-02 21:11:09 +0000571def addModernClangGDBTests(f, jobs, install_prefix):
David Blaikie1bc5c372012-12-05 05:29:12 +0000572 make_vars = [WithProperties('RUNTESTFLAGS=CC_FOR_TARGET=\'{0}/bin/clang\' '
573 'CXX_FOR_TARGET=\'{0}/bin/clang++\' '
David Blaikie759bb752013-04-18 23:13:11 +0000574 'CFLAGS_FOR_TARGET=\'-w -fno-limit-debug-info\''
David Blaikief89877b2013-01-29 23:46:26 +0000575 .format(install_prefix))]
David Blaikiedad03d52012-11-16 22:37:12 +0000576 f.addStep(SVN(name='svn-clang-tests', mode='update',
David Blaikief3f300b2012-11-17 01:13:41 +0000577 svnurl='http://llvm.org/svn/llvm-project/clang-tests-external/trunk/gdb/7.5',
David Blaikiedad03d52012-11-16 22:37:12 +0000578 workdir='clang-tests/src'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000579 f.addStep(Configure(command='../src/configure',
David Blaikief3f300b2012-11-17 01:13:41 +0000580 workdir='clang-tests/build/'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000581 f.addStep(WarningCountingShellCommand(name='gdb-75-build',
582 command=['make', WithProperties('-j%s' % jobs)],
583 haltOnFailure=True,
584 workdir='clang-tests/build'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000585 f.addStep(commands.DejaGNUCommand.DejaGNUCommand(
David Blaikiedad03d52012-11-16 22:37:12 +0000586 name='gdb-75-check',
David Blaikieb83bfdf2012-12-05 04:33:42 +0000587 command=['make', '-k', WithProperties('-j%s' % jobs), 'check'] + make_vars,
David Blaikiedad03d52012-11-16 22:37:12 +0000588 workdir='clang-tests/build',
David Blaikie1bc5c372012-12-05 05:29:12 +0000589 logfiles={'dg.sum':'gdb/testsuite/gdb.sum',
590 'gdb.log':'gdb/testsuite/gdb.log'}))
David Blaikiedad03d52012-11-16 22:37:12 +0000591
592
593
Daniel Dunbar7363d032011-02-27 03:22:35 +0000594# FIXME: Deprecated.
595addClangTests = addClangGCCTests
596
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000597def getClangTestsIgnoresFromPath(path, key):
598 def readList(path):
599 if not os.path.exists(path):
600 return []
601
602 f = open(path)
603 lines = [ln.strip() for ln in f]
604 f.close()
605 return lines
606
607 ignores = {}
608
609 gcc_dg_ignores = {}
610 for lang in ('gcc', 'g++', 'objc', 'obj-c++'):
611 lang_path = os.path.join(path, 'gcc-4_2-testsuite', 'expected_results',
612 key, lang)
613 gcc_dg_ignores[lang] = (
614 readList(os.path.join(lang_path, 'FAIL.txt')) +
615 readList(os.path.join(lang_path, 'UNRESOLVED.txt')) +
616 readList(os.path.join(lang_path, 'XPASS.txt')))
617 ignores['gcc-4_2-testsuite' ] = gcc_dg_ignores
618
Daniel Dunbar7363d032011-02-27 03:22:35 +0000619 ignores_path = os.path.join(path, 'gdb-1472-testsuite', 'expected_results',
620 key)
621 gdb_dg_ignores = (
622 readList(os.path.join(ignores_path, 'FAIL.txt')) +
623 readList(os.path.join(ignores_path, 'UNRESOLVED.txt')) +
624 readList(os.path.join(ignores_path, 'XPASS.txt')))
625 ignores['gdb-1472-testsuite' ] = gdb_dg_ignores
626
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000627 return ignores
David Deanf8b35442012-12-11 00:35:12 +0000628
629from zorg.buildbot.PhasedBuilderUtils import getBuildDir, setProperty
Michael Gottesman94e9ee42013-04-04 06:52:04 +0000630from zorg.buildbot.builders.Util import _did_last_build_fail
David Deanf8b35442012-12-11 00:35:12 +0000631from buildbot.steps.source.svn import SVN as HostSVN
632
Michael Gottesman94e9ee42013-04-04 06:52:04 +0000633def phasedClang(config_options, is_bootstrap=True, use_lto=False,
634 incremental=False):
David Deanf8b35442012-12-11 00:35:12 +0000635 # Create an instance of the Builder.
636 f = buildbot.process.factory.BuildFactory()
637 # Determine the build directory.
638 f = getBuildDir(f)
639 # get rid of old archives from prior builds
640 f.addStep(buildbot.steps.shell.ShellCommand(
641 name='rm.archives', command=['sh', '-c', 'rm -rfv *gz'],
642 haltOnFailure=False, description=['rm archives'],
643 workdir=WithProperties('%(builddir)s')))
644 # Clean the build directory.
645 clang_build_dir = 'clang-build'
Michael Gottesman94e9ee42013-04-04 06:52:04 +0000646 if incremental:
647 f.addStep(buildbot.steps.shell.ShellCommand(
648 name='rm.clang-build', command=['rm', '-rfv', clang_build_dir],
649 haltOnFailure=False, description=['rm dir', clang_build_dir],
650 workdir=WithProperties('%(builddir)s'),
651 doStepIf=_did_last_build_fail))
652 else:
653 f.addStep(buildbot.steps.shell.ShellCommand(
654 name='rm.clang-build', command=['rm', '-rfv', clang_build_dir],
655 haltOnFailure=False, description=['rm dir', clang_build_dir],
656 workdir=WithProperties('%(builddir)s')))
657
David Deanf8b35442012-12-11 00:35:12 +0000658 # Cleanup the clang link, which buildbot's SVN always_purge does not know
659 # (in 8.5 this changed to method='fresh')
660 # how to remove correctly. If we don't do this, the LLVM update steps will
661 # end up doing a clobber every time.
662 #
663 # FIXME: Should file a Trac for this, but I am lazy.
664 f.addStep(buildbot.steps.shell.ShellCommand(
665 name='rm.clang-sources-link',
666 command=['rm', '-rfv', 'llvm/tools/clang'],
667 haltOnFailure=False, description=['rm', 'clang sources link'],
668 workdir=WithProperties('%(builddir)s')))
669 f.addStep(buildbot.steps.shell.ShellCommand(
670 name='rm.compiler-rt-sources-link',
671 command=['rm', '-rfv', 'llvm/projects/compiler-rt'],
672 haltOnFailure=False, description=['rm', 'compiler-rt sources link'],
673 workdir=WithProperties('%(builddir)s')))
Michael Gottesman2db83142013-08-05 21:44:45 +0000674 # TODO: We used to use a symlink here but it seems to not work. I am trying
675 # to get this builder to work so I am just going to copy it instead.
676 f.addStep(buildbot.steps.shell.ShellCommand(
677 name='rm.clang-tools-extra-source',
678 command=['rm', '-rfv', 'extra'],
679 haltOnFailure=True, workdir='clang.src/tools',
680 description=['rm', 'clang-tools-extra sources']))
David Deanf8b35442012-12-11 00:35:12 +0000681 # Pull sources.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000682 f = phased_builder_utils.SVNCleanupStep(f, 'llvm')
David Deanf8b35442012-12-11 00:35:12 +0000683 f.addStep(HostSVN(name='pull.llvm', mode='incremental', method='fresh',
684 repourl='http://llvm.org/svn/llvm-project/llvm/trunk',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000685 retry=(60, 5), workdir='llvm', description='pull.llvm',
686 alwaysUseLatest=False))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000687 f = phased_builder_utils.SVNCleanupStep(f, 'clang.src')
David Deanf8b35442012-12-11 00:35:12 +0000688 f.addStep(HostSVN(name='pull.clang', mode='incremental', method='fresh',
689 repourl='http://llvm.org/svn/llvm-project/cfe/trunk',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000690 workdir='clang.src', retry=(60, 5),
David Deanf8b35442012-12-11 00:35:12 +0000691 description='pull.clang', alwaysUseLatest=False))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000692 f = phased_builder_utils.SVNCleanupStep(f, 'clang-tools-extra.src')
Michael Gottesman1dcf8f82013-03-28 06:20:57 +0000693 f.addStep(HostSVN(name='pull.clang-tools-extra', mode='incremental',
694 method='fresh',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000695 repourl='http://llvm.org/svn/llvm-project/'
696 'clang-tools-extra/trunk',
Michael Gottesman1dcf8f82013-03-28 06:20:57 +0000697 workdir='clang-tools-extra.src', alwaysUseLatest=False,
698 retry=(60, 5), description='pull.clang-tools-extra'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000699 f = phased_builder_utils.SVNCleanupStep(f, 'compiler-rt.src')
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000700 f.addStep(HostSVN(name='pull.compiler-rt', mode='incremental',
701 method='fresh',
702 repourl='http://llvm.org/svn/llvm-project/compiler-rt/'
703 'trunk',
704 workdir='compiler-rt.src', alwaysUseLatest=False,
705 retry=(60, 5), description='pull.compiler-rt'))
706 # Create symlinks to the clang compiler-rt sources inside the LLVM tree.
David Deanf8b35442012-12-11 00:35:12 +0000707 # We don't actually check out the sources there, because the SVN purge
708 # would always remove them then.
709 f.addStep(buildbot.steps.shell.ShellCommand(
710 name='ln.clang-sources', haltOnFailure=True,
711 command=['ln', '-sfv', '../../clang.src', 'clang'],
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000712 workdir='llvm/tools', description=['ln', 'clang sources']))
David Deanf8b35442012-12-11 00:35:12 +0000713 f.addStep(buildbot.steps.shell.ShellCommand(
714 name='ln.compiler-rt-sources',
715 command=['ln', '-sfv', '../../compiler-rt.src', 'compiler-rt'],
716 haltOnFailure=True, workdir='llvm/projects',
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000717 description=['ln', 'compiler-rt sources']))
Michael Gottesman4a68b872013-03-28 19:03:52 +0000718 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesmanbcab1992013-03-28 18:37:21 +0000719 name='cp.clang-tools-extra-sources',
Michael Gottesman03495922013-03-28 18:40:44 +0000720 command=['cp', '-Rfv', '../../clang-tools-extra.src', 'extra'],
Michael Gottesman1dcf8f82013-03-28 06:20:57 +0000721 haltOnFailure=True, workdir='clang.src/tools',
Michael Gottesmanbcab1992013-03-28 18:37:21 +0000722 description=['cp', 'clang-tools-extra sources']))
David Deanf8b35442012-12-11 00:35:12 +0000723 # Checkout the supplemental 'debuginfo-tests' repository.
724 debuginfo_url = 'http://llvm.org/svn/llvm-project/debuginfo-tests/trunk'
725 f.addStep(HostSVN(name='pull.debug-info tests', mode='incremental',
726 repourl=debuginfo_url,
727 method='fresh',
728 workdir='llvm/tools/clang/test/debuginfo-tests',
729 alwaysUseLatest=False, retry = (60, 5),
730 description='pull.debug-info tests'))
731 # Clean the install directory.
732 f.addStep(buildbot.steps.shell.ShellCommand(
733 name='rm.clang-install', command=['rm', '-rfv', 'clang-install'],
734 haltOnFailure=False, description=['rm dir', 'clang-install'],
735 workdir=WithProperties('%(builddir)s')))
736 # Construct the configure arguments.
737 configure_args = ['../llvm/configure']
738 configure_args.extend(config_options)
Galina Kistanova702eccb2013-08-22 00:09:17 +0000739 configure_args.extend(['--disable-bindings',
David Deanf8b35442012-12-11 00:35:12 +0000740 '--enable-keep-symbols'])
741 configure_args.append(
Michael Gottesman65d940f2013-03-13 21:51:16 +0000742 WithProperties('--prefix=%(builddir)s/clang-install'))
Michael Gottesmanca56e8f2013-03-06 22:27:38 +0000743
David Deanf8b35442012-12-11 00:35:12 +0000744 # If we are using a previously built compiler, download it and override CC
745 # and CXX.
746 if is_bootstrap:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000747 f = artifacts.GetCompilerArtifacts(f)
David Deanf8b35442012-12-11 00:35:12 +0000748 else:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000749 f = phased_builder_utils.GetLatestValidated(f)
David Deanf8b35442012-12-11 00:35:12 +0000750 cc_command = ['find', 'host-compiler', '-name', 'clang']
751 f.addStep(buildbot.steps.shell.SetProperty(
752 name='find.cc',
753 command=cc_command,
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000754 extract_fn=phased_builder_utils.find_cc,
David Deanf8b35442012-12-11 00:35:12 +0000755 workdir=WithProperties('%(builddir)s')))
756 f.addStep(buildbot.steps.shell.ShellCommand(
757 name='sanity.test', haltOnFailure=True,
758 command=[WithProperties('%(builddir)s/%(cc_path)s'), '-v'],
759 description=['sanity test']))
760 configure_args.extend([
761 WithProperties('CC=%(builddir)s/%(cc_path)s'),
762 WithProperties('CXX=%(builddir)s/%(cc_path)s++')])
Michael Gottesman65d940f2013-03-13 21:51:16 +0000763
764 # If we need to use lto, find liblto, add in proper flags here, etc.
765 if use_lto:
Michael Gottesman01f0a622013-03-13 22:38:38 +0000766 liblto_command = ['find', WithProperties('%(builddir)s/host-compiler'),
767 '-name', 'libLTO.dylib']
Michael Gottesman1da57ae2013-03-13 21:54:23 +0000768 f.addStep(buildbot.steps.shell.SetProperty(
Michael Gottesman65d940f2013-03-13 21:51:16 +0000769 name='find.liblto',
770 command=liblto_command,
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000771 extract_fn=phased_builder_utils.find_liblto,
Michael Gottesman65d940f2013-03-13 21:51:16 +0000772 workdir=WithProperties('%(builddir)s')))
773 configure_args.append(
774 '--with-extra-options=-flto -gline-tables-only')
775
David Deanf8b35442012-12-11 00:35:12 +0000776 # Configure the LLVM build.
Michael Gottesmand97d8502013-04-04 07:57:31 +0000777 if incremental:
778 # *NOTE* This is a temporary work around. I am eventually going to just
779 # set up cmake/ninja but for now I am sticking with the make => I need
780 # configure to run only after a failure so on success I have incremental
781 # builds.
782 f.addStep(buildbot.steps.shell.ShellCommand(
783 name='configure.with.host', command=configure_args,
784 haltOnFailure=True, description=['configure'],
785 workdir=clang_build_dir,
786 doStepIf=_did_last_build_fail))
787 else:
788 f.addStep(buildbot.steps.shell.ShellCommand(
789 name='configure.with.host', command=configure_args,
790 haltOnFailure=True, description=['configure'],
791 workdir=clang_build_dir))
792
David Deanf8b35442012-12-11 00:35:12 +0000793 # Build the compiler.
Michael Gottesman65d940f2013-03-13 21:51:16 +0000794 make_command = ['make', '-j', WithProperties('%(jobs)s')]
Galina Kistanovabfb29d22013-05-09 23:53:24 +0000795 timeout = 40*60 # Normal timeout is 20 minutes.
Michael Gottesman65d940f2013-03-13 21:51:16 +0000796 if use_lto:
797 make_command.append(WithProperties('DYLD_LIBRARY_PATH=%(liblto_path)s'))
Michael Gottesman2e7385c2013-08-12 17:57:27 +0000798 timeout = 240*60 # LTO timeout is 240 minutes.
Michael Gottesman65d940f2013-03-13 21:51:16 +0000799
David Deanf8b35442012-12-11 00:35:12 +0000800 f.addStep(buildbot.steps.shell.ShellCommand(
Michael Gottesman65d940f2013-03-13 21:51:16 +0000801 name='make', command=make_command,
Michael Gottesmanbab77ac2013-03-14 05:36:53 +0000802 haltOnFailure=True, description=['make'], workdir=clang_build_dir,
803 timeout=timeout))
David Deanf8b35442012-12-11 00:35:12 +0000804 # Use make install-clang to produce minimal archive for use by downstream
805 # builders.
806 f.addStep(buildbot.steps.shell.ShellCommand(
807 name='make.install-clang', haltOnFailure=True,
Michael Gottesmanf8748fb2013-03-28 06:21:03 +0000808 command=['make', 'install-clang', '-j',
809 WithProperties('%(jobs)s'),
810 'RC_SUPPORTED_ARCHS=armv7 i386 x86_64'],
David Deanf8b35442012-12-11 00:35:12 +0000811 description=['make install'], workdir=clang_build_dir))
812 # Save artifacts of this build for use by other builders.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000813 f = artifacts.uploadArtifacts(f)
David Deanf8b35442012-12-11 00:35:12 +0000814 # Run the LLVM and Clang regression tests.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000815 f.addStep(lit_test_command.LitTestCommand(name='run.llvm.tests', haltOnFailure=True,
816 command=['make', '-j', WithProperties('%(jobs)s'),
Michael Gottesman73138db2013-08-05 22:23:08 +0000817 'VERBOSE=1', 'check-all'],
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000818 description=['all', 'tests'],
819 workdir=clang_build_dir))
David Deanf8b35442012-12-11 00:35:12 +0000820 return f