building clang outside the LLVM source tree

Hi,

I intend to build clang packages for Debian. I understand that clang should
be built alongside LLVM because clang is a moving target right now, however, I
intend to build at a 'point-in-time' i.e. the same version of clang that was
tagged when LLVM was last released.

I have a few questions:

- Is it possible to build clang outside the LLVM source tree? i.e. I have a
  version of LLVM installed somewhere and I would like to use the headers and
  the libraries that were installed. My guess is that llvm-config has been
  provided for doing this.

- To do the above, do I have to craft my own build system? I poked around and
  got a feeling that the clang build system depends on a 'source' location of
  LLVM, and clang is expected to be somewhere in the same source tree as LLVM.

These Debian packages are for the Debian 'experimental' distribution (because
clang hasn't been officially released yet) but a few days after uploading to
experimental, people using Debian unstable and testing will likely be able to
use unmodified binary packages.

Also, the current plan is to create the following binary packages from the
clang source:

clang - will have the driver and other programs
clang-dev - the headers and static libraries
clang-doc - the documentation

In a situation like this, I would've ideally created a clang-lib package also
with shared libraries. But I intend to do that only when clang is released
officially. Please do let me know if this sounds reasonable.

Regards,

Giridhar

Y Giridhar Appaji Nag wrote:

Hi,

I intend to build clang packages for Debian. I understand that clang should
be built alongside LLVM because clang is a moving target right now, however, I
intend to build at a 'point-in-time' i.e. the same version of clang that was
tagged when LLVM was last released.

I have a few questions:

- Is it possible to build clang outside the LLVM source tree? i.e. I have a
  version of LLVM installed somewhere and I would like to use the headers and
  the libraries that were installed. My guess is that llvm-config has been
  provided for doing this.

- To do the above, do I have to craft my own build system? I poked around and
  got a feeling that the clang build system depends on a 'source' location of
  LLVM, and clang is expected to be somewhere in the same source tree as LLVM.

If you have an LLVM source tree, it should be possible to put Clang into
its own directory and simply adjust the LEVEL variable in Clang's root
Makefile.

If you don't, it *should* be possible to build Clang by copying
Makefile.common and Makefile.rules to its directory, and generating an
appropriate Makefile.config, then setting LEVEL to the current
directory. Aside from all the things defined in the normal config, it
would also have to set the paths to the compiled tools.

But I'm not 100% sure if that will work.

These Debian packages are for the Debian 'experimental' distribution (because
clang hasn't been officially released yet) but a few days after uploading to
experimental, people using Debian unstable and testing will likely be able to
use unmodified binary packages.

Also, the current plan is to create the following binary packages from the
clang source:

clang - will have the driver and other programs
clang-dev - the headers and static libraries
clang-doc - the documentation

In a situation like this, I would've ideally created a clang-lib package also
with shared libraries. But I intend to do that only when clang is released
officially. Please do let me know if this sounds reasonable.
  

Sounds reasonable to me. I personally have no idea how to create shared
Clang libraries, though.

Sebastian

Y Giridhar Appaji Nag wrote:
> - Is it possible to build clang outside the LLVM source tree? i.e. I have a
>
> - To do the above, do I have to craft my own build system? I poked around and

If you have an LLVM source tree, it should be possible to put Clang into

If you don't, it *should* be possible to build Clang by copying
Makefile.common and Makefile.rules to its directory, and generating an
appropriate Makefile.config, then setting LEVEL to the current
directory. Aside from all the things defined in the normal config, it
would also have to set the paths to the compiled tools.

But I'm not 100% sure if that will work.

I was actually trying this, and had to modify the Makefile.config (generated
when LLVM was built) quite a bit, so I was wondering if this is the intended
way to go about it.

In any case, sounds like it is safe to assume that instructions on
http://llvm.org/docs/Projects.html mostly concern projects that are built when
the LLVM source tree is also available.

> In a situation like this, I would've ideally created a clang-lib package also
> with shared libraries. But I intend to do that only when clang is released
> officially. Please do let me know if this sounds reasonable.
>
Sounds reasonable to me. I personally have no idea how to create shared
Clang libraries, though.

I was assuming --enable-shared in LLVM ./configure would enable this, I might
be wrong.

Cheers,

Giridhar

I wouldn't suggest building clang binaries based on shared libraries;
it'll be a significant performance hit.

-Eli