Unix Technical Forum

gcc is including all modules in libraries I link against

This is a discussion on gcc is including all modules in libraries I link against within the AIX Operating System forums, part of the Unix Operating Systems category; --> NB: I tried to post this once and I think it failed; sorry if it gets posted twice. gcc ...


Go Back   Unix Technical Forum > Unix Operating Systems > AIX Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-05-2008, 04:18 AM
David Kramer
 
Posts: n/a
Default gcc is including all modules in libraries I link against

NB: I tried to post this once and I think it failed; sorry if it gets
posted twice.

gcc 3.4.0
AIX 5.2

My company has a large application we normally build with xlC. I'm
charged with porting it to the GNU toolchain in preparation to porting
it to other architectures. I built a gcc 3.4.0 bootstrapped from a
gcc 3.3.3 I downloaded. I've built binutils 2.15, but I can't get
anything linked with it, so I'm still using the native linker.

I have a two-fold problem.

1) The table of contents is > 64K, and according to their respective
documentations, all options that either make the TOC bigger in ld, or
put less in the TOC in gcc, make the program run slower. This is not
desirable, but not a show-stopper.

2) A library of ours (tccommon) that we are linking in has classes
that reference another class (status) in another library (tcdb). The
application I am trying to link requires some classes from tccommon,
but
not any of the ones that require the status class. However, the
linker is complaining that the status class is missing (undefine
symbols)
anyway. I thought they would have been garbage collected out.

The xlC compiler has an option, "-qfuncsect", which puts each function
in a separate csect. This seems equivalent to g++'s
"-ffunction-sections".
The kicker is that xlC has an option "-qtwolink" to do a two-pass link
to eliminate any sections containing only unreferenced objects. That
killed both birds with two stones. That effectively prevents any
objects in
the libraries that aren't called in the application from being linked
in.

I can't seem to find a comparable g++ option to not link in objects
that are not referenced, and that means when I link my application
against
tccommon, it's claiming that the status class methods are undefined,
even though nothing the application is using from tccommon uses the
status
class.

This is bugging me, because it seems to me if you do
g++ -o myapp myapp.cpp -lmylib
that only objects in libmylib.a that are needed by myapp.o would be
linked in, but it seems that all of libmylib.a is being included.
What's up with that?

I added -Wl,-bigtoc, which turns the error about the TOC being too big
into a warning, but this is just hiding the problem, and according to
the documentation, creates performance issues.


Thanks in advance.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:10 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com