This is the mail archive of the
mailing list for the GCC project.
Re: Issue with main function expansion and Ada
- From: Nicolas Roche <roche at adacore dot com>
- To: Mike Stump <mrs at apple dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 27 Mar 2006 12:29:04 +0200
- Subject: Re: Issue with main function expansion and Ada
- References: <4423DAB1.firstname.lastname@example.org> <F3069C99-E638-4A3F-82A5-FC526F70A25E@apple.com>
I just saw that I sent this email to the wrong mailing list. So I
reforward to email@example.com
I am currently working on having GCC 4.1 working on mingw with ZCX
exceptions and I got the following issue with Ada and the constructors:
On windows a __main function in charge of calling the constructors (so
that register_frame_info is called) is used. This function is called
by main and the call is added by expand_main_function in function.c.
expand_main_function is called in tree_expand_cfg (cfgexpand.c) only
if the current function is the main one :
/* If this function is `main', emit a call to `__main'
to run global initializers, etc. */
if (DECL_NAME (current_function_decl)
&& MAIN_NAME_P (DECL_NAME (current_function_decl))
&& DECL_FILE_SCOPE_P (current_function_decl))
The issue in Ada is that the result of DECL_NAME for the main function
is not "main" but somethind like "_ada_main__main" because the main
function is in a package called ada_main (generated by the binder).
The consequence is that expand_main_function will never be called (and
so my exception tables not registered :-().
Using DECL_ASSEMBLER_NAME instead of DECL_NAME solves the issue as the
exported name of that function will be "main".
Is this change seems reasonable ?
(If yes I will do a complete test before submiting the patch)
Note that this affect potentially all the platforms that use __main to
call the constructors (so I think mainly non elf platforms ..).
Thanks in advance for your answers
Mike Stump wrote:
On Mar 24, 2006, at 3:40 AM, Nicolas Roche wrote:
Using DECL_ASSEMBLER_NAME instead of DECL_NAME solves the issue as
the exported name of that function will be "main".
Careful; on some systems name it _main. But on others, you don't
Well it works even in that case as my test was done on Mingw wich use
_main and not main.