【问题标题】:sparse - Fixing build warningssparse - 修复构建警告
【发布时间】:2013-08-09 13:28:25
【问题描述】:

我正在编译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
抄送目标.o
CC parse.o
CC tokenize.o
CC 预处理.o
CC 符号.o
CC lib.o
抄送范围.o
CC 表达式.o
CC show-parse.o
CC 评估.o
CC 展开.o
CC inline.o
CC 线性化.o
CC char.o
CC 排序.o
抄送分配.o
CC compat-linux.o
CC ptrlist.o
CC 流.o
抄送 cse.o
CC 简化.o
抄送备忘录.o
CC liveness.o
CC 存储.o
CC unssa.o
CC dissect.o
AR libsparse.a
LINK 测试词法分析
CC test-parsing.o
LINK 测试解析
CC 混淆.o
LINK 混淆
CC 编译.o
CC compile-i386.o
compile-i386.c:在函数'emit_insn_atom'中:
compile-i386.c:719:7:警告:忽略'write'的返回值,用属性warn_unused_result [-Wunused-result]声明强>
LINK编译
抄送图.o
链接图
CC 稀疏.o
链接稀疏
CC test-linearize.o
LINK 测试线性化
抄送例子.o
链接示例
CC test-unssa.o
LINK 测试-unssa
CC test-dissect.o
LINK 测试剖析
CC ctags.o
链接 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: 未找到
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 

【问题讨论】:

    标签: linux-kernel


    【解决方案1】:

    正确安装 llvm :

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

    $ 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.cline 719 处调用 write() 的结果

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

    修复此错误很简单,只需将 compile-i386.cline 719 修改为

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

    由于在 Makefile

    第 16 行 向 gcc 传递了 -Wall(启用所有警告)标志,因此在构建期间触发了此警告

    CFLAGS += -Wall -Wwrite-strings

    【讨论】:

    • 感谢 TheCodeArtist。我试过你的建议来安装 llvm。但它会在那里引发更多错误。安装日志附加有问题。
    • 抱歉,我无法将构建日志附加到问题中,因此我将其添加到以下答案部分。再次感谢。
    • 用确切的细节/步骤更新了我的答案,以成功下载和构建稀疏。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-31
    • 1970-01-01
    • 1970-01-01
    • 2019-12-07
    • 2019-10-21
    • 2019-08-08
    • 2020-11-28
    相关资源
    最近更新 更多