[vbox-dev] recompiler msvc port

Nikolay Igotti Nikolay.Igotti at Sun.COM
Mon Jul 20 13:34:18 GMT 2009


   Hi Huihong,

 There are 2 places to look at:
  - global variable assigned to a register (see SAVE_GLOBAL_REGISTER in 
osdep.h), using syntax
    register host_reg_t  globalVariable asm("r14");
   See no easy way to fix it (unlikly MSVC has such feature as binding 
variable to a register permanently),    
   other than explicit  syncing globals into the  register on entry to 
the  generated code prologue.
  - calling convention (that's what likely bites you) - you need to fix 
the way TCG calls external functions,
    to adopt MSVC calling convention (i.e. which argument goes into 
which register).

 As I said, it's not really easy, yet feasible.

 Thanks,
   Nikolay


Huihong Luo wrote:
> Hi Nikolay,
>  
> I built the recompiler with vs2005 after removing C99 features etc. 
> However, it does not work, throwing "Invalid Instruction" at runtime.
>  
> You've mentioned about "global registers variables", can you be more 
> specific as what code to change? and any hardcoded stuff that needs to 
> be ported? such as host register env, calling conventions, etc. Let me 
> know any info that may save the efforts.
>  
> Right now, I am working on 32-bit.
>  
> - Huihong
>
>
> --- On *Wed, 7/15/09, Nikolay Igotti /<Nikolay.Igotti at Sun.COM>/* wrote:
>
>
>     From: Nikolay Igotti <Nikolay.Igotti at Sun.COM>
>     Subject: Re: [vbox-dev] Is gcc 3.3.x really necessary to compile
>     the recompiler?
>     To: "Huihong Luo" <huisinro at yahoo.com>
>     Cc: "VirtualBox developer's list" <vbox-dev at virtualbox.org>
>     Date: Wednesday, July 15, 2009, 2:26 AM
>
>         Hi Huihong,
>
>     Don't think MSVC compilation can be easily done (C compiler in
>     MSVC also don't support C99, whose array initialization by index
>     feature is heavily used).
>     Maybe easier will be to use MinGW64. Cross compilation process is
>     just a compilation with cross-compiler :) - you build GCC as
>     Windows executable capable to produce Linux binaries. There are
>     docs on the net. GCC version is around 3.4, IIRC.
>
>     Thanks,
>        Nikolay.
>
>
>
>     Huihong Luo пишет:
>     > Hi Nilolay,
>     >  I will give it a try to see if msvc++ compilation of recompiler
>     can be easily done.
>     >  In the meantime, can you give some details on the cross
>     compilation process? which tool are you using? which version? more
>     info is highly appreciated.
>     >  Thanks for your very helpful info thus far,
>     >  Huihong
>     >
>     > --- On *Tue, 7/14/09, Nikolay Igotti /<Nikolay.Igotti at Sun.COM
>     <http://us.mc343.mail.yahoo.com/mc/compose?to=Nikolay.Igotti@Sun.COM>>/*
>     wrote:
>     >
>     >
>     >     From: Nikolay Igotti <Nikolay.Igotti at Sun.COM
>     <http://us.mc343.mail.yahoo.com/mc/compose?to=Nikolay.Igotti@Sun.COM>>
>     >     Subject: Re: [vbox-dev] Is gcc 3.3.x really necessary to compile
>     >     the recompiler?
>     >     To: "Huihong Luo" <huisinro at yahoo.com
>     <http://us.mc343.mail.yahoo.com/mc/compose?to=huisinro@yahoo.com>>
>     >     Cc: "VirtualBox developer's list" <vbox-dev at virtualbox.org
>     <http://us.mc343.mail.yahoo.com/mc/compose?to=vbox-dev@virtualbox.org>>
>     >     Date: Tuesday, July 14, 2009, 12:25 PM
>     >
>     >     Hi Huihong,
>     >
>     >     Actually this file is built on Windows using cross-compiler for
>     >     Linux target :). It's being built this way, because there was no
>     >     good MinGW for 64-bit at times it was done, and REM relies
>     on GCC
>     >     extensions (notably global registers variables and some FP
>     stuff)
>     >     to function correctly. Right approach would be to rebuild
>     >     recompiler with MSVC eventually, but it needs a volunteer (I
>     think
>     >     it was done for QEMU, so should be feasible).
>     >     Also if taking MinGW64 approach don't forget calling convention
>     >     difference on AMD64 between Linux and Windows. REM relies on
>     that
>     >     too (not too hard to fix, for sure, just need a bit of
>     >     understanding in TCG).
>     >
>     >     If you (or someone else on this list ) will do that - I can help
>     >     with getting patch integrated (never found enough time/desire to
>     >     do that myself).
>     >
>     >     Thanks,
>     >     Nikolay.
>     >
>     >
>     >     Huihong Luo пишет:
>     >     > Hi Nikolay,
>     >     > Thanks for the clarification. It's much easier without
>     sticking
>     >     to the old gcc version.
>     >     > Yes, I noticed that VBoxRem2.rel is an ELF image. Can you
>     >     explain how this file is built? I assume it's done on Linux. Do
>     >     you use mingw toolchain on linux to do the cross compile? Since
>     >     it's ELF image, perhaps it's built from pure linux gcc (w/o
>     cross
>     >     compile to windows)?
>     >     > I am trying to eliminate VBoxREM2.rel on windows using
>     MingW64,
>     >     in other words, combining the current VBoxREM.dll + VBoxREM2.rel
>     >     ==> VBoxREM.dll
>     >     > Thanks,
>     >     > Huihong
>     >     >
>     >     > --- On *Tue, 7/14/09, Nikolay Igotti
>     /<Nikolay.Igotti at Sun.COM
>     <http://us.mc343.mail.yahoo.com/mc/compose?to=Nikolay.Igotti@Sun.COM>
>     > 
>        <http://us.mc343.mail.yahoo.com/mc/compose?to=Nikolay.Igotti@Sun.COM>>/*
>     >     wrote:
>     >     >
>     >     >
>     >     >     From: Nikolay Igotti <Nikolay.Igotti at Sun.COM
>     <http://us.mc343.mail.yahoo.com/mc/compose?to=Nikolay.Igotti@Sun.COM>
>     > 
>        <http://us.mc343.mail.yahoo.com/mc/compose?to=Nikolay.Igotti@Sun.COM>>
>     >     >     Subject: Re: [vbox-dev] Is gcc 3.3.x really necessary
>     to compile
>     >     >     the recompiler?
>     >     >     To: "Huihong Luo" <huisinro at yahoo.com
>     <http://us.mc343.mail.yahoo.com/mc/compose?to=huisinro@yahoo.com>
>     > 
>        <http://us.mc343.mail.yahoo.com/mc/compose?to=huisinro@yahoo.com>>
>     >     >     Cc: "VirtualBox developer's list"
>     <vbox-dev at virtualbox.org
>     <http://us.mc343.mail.yahoo.com/mc/compose?to=vbox-dev@virtualbox.org>
>     > 
>        <http://us.mc343.mail.yahoo.com/mc/compose?to=vbox-dev@virtualbox.org>>
>     >     >     Date: Tuesday, July 14, 2009, 2:24 AM
>     >     >
>     >     >     Hi Huihong,
>     >     >
>     >     >
>     >     >     Recompiler should build OK with recent gcc. Gcc 3
>     limitation was
>     >     >     applicable to 'old' recompiler, not relying on TCG for
>     >     >     codegeneration. Windows 64-bit REM is built to ELF image,
>     >     not PE,
>     >     >     thus MinGW shall be of little help to you.
>     >     >
>     >     >     Thanks,
>     >     >     Nikolay.
>     >     >
>     >     >
>     >     >     Huihong Luo wrote:
>     >     >     > The reason I asked is that gcc 4.4.3 seems to be working
>     >     fine on
>     >     >     linux, so I am very confused about gcc requirement.
>     >     >     > I am trying to use the latest gcc4.4.0 mingw64 bit
>     on amd64 to
>     >     >     build the recompiler, would this be a problem?
>     >     >     > Does 3.3.x requirement only apply to mingw32? in
>     other cases,
>     >     >     gcc 4 is OK?
>     >     >     > Thanks,
>     >     >     >
>     >     >     >
>     >     >       
>     ------------------------------------------------------------------------
>     >     >     >
>     >     >     > _______________________________________________
>     >     >     > vbox-dev mailing list
>     >     >     > vbox-dev at virtualbox.org
>     <http://us.mc343.mail.yahoo.com/mc/compose?to=vbox-dev@virtualbox.org>
>     > 
>        <http://us.mc343.mail.yahoo.com/mc/compose?to=vbox-dev@virtualbox.org>
>     >     >       
>     <http://us.mc343.mail.yahoo.com/mc/compose?to=vbox-dev@virtualbox.org>
>     >     >     > http://vbox.innotek.de/mailman/listinfo/vbox-dev
>     >     >     >
>     >     >
>     >     >
>     > 
>        ------------------------------------------------------------------------
>     >     >
>     >     > _______________________________________________
>     >     > vbox-dev mailing list
>     >     > vbox-dev at virtualbox.org
>     <http://us.mc343.mail.yahoo.com/mc/compose?to=vbox-dev@virtualbox.org>
>     > 
>        <http://us.mc343.mail.yahoo.com/mc/compose?to=vbox-dev@virtualbox.org>
>     >     > http://vbox.innotek.de/mailman/listinfo/vbox-dev
>     >     >   
>     >
>     ------------------------------------------------------------------------
>     >
>     > _______________________________________________
>     > vbox-dev mailing list
>     > vbox-dev at virtualbox.org
>     <http://us.mc343.mail.yahoo.com/mc/compose?to=vbox-dev@virtualbox.org>
>     > http://vbox.innotek.de/mailman/listinfo/vbox-dev
>     >   
>





More information about the vbox-dev mailing list