public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58592] New: -flto -fwhole-program caused undefined reference in g++ 4.7.3
@ 2013-10-02  2:59 suihong.liang at gmail dot com
  2013-10-02  8:19 ` [Bug c++/58592] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: suihong.liang at gmail dot com @ 2013-10-02  2:59 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58592

            Bug ID: 58592
           Summary: -flto -fwhole-program caused undefined reference in
                    g++ 4.7.3
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: suihong.liang at gmail dot com

Created attachment 30945
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30945&action=edit
source code and makefiles

Bug 41729 seems to be the same issue, however it was for 4.5.0 and it was
closed.

g++ 4.6.3 works fine, it compiles and runs.

However g++ 4.7.3 gives linking error "undefined reference".

Below shows the steps to reproduce. Thanks in advance!

linkerror/lib# make clean; make
rm -f *.o *.so
g++ -flto -fwhole-program -Wall -Werror -pedantic -Wextra -Weffc++ -Waddress
-Warray-bounds -Wno-builtin-macro-redefined -Wc++0x-compat -Wundef -std=c++0x
-c -fPIC A.cpp
g++ -flto -fwhole-program -Wall -Werror -pedantic -Wextra -Weffc++ -Waddress
-Warray-bounds -Wno-builtin-macro-redefined -Wc++0x-compat -Wundef -std=c++0x
-shared -o libself.so A.o 

linkerror/app# make clean; make
rm -f *.o a.out
g++ -flto -fwhole-program -Wall -Werror -Wextra -pedantic -Weffc++ -Waddress
-Warray-bounds -Wno-builtin-macro-redefined -Wc++0x-compat -Wundef -std=c++0x
-c main.cpp
g++ -flto -fwhole-program -Wall -Werror -Wextra -pedantic -Weffc++ -Waddress
-Warray-bounds -Wno-builtin-macro-redefined -Wc++0x-compat -Wundef -std=c++0x
-o a.out main.o -L../lib -lself
/tmp/ccWfzcXT.ltrans0.ltrans.o: In function `main':
ccWfzcXT.ltrans0.o:(.text+0x1c): undefined reference to `A::A()'
ccWfzcXT.ltrans0.o:(.text+0x31): undefined reference to `A::~A()'
collect2: error: ld returned 1 exit status
make: *** [all] Error 1


# g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.7.3-1ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs
--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.7 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin
--with-system-zlib --enable-objc-gc --with-cloog --enable-cloog-backend=ppl
--disable-cloog-version-check --disable-ppl-version-check --enable-multiarch
--disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --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.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1) 


# uname -a
Linux sinit 3.8.0-31-generic #46-Ubuntu SMP Tue Sep 10 20:03:44 UTC 2013 x86_64
x86_64 x86_64 GNU/Linux


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/58592] -flto -fwhole-program caused undefined reference in g++ 4.7.3
  2013-10-02  2:59 [Bug c++/58592] New: -flto -fwhole-program caused undefined reference in g++ 4.7.3 suihong.liang at gmail dot com
@ 2013-10-02  8:19 ` rguenth at gcc dot gnu.org
  2013-10-02 13:38 ` suihong.liang at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-10-02  8:19 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58592

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
try removing -fwhole-program and add -fuse-linker-plugin

Note that it's unlikely we that somebody works on this for 4.7, which means
you may want to try GCC 4.8.1 or later.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/58592] -flto -fwhole-program caused undefined reference in g++ 4.7.3
  2013-10-02  2:59 [Bug c++/58592] New: -flto -fwhole-program caused undefined reference in g++ 4.7.3 suihong.liang at gmail dot com
  2013-10-02  8:19 ` [Bug c++/58592] " rguenth at gcc dot gnu.org
@ 2013-10-02 13:38 ` suihong.liang at gmail dot com
  2013-10-02 18:22 ` suihong.liang at gmail dot com
  2013-10-02 19:36 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: suihong.liang at gmail dot com @ 2013-10-02 13:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58592

suihong.liang at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #2 from suihong.liang at gmail dot com ---
Thanks Richard. That solved the linking error.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/58592] -flto -fwhole-program caused undefined reference in g++ 4.7.3
  2013-10-02  2:59 [Bug c++/58592] New: -flto -fwhole-program caused undefined reference in g++ 4.7.3 suihong.liang at gmail dot com
  2013-10-02  8:19 ` [Bug c++/58592] " rguenth at gcc dot gnu.org
  2013-10-02 13:38 ` suihong.liang at gmail dot com
@ 2013-10-02 18:22 ` suihong.liang at gmail dot com
  2013-10-02 19:36 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: suihong.liang at gmail dot com @ 2013-10-02 18:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58592

suihong.liang at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
            Version|4.7.3                       |4.8.1
         Resolution|WONTFIX                     |---

--- Comment #3 from suihong.liang at gmail dot com ---
Looks like 4.8.1 has the same issue of linking error when "-flto
-fwhole-program" is used. Detailed output is below. And The source files are
from the attachment.

root@sinit:linkerror/lib# make clean
rm -f *.o *.so
root@sinit:/media/sf_symbolic/self/linkerror/lib# make
/usr/local/bin/g++ -flto -fwhole-program -Wall -Werror -pedantic -Wextra
-Weffc++ -Waddress -Warray-bounds -Wno-builtin-macro-redefined -Wc++0x-compat
-Wundef -std=c++0x -c -fPIC A.cpp
/usr/local/bin/g++ -flto -fwhole-program -Wall -Werror -pedantic -Wextra
-Weffc++ -Waddress -Warray-bounds -Wno-builtin-macro-redefined -Wc++0x-compat
-Wundef -std=c++0x -shared -o libself.so A.o 

root@sinit:linkerror/lib# cd ../app

root@sinit:linkerror/app# make clean; make
rm -f *.o a.out
/usr/local/bin/g++ -flto -fwhole-program -Wall -Werror -Wextra -pedantic
-Weffc++ -Waddress -Warray-bounds -Wno-builtin-macro-redefined -Wc++0x-compat
-Wundef -std=c++0x -c main.cpp
/usr/local/bin/g++ -flto -fwhole-program -Wall -Werror -Wextra -pedantic
-Weffc++ -Waddress -Warray-bounds -Wno-builtin-macro-redefined -Wc++0x-compat
-Wundef -std=c++0x -o a.out main.o -L../lib -lself
/tmp/cchAPumN.ltrans0.ltrans.o: In function `main':
cchAPumN.ltrans0.o:(.text+0x1c): undefined reference to `A::A()'
cchAPumN.ltrans0.o:(.text+0x31): undefined reference to `A::~A()'
collect2: error: ld returned 1 exit status
make: *** [all] Error 1


root@sinit# /usr/local/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/usr/local/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-linux-gnu/4.8.1/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../configure --disable-multilib --enable-languages=c,c++
--enable-shared --enable-linker-build-id --without-included-gettext
--enable-threads=posix --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin
--with-system-zlib --with-cloog --enable-cloog-backend=ppl
--disable-cloog-version-check --disable-ppl-version-check --disable-werror
--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.8.1 (GCC) 

# uname -r
3.8.0-31-generic


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/58592] -flto -fwhole-program caused undefined reference in g++ 4.7.3
  2013-10-02  2:59 [Bug c++/58592] New: -flto -fwhole-program caused undefined reference in g++ 4.7.3 suihong.liang at gmail dot com
                   ` (2 preceding siblings ...)
  2013-10-02 18:22 ` suihong.liang at gmail dot com
@ 2013-10-02 19:36 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-10-02 19:36 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58592

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually this is not a bug as you are putting -fwhole-program on the link of
the library but you don't export at all A::A() from there.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-10-02 19:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-02  2:59 [Bug c++/58592] New: -flto -fwhole-program caused undefined reference in g++ 4.7.3 suihong.liang at gmail dot com
2013-10-02  8:19 ` [Bug c++/58592] " rguenth at gcc dot gnu.org
2013-10-02 13:38 ` suihong.liang at gmail dot com
2013-10-02 18:22 ` suihong.liang at gmail dot com
2013-10-02 19:36 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).