1

我正在编译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,禁用测试检查
Makefile:79:您的系统没有 llvm,禁用 sparse-llvm

CC test-lexing.o
CC target.o
CC parse.o
CC tokenize.o
CC pre-process.o
CC 符号。 o
CC lib.o
CC 范围.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 simple.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混淆
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 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 测试剖析
CC ctags.o
LINK ctags
GEN sparse.pc

修复以下
Makefile:63:您的系统没有libxml,禁用c2xml
Makefile:75:您的系统没有libgtk2,禁用test-inspect

经过:

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

为了

/bin/sh: 1: llvm-config: not found
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 的建议,这里是 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 
4

1 回答 1

0

正确安装 llvm :

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

$ sudo apt-get install llvm

下载最新的sparse源码

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

构建和安装稀疏

$ cd sparse
$ make
$ make install

在 Ubuntu 10.04 上测试


修复无害的警告:

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

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

修复这个错误就像修改compile-i386.c第 719 行一样简单

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

由于在Makefile的第 16 行-Wall传递给 gcc 的 (Enable ALL warnings) 标志,在构建期间会触发此警告

CFLAGS += -Wall -Wwrite-strings

于 2013-08-09T03:19:24.100 回答