public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tristan Gingold <gingold@adacore.com>
To: Richard Guenther <rguenther@suse.de>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	Eric Botcazou <ebotcazou@adacore.com>
Subject: Re: [Patch/cfgexpand]: also consider assembler_name to call expand_main_function
Date: Wed, 14 Mar 2012 16:25:00 -0000	[thread overview]
Message-ID: <E84AEAAD-CEF2-4ECD-AECC-AFFB123B2AAC@adacore.com> (raw)
In-Reply-To: <alpine.LNX.2.00.1203141707100.27160@zhemvz.fhfr.qr>


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.

  reply	other threads:[~2012-03-14 16:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-14 16:04 Tristan Gingold
2012-03-14 16:09 ` Richard Guenther
2012-03-14 16:25   ` Tristan Gingold [this message]
2012-03-15  9:38     ` Richard Guenther
2012-03-15 12:51       ` Tristan Gingold
2012-03-20 12:07       ` Tristan Gingold
2012-03-20 12:22         ` Richard Guenther
2012-03-20 14:12           ` Tristan Gingold
2012-03-20 14:20             ` Richard Guenther
2012-03-20 16:00               ` Tristan Gingold
2012-03-20 16:02                 ` Richard Guenther
2012-03-20 16:06                   ` Tristan Gingold
2012-03-21  7:44                     ` Richard Guenther
2012-03-20 17:18           ` Jan Hubicka
2012-03-21  8:40             ` Tristan Gingold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E84AEAAD-CEF2-4ECD-AECC-AFFB123B2AAC@adacore.com \
    --to=gingold@adacore.com \
    --cc=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).