This is an archive of the discontinued LLVM Phabricator instance.

[test-suite] Introduce a new CMake+LIT based harness
ClosedPublic

Authored by jmolloy on Oct 25 2015, 6:29 AM.

Details

Reviewers
beanz
cmatthews
Summary

This introduces a replacement for the Makefile based build system. This replacement build system uses CMake for configuring and compiling the tests, and LIT for running them. LIT will report both compile and execution times as metrics, available by using the '-o' option to output JSON or '-v' (without '-s').

The advantages of this setup are:

  • Use of the same technologies used in LLVM itself means there's more expertise available to debug, fix and extend, and fewer disparate command line flags to remember.
  • A common-off-the-shelf solution means there's much less custom code to maintain, only glue.
  • More readable output by default, more debuggable by far.
  • The ability to run just one test, quickly and easily.
  • The ability to perform test repeats without cleaning and recompiling first.
  • Because the command line is simple, LNT is not required to run a test.

The disadvantages are:

  • Not all of the features in the Makefile system are supported or are going to be. For example, llvm-gcc support, compiling with opt & llc. Clang is stable and expected now - we don't need these workarounds.

This commit introduces the CMake and LIT glue and a python script that can parse all the Makefiles in SingleSource & MultiSource and can generate equivalent CMakeLists.txt. The intention is that this is run once and the resulting files checked in then never used again.

With this script run, the entire test-suite builds and runs. Example command lines:

$ mkdir build; cd build
$ cmake -DCMAKE_C_COMPILER=/path/to/my/clang .. # CMake finds clang++ and introspects the target OS/arch/endianness
$ make -j12
$ llvm-lit -sv .

Ninja also works, but the way the ninja makefiles are generated means there is no way to build all tests in an arbitrary subtree (as LNT's --only-test does). With ninja you can build all tests or a single test.

All feedback welcome! Please also see the discussion on llvm-commits.

Diff Detail

Repository
rL LLVM

Event Timeline

jmolloy updated this revision to Diff 38344.Oct 25 2015, 6:29 AM
jmolloy retitled this revision from to [test-suite] Introduce a new CMake+LIT based harness.
jmolloy updated this object.
jmolloy added reviewers: beanz, cmatthews.
jmolloy set the repository for this revision to rL LLVM.
jmolloy added a subscriber: llvm-commits.
beanz edited edge metadata.Oct 26 2015, 2:52 PM

Thank you for doing this! This looks like a great start to get the ball rolling!

CMakeLists.txt
2

Do we need to make this 2.8.12.2? If we make it 3.2 then we can fold away some of the later version checks and features, and since this is a new CMake build system I'd kinda like to have it ditch support for legacy versions.

cmake/modules/SingleMultiSource.cmake
162

Probably need to add something like this add_dependencies(${source_exename} timeit fpcmp) here.

190

Same as above.

MatzeB added a subscriber: MatzeB.Oct 26 2015, 8:50 PM

First: I really like where this is going! Thanks for working on this!

Some early comments after playing around with it for a while:

  • I could not get lit to show the commandlines of tests that do not fail. This would be very nice to have for the benchmarks.
  • I think we need cmake to generate a lit.cfg in the build directory or it will fail when the builddirectory is not a subdirectory of the test-suite.

I'd like to go further in simplifying the test commandlines. Right now the .test files still contain all the RunSafely.sh/timeit/... stuff. IMO this should be part of the benchmark driver (=lit.cfg). I think we should allow "RUN: " lines for the benchmark and "VERIFY:" lines for checking the benchmark results. With a custom lit test we should be able to prefix the RunSafely stuff automatically for all RUN: lines and run the VERIFY: lines as is. This is probably also useful if we are going to make the benchmark driver smarter and allow it for example to run a benchmark multiple times and aggregate the times :) In fact I started hacking on this and may have a proof of concept for this in the next days...

asl added a subscriber: asl.Oct 26 2015, 9:55 PM
asl added inline comments.
CMakeLists.txt
2

I guess the real case is what are the "default" versions available on different systems we're going to support.

jmolloy marked 2 inline comments as done.Oct 27 2015, 7:04 AM

Hi guys,

Thanks for the quick feedback! Chris, I've added those dependencies. I still need to work out exactly what to do with timeit versus timeit.sh and add logic for switching between one or the other, although Mattias' patch in D14106 supersedes this.

I've removed the python script as Renato has kindly run it to generate the CMakeLists.txt and will check that in when this one is approved.

If you're happy, shall we get this in tree?

Cheers,

James

jmolloy updated this revision to Diff 38541.Oct 27 2015, 7:05 AM
jmolloy edited edge metadata.
jmolloy added inline comments.
CMakeLists.txt
2

My unscientific straw poll of LLVM users inside ARM says that 2.8.12.2 is still the minimum we can expect - Ubuntu 14.10 LTS still ships this, I'm afraid, and as it's the latest LTS I'm not sure it's old enough to deprecate.

I could not get lit to show the commandlines of tests that do not fail. This would be very nice to have for the benchmarks.

This has been a feature request in the past for LIT, and honestly I thought it got implemented. A grep in my inbox turns up nothing though, so maybe I was delusional. Either way, it seems like a good feature to add to LIT and we should do that.

James

beanz accepted this revision.Oct 27 2015, 9:58 AM
beanz edited edge metadata.

LGTM. One comment below, more for posterity than anything else.

CMakeLists.txt
2

The minimum version is dictated per-project, there is no global expectation. There is more burden involved in raising a version, than creating a new project with a higher minimum requirement, which is why I asked that we consider moving this up (to avoid having to move it up later).

We don't have any requirement or expectation that we will support the version of tools in an LTS Linux release. We have had this conversation numerous times, and it is not considered unreasonable that we might in the future request that Linux users behave like all the other users of LLVM and acquire their own copies of CMake (neither OS X nor Windows ship CMake or package managers). The reason LLVM and Clang haven't raised their minimum versions is that we haven't had compelling reasons to justify the change.

I believe that starting a new build system free of version-based checks is compelling reason to start this new project with a higher minimum version. Ideally I would want this to require at least CMake 3.2 which has been out for 6 months or so. That said, my personal preference for trying to push forward our CMake version isn't motivation enough to argue about landing this patch.

This revision is now accepted and ready to land.Oct 27 2015, 9:58 AM
tra added a subscriber: tra.Oct 28 2015, 10:43 AM
tra added inline comments.
cmake/modules/SingleMultiSource.cmake
139

When test suite is configured as part of whole llvm+projects+clang tree CMAKE_SOURCE_DIR points to the top of the tree and there's no lit-test-template.in there.

Perhaps you should use PROJECT_SOURCE_DIR here.

beanz added inline comments.Oct 28 2015, 10:48 AM
cmake/modules/SingleMultiSource.cmake
139

We should actually probably put a check in prohibiting building the test-suite in-tree. It doesn't work properly if you build it in-tree because it will use the system compiler not the just-built clang.

cmatthews accepted this revision.Oct 28 2015, 10:53 AM
cmatthews edited edge metadata.
tra added inline comments.Oct 28 2015, 11:31 AM
CMakeLists.txt
68

Timeit ends up being $CMAKE_BINARY_DIR/bin/timeit if test-suite is configured as part of llvm tree.

MatzeB added a comment.EditedOct 28 2015, 1:17 PM

Timeit ends up being $CMAKE_BINARY_DIR/bin/timeit if test-suite is configured as part of llvm tree.

Note that I will soon commit http://reviews.llvm.org/D14106 which will make this bit obsolete (as lit will insert the timeit/RunSafely calls then).

Disregard that, I was thinking about the timeit reference in the .test template file not this one.

jmolloy closed this revision.Apr 27 2016, 7:26 AM