Does g++ really need to compile main, if c++ code is involved?

Ian Lance Taylor iant@google.com
Tue Mar 25 03:32:00 GMT 2014


On Mon, Mar 24, 2014 at 11:02 AM, Florian Weimer <fw@deneb.enyo.de> wrote:
> * Ian Lance Taylor:
>
>> You neglected to say what machine you were running on.  __main is only
>> used on some platforms.  In particular it is not used on GNU/Linux.
>
> Do you know how this behavior of collect2 is controlled?  I would like
> to add this to the gccint documentation.

The existing documentation is at
http://gcc.gnu.org/onlinedocs/gccint/Initialization.html and the
following section
http://gcc.gnu.org/onlinedocs/gccint/Macros-for-Initialization.html .

In short, if use_collect2 is not set to yes in config.gcc, then
collect2 will not generate a __main function.  If use_collect2 is set
to yes, but if you define LD_INIT_SWITCH, then collect2 will also not
generate a call to a __main function.

Ian



More information about the Gcc-help mailing list