[Qt-creator] Bundling clang (for code model) with qt-creator package

Nikolai Kosjar nikolai.kosjar at qt.io
Mon Dec 12 11:39:34 CET 2016


On 12/12/2016 03:13 AM, Andrzej Telszewski wrote:
> *1) Configure, build and temporarily install LLVM:*
>
> $ tar xvf llvm-3.9.0.src.tar.xz
> $ mv llvm-3.9.0.src llvm-src
> $ cd llvm-src/tools
> $ tar xvf cfe-3.9.0.src.tar.xz
> $ mv cfe-3.9.0.src clang
> $ cd -
> $ cd llvm-src
>
> $ mkdir build
> $ cd build
> $ cmake \
>     -DCMAKE_INSTALL_PREFIX=/tmp/llvm-ins \
>     -DCMAKE_BUILD_TYPE=Release \
>     -G "Unix Makefiles" \
>     -DLLVM_BUILD_TOOLS=OFF \
>     -DLLVM_INCLUDE_EXAMPLES=OFF \
>     -DLLVM_INCLUDE_TESTS=OFF \
>     -DLLVM_ENABLE_RTTI=ON \
>     -DLLVM_TARGETS_TO_BUILD="X86" \
>     ..
>   $ make
>   $ make install
>   $ # We disabled building of all the tools, but we still need some.
>   $ make llvm-config
>   $ cp -a bin/llvm-config /tmp/llvm-ins/bin
> $ cd -
>
> Questions:
> 1. In build_clang.py, depending on "bitness" (which I guess is x86 vs
> x86_64), you set -DLLVM_TARGETS_TO_BUILD=X86 in the case of 32 bits and
> -DLLVM_TARGETS_TO_BUILD=AArch64 in the case of 64 bits. Why is it so? In
> particular, why AArch64?
> 2. As you can see, I passed some additional flags (not found in
> build_clang.py), like -DLLVM_BUILD_TOOLS=OFF, mainly to shorten the
> build time. Can you think of any troubles I might get with the cmake
> configuration as you see above?

I'm not know what exactly LLVM_BUILD_TOOLS=OFF excludes. But at least 
the clang soures are located in a "tools" directory within LLVM 
(${LLVM_SOURCE}/tools/clang), so you might want to double check whether 
the clang executable was really build (needed for the clang static 
analyzer).

Except the clang executables and llvm-config no other executable from 
LLVM should be required.

> 3. Are there any important flags missing compared to the ones generated
> by build_clang.py?

No.

Note also that nowadays Qt Creator's README.md includes instructions to 
get/build llvm/clang:

   http://code.qt.io/cgit/qt-creator/qt-creator.git/tree/README.md
   Section "## Get LLVM/Clang for the Clang Code Model"

> 4. Are there any other flags that would be worth adding? Please note
> that I removed -DCMAKE_C_FLAGS and -DCMAKE_CXX_FLAGS for clarity, I
> actually have them in my real build/packaging script.

If you find other flags worth adding, share them with us :)

> When it comes to build_clang.py, this script expects some environment
> variables, like PKG_NODE_ROOT, CLANG_BRANCH, and more:
> 1. Where do they come from? How can I get them? :-)
> 2. How can I determine which exact versions of software and any other
> flags you used to create the given QTC release?
> 3. There is apply_patches(): how can I know if you applied some patches
> and if so, where can I find them?
>
> *2) Configure, build and temporarily install QTC:*
>
> $ tar xvf qt-creator-opensource-src-4.2.0-rc1.tar.xz
> $ cd qt-creator-opensource-src-4.2.0-rc1
> $ qmake-qt5 qtcreator.pro \
>     QTC_PREFIX=/usr \
>     IDE_LIBRARY_BASENAME=lib \
>     LLVM_INSTALL_DIR=/tmp/llvm-ins \
>     QBS_INSTALL_DIR=/usr
> $ make
> $ make install INSTALL_ROOT=/tmp/qtc-ins
> $ make docs
> $ make install_docs INSTALL_ROOT=/tmp/qtc-ins
>
> $ # Install LLVM/Clang bits needed for running QTC.
> $ mkdir -p /tmp/qtc-ins/usr/libexec/qtcreator/clang/bin
> $ cp -a /tmp/llvm-ins/bin/clang
> /tmp/qtc-ins/usr/libexec/qtcreator/clang/bin
> $ cp -a /tmp/llvm-ins/bin/clang-3.9
> /tmp/qtc-ins/usr/libexec/qtcreator/clang/bin
> $ mkdir -p /tmp/qtc-ins/usr/lib/qtcreator
> $ cp -a /tmp/llvm-ins/lib/libclang.so* /tmp/qtc-ins/usr/lib/qtcreator
> $ mkdir -p /tmp/qtc-ins/usr/libexec/qtcreator/clang/lib/clang
> $ cp -a /tmp/llvm-ins/lib/clang/*
> /tmp/qtc-ins/usr/libexec/qtcreator/clang/lib/clang
>
> Questions:
> 1. In deployqt.py, you tweak rpath-s, but I found that simply copying
> libclang into /tmp/qtc-ins/usr/lib/qtcreator just works. So is this step
> necessary? As a side note, I'm only bundling clang, as all the other
> libraries (including Qt) are already installed system-wide.
>
> *3. I create the package out of /tmp/qtc-ins and I'm done.*
>
> General question:
> Have I missed something? ;-)
>
> Some final notes:
> - I'm building on x86_64 system,
> - both Clang Code Model and Clang Static Analyzer seem to work just fine
> with the described build/install instructions,
> - although I tried hard not to make a mistake, there might be some
> somewhere. I extracted and tweaked the commands from my build script for
> clarity. Anyways, the build and packaging works as expected using my
> build script.
>
> I know I asked quite some count of questions.
> Thanks in advance for the help!
>




More information about the Qt-creator mailing list