Is anyone using the LLDB CMake standalone build?

I thought that Zach was on Windows, but I would be surprised as I can’t get it to work with an installed Clang. It errors in the cmake step, unable to find some cmake module.

Is anyone genuinely trying to support this CMake configuration? It adds quite a bit of complexity. If so, could they fix this error or suggest how to fix it on the Clang side? (I help maintain the Clang cmake build, so I’m happy to enact any reasonable changes needed…)

This came up because I have a change to the LLDB CMake build but am currently unable to test it in a fully standalone build (IE, w/o a source tree).

-Chandler

Works for us on both Linux and Mac OS X with a quite recent trunk revision. What’s the error message?

  • Mario

We aren’t using it and I don’t think we will want to in the future.

I’m not using the standalone build on Windows, i just suffer through opening a mega solution. Reid did some work recently to make it better, but it still doesn’t totally support anyone’s needs.

The main motivation for having a standalone build is that it’s a necessary (but not necessarily sufficient) precursor to having a usable xcode solution, which is itself a necessary (but again perhaps not sufficient) precondition to moving towards a single build system.

I’m not versed enough in the LLVM core shared CMake infrastructure, but I envision a world where supporting a standalone build requires almost 0 project specific CMake code. Sadly, achieving that seems quite difficult

Debugged it.

So, the standalone build only works if you are also using the Clang standalone build, as otherwise the necessary cmake bits don’t make it to the build (or install) tree. I don’t know if that is specifically the intent, or whether it’s reasonable.

Also, the standalone build is broken in the presence of python3 on the system, but I’ve fixed that and will commit that fix shortly.

Anyways, thanks for letting me know that it is in use.

The main motivation for having a standalone build is that it’s a necessary (but not necessarily sufficient) precursor to having a usable xcode solution, which is itself a necessary (but again perhaps not sufficient) precondition to moving towards a single build system.

I’ve always assumed that the reason the apple guys don’t generate their xcode projects from cmake is that there is some magic in the xcode projects that isn’t supported by cmake-xcode project generator. Is there any truth to that?

What is the intended purpose of the LLDB CMake standalone build? If it is to build against an installed clang/llvm, it doesn’t seem like it’s worth the extra complexity…

Vince

Someone jump in and correct me if I’m wrong, but I believe there are many reasons that Apple sticks with a hand-maintained Xcode project. I will try to summarize some of the reasons here:

  1. People are more comfortable editing a native solution file than editing CMake. I certainly sympathize with this, as I also strongly prefer editing a Visual Studio solution over a CMake file. Before working on LLDB, I had actually never even written a line of CMake before.

  2. The Xcode projects generated by CMake are slow, almost to the point of being unusable. This is a widespread problem with IDEs, and indeed the MSVC generator suffers from the same problem. The issue here is related to the size of the project / solutions. Every CMake target (which ultimately translates to a static library or shared library) ends up as a project in your solution (MSVC) or target in your project (Xcode). This is the layer at which dependency analysis is performed and build parallelization is implemented, so having more projects causes tremendous slowdown in loading projects/solutions and generating information for intellisense/code completion. Visual Studio has gotten much better in this regard with recent versions, but it’s still an issue. And I think Xcode has not gotten much better in this regard. In short, an Xcode generated solution, while it will technically work, is almost unusable for performance reasons.

  3. The Xcode projects generated by CMake aren’t as pretty as hand-generated Xcode projects. It’s actually possible to make prettier generated projects by adding some stuff to the CMake, but right now they just don’t look as nice.

  4. Legacy reasons (aka old habits die hard). The LLDB group at Apple has historically treated LLVM and clang as libraries, and in the past the only supported way to build LLDB was against a known revision of clang and LLVM, and only recently (well, not recent anymore, but legacy decisions can have long lasting implications) was it changed so that LLDB is expected to always build against tip of trunk LLVM / clang. One of the things that came out of this early separation was that an Xcode build of LLDB does not even use the canonical on-disk directory hierarchy that all other LLVM subprojects use. A normal LLVM directory layout looks like this:

llvm
– tools
---- lldb
---- clang
---- lld

Since LLDB considers itself “not an LLVM subproject, but rather a standalone project which uses LLVM”, it organizes itself like this:

lldb
– llvm
---- tools
------ clang
------ lld

Of course, this is just an implementation detail, as we’ve shown that lldb can be built as a normal subproject on all other platforms using the first layout, but this basically boils down to “old habits die hard”. It’s what people are used to.

It’s certainly easy to sympathize with numbers 1, 3, and 4 but ultimately I think (or at least hope) that people would be willing to sacrifice these for the greater good of having a unified build system. Number 2 however, is probably a showstopper though.

I’m not sure just how bad the Xcode solution is in terms of performance, but it’s the primary reason why the the standalone build exists. The standalone build generates a much smaller project/solution, with only those projects and targets that are part of LLDB itself, and not projects from LLVM, clang, etc. It attempts to use an installed LLVM / clang instead of building one.

One thing that has worked very well for me on Windows is using my IDE for editing and debugging, but not for building. There’s quite a lot to like about this approach. For starters, the performance of building from inside the IDE is irrelevant now, because you’re not building from the IDE anymore. For Visual Studio this makes a huge difference, but I’m not sure if it makes a difference for Xcode. Another advantage of this approach is that honestly, ninja is just faster than everything else. It really is. And not a little bit, but a lot. I’m a big fan of my IDE and you will only pry it out of my cold dead hands, but after I tried ninja once or twice, it was obvious that it was a huge win over building from the IDE. All it takes me is typing “ninja” from a command shell. Even I can manage that. Everything else - debugging, code completion, editing experience, file browsing - still works. I just don’t hit build from inside the IDE.

It would be worth seeing if an approach like this would work well with people from Apple. Or alternatively, maybe seeing if the Xcode IDE team within apple would be willing to prioritize IDE performance in the case of these larger projects. Visual Studio seems to have come a long way here, so it doesn’t seem impossible for Xcode to improve here, it just has some work to do.

FWIW, we use exactly the setup you outlined, for the reasons you mention: CMake build to build LLDB and dependencies, XCode for debugging and code editing. We are mostly concerned with Mac OS X/iOS but are also building for Linux that way.

From an API user perspective it’s very nice to have a cross-platform build that also integrates well with CI servers.

We use the “normal” LLVM layout mentioned below. We use cmake on 64 bit Linux and Windows to set up our build environment, the build with make on Linux and msbuild on Windows (although, on my Windows box I open the solution in VS).

We package a full toolset (clang, llvm tools, lldb) together, so our lldb builds compile everything from source.

Just curious - why not ninja on Windows? As long as you run vcvars beforehand (which you have to use anyway even for an MSBuild build) the output is going to be identical to that which is produced by MSBuild, but it will be faster.

Institutional inertia? J

I’m not sure – I’m not on the build team – but I’ll forward your suggestion on to them.

Is that true now? The last time I tried ninja on windows (months ago) to full rebuild LLDB/llvm/clang it was not significantly faster and had lots of problems with the tablegen steps.

What kind of problems? ninja is the only thing I’ve used for the past 6 months and I’ve never had an issue. Granted I did have many issues in the beginning, but I’m not sure if they were ninja specific so much as just issues with LLDB not having been well supported on Windows.

I would encourange you to give it a try again. If you still have issues, make a new thread about it so we don’t derail this one. But I’m definitely curious to hear about your experience now.

The primary speed benefit from ninja comes from incremental builds, but clean ninja builds should still be faster than clean MSBuild builds as well.

So lldb is supposed to build with cmake on OS X. Last time I tried (to get lldb-mi on OS X 10.9), I failed to get that to work.
Maybe I need to fetch the lldb tree in an llvm tree I fetched first?

I've always assumed that the reason the apple guys don't generate their
xcode projects from cmake is that there is some magic in the xcode projects
that isn't supported by cmake-xcode project generator. Is there any truth
to that?

Or it's just that the Xcode generator is flaky, and tends to generate "corrupt" projects (in my experience that's true for most all KDE cmake projects).

ninja is just faster than everything else. It really is.
And not a little bit, but a lot. I'm a big fan of my IDE and you will only
pry it out of my cold dead hands, but after I tried ninja once or twice, it
was obvious that it was a huge win over building from the IDE. All it
takes me is typing "ninja" from a command shell. Even I can manage that.
Everything else - debugging, code completion, editing experience, file
browsing - still works. I just don't hit build from inside the IDE.

Seems it should be possible to set up Xcode to use (ninja as/with) an external build system ... Or you could try KDevelop, which supports cmake projects and ninja "natively" (i.e. with plugins).
Out of curiosity, does the ninja generator generate files that allow the equivalent of `make help` to get a list of known targets?
And what about install/fast?

R.

So lldb is supposed to build with cmake on OS X. Last time I tried (to get lldb-mi on OS X 10.9), I failed to get that to work.
Maybe I need to fetch the lldb tree in an llvm tree I fetched first?

It’s only going to work insofar as it’s being actively maintained. That’s the problem – most of the people on Apple platforms aren’t currently using the CMake build. So it may need some work. Please do fix any issues you find with it.

Seems it should be possible to set up Xcode to use (ninja as/with) an external build system … Or you could try KDevelop, which supports cmake projects and ninja “natively” (i.e. with plugins).
Out of curiosity, does the ninja generator generate files that allow the equivalent of make help to get a list of known targets?
And what about install/fast?

There is an msvs-ninja generator that does something similar to what you propose. You get a Visual Studio solution, but hitting “build” delegates the actual work out to ninja. This is something that has to be supported directly in CMake though, so it’s beyond the scope of what we can realistically do.

You can use ninja -t targets to get a list of targets. The CMake defines an “install” target, so all you have to do is build that target to install. “ninja install” would be the command. Various CMake variables that you specify at CMake gen time control how the components are installed. Not sure what “fast” is that you mention though.

Super late super brief comment:

I spent some time hacking the standalone LLDB build to work a few weeks ago. I got it to work for me, but I didn’t bang on it particularly hard so I’m not surprised that you’re running into issues. My hope was to get it to a place where distros could use it and IDE users could use it for the smaller project files.

It's only going to work insofar as it's being actively maintained. That's
the problem -- most of the people on Apple platforms aren't currently using
the CMake build. So it may need some work. Please do fix any issues you
find with it.

What are the prerequisites for building the CMake standalone build? The term standalone appears to be misleading; the CMake file suggests one does need to have built the rest of llvm first?

Is that also true for lldb-mi??

There is an msvs-ninja generator that does something similar to what you
propose. You get a Visual Studio solution, but hitting "build" delegates
the actual work out to ninja. This is something that has to be supported
directly in CMake though, so it's beyond the scope of what we can
realistically do.

Supposing CMake generates functional Xcode llvm projects, you could always add an additional target to it (or rather, replace the generated targets but leave the files), one that uses the external build system.
Then again, it might be easier just to import the source tree into Xcode, and add the external target.

BTW: http://milianw.de/blog/katekdevelop-sprint-2014-let-there-be-clang
http://kfunk.org/2014/04/28/gsoc-2014-improving-the-clang-integration-in-kdevelop/

an "install" target, so all you have to do is build that target to install.
"ninja install" would be the command. Various CMake variables that you
specify at CMake gen time control how the components are installed. Not
sure what "fast" is that you mention though.

From what I understand, make install/fast skips the regular make step that is executed before doing the install proper, and which can take a considerable amount of time. It's esp. nice when rebuilding/installing a sub target.

It also prints out nicely which components were (re)installed, and which were already up-to-date.

R.

+lldb-dev@cs.uiuc.edu​ since this is of general interest.

Here are build timings on my local machine comparing Ninja against MSBuild on Windows.

Ninja MSBuild
Clean Build 0:11:4.16 0:14:4.33
Changed LLDB/ArchSpec.h 0:3:3.47 0:3:51.46
Changed LLVM/StringRef.h 0:9:47.32 0:13:48.72

Thanks!

Here are build timings on my local machine comparing Ninja against MSBuild
on Windows.

That's for building lldb I presume? How does MSBuild compare to (GNU) make?

                                             Ninja MSBuild
Clean Build 0:11:4.16 0:14:4.33

That's a larger difference than I would have expected - it seems the time spent compiling is short compared to the time that could be spent tracking dependencies?

R

+Nico Weber

Nico might be able to give you some more insight on exactly why Ninja is faster than MSBuild. My (limited) understanding is that it has better dependency tracking, but I’m not sure where the “betterness” comes from.

I’m not sure how MSBuild compares to GNU Make. I’m not sure if anyone actually uses Make to build LLDB on Windows or if it even works. I know at some point, even if way off into the future, it would be nice to get rid of the configure/make build entirely. The only reason it’s still around is because it supports a few features not supported by the CMake build. If / when those issues get resolved, I think the LLVM side will try to remove it, and then we should follow suit.