32-bit x86LLVM,KLEE安装

kain posted @ 2011年10月31日 11:01 in Linux with tags llvm klee llvm-gcc , 4052 阅读

1

先在网上下载了LLVM2.8的代码,然后解压到

 

 

 

 

 

 

llvm-2.8文件夹

 

 

 

 

 

 

 

 

$ curl -O http://llvm.org/releases/2.8/llvm-2.8.tgz 
$ tar zxvf llvm-2.8.tgz 
$ cd llvm-2.8 
$ ./configure --enable-optimized --enable-assertions

 

 

 

 

 

 

 

后半句的作用就是使用代码优化


$ make

   make install

 

 

2

安装LLVM-gcc

在网上下载LLVM 2.8 release of llvm-gcc 源码

解压到llvm-gcc文件夹

然后在与llvm-gcc等同的目录下创建obj,install文件夹

进入obj文件夹下

执行配置命令

../llvm-gcc4.2-x.y.source/configure --prefix=`pwd`/../install --program-prefix=llvm --enable-llvm=$LLVMOBJDIR --enable-languages=c,c++$EXTRALANGS $TARGETOPTIONS --target=i686-pc-linux-gnu --with-tune=generic --with-arch=pentium4

说明:

 

 

 

 

 

 

 

--prefix=`pwd`/../install安装在了等级的install文件(刚刚创建的)

 

 

 

 

 

 

 

 

生成make $BUILDOPTIONS

 

然后make install

 

 

 

 

 

 

 

make是用来编译的,它从Makefile中读取指令,然后编译。
make install是用来安装的,它也从Makefile中读取指令,安装到指定的位置。

添加路径到  vim ~/.bash_profile

source ~/.bash_profile使路径立即生效

 

 

 

 

 

 

 

重新make了llvm,使用了configure -h 查看帮助

除了上面两个选项外,又重新增加了指定llvmgcc,llvmg++的绝对路径(不然make check的时候会有问题,而且编译uClibc的时候要改变$LLVMGCC到llvmgcc的绝对路径)

 

 

3.安装KLEE

3.1先安装uClibc

 

$ tar zxvf klee-uclibc-0.01.tgz 

 

 

 

 

 

 

 

$ ./configure --with-llvm=path/to/llvm 
$ make

这时候出现了问题,说什么找不到,主要是自动生成的Makefile的问题,这时候修改Rules.mak中tool的路径(在llvm下面,Realease+Assert/bin)

 

在make

3.2安装KLEE

 

下载

配置

 

 

 

 

 

./configure --with-llvm=path/to/llvm --with-uclibc=path/to/klee-uclibc --enable-posix-runtime

 

make

 

 

 

 

 

这时候的make check就可以通过了

 

小技巧:find /fse/ | xargs grep  “llvm”

查找/fse/文件夹下面的文件,谁的内容有llvm               

Avatar_small
dbl 说:
2014年5月28日 15:35

make的时候出现很多错误
sic'
make[1]: *** [Intrinsic/.makeall] Error 2
make[1]: Leaving directory `/home/qwe/Downloads/klee/runtime'
求救

Avatar_small
dbl 说:
2014年5月28日 15:36

/usr/include/assert.h:71: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘extern’
/usr/include/assert.h: In function ‘__assert_perror_fail’:
/usr/include/assert.h:79: error: expected declaration specifiers before ‘__THROW’
/usr/include/assert.h:85: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__THROW’
/usr/include/assert.h:88: error: expected declaration specifiers before ‘__END_DECLS’
In file included from /home/qwe/Downloads/klee/include/klee/klee.h:13,


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter