This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libffi 3.2.1 and master, can't build with Visual Studio 2012


Richard,

Thanks for caring.

To compile with Visual Studio 2013, I'm using Cygwin because this is where I have Autotools installed.

1. navigate to C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts
2. open either the x86 or x64 native tools command prompt depending on what you want to build
3. $ C:\cygwin64\Cygwin.bat
4. $ cd path/to/libffi
5. $ ./autogen.sh

Once inside Cygwin, to build the x86 architecture (if you launched the x86 prompt)

6. $ mkdir build-x86
7. $ cd build-x86
8. $ ../configure CC=../msvcc.sh CXX=../msvcc.sh LD=link CPP="cl -nologo -EP" --build=i686-unknown-cygwin

Once inside Cygwin, to build the x86_64 architecture (if you launched the x64 prompt)

6. $ mkdir build-x64
7. $ cd build-x64
8. $ ../configure CC="../msvcc.sh -m64" CXX="../msvcc.sh -m64" LD=link CPP="cl -nologo -EP" --build=i686-unknown-cygwin
9. $ rm include/ffitarget.h
10. $ cp ../src/x86/ffitarget.h include/

Finally,

9. $ rm include/ffitarget.h
10. $ cp ../src/x86/ffitarget.h include/
11. comment out #define FFI_TARGET_HAS_COMPLEX_TYPE from include/ffitarget.h
12. make

Steps 9. and 10. are required because Visual Studio doesn't understand Cygwin's symlinks. And now you realize Windows platform with Visual Studio is really a second class citizen if msvcc.sh wasn't a strong enough hint ;)

If you reproduce this, on tag v3.2.1 you will build for the x86 architecture just fine while MASM bails out on win64.asm with error A2075 for the x86_64 architecture. To make the x86_64 architecture, I have to replace "jmp SHORT" with "jmp" in win64.asm lines 1026 and 1035.

You can reproduce these steps with Visual Studio 2012: just launch the appropriate command prompt before Cygwin and you'll face the C99 issues.

Hope that helps!
Gregory

PS: if someone knows how to achieve the equivalent with less hoops I'm totally all hears
________________________________________
From: Richard Henderson <rth@redhat.com>
Sent: Tuesday, November 18, 2014 5:02 PM
To: GrÃgory Pakosz; libffi-discuss@sourceware.org
Cc: nield.a.d@gmail.com; rth@twiddle.net
Subject: Re: libffi 3.2.1 and master, can't build with Visual Studio 2012

On 11/18/2014 04:23 PM, GrÃgory Pakosz wrote:
> âHello,
>
> I would like to inform you it's not possible to build libffi 3.2.1 with Visual Studio 2012 anymore as it's not a C99 compiler.
>
> In src/x86/ffi.c,
>
>   - src/x86/ffi.c doesn't compile because
>     - commit 098dca6b31e declares "size_t z" variables not at the beginning of blocks which is possible in C99 only
>     - commit 5d6340ef2cf8 moves "int i" variable declaration from beginning to middle of block
>     - this appears to be fixed in master by commit b21ec1ce783â though

These are simply oversights that can easily be fixed.

> static const struct abi_params abi_params[FFI_LAST_ABI] = {
>   [FFI_SYSV] = { 1, 0 },
>   [FFI_THISCALL] = { 1, 1, { R_ECX } },
>   [FFI_FASTCALL] = { 1, 2, { R_ECX, R_EDX } },
>   [FFI_STDCALL] = { 1, 0 },
>   [FFI_PASCAL] = { -1, 0 },
>   [FFI_REGISTER] = { -1, 3, { R_EAX, R_EDX, R_ECX } },
>   [FFI_MS_CDECL] = { 1, 0 }
> };

This one's tricky, without simply forcing X86 an X86_WIN32 to have the same
ffi_abi enumeration.  Currently, while they have the same symbols, the symbols
have different values.  So *not* using designated initializers is hard.

I suppose we could fill in the values at runtime from a switch statement,
but read-only data appeals to me...

And all of that's moot without re-porting the assembly back to masm, which I
was not looking forward to doing.

I have downloaded the recently released gratis VS 2013 Community, but I havn't
yet looked into it enough to figure out how to actually do things with it.
Do I really have to create some sort of project to get things to build, or
is there a command-line compiler included?

How are you building libffi with VS?


r~

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]