- 在GCC-6.1中不使用金链接器 [英] -fsanitize not using gold linker in GCC-6.1

查看:241
本文介绍了 - 在GCC-6.1中不使用金链接器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新(2016年9月30日)



gcc-6.2的Ubuntu版本((Ubuntu 6.2.0-3ubuntu11〜16.04)6.2.0 20160901)no






我使用gcc-6.1的Ubuntu版本(1)((Ubuntu 6.1。 1-3ubuntu11〜14.04.1)6.1.1 20160511),GNU binutils 2.24和支持GLIBCXX_3.4.22的libstdc ++。即使是在一个简单的hello world程序中,指定一个杀毒软件也不会强制使用gold linker。

main.cpp



  #include< iostream> 
int main(){
std :: cout<< 你好,世界!\ n;

$ / code>

编译和链接

  g ++ -fsanitize = address -c -o main main.cpp 
g ++ -fsanitize = address -o main main.o

给出错误

  / usr / bin / ld:无法识别的选项'--push-state'
/ usr / bin / ld:对使用信息使用--help选项
collect2:错误:ld返回1退出状态

这表明 -fsanitize 选项没有选择黄金链接器。当然,简单的解决方法是在链接过程中使用 -fuse-ld = gold ,但以前的gcc版本在使用杀毒软件时并不需要。例如,这个代码在gcc-5.3和4.9(都是Ubuntu版本)下工作得很好。是否有其他人在非Ubuntu版本的gcc-6.1上遇到这个问题? Ubuntu构建破坏了吗?






[1]建立了以下标志(gcc-5.3和gcc-4.9被构建只有名称和后缀不同)

   -  with-pkgversion ='Ubuntu 6.1.1-3ubuntu11〜14.04.1 '
--with-bugurl = file:///usr/share/doc/gcc-6/README.Bugs
--enable-languages = c,ada,c ++,java,go,d ,fortran,objc,obj-c ++
--prefix = / usr
- 程序后缀= -6
- 启用共享
- 启用链接器 - 创建-id
--libexecdir = / usr / lib
--without-included-gettext
--enable-threads = posix
--libdir = / usr / lib
--enable-nls
--with-sysroot = /
--enable-clocale = gnu
--enable-libstdcxx - debug
--enable-libstdcxx- time = yes
--with-default-libstdcxx-abi =兼容gcc4的
--disable-libstdcxx -double-abi
--enable-gnu-unique-object
--disable-vtable-verify
--enable-libmpx
--enable-plugin
--with-system-zlib
--disable-browser-plugin
--enable-java-awt = gtk
--enabl e-gtk-cairo
--with-java-home = / usr / lib / jvm / java-1.5.0 -gcj-6-amd64 / jre
--enable -java-home
--with-jvm-root-dir = / usr / lib / jvm / java-1.5.0-gcj-6-amd64
--with-jvm-jar-dir = / usr / lib / jvm -exports / java-1.5.0-gcj-6-amd64
--with-arch-directory = amd64
--with-ecj-jar = / usr / share / java / eclipse-ecj。 jar
--enable-objc-gc
--enable-multiarch
--disable-werror
--with-arch-32 = i686
--with -abi = m64
--with-multilib-list = m32,m64,mx32
- 启用multilib
--with-tune =通用
- 启用检查= release
--build = x86_64-linux-gnu
--host = x86_64-linux-gnu
--target = x86_64-linux-gnu

$ b $ b

  -fuse-ld = gold 


Update (30-Sept-2016)

The Ubuntu build of gcc-6.2 ((Ubuntu 6.2.0-3ubuntu11~16.04) 6.2.0 20160901) no longer has this issue.


I'm using the Ubuntu build of gcc-6.1[1] ((Ubuntu 6.1.1-3ubuntu11~14.04.1) 6.1.1 20160511), GNU binutils 2.24, and libstdc++ with GLIBCXX_3.4.22 support. Even on a simple "hello world" program, specifying a sanitizer is not forcing use of the gold linker.

main.cpp

#include <iostream>
int main() {
    std::cout << "Hello, world!\n";
}

Compiling and linking

g++ -fsanitize=address -c -o main main.cpp
g++ -fsanitize=address -o main main.o

gives the error

/usr/bin/ld: unrecognized option '--push-state'
/usr/bin/ld: use the --help option for usage information
collect2: error: ld returned 1 exit status

Which indicates the -fsanitize option isn't selecting the gold linker. Of course, the simple fix is to use -fuse-ld=gold during linking, but previous builds of gcc didn't need this when using the sanitizers. For example, this code works perfectly fine under gcc-5.3 and 4.9 (both are Ubuntu builds). Is anyone else having this issue with non-Ubuntu builds of gcc-6.1? Are the Ubuntu builds broken?


[1] Built with the following flags (gcc-5.3 and gcc-4.9 were built with only differences in the names and suffixes)

--with-pkgversion='Ubuntu 6.1.1-3ubuntu11~14.04.1'
--with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++
--prefix=/usr
--program-suffix=-6
--enable-shared
--enable-linker-build-id
--libexecdir=/usr/lib
--without-included-gettext
--enable-threads=posix
--libdir=/usr/lib
--enable-nls
--with-sysroot=/
--enable-clocale=gnu
--enable-libstdcxx-debug
--enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=gcc4-compatible
--disable-libstdcxx-dual-abi
--enable-gnu-unique-object
--disable-vtable-verify
--enable-libmpx
--enable-plugin
--with-system-zlib
--disable-browser-plugin
--enable-java-awt=gtk
--enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre
--enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64
--with-arch-directory=amd64
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc
--enable-multiarch
--disable-werror
--with-arch-32=i686
--with-abi=m64
--with-multilib-list=m32,m64,mx32
--enable-multilib
--with-tune=generic
--enable-checking=release
--build=x86_64-linux-gnu
--host=x86_64-linux-gnu
--target=x86_64-linux-gnu

解决方案

For me the same problem and same solution using

 -fuse-ld=gold

这篇关于 - 在GCC-6.1中不使用金链接器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆