c++ -flto always results in unresolved symbols

Bug #872687 reported by Tom Vijlbrief
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
binutils
Fix Released
Medium
binutils (Ubuntu)
Fix Released
High
Unassigned
Oneiric
Fix Released
High
Unassigned

Bug Description

TEST CASE
=======main.cc =====
int main() {}
===================

c++ -flto main.cc

EXPECTED RESULT:
Builds fine

WHAT HAPPENS:
results in unresolved symbol errors on latest oneiric beta

WORKAROUND
Adding -static is a work around

Revision history for this message
In , Matthias Klose (doko) wrote :

seen with the 2.22 branch (and the fix for pr13250 applied), works with gold, gcc is 4.6 from the branch.

$ cat foo.cc
int main() {}

$ g++ -B/usr/lib/gold-ld/ -Wl,--as-needed -flto foo.cc
ok

$ $ gcc -Wl,--as-needed -flto foo.cc
ok

$ $ g++ -Wl,--as-needed -flto foo.cc
/lib/i386-linux-gnu/libc.so.6: undefined reference to `_dl_argv@GLIBC_PRIVATE'
/lib/i386-linux-gnu/libc.so.6: undefined reference to `__libc_stack_end@GLIBC_2.1'
/lib/i386-linux-gnu/libc.so.6: undefined reference to `__libc_enable_secure@GLIBC_PRIVATE'
/lib/i386-linux-gnu/libc.so.6: undefined reference to `_rtld_global@GLIBC_PRIVATE'
/lib/i386-linux-gnu/libc.so.6: undefined reference to `___tls_get_addr@GLIBC_2.3'
/lib/i386-linux-gnu/libc.so.6: undefined reference to `_rtld_global_ro@GLIBC_PRIVATE'
collect2: ld returned 1 exit status

Revision history for this message
Matthias Klose (doko) wrote :

better work arounds are

 - use -Wl,--no-as-needed
 - use gold (-B/usr/lib/gold-ld/)

affects: gcc-defaults (Ubuntu) → binutils (Ubuntu)
Changed in binutils (Ubuntu):
importance: Undecided → High
status: New → Confirmed
Changed in binutils:
importance: Unknown → Medium
status: Unknown → Confirmed
Revision history for this message
In , Matthias Klose (doko) wrote :

also seen on the trunk.

glibc-2.13 or glibc trunk doesn't make a difference

Revision history for this message
In , Hjl-tools (hjl-tools) wrote :

It is a regression.

Revision history for this message
In , Hjl-tools (hjl-tools) wrote :
Revision history for this message
In , Cvs-commit (cvs-commit) wrote :

CVSROOT: /cvs/src
Module name: src
Changes by: <email address hidden> 2011-10-20 09:50:59

Modified files:
 ld : ChangeLog plugin.c plugin.h ldlang.c

Log message:
 PR ld/13287
 * plugin.c (plugin_should_reload): New function.
 * plugin.h (plugin_should_reload): Declare.
 * ldlang.c (open_input_bfds): Use above function.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&r1=1.2383&r2=1.2384
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/plugin.c.diff?cvsroot=src&r1=1.42&r2=1.43
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/plugin.h.diff?cvsroot=src&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldlang.c.diff?cvsroot=src&r1=1.378&r2=1.379

Matthias Klose (doko)
Changed in binutils (Ubuntu Oneiric):
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package binutils - 2.21.90.20111019-2ubuntu1

---------------
binutils (2.21.90.20111019-2ubuntu1) precise; urgency=low

  * Merge with Debian.

binutils (2.21.90.20111019-2) unstable; urgency=low

  * Fix PR ld/13287, taken from the trunk. LP: #872687.

binutils (2.21.90.20111019-1) unstable; urgency=low

  * Snapshot, taken from the binutils-2_22-branch 20111019.
 -- Matthias Klose <email address hidden> Thu, 20 Oct 2011 13:12:50 +0200

Changed in binutils (Ubuntu):
status: Confirmed → Fix Released
Changed in binutils:
status: Confirmed → In Progress
Revision history for this message
In , Cvs-commit (cvs-commit) wrote :

CVSROOT: /cvs/src
Module name: src
Branch: binutils-2_22-branch
Changes by: <email address hidden> 2011-10-25 03:15:08

Modified files:
 ld : ChangeLog ldlang.c plugin.c plugin.h

Log message:
 PR ld/13287
 2011-10-20 Alan Modra <email address hidden>
 * plugin.c (plugin_should_reload): New function.
 * plugin.h (plugin_should_reload): Declare.
 * ldlang.c (open_input_bfds): Use above function.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.2373.2.6&r2=1.2373.2.7
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldlang.c.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.378&r2=1.378.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/plugin.c.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.40.2.2&r2=1.40.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/plugin.h.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.9&r2=1.9.2.1

Revision history for this message
In , Alan Modra (amodra-gmail) wrote :

Fixed.

Revision history for this message
Martin Pitt (pitti) wrote : Please test proposed package

Hello Tom, or anyone else affected,

Accepted binutils into oneiric-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in binutils (Ubuntu Oneiric):
status: Confirmed → Fix Committed
tags: added: verification-needed
Changed in binutils:
status: In Progress → Fix Released
Revision history for this message
Tom Vijlbrief (tvijlbrief) wrote :

Hi Martin

I installed the binutils from proposed and build the StockFish chess program
(which failed to build initially) with -flto and also
combined with the PGO build option.

No problems, the new binutils works just fine!

description: updated
tags: added: verification-done
removed: verification-needed
tags: added: testcase
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package binutils - 2.21.53.20110810-0ubuntu5

---------------
binutils (2.21.53.20110810-0ubuntu5) oneiric-proposed; urgency=low

  * Fix PR ld/13287, taken from the trunk. LP: #872687.
 -- Matthias Klose <email address hidden> Thu, 20 Oct 2011 15:13:07 +0200

Changed in binutils (Ubuntu Oneiric):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.