From: Kuba Ober kuba@mareimbrium.org
I'm currently hacking on gcc for an embedded target (Z8 Encore), but I wouldn't mind giving it a try while I'm digging in the gcc tree.
Cool!
I'd like to hear any suggestions as to how to tell the compiler to use that calling convention (I'm not talking about implementation, just how the compiler used would tell it).
I presume it'd need to be something that can be set globally per each compiler invocation, as well as a per declaration override.
I'm thinking of "-msvc" (like -liberty ;) compiler option to force a MSVC-compatible ABI, and for now that'd only apply to 64 bit code (i.e. with -m64). Maybe in the future it could enable something special for 32 bit code as well.
I'm all ears about the per-declaration override (a pragma? an __attribute__?), and about alternatives to -msvc.
__attribute__ seems most logical to me. Perhaps __attribute__(__msvccall__) (in the __attribute__(__stdcall__) tradition? An alternative to -msvc could perhaps be -mrtd ("Alternate calling convention"). For i386 builds of gcc, -mrtd makes stdcall the default calling convention. It is currently a noop for x86_64. I kind of like your -msvc though :-) For Wine the compiler option seems more important then the override.
I'd be submitting a patch to mingw32 people as soon as it's done, in addition to posting it here. Note that the only way for me to test it would be to inspect the assembly output, as I'm not running 64 bit environment here (even though I'm on a 64 bit AMD processor). So it'd need testing from 64 bit people here at least.
I'm volunteering. I could also give you ssh access to a 64 bit environment.
Ge van Geldorp.
I'd be submitting a patch to mingw32 people as soon as it's done, in addition to posting it here. Note that the only way for me to test it would be to inspect the assembly output, as I'm not running 64 bit environment here (even though I'm on a 64 bit AMD processor). So it'd need testing from 64 bit people here at least.
I'm volunteering. I could also give you ssh access to a 64 bit environment.
Once I get sensible assembly coming out I'll let you know. I'll try the __attribute__(__msvccall__) for per-function, and -msvc for per-file.
Cheers, Kuba
"Ge van Geldorp" ge@gse.nl writes:
__attribute__ seems most logical to me. Perhaps __attribute__(__msvccall__) (in the __attribute__(__stdcall__) tradition? An alternative to -msvc could perhaps be -mrtd ("Alternate calling convention"). For i386 builds of gcc, -mrtd makes stdcall the default calling convention. It is currently a noop for x86_64. I kind of like your -msvc though :-) For Wine the compiler option seems more important then the override.
Just the other way around actually, Wine can't use a global option since we have to call Unix functions. The only way is to have an explicit attribute on Windows APIs.
Hello guys,
I'm about to jump in the middle of discussion. The problem is not only with the calling convention, but with the whole ABI rather. I've had GCC patched to use the MSVC x64 calling convention (without a switch though) for about a year now, but it doesn't solve the problem. There is much more ABI differences including the exception handling (and yes, I mean exception handling in C, not only C++) where MSVC generates special unwinding information for the functions. I'm not sure if it would be even possible to mix the ABI this way, but I'm open to hear some suggestions.
Regards, Filip
P.S. I'll try to publish the .diffs for GCC/binutils somewhere, but it's really not of much use.
On Wednesday 21 June 2006 06:39, Filip Navara wrote:
Hello guys,
I'm about to jump in the middle of discussion. The problem is not only with the calling convention, but with the whole ABI rather. I've had GCC patched to use the MSVC x64 calling convention (without a switch though) for about a year now, but it doesn't solve the problem. There is much more ABI differences including the exception handling (and yes, I mean exception handling in C, not only C++) where MSVC generates special unwinding information for the functions. I'm not sure if it would be even possible to mix the ABI this way, but I'm open to hear some suggestions.
Does gcc have some C exception handling of its own? If not then we may be able to add that. gcc is pretty well tweakable, although it takes a lot of time to figure things out for the first time.
If you'd have any more pointers to specific information, that would help me out immensely. The diffs that you have would help me out for sure.
Is the MSVC x64 ABI documented somewhere? I didn't have time to wade through MSDN in search of that yet . . .
Kuba
On 21/06/06, Kuba Ober kuba@mareimbrium.org wrote:
Is the MSVC x64 ABI documented somewhere? I didn't have time to wade through MSDN in search of that yet . . .
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/Kernel_d/hh... has some info.
----- PŮVODNÍ ZPRÁVA ----- Od: "Kuba Ober" kuba@mareimbrium.org Komu: wine-devel@winehq.org Předmět: Re: Win64 status Datum: 21.6.2006 - 13:01:23
On Wednesday 21 June 2006 06:39, Filip Navara wrote:
Hello guys,
I'm about to jump in the middle of discussion. The problem is not only
with the calling convention, but with the whole ABI
rather. I've had
GCC patched to use the MSVC x64 calling convention
(without a switch
though) for about a year now, but it doesn't solve
the problem. There
is much more ABI differences including the exception
handling (and yes,
I mean exception handling in C, not only C++) where
MSVC generates special
unwinding information for the functions. I'm not
sure if it would be
even possible to mix the ABI this way, but I'm open
to hear some
suggestions.
I started uploading the diffs to www.volny.cz/xnavara/mingw64/, but it's kind of hard to rescue it since I have nothing to diff against since the MinGW64 CVS is down and it takes quite a while to find the right revision of files...
Does gcc have some C exception handling of its own? If not then we may be able to add that. gcc is pretty well tweakable, although it takes a lot of time to figure things out for the first time.
No, it doesn't.
If you'd have any more pointers to specific information, that would help me out immensely. The diffs that you have would help me out for sure.
Is the MSVC x64 ABI documented somewhere? I didn't have time to wade through MSDN in search of that yet . . .
As for the documentation I can recommend - http://blogs.msdn.com/freik/archive/category/12430.aspx - MSDN - the PE-COFF v8 document recently updated by MS (http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx) - the ABI document that comes with some MSVC versions
Regards, Filip
As for the documentation I can recommend
- http://blogs.msdn.com/freik/archive/category/12430.aspx
- MSDN
- the PE-COFF v8 document recently updated by MS
(http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx)
- the ABI document that comes with some MSVC versions
Thank you for the pointers, and thanks to H. Verbeet for the link as well!
That looks like some fun reading :/ Anyway, it seems easier than porting gcc to a new architecture from scratch ;)
Cheers, Kuba