This is an archive of the discontinued LLVM Phabricator instance.

[buildbot] Add check-fuzzer to Asan buildbot on Windows.
ClosedPublic

Authored by mpividori on Feb 7 2017, 1:05 PM.

Diff Detail

Event Timeline

mpividori created this revision.Feb 7 2017, 1:05 PM
zturner edited edge metadata.Feb 7 2017, 1:07 PM

Can you delete and re-create, and add llvm-commits to the subscribers? (It doesn't work if you add it after the fact, it has to be done the first time you create the review)

Hmm, actually it looks like llvm-commits is already added, I'm not sure why it's not sending out email

Zturner, but I added llvm-commit when I created the diff. It looks like it doesnt work...

Ahh it just sent out the email, I guess it was delayed.

zturner added inline comments.Feb 7 2017, 1:10 PM
zorg/buildbot/builders/SanitizerBuilderWindows.py
134

Should this be -DLLVM_USE_SANITIZER_COVERAGE=YES? (The R is missing in Sanitizer)

mpividori added inline comments.Feb 7 2017, 1:12 PM
zorg/buildbot/builders/SanitizerBuilderWindows.py
134

@zturner the flag is LLVM_USE_SANITIZE_COVERAGE (yes it is confusing...).

mpividori updated this revision to Diff 87535.Feb 7 2017, 3:49 PM

+ Split build and testing into 2 steps so it is easier to understand when it fails.
+ Add asan dll path to Path, so it is found when executing the tests.
+ Add bin dir to Path, so tools like FileCheck, not and sancov are found when executing the tests.

rnk, does this look correct to you? I dont' see anything obviously wrong, but you are more familiar with this bot than I am.

zorg/buildbot/builders/SanitizerBuilderWindows.py
129

The backslashes here need to be escaped or they will be treated as escape characters. Or use path.join so you don't have to deal with slashes at all.

mpividori updated this revision to Diff 87540.Feb 7 2017, 4:08 PM

Use os.path.join instead of backslashes.

rnk added inline comments.Feb 7 2017, 5:18 PM
zorg/buildbot/builders/SanitizerBuilderWindows.py
129

This won't work, this code will execute on the master, not the build slave, so the CWD will be wrong, and we won't be able to glob. I think it might be possible to construct a relative path to clang-cl, but I'm not sure how to add the absolute runtime library path to PATH.

@rnk I am not sure I understand what you mean. All the steps will be executed in the same machine, won't they? So, after building clang and compiler-rt with MSVC, we have the binaries and libraries in build_dir\Release . I am adding them to PATH.

@rnk Ah you mean: abspath . Ok I got it.

Ahh yes, classic master/slave problems :(

I had this problem once before, I think in the LLDB builder, and Galina showed me a way to get the current directory on the master, but I'll have to do some digging to find it.

Ok here it is.

# get full path to build directory
f.addStep(SetProperty(name="get_builddir",
                      command=["pwd"],
                      property="builddir",
                      description="set build dir",
                      workdir=build_dir))

# Use the build directory via the %(builddir) syntax.
cmake_cmd = [
    "cmake", "-G", "Ninja", "../llvm",
    "-DCMAKE_BUILD_TYPE=" + config,
    "-DPYTHON_HOME=" + python_source_dir,
    "-DCMAKE_INSTALL_PREFIX=../install",
    "-DLLDB_TEST_COMPILER=\"%(builddir)s/bin/clang.exe\""
    ]
mpividori updated this revision to Diff 87578.Feb 7 2017, 6:24 PM

Ok. Now it should work fine. Would you agree?

mpividori updated this revision to Diff 87668.Feb 8 2017, 8:49 AM

Done. Let me know if you agree. Do I need a special permission to push the commit?

zturner added inline comments.Feb 8 2017, 9:00 AM
zorg/buildbot/builders/SanitizerBuilderWindows.py
150–151

Does this work? I know Property('slave_env') will return the slave environment as a dictionary, but is this just a local dictionary where changes made to it don't get written back to the slave? That's what I expect.

If so you might need to do something like

newPath = ";".join([bin_path, dll_path, Property('slave_env')['Path']])
f.addStep(SetProperty(name="set toolchain path",
                          command=["set", "PATH", "=", newPath],
                          description="set toolchain path",
                          workdir=build_dir))

(I'm honestly not 100% sure though, so confirm that I'm right if you can)

Actually wait, each step runs with env=Property('slave_env'). So even if you set the path beforehand, this will override your changes because it will already have PATH in this env. So you need to save off the value of Property(slave_env), fix up the PATH environment variable, and then use that as the value of the env keyword argument in subsequent calls.

@zturner I am modifying the Property('slave_env') dictionary. I update the value mapped to the key: Path , to add the new directories.

rnk added inline comments.Feb 8 2017, 9:10 AM
zorg/buildbot/builders/SanitizerBuilderWindows.py
135

This might fail if many version of clang have been built and the lib directory contains more than one version. I suspect the bot already has more than one version directory.

142

I doubt this will work. A "Property" is not a string or dictionary. The master never sees the property values until the build actually executes. It has to generate the list of steps to execute up front, before actually running any of them. When you say "addStep", that adds a step to be run in the future on another machine. The steps don't run synchronously inside this python code.

As an alternative, we don't need to set PATH if we link statically, right? I'd recommend we do that. Set "-DLLVM_USE_CRT_"+config.upper()"=MT" in the cmake command to do that.

@zturner I am modifying the Property('slave_env') dictionary. I update the value mapped to the key: Path , to add the new directories.

It might work if you save the value of Property('slave_env') into a local variable first, then modify the values in that local variable, then reference the local variable in all subsequent lines that say env = Property('slave_env'). Otherwise I don't know if it will just ask the slave for its value new every time. (This is all very magic black-box type stuff).

Or maybe I'm totally wrong and what Reid said is correct, that the master never sees the value of the properties :) I'm obviously not going to be putting buildbot on my resume :)

mpividori added inline comments.Feb 8 2017, 10:56 AM
zorg/buildbot/builders/SanitizerBuilderWindows.py
135

@rnk yes I considered that. But we are removing the build directory before starting, with the step: RemoveDirectory(name='clean '+build_dir

mpividori updated this revision to Diff 87676.Feb 8 2017, 11:01 AM

Let mw know if you agree with this diff. I use Interpolate() and I update PATH in the slave_env.

zorg/buildbot/builders/SanitizerBuilderWindows.py
142

@rnk Thanks. We also need to set PATH because we need to add Filecheck, not, sancov to PATH.

rnk added inline comments.Feb 8 2017, 11:02 AM
zorg/buildbot/builders/SanitizerBuilderWindows.py
135

No, that step is conditional on cleanBuildIfRequested, which is typically false. The builder is intended to be fast and incremental.

rnk added inline comments.Feb 8 2017, 11:09 AM
zorg/buildbot/builders/SanitizerBuilderWindows.py
142

True, but we don't have to compute the clang version to compute the path the bin directory. Static linking would still eliminate the need for this "dir /b" step.

144

Why add config? A ninja build will put the binaries in "%(builddir)s/bin", right?

149

This will probably work, nice :)

gkistanova requested changes to this revision.Feb 8 2017, 11:17 AM

Hello Marcos,

I have commented couple things inline.

You may want to reconsider how you try to set the environments. What you are trying to do wouldn't work. Property('slave_env') is a local snapshot of the slave envs, and does not get propagated back to the slave.
You either would need to use a build step env param to set an env var, or do something else which would not require that.
At the first glance, Reid's suggestion of reducing the number of dependencies looks as a way to go, unless you have a strong reason to dial with DLLs.

zorg/buildbot/builders/SanitizerBuilderWindows.py
119

Depending on a build slave version, RemoveDirectory might not work well on Windows, if some directories are not empty or temporarily locked by some service or anti-virus. Just FYI.

Unfortunately, there is no good solution for this. Issuing "rmdir /S /Q" command might fail too, depending on the shell.

134

All these could be done simpler.

Every build step has a property "workdir" which contains a fully qualified path. When referencing a path, you could do something like

WithProperties(
     "-DCMAKE_CXX_COMPILER=%(workdir)s/" + staged_install + "/bin/clang++"
 ))

No need to be canonical with the directory separator as well, forward slashes would do just fine.

You can check how similar to this is done in the UnifiedTreeBuilder.py, lines 365-375.

151

All these could be done simpler.

Every build step has a property "workdir" which contains a fully qualified path. When referencing a path, you could do something like

WithProperties(
     "-DCMAKE_CXX_COMPILER=%(workdir)s/" + staged_install + "/bin/clang++"
 ))

No need to be canonical with the directory separator as well, forward slashes would do just fine.

You can check how similar to this is done in the UnifiedTreeBuilder.py, lines 365-375.

153

Could you use the CmakeCommand instead of the ShellCommand, please?

This revision now requires changes to proceed.Feb 8 2017, 11:17 AM
mpividori updated this revision to Diff 87710.Feb 8 2017, 1:44 PM
mpividori edited edge metadata.

@gkistanova @rnk Thanks for your feedback.
I have included suggested changes.
Unfortunately, I can't use MT for now. There is a problem with clang driver, and the order of static libraries. I will file a bug in bugzilla.
I still need to update the code to use CmakeCommand. Maybe in a different diff?

rnk accepted this revision.Feb 8 2017, 2:20 PM

lgtm

Let's see if this Interpolate usage actually works, I guess. :)

gkistanova requested changes to this revision.Feb 8 2017, 4:17 PM

We run buildbot 0.8.5 on the master. It does not have Interpolate.
So, please use WithProperties instead.

This revision now requires changes to proceed.Feb 8 2017, 4:17 PM
mpividori updated this revision to Diff 87732.Feb 8 2017, 4:43 PM
mpividori edited edge metadata.

@gkistanova Ok. Done. Let me know if you agree with the last diff.

Ready to land?

gkistanova accepted this revision.EditedFeb 9 2017, 12:08 PM

Hello Marcos,

Feel free to commit after fixing that missing comma.

Would you make sure the slave for that builder will connect to the silent master and not production, to stage it for a day or two, please?

zorg/buildbot/builders/SanitizerBuilderWindows.py
132

You are missing a comma here between the arguments.

This revision is now accepted and ready to land.Feb 9 2017, 12:08 PM
gkistanova added inline comments.Feb 9 2017, 12:09 PM
zorg/buildbot/builders/Util.py
23

A cosmetic - "and and"

rnk added a comment.Feb 9 2017, 1:07 PM

Hello Marcos,

Feel free to commit after fixing that missing comma.

Would you make sure the slave for that builder will connect to the silent master and not production, to stage it for a day or two, please?

The builder is already connected to the normal build master, though. Should we move it?

Yes, please, once this change is landed.
Just stop the slave, point it to the silent master, and start it again. It should connect with the same credentials.
In a day or two of the reliably green builds on the staging, feel free to return it back to the normal build master.

It seems less than ideal for our existing coverage to go silent if we connect this to the non production master.

What if we set haltOnFailure=False and flunkOnFailure=False for all of the newly added steps, until we can confirm that it's stable?

Hi Zachary,

This could do, if you are sure that these steps would not compromise the whole build.
Anyway, you can re-point the slave to the silent master if something would go wrong. Just be ready to act quickly. :)

Sounds good. Any chance of a master restart today after landing this, so that we can see by tomorrow morning if it's going to be a problem?

I'll restart the master at the end of the day today.

This revision was automatically updated to reflect the committed changes.