From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20760 invoked by alias); 2 Oct 2013 18:22:47 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 20726 invoked by uid 48); 2 Oct 2013 18:22:44 -0000 From: "suihong.liang at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/58592] -flto -fwhole-program caused undefined reference in g++ 4.7.3 Date: Wed, 02 Oct 2013 18:22:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.8.1 X-Bugzilla-Keywords: lto X-Bugzilla-Severity: normal X-Bugzilla-Who: suihong.liang at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status version resolution Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-10/txt/msg00112.txt.bz2 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