用clang编译SPEC2006 过程中的问题(与gcc,ld相关)

来源:互联网 发布:数据接口大全 编辑:程序博客网 时间:2024/06/15 22:07

1. 重复定义__strcspn_c1

编译401.bzip2时错误

/usr/include/bits/string2.h:972: multiple definition of `__strcspn_c1'
bgm.o:/usr/include/bits/string2.h:972: first defined here
dinkini.o: In function `__strcspn_c2':
/usr/include/bits/string2.h:983: multiple definition of `__strcspn_c2'
bgm.o:/usr/include/bits/string2.h:983: first defined here
dinkini.o: In function `__strcspn_c3':
/usr/include/bits/string2.h:996: multiple definition of `__strcspn_c3'
bgm.o:/usr/include/bits/string2.h:996: first defined here

分析:该问题一般是在使用较老版本的gcc库时碰到,例如在centos操作系统平台上,gcc是4.1.2时会碰到该问题,问题原因SPEC中部分代码时C89,但是clang默认版本为CC89,从而导致出现该错误。更详细解释可以参考:

http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-December/027958.html

GCC从4.5开始,才完全支持C99.

https://gcc.gnu.org/c99status.html 

解决:在编译选项中添加-std=gnu89

另外, 429.mcf, 433.milc, 445.gobmk等也存在同样问题

2. 编译403.gcc是的重复定义错误

错误信息:

mp/concat-yeQL2V.o: In function `gnu_dev_major':
/usr/include/sys/sysmacros.h:44: multiple definition of `gnu_dev_major'
/tmp/alloca-YSgYzY.o:/usr/include/sys/sysmacros.h:44: first defined here
/tmp/concat-yeQL2V.o: In function `gnu_dev_makedev':
/usr/include/sys/sysmacros.h:56: multiple definition of `gnu_dev_makedev'
/tmp/alloca-YSgYzY.o:/usr/include/sys/sysmacros.h:56: first defined here
/tmp/concat-yeQL2V.o: In function `gnu_dev_minor':
/usr/include/sys/sysmacros.h:50: multiple definition of `gnu_dev_minor'
/tmp/alloca-YSgYzY.o:/usr/include/sys/sysmacros.h:50: first defined here
/usr/bin/ld: Dwarf Error: Invalid or unhandled FORM value: 25.
/usr/bin/ld: Dwarf Error: Invalid or unhandled FORM value: 25.
/usr/bin/ld: Dwarf Error: Invalid or unhandled FORM value: 25.
/usr/bin/ld: Dwarf Error: Invalid or unhandled FORM value: 25.
/usr/bin/ld: Dwarf Error: Invalid or unhandled FORM value: 25.
/usr/bin/ld: Dwarf Error: Invalid or unhandled FORM value: 25.
/usr/bin/ld: Dwarf Error: Invalid or unhandled FORM value: 25.
/usr/bin/ld: Dwarf Error: Invalid or unhandled FORM value: 25.
/usr/bin/ld: Dwarf Error: Invalid or unhandled FORM value: 25.
/usr/bin/ld: Dwarf Error: Invalid or unhandled FORM value: 25.
/tmp/getpwd-UxjZIi.o: In function `fstat':
/usr/include/sys/stat.h:449: multiple definition of `fstat'
/tmp/c-parse-7tFGiF.o:/usr/include/sys/stat.h:449: first defined here
/tmp/getpwd-UxjZIi.o: In function `fstat64':
/usr/include/sys/stat.h:498: multiple definition of `fstat64'
/tmp/c-parse-7tFGiF.o:/usr/include/sys/stat.h:498: first defined here
/tmp/getpwd-UxjZIi.o: In function `fstatat':


分析:ld版本过旧,当前版本是 

GNU ld version 2.17.50.0.6-9.el5 20061020
Copyright 2005 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.

更新后版本是

GNU ld (GNU Binutils) 2.20.1.20100303

并将该链接器添加到对应路径中,例如PATH和LD_LIBRARY_PATH

问题解决。



如果还需要编译其他C++程序,那么最好安装binutils 2.25.

http://ftp.gnu.org/gnu/binutils/

0 0