Bug 234183

Summary: Change g++ to use --as-needed
Product: [Fedora] Fedora Reporter: Bryan Mason <nobody+bjmason>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED INSUFFICIENT_DATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: drepper, triage
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard: bzcl34nup
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-05-07 01:22:13 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Bryan Mason 2007-03-27 16:30:10 UTC
+++ This bug was initially created as a clone of Bug #191162 +++

Here's the simplest of all "hello world" programs :

   % cat foo.C
   #include <iostream>

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

When compiled and linked with default gcc4 options on RHEL4 I get:

   % x86_64-rhel4-4.0.2-g++ foo.C -o foo
   % ldd -u -r foo
   Unused direct dependencies:
           /lib64/tls/libm.so.6
           /lib64/libgcc_s.so.1

[Using "g++ -o foo foo.cc -v" shows that] libm is indeed being pulled in
(newlines added for legibility):

   /usr/libexec/gcc/x86_64-redhat-linux/4.0.2/collect2
   --eh-frame-hdr
   -m elf_x86_64
   -dynamic-linker /lib64/ld-linux-x86-64.so.2
   -o foo
   /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../lib64/crt1.o
   /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../lib64/crti.o
   /usr/lib/gcc/x86_64-redhat-linux/4.0.2/crtbegin.o

   -L/usr/lib/gcc/x86_64-redhat-linux/4.0.2
   -L/usr/lib/gcc/x86_64-redhat-linux/4.0.2
   -L/usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../lib64
   -L/usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../.. -L/lib/../lib64
   -L/usr/lib/../lib64 /tmp/ccgaawQ2.o

   -lstdc++
   -lm
   -lgcc_s
   -lgcc
   -lc
   -lgcc_s
   -lgcc

   /usr/lib/gcc/x86_64-redhat-linux/4.0.2/crtend.o
   /usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../lib64/crtn.o

It sounds plausible that this happens because libstdc++ may sometimes need
it, so the remaining question is why -Wl,--as-needed is not the default.

Comment 2 Bug Zapper 2008-04-03 23:50:29 UTC
Based on the date this bug was created, it appears to have been reported
against rawhide during the development of a Fedora release that is no
longer maintained. In order to refocus our efforts as a project we are
flagging all of the open bugs for releases which are no longer
maintained. If this bug remains in NEEDINFO thirty (30) days from now,
we will automatically close it.

If you can reproduce this bug in a maintained Fedora version (7, 8, or
rawhide), please change this bug to the respective version and change
the status to ASSIGNED. (If you're unable to change the bug's version
or status, add a comment to the bug and someone will change it for you.)

Thanks for your help, and we apologize again that we haven't handled
these issues to this point.

The process we're following is outlined here:
http://fedoraproject.org/wiki/BugZappers/F9CleanUp

We will be following the process here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping to ensure this
doesn't happen again.

Comment 3 Bug Zapper 2008-05-07 01:22:11 UTC
This bug has been in NEEDINFO for more than 30 days since feedback was
first requested. As a result we are closing it.

If you can reproduce this bug in the future against a maintained Fedora
version please feel free to reopen it against that version.

The process we're following is outlined here:
http://fedoraproject.org/wiki/BugZappers/F9CleanUp