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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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. |