用clang編譯SPEC2006 過程中的問題(與gcc,ld相關)

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/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章