稀疏 - 修复构建警告

时间:2013-08-09 01:23:59

标签: linux-kernel

我正在编译sparse - linux内核检查工具。

但它会引发以下警告:

  

lovegcy @ knltest-VirtualBox:〜/ git_root / sparse $ make
       GEN version.h    / bin / sh:1:llvm-config:not found
   Makefile:63:您的系统没有libxml,禁用c2xml
  Makefile:75:你的系统没有libgtk2,禁用了test-inspect
  Makefile:79:你的系统没有llvm,禁用sparse-llvm

       CC test-lexing.o
       CC target.o
       CC parse.o
       CC tokenize.o
       CC预处理.o
       CC symbol.o
       CC lib.o
       CC scope.o
       CC表达.o
       CC show-parse.o
       CC评估.o
       CC expand.o
       CC inline.o
       CC linearize.o
       CC char.o
       CC sort.o
       CC allocate.o
       CC compat-linux.o
       CC ptrlist.o
       CC flow.o
       CC cse.o
       CC简化.o
       CC memops.o
       CC liveness.o
       CC storage.o
       CC unssa.o
       CC剖析.o
       AR libsparse.a
       LINK test-lexing
       CC test-parsing.o
       LINK测试解析
       CC obfuscate.o
       LINK混淆了        CC compile.o
       CC compile-i386.o
  compile-i386.c:在函数'emit_insn_atom'中:
   compile-i386.c:719:7:警告:忽略'write'的返回值,使用属性warn_unused_result声明[-Wunused-result]
       LINK编译
       CC graph.o
       链接图
       CC sparse.o
       链接稀疏
       CC test-linearize.o
       LINK test-linearize
       CC example.o
       链接示例
       CC test-unssa.o
       LINK test-unssa
       CC test-dissect.o
       LINK test-dissect
       CC ctags.o
       LINK ctags
       GEN sparse.pc

修正以下内容 Makefile:63:你的系统没有libxml,禁用c2xml
Makefile:75:您的系统没有libgtk2,禁用了test-inspect

by:

$ sudo apt-get install libxml2-dev libgtk2.0-dev

对于

  

/ bin / sh:1:llvm-config:未找到
  Makefile:79:你的系统没有llvm,禁用sparse-llvm

安装了llvm-3.2-dev,但它仍然存在。

我仍然不知道如何修复以下警告:

  

compile-i386.c:在函数'emit_insn_atom'中:
  compile-i386.c:719:7:警告:忽略'write'的返回值,使用属性warn_unused_result声明[-Wunused-result]

有人可以提出一些建议吗?

非常感谢!


更新:在TheCodeArtist's suggestion之后,这是llvm安装后的构建错误日志。

lovegcy@knltest-VirtualBox:~/git_root/sparse$ make
CC test-lexing.o
CC target.o
CC parse.o
CC tokenize.o
CC pre-process.o
CC symbol.o
CC lib.o
CC scope.o
CC expression.o
CC show-parse.o
CC evaluate.o
CC expand.o
CC inline.o
CC linearize.o
CC char.o
CC sort.o
CC allocate.o
CC compat-linux.o
CC ptrlist.o
CC flow.o
CC cse.o
CC simplify.o
CC memops.o
CC liveness.o
CC storage.o
CC unssa.o
CC dissect.o
AR libsparse.a
LINK test-lexing
CC test-parsing.o
LINK test-parsing
CC obfuscate.o
LINK obfuscate
CC compile.o
CC compile-i386.o
compile-i386.c: In function ‘emit_insn_atom’:
compile-i386.c:719:7: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
LINK compile
CC graph.o
LINK graph
CC sparse.o
LINK sparse
CC test-linearize.o
LINK test-linearize
CC example.o
LINK example
CC test-unssa.o
LINK test-unssa
CC test-dissect.o
LINK test-dissect
CC ctags.o
LINK ctags
CC c2xml.o
LINK c2xml
CC test-inspect.o
CC ast-model.o
CC ast-view.o
CC ast-inspect.o
LINK test-inspect
CC sparse-llvm.o
LINK sparse-llvm
/usr/lib/llvm-3.2/lib/libLLVMSupport.a(Signals.o): In function PrintStackTrace(void*)':
(.text+0x74): undefined reference todladdr'
/usr/lib/llvm-3.2/lib/libLLVMSupport.a(Signals.o): In function PrintStackTrace(void*)':
(.text+0x1fe): undefined reference todladdr'
/usr/lib/llvm-3.2/lib/libLLVMSupport.a(Mutex.o): In function llvm::sys::MutexImpl::MutexImpl(bool)':
(.text+0x58): undefined reference topthread_mutexattr_init'
/usr/lib/llvm-3.2/lib/libLLVMSupport.a(Mutex.o): In function llvm::sys::MutexImpl::MutexImpl(bool)':
(.text+0x64): undefined reference topthread_mutexattr_settype'
/usr/lib/llvm-3.2/lib/libLLVMSupport.a(Mutex.o): In function llvm::sys::MutexImpl::MutexImpl(bool)':
(.text+0x74): undefined reference topthread_mutexattr_setpshared'
/usr/lib/llvm-3.2/lib/libLLVMSupport.a(Mutex.o): In function llvm::sys::MutexImpl::MutexImpl(bool)':
(.text+0x88): undefined reference topthread_mutexattr_destroy'
/usr/lib/llvm-3.2/lib/libLLVMSupport.a(Mutex.o): In function llvm::sys::MutexImpl::tryacquire()':
(.text+0x179): undefined reference topthread_mutex_trylock'
/usr/lib/llvm-3.2/lib/libLLVMSupport.a(RWMutex.o): In function llvm::sys::RWMutexImpl::RWMutexImpl()':
(.text+0x3e): undefined reference topthread_rwlock_init'
/usr/lib/llvm-3.2/lib/libLLVMSupport.a(RWMutex.o): In function llvm::sys::RWMutexImpl::~RWMutexImpl()':
(.text+0x80): undefined reference topthread_rwlock_destroy'
/usr/lib/llvm-3.2/lib/libLLVMSupport.a(RWMutex.o): In function llvm::sys::RWMutexImpl::reader_acquire()':
(.text+0xb9): undefined reference topthread_rwlock_rdlock'
/usr/lib/llvm-3.2/lib/libLLVMSupport.a(RWMutex.o): In function llvm::sys::RWMutexImpl::reader_release()':
(.text+0xe9): undefined reference topthread_rwlock_unlock'
/usr/lib/llvm-3.2/lib/libLLVMSupport.a(RWMutex.o): In function llvm::sys::RWMutexImpl::writer_acquire()':
(.text+0x119): undefined reference topthread_rwlock_wrlock'
/usr/lib/llvm-3.2/lib/libLLVMSupport.a(RWMutex.o): In function llvm::sys::RWMutexImpl::writer_release()':
(.text+0x149): undefined reference topthread_rwlock_unlock'
/usr/lib/llvm-3.2/lib/libLLVMSupport.a(ThreadLocal.o): In function llvm::sys::ThreadLocalImpl::~ThreadLocalImpl()':
(.text+0x25): undefined reference topthread_key_delete'
/usr/lib/llvm-3.2/lib/libLLVMSupport.a(ThreadLocal.o): In function llvm::sys::ThreadLocalImpl::ThreadLocalImpl()':
(.text+0xae): undefined reference topthread_key_create'
/usr/lib/llvm-3.2/lib/libLLVMSupport.a(ThreadLocal.o): In function llvm::sys::ThreadLocalImpl::setInstance(void const*)':
(.text+0xe2): undefined reference topthread_setspecific'
/usr/lib/llvm-3.2/lib/libLLVMSupport.a(ThreadLocal.o): In function llvm::sys::ThreadLocalImpl::getInstance()':
(.text+0x10a): undefined reference topthread_getspecific'
/usr/lib/llvm-3.2/lib/libLLVMSupport.a(Threading.o): In function llvm::llvm_execute_on_thread(void (*)(void*), void*, unsigned int)':
(.text+0x1c2): undefined reference topthread_create'
/usr/lib/llvm-3.2/lib/libLLVMSupport.a(Threading.o): In function llvm::llvm_execute_on_thread(void (*)(void*), void*, unsigned int)':
(.text+0x1da): undefined reference topthread_join'
/usr/lib/llvm-3.2/lib/libLLVMSupport.a(Threading.o): In function llvm::llvm_execute_on_thread(void (*)(void*), void*, unsigned int)':
(.text+0x20c): undefined reference topthread_attr_setstacksize'
collect2: error: ld returned 1 exit status
make: * [sparse-llvm] Error 1 

1 个答案:

答案 0 :(得分:0)

正确安装llvm:

在构建过程中, make 要检测系统上的llvm,需要在系统上正确安装llvm-config。在Ubuntu上,将下载以下命令(~16MB包)并正确安装所有依赖项

$ sudo apt-get install llvm

下载稀疏的最新来源

$ git clone git://git.kernel.org/pub/scm/devel/sparse/sparse.git

构建并安装稀疏

$ cd sparse
$ make
$ make install

在Ubuntu 10.04上测试


修复无害的警告:

以下错误在当前上下文中是无害的,因为我们不关心在第719行 编译-i386.c中调用write()的结果

compile-i386.c:719:7: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]

修复此错误非常简单,只需将 line-i386.c 第719行修改为

即可。
comment[0] = write(STDOUT_FILENO, s, strlen(s));

由于 Makefile 第16行传递给gcc的-Wall(启用所有警告)标记,因此会在构建期间触发此警告

CFLAGS += -Wall -Wwrite-strings