利用者:Ideasman42/BlenderClang

提供: wiki
< 利用者:Ideasman42
2018年6月29日 (金) 04:40時点におけるYamyam (トーク | 投稿記録)による版 (1版 をインポートしました)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

Installing LLVM & Clang from svn (tested on linux) inst_llvm.sh

Use this if you cant get a pre-compiled llvm/clang or if you want to have the lastest clang.

This script installs llvm & clang from source, re-running will update the installation.

#!/bin/sh

SRCDIR="/opt/src"
INSTDIR="/opt/llvm"

echo ""

if [ -d $SRCDIR/llvm/.svn ] ; then
	echo "Updating "$SRCDIR"/llvm ..."
	svn up $SRCDIR/llvm $SRCDIR/llvm/tools/clang
else
	echo "Checking out "$SRCDIR"/llvm ..."
	svn checkout http://llvm.org/svn/llvm-project/llvm/trunk $SRCDIR/llvm
	svn checkout http://llvm.org/svn/llvm-project/cfe/trunk $SRCDIR/llvm/tools/clang
fi


rm -rf $INSTDIR

mkdir $SRCDIR/llvm_cmake
cd $SRCDIR/llvm_cmake

echo ""
echo "Building..."

cmake ../llvm \
	-DCMAKE_INSTALL_PREFIX:STRING=$INSTDIR \
	-DCMAKE_BUILD_TYPE:STRING=Debug \
	-DLLVM_ENABLE_THREADS:BOOL=ON

make -j6

echo ""
echo "Installing..."

make install


cp $SRCDIR/llvm/tools/clang/tools/scan-view/scan-view $INSTDIR/bin/
cp $SRCDIR/llvm/tools/clang/tools/scan-view/*.py $INSTDIR/bin/

cp $SRCDIR/llvm/tools/clang/tools/scan-build/scan-build $INSTDIR/bin/
cp $SRCDIR/llvm/tools/clang/tools/scan-build/ccc-analyzer $INSTDIR/bin/
cp $SRCDIR/llvm/tools/clang/tools/scan-build/c++-analyzer $INSTDIR/bin/
cp $SRCDIR/llvm/tools/clang/tools/scan-build/sorttable.js $INSTDIR/bin/
cp $SRCDIR/llvm/tools/clang/tools/scan-build/scanview.css $INSTDIR/bin/

echo ""
echo "Done!"

Configuring CMake

Assuming you know about building with cmake and blender see: Dev:2.5/Doc/Building_Blender/Linux/Ubuntu/CMake

clang will need to be added to the $PATH, edit your ~/.bashrc and add this line.

export PATH=$PATH:/opt/llvm/bin

Run cmake with these args.

cmake ../blender \
	-DCMAKE_CXX_COMPILER:FILEPATH=/opt/clang/bin/c++-analyzer \
	-DCMAKE_C_COMPILER:FILEPATH=/opt/clang/bin/ccc-analyzer

note:

  • You may need to explicitly add in GCC includes, eg:
    -DCMAKE_CXX_FLAGS:STRING="-I/usr/include/c++/4.5.2 -I/usr/include/c++/4.5.2/x86_64-unknown-linux-gnu"
  • /usr/share/clang/scan-build/c++-analyzer is the default path if you use a pre-compiled build
  • on GCC 4.6 you may get an error with __extern_always_inline
    In this case you can use -DCMAKE_CXX_FLAGS:STRING="-D__extern_always_inline=inline"

Compiling Blender

The usual make in the cmake dir will build blender however clang can output nice error html like this

http://www.graphicall.org/ftp/ideasman42/2011-01-07-2/

To get this html output run...

export CCC_ANALYZER_CPLUSPLUS=1  # for C++ analysis 
scan-build -o /tmp/clang make -j6

After building (takes about an 1.5 hrs for me), you will have a directory like /tmp/clang/2011-01-07-2/ with html ouput of scan-build.

Continuous Static Checker Server

Currently we have blender static check running on a server.

This is doing C checks only because there is a header issue with clang and gcc headers on this system.