This is an archive of the discontinued LLVM Phabricator instance.

Create an experimental Windows LLDB Builder
ClosedPublic

Authored by zturner on Dec 19 2014, 3:42 PM.

Details

Summary

This creates a Windows buildbot for LLDB, with the following properties:

  1. Only builds x86.
  2. Only compiles, does not run tests.
  3. Uses MSVC 2013 as the compiler, with the CMake / ninja generator.

I wanted to test this by setting up a local zorg buildmaster and connecting my slave to it, but I was unable to get it working properly. I'm going on vacation next week, so I thought I would put this up in the meantime and at least see if I'm going about this all wrong, or if this code looks like a reasonable starting point.

Diff Detail

Repository
rL LLVM

Event Timeline

zturner updated this revision to Diff 17526.Dec 19 2014, 3:42 PM
zturner retitled this revision from to Create an experimental Windows LLDB Builder.
zturner updated this object.
zturner edited the test plan for this revision. (Show Details)
zturner added reviewers: gkistanova, samsonov, timurrrr.
zturner added a subscriber: Unknown Object (MLST).

+Evgeniy who was adding other bots lately.

buildbot/osuosl/master/config/builders.py
617 ↗(On Diff #17526)

please specify the VS version where these env values came from

630 ↗(On Diff #17526)

Are you sure the framework envs are required? I don't remember setting them on our other bots

643 ↗(On Diff #17526)

Ditto NETFX dirs

zorg/buildbot/builders/LLDBBuilder.py
29 ↗(On Diff #17526)

Evgeniy might have a different opinion, e.g. suggest to use annotator instead?

eugenis added inline comments.Dec 23 2014, 4:02 AM
zorg/buildbot/builders/LLDBBuilder.py
29 ↗(On Diff #17526)

Whatever works for you.

What would you use yourself if you wanted to create a brand new bot?

zturner updated this revision to Diff 17674.Dec 29 2014, 11:31 AM
zturner edited edge metadata.

Removed manual setting of environment and do it automatically using vcvarsall. Also cleaned up the interface to the lldb cmake windows build factory generator by sinking some more logic into the factory generator method.

Still having trouble setting up a zorg buildmaster locally, but I will keep trying.

Post-holiday bump. I assume people are back to their regular schedules by now, so Galina could you please take a look?

gkistanova edited edge metadata.EditedJan 6 2015, 3:59 PM

Hello Zachary,

Thanks for working on this!

It is almost there. Please see my comments inline above.
Feel free to commit with the fixed ## 2 and 4.

Don't worry about having a local master. I'll stage the changes and will let you know if anything would go wrong. I feel much more comfortable with the current patch.

buildbot/osuosl/master/config/slaves.py
174 ↗(On Diff #17674)

The 'jobs' property is not used by the factory. See the note # 4 below.

zorg/buildbot/builders/LLDBBuilder.py
28 ↗(On Diff #17674)
  1. Having all the env vars from a slave could be too much and noisy in the logs. How about white list only what you really need? This is not a show stopper, though.
39 ↗(On Diff #17674)
  1. Could you use raw strings here and everywhere else for Windows paths with dir separators, please? Like r'C:\src\python\'.
45 ↗(On Diff #17674)
  1. Maybe add an optional env param here and support optional env property propagated from a slave and builder definitions to merge with the envs you are requesting from the slave?

In some cases it might be needed to define something in addition.

Not a how stopper and could wait till someone would really need the feature. Just be nice to have it.

72 ↗(On Diff #17674)
  1. Here you are missing the 'jobs' property defined with the slave. You need to reconcile the 'jobs' param with the 'jobs' property before building the cmd string.

Thanks for the comments. I will work on a fix for the issues you pointed out.

zorg/buildbot/builders/LLDBBuilder.py
28 ↗(On Diff #17674)

I thought about that, but it's difficult to know exactly which ones we need. There are some that are obvious, like include paths, library paths, etc, but some that are not so obvious. In theory we just need to be able find cl.exe, link.exe, and include / library paths, but the use of many of the other variables is kind of mysterious and not well documented by Microsoft, so it's not clear if we will trigger their access somehow.

In other words, I can come up with a whitelist but I would not be 100% confident that it would be accurate.

39 ↗(On Diff #17674)

Unfortunately it seems like a raw string cannot end with a single backslash. This might be a bug in python, but I tested it out. r'C:\src\python\' is an error, and r'C:\src\python\\' actually puts two backslashes at the end.

I can probably change it to not include any backslashes at the end though, and then just make sure that the case of 0 backslashes and 1 backslash are both correctly handled in the function.

gkistanova added inline comments.Jan 7 2015, 9:25 AM
zorg/buildbot/builders/LLDBBuilder.py
28 ↗(On Diff #17674)

Agree. This could be time consuming. Adding a FIXME: with the description of the issue would do for now.

zturner updated this revision to Diff 17865.Jan 7 2015, 10:34 AM
zturner edited edge metadata.

Fixed suggested issues. I didn't fix #3 yet because I may need that feature when I add support for running the test suite on the build bot, which I plan to implement soon. To keep the changelist smaller and easier to diagnose errors, I will implement it then (if it ends up being needed).

I'm also not sure I did the property resolution correctly. I tried to go from some example about how other builders do it, but again with no way to test it in a real master/slave environment I'm not sure it's correct.

rfoos added a subscriber: rfoos.Jan 7 2015, 1:21 PM
rfoos added inline comments.
zorg/buildbot/builders/LLDBBuilder.py
14 ↗(On Diff #17674)

I think these are intended to define a 32 or 64 bit host executable for X86 or ARM.

They not to define an LLVM cross compiler target arch (i.e. AARCH64, Hexagon...)

To match the build host, vcvarsall %PROCESSOR_ARCHITECTURE%

21 ↗(On Diff #17674)

Why not use buildbot's SetProperty? It has a facility for returning stdout. This seems like more work to support.

28 ↗(On Diff #17674)

I'm not sure the env is so much longer using this method. The existing slave environment on Windows is quite long, and many of the variables are needed for other purposes.

Once you have the slave environment into a dictionary you can define merge and strip functions.

39 ↗(On Diff #17674)

I second the motion for 0 trailing backslashes. I've not had a case where this has been a problem to date.

x=r"""c:\asdf\\"""
print x

c:\asdf\\

I think it's a bug too, and that I would have no luck in getting it accepted by the python community :)

Since you have to quote all the paths in windows, this appears to work

x=r""""c:\asdf\ fdas \""""
print x

"c:\asdf\ fdas \"

But I think something else that escapes this string will mess it up later.

45 ↗(On Diff #17674)

I'm suggesting a generic way to invoke VCVARSALL.BAT that works on any buildslave.

This is for a 64 bit MSVC build, using a 64 bit version of Python.
slavenvCmd=r"""PATH=C:\Python2764;C:\Python2764\Scripts;%PATH% & "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" amd64 & set""",

(As part of this, I have to admit that I don't have a generic method for identifying a 64 bit python needed for 64 bit builds of LLDB)

If you have multiple MSVC installations, these variables provide a reliable index to vcvarsall.bat. The locations are installation dependant, and the values can be different for each buildslave.

VS100COMNTOOLS=c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools
\
VS110COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools
\
VS120COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools
\
ATM, MSVC 2013 is all that works. As it was in the past, MSVC 2014/2015 will become an option soon.

side note, VSINSTALLDIR isn't defined until after vcvarsall is run and a specific version selected.

72 ↗(On Diff #17674)

I'm having the same bug, but can we add loadaverage?

I have fast servers, and they overload themselves, keep going and plow through builds with 140+ loadaverages (32 being 100% utilization)

zturner added inline comments.Jan 7 2015, 1:30 PM
zorg/buildbot/builders/LLDBBuilder.py
14 ↗(On Diff #17674)

For the above 2 cases, it's talking about both the host AND the target. In other words:

"vcvarsall x86" will use a 32-bit toolchain that produces 32-bit target executables
"vcvarsall amd64" will use a 64-bit toolchain that produces 64-bit target executables.

There are actually more values you can specify for the first argument to vcvarsall for cross compilation, but I'm not supporting those here.

I provided this argument because this way we can (later) provide slaves for both x86 and x64 on the same physical builder.

21 ↗(On Diff #17674)

I guess because I don't know how it works. Isn't this the standard pythonic way to do this though?

45 ↗(On Diff #17674)

I don't want to put Python in the path because LLDB requires linking against a manually compiled python, and I don't want anything to get confused. Also if we ever make a builder with a new version of MSVC (say 2015), you would have to change this. It seems like the way I've done it is sufficient, you just supply it a path to any version of MSVC, where it defaults to MSVC 2013, and it just works.

zturner added inline comments.Jan 7 2015, 2:06 PM
zorg/buildbot/builders/LLDBBuilder.py
45 ↗(On Diff #17674)

Read this for information about why LLDB requires a custom built version of Python

http://lldb.llvm.org/build.html#BuildingLldbOnWindows

One reason I'm fond of the solution I've got here is because both the python source dir and the MSVC dir are configurable, so it's future proof against MSVC versions and should easily handle the case of specifying a 64-bit python. Just build 32 and 64-bit pythons from different source trees, and pass a different value for the python source dir.

rfoos added inline comments.Jan 7 2015, 2:29 PM
zorg/buildbot/builders/LLDBBuilder.py
21 ↗(On Diff #17674)

buildbotic vs. pythonic :)
I'm OK with it as long as the subprocess is running on the buildslave. I had thought that code like that was running on the buildmaster.

45 ↗(On Diff #17674)

Currently I'm building with a standard python release, and running with a pre-built MSVC2013 python.

We were doing fairly well without it, but when LLDB is a debug version, the python also has to be a debug version and none of the released pythons are built for debug.

changing the slave_envCmd from the builder is all you have to do to switch things as well, but the slave_envCmd also works for Linux r"""printenv""" which was one of my goals in a Windows/Linux build factory.

zturner added inline comments.Jan 7 2015, 2:37 PM
zorg/buildbot/builders/LLDBBuilder.py
45 ↗(On Diff #17674)

Not sure what you mean about building vs. running. LLDB embeds python, and then links against itself via an extension module, so whatever you build with is also what you run with. The extension module must be compiled with the same version of MSVC as the version of Python that LLDB links against.

AFAIK there is nothing special about Debug / Release here. I used to think there was, but then I found out that the same issue is present for Release. So you always need to compile python, regardless of whether it's a debug or release build of LLDB.

rfoos added inline comments.Jan 7 2015, 3:37 PM
zorg/buildbot/builders/LLDBBuilder.py
45 ↗(On Diff #17674)

You are right. Somebody else stashed an MSVC2013 python and I missed it. We are linking against a 32 or 64 bit version of MSVC2013 python.

So we don't need to compile python on each build, but once for each build config matching the lldb build config.

gkistanova added inline comments.Jan 9 2015, 12:16 PM
zorg/buildbot/builders/LLDBBuilder.py
72 ↗(On Diff #17674)

Yes, at the end we need both, the job and the loadaverage.

Galina, Are you ok with the patch as is, now that I've addressed 1, 2, and 4?

Looks good to me. Please feel free to commit.

The "job" property wouldn't work, but this is fine for now. I'll follow up.

This revision was automatically updated to reflect the committed changes.