Ticket #1846 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

win32 compile fails on sysmem.c on mingw gcc 4.5 (w. workaround)

Reported by: ronaldws Owned by:
Priority: normal Milestone: 2.10
Component: build Version: 2.10.0
Severity: medium Keywords:
Cc: Language:
Patch status: Platform: win32

Description

mingw32-make fails with diagnostic output included below.

As a workaround if I change line 26 of config/gen/platform/win32/sysmem.c from:

#if defined MINGW32 && GNUC < 4

to:

#if defined MINGW32 /* && GNUC < 4 */

then parrot builds OK and tests out mostly OK. Rebuild requires mingw32-make realclean and perl Configure.pl followed by mingw32-make. Some preprocessing of sysmem.c seems to mean that mingw32-make clean is not enough.

Fixing this properly will require someone with a better understanding of mingw gcc access to the MEMORYSTATUSEX structure across various compiler versions.

Diagnostic output:

config/gen/platform/win32/sysmem.c: In function 'Parrot_sysmem_amount':

config/gen/platform/win32/sysmem.c:57:5: error: 'MEMORYSTATUSEX' undeclared (first use in this function)

config/gen/platform/win32/sysmem.c:57:5: note: each undeclared identifier is reported only once for each function it appears in

config/gen/platform/win32/sysmem.c:57:20: error: expected ';' before 'statex'

config/gen/platform/win32/sysmem.c:59:5: error: 'statex' undeclared (first use in this function)

Attachments

begin.patch Download (486 bytes) - added by ronaldws 4 years ago.
Detect Mingw gcc set to too old version of Windows

Change History

  Changed 4 years ago by fperrad

I wrote this condition (see  http://github.com/parrot/parrot/commit/ad6f3e3c641504d0be47a3dc02318bc289f17523)

mingw/gcc 3.4.5 (from mingw.org) doesn't supply a declaration of _MEMORYSTATUSEX, MEMORYSTATUSEX, LPMEMORYSTATUSEX.

mingw/gcc 4.4.3 (which comes with Strawberry Perl 5.12.1) supply it in the file i686-w64-mingw32/include/winbase.h.

mingw/gcc 3.4.5 is still used by one machine on  http://tt.taptinder.org/

  Changed 4 years ago by ronaldws

I use Mingw with gcc 4.5 and Activestate Perl. After looking at my include files I noticed that MEMORYSTATUSEX is described in my winbase.h file but the definition is not compiled in because my windef.h file sets my WINVER and _WIN32_WINNT to 0x0400 and in my winbase.h :

#if (_WIN32_WINNT >= 0x0500)
typedef struct _MEMORYSTATUSEX {
...
#endif

I am working under Windows Vista and am still looking into it a bit.

follow-up: ↓ 4   Changed 4 years ago by ronaldws

_WIN32_WINNT is essentially a copy of the definition of WINVER in my environment and my value of 0x0400 seems to correspond to WinNT 4.0/Windows 98. Parrot probably doesn't want to support those versions of Windows. I found some documentation on WINVER at the links included below and when I changed mine to 0x0501 (for WinXP) things compiled OK. I find it reasonable for the compiler to detect such a condition more clearly and will attach a patch to emit a compile time error for Windows versions less than Windows2000 under gcc.

Hope this helps someone.

Some helpful links:
 Some postings
 A link from Microsoft
 Mingw wiki posting about definitions of windows versions

Changed 4 years ago by ronaldws

Detect Mingw gcc set to too old version of Windows

in reply to: ↑ 3 ; follow-up: ↓ 5   Changed 4 years ago by jkeenan

Replying to ronaldws:

WinNT 4.0/Windows 98. Parrot probably doesn't want to support those versions of Windows.

No, we can certainly exclude support for those versions of Windows based on already established policy.

I haven't attempted to boot my Windows 98 box in years, so I can't test the patch. It looks sane to me, but perhaps fperrad or others more knowledgeable about Windows should look at it.

Thank you very much.

kid51

in reply to: ↑ 4   Changed 4 years ago by ronaldws

Replying to jkeenan:

Replying to ronaldws:

WinNT 4.0/Windows 98. Parrot probably doesn't want to support those versions of Windows.

I haven't attempted to boot my Windows 98 box in years, so I can't test the patch.

Just to clarify ... I am running under Windows Vista. My MingW installation seems to have set WINVER to a value for an old version of Windows probably to maximize compatability of compiler output across Windows versions. This may or may not be common - I'm not sure about defaults for different MingW installations. In essence, what seems to be happening here is that we are requiring a compiler interface for more modern versions of the Windows API to take advantage of a more modern memory analysis API. More serious analysis may allow for the use of the older MEMORYSTATUS structure instead of or as well as the MEMORYSTATUSEX function.

For the time being I was hoping that the discussion here might suggest some straight forward approaches to simply help someone with a different WINVER default to get parrot to compile.

Ron

follow-up: ↓ 7   Changed 4 years ago by fperrad

See  http://github.com/parrot/parrot/commit/a8192ac19b7f338117a1ac1c355219cb4a12ba5c

Finally, I put the check in config/gen/platform/win32/misc.h which populates include/parrot/platform.h (instead of config/gen/platform/win32/begin.c which populates src/platform.c).

So, it fails early.

in reply to: ↑ 6   Changed 4 years ago by fperrad

Replying to fperrad:

See  http://github.com/parrot/parrot/commit/a8192ac19b7f338117a1ac1c355219cb4a12ba5c Finally, I put the check in config/gen/platform/win32/misc.h which populates include/parrot/platform.h (instead of config/gen/platform/win32/begin.c which populates src/platform.c). So, it fails early.

See a8192ac works also.

  Changed 4 years ago by fperrad

Ronald,

is it ok for you now ?

  Changed 4 years ago by ronaldws

Yes - as far as I know it is fine to close this ticket.

Ron

  Changed 4 years ago by fperrad

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.