Bug #75412 [Fbk->Asn]: Build with Mingw-w64

From: Date: Mon, 23 Oct 2017 02:12:09 +0000
Subject: Bug #75412 [Fbk->Asn]: Build with Mingw-w64
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211852@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75412&edit=1

 ID:                 75412
 User updated by:    svnpenn at gmail dot com
 Reported by:        svnpenn at gmail dot com
 Summary:            Build with Mingw-w64
-Status:             Feedback
+Status:             Assigned
 Type:               Bug
 Package:            *General Issues
 Operating System:   Windows
 PHP Version:        7.1.10
 Assigned To:        kalle
 Block user comment: N
 Private report:     N

 New Comment:

added comment


Previous Comments:
------------------------------------------------------------------------
[2017-10-23 02:11:20] svnpenn at gmail dot com

@kalle that looks good so far but again those are only 2 issues. So far I have come across similar
issues with the below additional files. Probably most files that assume "WIN32 == Visual
Studio" are going to need some attention. Note I am working on a patch myself, but it is a slow
process so maybe someone will be faster at it than me.

TSRM/TSRM.h
TSRM/tsrm_config_common.h
ext/fileinfo/libmagic/compress.c
ext/phar/func_interceptors.c
ext/phar/stream.c
ext/standard/basic_functions.c
ext/standard/crypt_freesec.c
ext/standard/dns.c
ext/standard/file.c
ext/standard/ftp_fopen_wrapper.c
ext/standard/http_fopen_wrapper.c
ext/standard/streamsfuncs.c
main/php_compat.h
main/php_network.h
main/php_syslog.h

------------------------------------------------------------------------
[2017-10-23 01:44:25] kalle@php.net

Hi, thanks for the information.

I don't think defining or altering the macros/header files is a viable thing to make support
for MingW, however I tried to make a patch based on your comment but I do not have any environment
to be able to even test it, I put up a gist here if (tho it was done against master, it should apply
for lower branches):
https://gist.github.com/KalleZ/7b72d4a62e1e90784788ff2c18d673e6

(Please change back the status of this report after testing)

Thanks!

------------------------------------------------------------------------
[2017-10-23 01:04:46] svnpenn at gmail dot com

After some closer looking, "u_char" is actually defined by Mingw-w64
"_bsd_types.h" [1]:

typedef unsigned char      u_char;

which is in turn included by "winsock2.h" [2]:

#include <_bsd_types.h>

we know this to be true because PHP is already doing it [3]:

#include <winsock2.h> /* Includes definition for u_char */

So we can bypass this particular error by including "winsock2.h" in the approriate place.
However as said before this is not the only issue preventing Mingw-w64 build. Here is another
example:

ext/date/php_date.c:2615:66: error: unknown type name ‘suseconds_t’

this is caused by not defining "PHP_WIN32" [4]. However, even if you define it, it still
fails:

win32/time.h:20:8: error: redefinition of ‘struct timezone’

So in this case either "win32/time.h" need to be modified to support both Visual Studio
and Mingw-w64, or perhaps a "mingw/time.h" needs to be introduced. Again, this is only one
problem currently with trying a Mingw-w64 build.

[1] http://github.com/mirror/mingw-w64/blob/8bcc708/mingw-w64-headers/crt/_bsd_types.h
[2] http://github.com/mirror/mingw-w64/blob/8bcc708/mingw-w64-headers/include/winsock2.h
[3] http://github.com/php/php-src/blob/e823770/main/mergesort.c#L66
[4] http://github.com/php/php-src/blob/e823770/ext/date/php_date.c#L33-L37

------------------------------------------------------------------------
[2017-10-21 19:17:52] svnpenn at gmail dot com

@kalle

it is not just u_char, several issues - but that is one

------------------------------------------------------------------------
[2017-10-21 18:30:09] kalle@php.net

Hi @svnpenn

I think the main reason for this not being supported is that no one on the development team have
ever done a build like that or there have been any past requests for it.

If its only u_char thats the issue, then perhaps the define can be moved to php.h (in php-src/main),
where a lot of cross OS compatibility macros and types also are defined.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=75412


--
Edit this bug report at https://bugs.php.net/bug.php?id=75412&edit=1


Thread (14 messages)

« previous php.bugs (#211852) next »