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
-fuse-ld=gold
explicitly solves the problem. – Evadnee-fuse-ld=gold
solves it though. Thanks! – Indoiranian-fuse-ld=gold
solves the issue. Anyone submitted a bug report? – Urnfieldlld
linker with sanitizers on ubuntu, because it is notgold
but still unrecognizes--push-state
– Muslim