This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [Fortran] RFC: Patch to support STDCALL etc. (PR 34112) * PING *
- From: FX <fxcoudert at gmail dot com>
- To: Fortran List <fortran at gcc dot gnu dot org>, gcc-patches at gcc dot gnu dot org, Tobias Burnus <burnus at net-b dot de>, Dennis Wassel <dennis dot wassel at googlemail dot com>
- Date: Sat, 18 Jul 2009 14:53:38 +0200
- Subject: Re: [Fortran] RFC: Patch to support STDCALL etc. (PR 34112) * PING *
- References: <445BDDF0-75BF-4B11-9697-0B8CCB444A44@gmail.com>
The problem is that the symbols are not name-decorated on the
Fortran side:
I've investigated a bit, using my cross-compiler, and found the
following:
* i386_pe_mangle_decl_assembler_name() (in config/i386/winnt.c) is
where the decoration happens; it's never called when compiling
Fortran, but called when compiling equivalent C code
* in C, this is done from lhd_set_decl_assembler_name() (in
langhooks.c), which calls targetm.mangle_decl_assembler_name (which,
on i386 PE targets, is i386_pe_mangle_decl_assembler_name)
* in Fortran, we simply use SET_DECL_ASSEMBLER_NAME directly (in
trans-common.c and trans-decl.c), without allowing further mangling/
decoration
To fix this, I propose to add a function gfc_set_decl_assembler_name,
which calls targetm.mangle_decl_assembler_name first and then uses
SET_DECL_ASSEMBLER_NAME. All curent uses of SET_DECL_ASSEMBLER_NAME
should probably be switched to gfc_set_decl_assembler_name().
The patch attached does what I describe above. I have been able to
test that it does build for my cross-compiler (i386-darwin to i586-
mingw32), gives object files with properly decorated function names
and not warning at link time. The resulting executable (from Dennis'
test) runs fine in a VirtualBox, and does not hit any abort. I am not
able to bootstrap (nor regtest) a native compiler on a non-win32
platform, which should be tested before applying the patch. I don't
expect any tricky issue though, as the only targets using the
mangle_decl_assembler_name target hook are i386-winnt (cygwin and
mingw) and i386-netware (don't know what that is).
I hope this helps, sorry I can't do more.
FX
PS: one misc thing I noted: add_attributes_to_decl() has a misleading
name: it doesn't add anything, it simply builds a list of the
appropriate attributes.
Attachment:
stdcall.diff
Description: Binary data