Public bug reported:

Any C++ program I tried to build with GCC failed with undefined
reference errors. As a test case, I have created a simple Hello World
program:

$ cat hello.cpp 
#include <iostream>

int main()
{
  std::cout << "Hello world!" << std::endl;
}

$ g++ -o hello hello.cpp -flto
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/libstdc++.so: undefined reference to 
`_Unwind_GetDataRelBase@GCC_3.0'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/libstdc++.so: undefined reference to 
`_Unwind_SetIP@GCC_3.0'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/libstdc++.so: undefined reference to 
`_Unwind_RaiseException@GCC_3.0'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/libstdc++.so: undefined reference to 
`_Unwind_GetLanguageSpecificData@GCC_3.0'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/libstdc++.so: undefined reference to 
`_Unwind_GetRegionStart@GCC_3.0'
/lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_argv@GLIBC_PRIVATE'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/libstdc++.so: undefined reference to 
`_Unwind_DeleteException@GCC_3.0'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/libstdc++.so: undefined reference to 
`_Unwind_SetGR@GCC_3.0'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/libstdc++.so: undefined reference to 
`_Unwind_Resume@GCC_3.0'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/libstdc++.so: undefined reference to 
`_Unwind_GetIPInfo@GCC_4.2.0'
/lib/x86_64-linux-gnu/libc.so.6: undefined reference to 
`_rtld_global_ro@GLIBC_PRIVATE'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/libstdc++.so: undefined reference to 
`__tls_get_addr@GLIBC_2.3'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/libstdc++.so: undefined reference to 
`_Unwind_Resume_or_Rethrow@GCC_3.3'
/lib/x86_64-linux-gnu/libc.so.6: undefined reference to 
`_rtld_global@GLIBC_PRIVATE'
/lib/x86_64-linux-gnu/libc.so.6: undefined reference to 
`__libc_enable_secure@GLIBC_PRIVATE'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/libstdc++.so: undefined reference to 
`_Unwind_GetTextRelBase@GCC_3.0'
collect2: ld returned 1 exit status

Every C++ program I tried to build with -flto failed at link stage. C
programs compile without problems. A workaround is to add the -B/usr/lib
/gold-ld/ switch to the command line:

$ g++ -B/usr/lib/gold-ld/ -flto -o hello hello.cpp
$ # Success

ProblemType: Bug
DistroRelease: Ubuntu 11.10
Package: binutils 2.21.53.20110810-0ubuntu4
ProcVersionSignature: Ubuntu 3.0.0-12.20-generic 3.0.4
Uname: Linux 3.0.0-12-generic x86_64
NonfreeKernelModules: fglrx
ApportVersion: 1.23-0ubuntu4
Architecture: amd64
Date: Thu Nov  3 21:43:56 2011
InstallationMedia: Ubuntu 11.04 "Natty Narwhal" - Release amd64 (20110427.1)
ProcEnviron:
 LANGUAGE=pt_BR:pt:en
 PATH=(custom, no user)
 LANG=pt_BR.UTF-8
 SHELL=/bin/bash
SourcePackage: binutils
UpgradeStatus: Upgraded to oneiric on 2011-10-15 (19 days ago)

** Affects: binutils (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug oneiric running-unity

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/885927

Title:
  g++ fails to link when using the -flto switch

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/binutils/+bug/885927/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to