help-gplusplus
[Top][All Lists]
Advanced

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

Re: Q1: function-level linking is not working as expected


From: Paul Pluzhnikov
Subject: Re: Q1: function-level linking is not working as expected
Date: Tue, 24 Apr 2007 22:32:01 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)

Michael Kilburn <crusader.mike@gmail.com> writes:

> 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.

If the file that was pulled in (the one defining empty foo()),
contains any global objects, then the constructors for such objects
are pulled in, anything that these constructors reference is pulled
in, etc. etc.

The constructors can not be garbage-collected, because they are
referenced from static_initialization_and_destruction().

Try putting 'int foo() { return 0; }' into a separate source file,
and adding the corresponding object file into the archive. I bet
you'll end up with a 5K exe file again.

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.


reply via email to

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