[Bug 737528] New: Switching to ld linker breaks gcc -flto
![](https://seccdn.libravatar.org/avatar/3035b38ff33cf86f480bb169b8500b80.jpg?s=120&d=mm&r=g)
https://bugzilla.novell.com/show_bug.cgi?id=737528 https://bugzilla.novell.com/show_bug.cgi?id=737528#c0 Summary: Switching to ld linker breaks gcc -flto Classification: openSUSE Product: openSUSE 12.2 Version: Factory Platform: All OS/Version: Linux Status: NEW Severity: Normal Priority: P5 - None Component: Development AssignedTo: bnc-team-screening@forge.provo.novell.com ReportedBy: grabli_2005@mail.ru QAContact: qa@suse.de Found By: --- Blocker: --- User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0) I note that previously factory uses gold linker for -flto compilation. Now I update factory and see that -flto compilation breaks and ld used instead. Steps to reproduce: 1. download and unzip SOCI 3.1.0 http://downloads.sourceforge.net/project/soci/soci/soci-3.1.0/soci-3.1.0.zip 2. make it: cmake -G "Unix Makefiles" -DWITH_BOOST=OFF -DWITH_ORACLE=OFF (...) && make 3. try compile sample with -flto:
cat sample.cpp #include <iostream> #include "soci.h" #include "soci-mysql.h"
using namespace std; using namespace soci; int main() { try { session sql(mysql, "dbname=test user=test password=test"); int count; sql << "select count(*) from phonebook", into(count); cout << "We have " << count << " entries in the phonebook.\n"; } catch (exception const &e) { cerr << "Error: " << e.what() << '\n'; } }
gcc -O2 -flto -o test -I[soci_include] -I/usr/include/mysql -L[soci_libs] test.cpp -lstdc++ -lsoci_core -lsoci_mysql -lmysqlclient -ldl -lpq `typeinfo for soci::details::ref_counted_statement_base' referenced in section `.data.rel.ro._ZTVN4soci7details26ref_counted_statement_baseE[vtable for soci::details::ref_counted_statement_base]' of /lib/libsoci_core.a(ref-counted-statement.cpp.o): defined in discarded section `.gnu.linkonce.t._ZTIN4soci7details26ref_counted_statement_baseE' of /tmp/ccMUJjta.o (symbol from plugin) `typeinfo for soci::details::ref_counted_statement_base' referenced in section `.data.rel.ro._ZTIN4soci7details21ref_counted_statementE[typeinfo for soci::details::ref_counted_statement]' of /lib/libsoci_core.a(ref-counted-statement.cpp.o): defined in discarded section `.gnu.linkonce.t._ZTIN4soci7details26ref_counted_statement_baseE' of /tmp/ccMUJjta.o (symbol from plugin) ..... and more similar errors
Now try switch to gold and make things workable: 1. make /tmp/ld symlink to gold linker 2. gcc -O2 -flto -B/tmp -o test -I[soci_include] -I/usr/include/mysql -L[soci_libs] test.cpp -lstdc++ -lsoci_core -lsoci_mysql -lmysqlclient -ldl -lpq Bingo! Everything works :) We need fix ld linker and switch back to gold (even witth fixed ld, because gold is better, it produce smaller binaries and http://sourceware.org/bugzilla/show_bug.cgi?id=12818 bug already fixed, fix in ld http://sourceware.org/bugzilla/show_bug.cgi?id=12772 still not in factory). Reproducible: Always -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
![](https://seccdn.libravatar.org/avatar/3035b38ff33cf86f480bb169b8500b80.jpg?s=120&d=mm&r=g)
https://bugzilla.novell.com/show_bug.cgi?id=737528
https://bugzilla.novell.com/show_bug.cgi?id=737528#c1
kk zhang
![](https://seccdn.libravatar.org/avatar/3035b38ff33cf86f480bb169b8500b80.jpg?s=120&d=mm&r=g)
https://bugzilla.novell.com/show_bug.cgi?id=737528
https://bugzilla.novell.com/show_bug.cgi?id=737528#c2
Jan Engelhardt
participants (1)
-
bugzilla_noreply@novell.com