This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch/cfgexpand]: also consider assembler_name to call expand_main_function


On Mar 14, 2012, at 5:08 PM, Richard Guenther wrote:

> On Wed, 14 Mar 2012, Tristan Gingold wrote:
> 
>> Hi,
>> 
>> the code to call expand_main_function currently only checks DECL_NAME.  This leads
>> to a hack in ada/gcc-interface/utils.c to handle the gnatbind generated file that could
>> declare:
>> 
>> package ada_main is
>> …
>>   function my_main
>>     (argc : Integer;
>>      argv : System.Address;
>>      envp : System.Address)
>>      return Integer;
>>   pragma Export (C, my_main, "main");
>> …
>> end ada_main;
>> 
>> But expand_main_function is also called for function whose name is main but assembly name isn't.  Eg:
>> 
>> package pkg is
>>   procedure main;
>> end pkg;
>> 
>> So I think we should consider the assembler name is set, otherwise the decl name.
>> 
>> Manually tested on ia64-hp-openvms (where this issue was discovered).
>> No C regressions for x86_64-darwin.
>> 
>> Ok for trunk ?
> 
> There are more checks for MAIN_NAME_P, so this certainly isn't enough.
> And if it is a good idea then the whole check, whether a FUNCTION_DECL
> is considered 'main' should be put into a function in tree.[ch] and
> used everywhere.  Note that what is 'main' is controlled by
> main_identifier_node, controlled by frontends.  So - why is that not
> enough to control for Ada?

Indeed, I think we could handle this issue in gigi for Ada.  (I also think
we don't want to handle crazy C code such as 'int my_main () asm ("main")'.

But, unless I missed something, doing this in gigi won't work with LTO.

Will write a predicate in tree.[ch].

Thank you for your comments,
Tristan.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]