Page 1 of 1

building Clang instructions

Posted: Mon Mar 18, 2013 2:37 am
by petah
(CL git head @ Debian Wheezy x64)

I was in the middle of trying to replace gcc with Clang when I realized LLVM's svn trunk will fetch the in-progress version 3.3, which also has renamed headers:

Code: Select all

./llvm/build-release/Release/lib/clang/3.3/include/
Since CL ships with Clang 3.2 headers, is that the version one should get?

Code: Select all

svn co http://llvm.org/svn/llvm-project/llvm/tags/RELEASE_32/final llvm
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/tags/RELEASE_32/final clang
Building Clang/Linux with cmake has a few caveats:

- requires "libxml2-dev" or barfs with "Could NOT find LibXml2 (missing: LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR)"
- without specifying an architecture it builds ALL possible targets (Windows only does x86 by default)
- the default for -DCLLVM_ENABLE_THREADS is 1, not sure if it's the intended goal

Code: Select all

cd ..
mkdir build-release
cd build-release
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" ..
I think the vanilla ../configure+make instructions build faster than with cmake, maybe because the following default to 1

LLVM_BUILD_TOOLS
LLVM_INCLUDE_TOOLS
LLVM_INCLUDE_EXAMPLES
LLVM_INCLUDE_TESTS
LLVM_ENABLE_WARNINGS
LLVM_ENABLE_PEDANTIC

any guidance about which are actually needed?

if using LLVM trunk, after copying the Clang lib over to CL, should the Clang headers be copied over too?

Code: Select all

rm -r (...)codelitegit/sdk/clang/Linux/<i386 | x86_64>/lib/clang
cp -r (...)llvm/build-release/Release/lib/clang (...)/codelitegit/sdk/clang/Linux/<i386 | x86_64>/lib/
Btw according to llvm.org docs, its git mirror (http://llvm.org/git/llvm.git) contains only trunk, not previous releases.

thx!

-- p

Re: building Clang instructions

Posted: Mon Mar 18, 2013 8:46 am
by eranif
petah wrote:I was in the middle of trying to replace gcc with Clang
codelite makes use of clang for code completion purposes. So it does not really matter if the headers were renamed
petah wrote:Since CL ships with Clang 3.2 headers, is that the version one should get?
If your plans are to use clang for building - then yes, get a stable release not svn trunk
petah wrote:Building Clang/Linux with cmake has a few caveats:
The instructions on the wiki page were intended for Windows users, on linux use these instructions:

http://codelite.org/Developers/HomePage#toc2

But again, these instructions are meant for the code completion - you might want to use a different configure line for building clang for production, something like:

Code: Select all

../configure --enable-optimized --disable-assertions --disable-debug --disable-shared
and also, run:

Code: Select all

sudo make install
Eran