[cfe-dev] Building clang outside of LLVM (with CMake)

Óscar Fuentes ofv at wanadoo.es
Wed Feb 2 17:59:48 PST 2011

Eric Christopher <echristo at apple.com> writes:

>> Apart from that, Eric, please note that we are talking about a
>> CMake-only feature. Unless you plan to change the LLVM build system (the
>> traditional one) for implementing it there is no gain at all for the
>> users on duplicating the platform tests inside the Clang tree.
> Conditionally including files into llvm based on build system is a non-starter
> for me. It's just ridiculous.

As a generic rule I agree with you, but this case is about a file
containing two macros which it is not included depending on the build
system, but depending on its existence.

However, if someone generates that header from the autoconfigured build
the conditionality goes away ;-) Seriously, though, I don't think the
divergence is serious enough to bother.

> That said, it looks like the config files are already installed by
> default when you install llvm which should solve the needing to
> configure llvm problem when building clang as a top level. There
> should still be a way for it to configure itself, but that's less of
> an issue for the cmake side of things.

IMO, as long as Clang is indivisible from LLVM, there is no reason for
not exploiting what LLVM has to offer.

> In addition, I'm sure there are a number of things that are configured
> at the top level for llvm that aren't needed for clang and for clang
> that aren't needed for llvm.

Exactly, this is what prompted this subthread. Those two macros
shouldn't be on LLVM's config.h, neither should be any mention of Clang
on LLVM's source tree.

It is an historic accident that Clang and other projects are built from
within LLVM. It was convenient to use the existing LLVM build system but
putting Clang on the same level as llvm-as is simply wrong, not only
from the conceptual point of view but as a practical matter too. The
CMake-based build will allow to treat Clang as a proper project at the
cost of conditionally including one header. That's a bargain, if you ask

More information about the cfe-dev mailing list