help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Q1: function-level linking is not working as expected


From: Michael Kilburn
Subject: Q1: function-level linking is not working as expected
Date: 24 Apr 2007 18:42:44 -0700
User-agent: G2/1.0

Hi

I am quite new with G++/GCC (I came from MSVC world) and currently
having some really annoying problems with GCC. This is the first one:

I am trying to get equivalent of MSVC's /Oy & /OPT:REF (function-level
linking) with GCC compiler. We have huge project where:
- OS is Linux
- G++ v4.0.3 (afaik)
- ld v2.15
- everything is C/C++ code and compiled/linked with the same options
- everything is linked statically
- one or two static libraries that makes 98% of executable image size
- executable image size is ~45Mb

After digging in google I found that these options fed into GCC chain
should do the trick:
-ffunction-sections
-fdata-sections
-Wl,--gc-sections

And indeed executable size was decreased to ~32Mb. But still it is
wrong -- I have created simple application that just calls empty
function from one of these libraries:
int main()
{
    foo(); // foo's body is empty
}

resulting image size was ~17Mb. If you comment out this call image
size = 5kb.


Any ideas how what is wrong?

Bye.
Sincerely yours, Michael.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]