[Bug lto/65544] New: LTO link fails with -static-libstdc++ + weak new/delete operators
t.poechtrager at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Mar 24 19:15:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65544
Bug ID: 65544
Summary: LTO link fails with -static-libstdc++ + weak
new/delete operators
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: lto
Assignee: unassigned at gcc dot gnu.org
Reporter: t.poechtrager at gmail dot com
$ cat test.cpp
#include <malloc.h>
#include <stdlib.h>
#include <stddef.h>
#define WEAK __attribute__((weak))
WEAK void *operator new(size_t size) throw()
{
void *p = malloc(size);
if(!p) abort();
return p;
}
WEAK void *operator new[](size_t size) throw()
{
void *p = malloc(size);
if(!p) abort();
return p;
}
WEAK void operator delete(void *p) throw() { if(p) free(p); }
WEAK void operator delete(void *p, size_t) throw() { if(p) free(p); }
WEAK void operator delete[](void *p) throw() { if(p) free(p); }
WEAK void operator delete[](void *p, size_t) throw() { if(p) free(p); }
int main(){}
$ i686-w64-mingw32-g++ test.cpp -static-libstdc++ # works
$ i686-w64-mingw32-g++ test.cpp -flto # works
$ g++ test.cpp -flto -static-libstdc++ # native g++ works too
$ g++ test.cpp -flto -static-libstdc++ -m32 # 32-bit is no problem
either
$ i686-w64-mingw32-g++ test.cpp -flto -static-libstdc++
`__ZdlPv' referenced in section `.text$_ZNSt9exceptionD0Ev' of
/opt/compiler/mingw-w64/lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/lib/../lib/libstdc++.a(eh_exception.o):
defined in discarded section `.text' of /tmp/cc4sS08t.o (symbol from plugin)
`__ZdlPv' referenced in section `.text$_ZNSt13bad_exceptionD0Ev' of
/opt/compiler/mingw-w64/lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/lib/../lib/libstdc++.a(eh_exception.o):
defined in discarded section `.text' of /tmp/cc4sS08t.o (symbol from plugin)
`__ZdlPv' referenced in section `.text$_ZN10__cxxabiv115__forced_unwindD0Ev' of
/opt/compiler/mingw-w64/lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/lib/../lib/libstdc++.a(eh_exception.o):
defined in discarded section `.text' of /tmp/cc4sS08t.o (symbol from plugin)
`__ZdlPv' referenced in section
`.text$_ZN10__cxxabiv119__foreign_exceptionD0Ev' of
/opt/compiler/mingw-w64/lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/lib/../lib/libstdc++.a(eh_exception.o):
defined in discarded section `.text' of /tmp/cc4sS08t.o (symbol from plugin)
`__ZdlPv' referenced in section
`.text$_ZN9__gnu_cxx24__concurrence_lock_errorD0Ev[__ZN9__gnu_cxx24__concurrence_lock_errorD0Ev]'
of
/opt/compiler/mingw-w64/lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/lib/../lib/libstdc++.a(eh_alloc.o):
defined in discarded section `.text' of /tmp/cc4sS08t.o (symbol from plugin)
`__ZdlPv' referenced in section
`.text$_ZN9__gnu_cxx26__concurrence_unlock_errorD0Ev[__ZN9__gnu_cxx26__concurrence_unlock_errorD0Ev]'
of
/opt/compiler/mingw-w64/lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/lib/../lib/libstdc++.a(eh_alloc.o):
defined in discarded section `.text' of /tmp/cc4sS08t.o (symbol from plugin)
`__ZdlPv' referenced in section
`.text$_ZN10__cxxabiv120__si_class_type_infoD0Ev' of
/opt/compiler/mingw-w64/lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/lib/../lib/libstdc++.a(si_class_type_info.o):
defined in discarded section `.text' of /tmp/cc4sS08t.o (symbol from plugin)
`__ZdlPv' referenced in section `.text$_ZNSt9type_infoD0Ev' of
/opt/compiler/mingw-w64/lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/lib/../lib/libstdc++.a(tinfo.o):
defined in discarded section `.text' of /tmp/cc4sS08t.o (symbol from plugin)
`__ZdlPv' referenced in section `.text$_ZN10__cxxabiv117__class_type_infoD0Ev'
of
/opt/compiler/mingw-w64/lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/lib/../lib/libstdc++.a(class_type_info.o):
defined in discarded section `.text' of /tmp/cc4sS08t.o (symbol from plugin)
collect2: error: ld returned 1 exit status
Is this a bug?
Version:
$ i686-w64-mingw32-g++ -v
Using built-in specs.
COLLECT_GCC=i686-w64-mingw32-g++
COLLECT_LTO_WRAPPER=/opt/compiler/mingw-w64/libexec/gcc/i686-w64-mingw32/4.9.2/lto-wrapper
Target: i686-w64-mingw32
Configured with: ../configure --prefix=/opt/compiler/mingw-w64
--target=i686-w64-mingw32 --with-gnu-ld --with-gnu-as
--enable-languages=c,c++,lto --disable-multilib --enable-lto
--enable-threads=posix
Thread model: posix
$ i686-w64-mingw32-ld -v
GNU ld (GNU Binutils) 2.25
For the native one:
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
4.9.2-10ubuntu10' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.9 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-vtable-verify
--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-4.9-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-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
Thread model: posix
gcc version 4.9.2 (Ubuntu 4.9.2-10ubuntu10)
$ ld -v
GNU ld (GNU Binutils for Ubuntu) 2.25
More information about the Gcc-bugs
mailing list