public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
* libffi 3.2.1 and master, can't build with Visual Studio 2012
@ 2014-11-18 15:23 Grégory Pakosz
  2014-11-18 16:02 ` Richard Henderson
  0 siblings, 1 reply; 4+ messages in thread
From: Grégory Pakosz @ 2014-11-18 15:23 UTC (permalink / raw)
  To: libffi-discuss; +Cc: nield.a.d, rth

​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

- for libffi master branch, starting with commit b9ac94f3af9b1c, the now uses designated initializers, e.g:

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 }
};


What do you think? Do you want to impose compiling libffi with a C99 compiler?

Regards,
Gregory


PS: The problems mentioned happen independently of the recent questions around Visual Studio supporting C99's complex types.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: libffi 3.2.1 and master, can't build with Visual Studio 2012
  2014-11-18 15:23 libffi 3.2.1 and master, can't build with Visual Studio 2012 Grégory Pakosz
@ 2014-11-18 16:02 ` Richard Henderson
  2014-11-18 17:14   ` Grégory Pakosz
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2014-11-18 16:02 UTC (permalink / raw)
  To: Grégory Pakosz, libffi-discuss; +Cc: nield.a.d, rth

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~

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: libffi 3.2.1 and master, can't build with Visual Studio 2012
  2014-11-18 16:02 ` Richard Henderson
@ 2014-11-18 17:14   ` Grégory Pakosz
  2015-04-21 18:15     ` Grégory Pakosz
  0 siblings, 1 reply; 4+ messages in thread
From: Grégory Pakosz @ 2014-11-18 17:14 UTC (permalink / raw)
  To: Richard Henderson, libffi-discuss; +Cc: nield.a.d, rth

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~

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: libffi 3.2.1 and master, can't build with Visual Studio 2012
  2014-11-18 17:14   ` Grégory Pakosz
@ 2015-04-21 18:15     ` Grégory Pakosz
  0 siblings, 0 replies; 4+ messages in thread
From: Grégory Pakosz @ 2015-04-21 18:15 UTC (permalink / raw)
  To: Richard Henderson, libffi-discuss

Bump?

Cheers,
Gregory

________________________________________
From: libffi-discuss-owner@sourceware.org <libffi-discuss-owner@sourceware.org> on behalf of Grégory Pakosz <gpakosz@myscript.com>
Sent: Tuesday, November 18, 2014 6:12 PM
To: Richard Henderson; 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

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~

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-04-21 18:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-18 15:23 libffi 3.2.1 and master, can't build with Visual Studio 2012 Grégory Pakosz
2014-11-18 16:02 ` Richard Henderson
2014-11-18 17:14   ` Grégory Pakosz
2015-04-21 18:15     ` Grégory Pakosz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).