m6w6 / ext-http

Extended HTTP Support
BSD 2-Clause "Simplified" License
79 stars 22 forks source link

3.0.1 build issue on Windows #55

Closed Jan-E closed 8 years ago

Jan-E commented 8 years ago

Compiling php_http.dll on Windows (x64, PHP7.0.11, nts, VC14) leads to this error with the 3.0.1RC1 release or the sources from git head

c:\php-sdk\php70dev\ext\http\src\php_http_api.h(116): error C2016: C requires that a struct
 or union has at least one member (compiling source file ext\http\src\php_http_options.c)
m6w6 commented 8 years ago

Uh, yeah lots of DEFINEs have changed in this refactoring, here's a current config.h from a Linux configure:


/* Define to 1 if you have the <arpa/inet.h> header file. */
#define HAVE_ARPA_INET_H 1

/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1

/* Have extended HTTP support */
#define HAVE_HTTP 1

/* Define to 1 if you have the `inet_pton' function. */
#define HAVE_INET_PTON 1

/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1

/* Define to 1 if you have the `iswalnum' function. */
#define HAVE_ISWALNUM 1

/* Define to 1 if you have the `nsl' library (-lnsl). */
/* #undef HAVE_LIBNSL */

/* Define to 1 if you have the `mbrtowc' function. */
#define HAVE_MBRTOWC 1

/* Define to 1 if <wchar.h> declares mbstate_t. */
#define HAVE_MBSTATE_T 1

/* Define to 1 if you have the `mbtowc' function. */
#define HAVE_MBTOWC 1

/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1

/* Define to 1 if you have the <netdb.h> header file. */
#define HAVE_NETDB_H 1

/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1

/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1

/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1

/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1

/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1

/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1

/* */
#define HAVE_UIDNA_IDNTOASCII 1

/* */
#define HAVE_UIDNA_NAMETOASCII_UTF8 1

/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1

/* Define to 1 if you have the <wchar.h> header file. */
#define HAVE_WCHAR_H 1

/* Define to 1 if you have the <wctype.h> header file. */
#define HAVE_WCTYPE_H 1

/* Define to 1 if your C compiler doesn't accept -c and -o together. */
/* #undef NO_MINUS_C_MINUS_O */

/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""

/* Define to the full name of this package. */
#define PACKAGE_NAME ""

/* Define to the full name and version of this package. */
#define PACKAGE_STRING ""

/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME ""

/* Define to the home page for this package. */
#define PACKAGE_URL ""

/* Define to the version of this package. */
#define PACKAGE_VERSION ""

/* */
#define PHP_HTTP_CAINFO "/etc/ssl/certs/ca-certificates.crt"

/* */
#define PHP_HTTP_CAPATH "/etc/ssl/certs"

/* */
#define PHP_HTTP_HAVE_CLIENT 1

/* */
#define PHP_HTTP_HAVE_CURLOPT_TLSAUTH_TYPE 1

/* */
#define PHP_HTTP_HAVE_EXT_HASH 1

/* */
#define PHP_HTTP_HAVE_EXT_ICONV 1

/* */
#define PHP_HTTP_HAVE_EXT_PROPRO 1

/* */
#define PHP_HTTP_HAVE_EXT_RAPHF 1

/* */
#define PHP_HTTP_HAVE_IDNA2003 1

/* */
#define PHP_HTTP_HAVE_IDNA2008 1

/* */
#define PHP_HTTP_HAVE_LIBCURL 1

/* */
/* #undef PHP_HTTP_HAVE_LIBCURL_ARES */

/* */
/* #undef PHP_HTTP_HAVE_LIBCURL_AXTLS */

/* */
#define PHP_HTTP_HAVE_LIBCURL_CAINFO 1

/* */
#define PHP_HTTP_HAVE_LIBCURL_CAPATH 1

/* */
/* #undef PHP_HTTP_HAVE_LIBCURL_GNUTLS */

/* */
/* #undef PHP_HTTP_HAVE_LIBCURL_GSKIT */

/* */
#define PHP_HTTP_HAVE_LIBCURL_HTTP 1

/* */
#define PHP_HTTP_HAVE_LIBCURL_HTTP2 1

/* */
/* #undef PHP_HTTP_HAVE_LIBCURL_MBEDTLS */

/* */
/* #undef PHP_HTTP_HAVE_LIBCURL_NSS */

/* */
#define PHP_HTTP_HAVE_LIBCURL_OPENSSL 1

/* */
/* #undef PHP_HTTP_HAVE_LIBCURL_POLARSSL */

/* */
/* #undef PHP_HTTP_HAVE_LIBCURL_SECURETRANSPORT */

/* */
#define PHP_HTTP_HAVE_LIBCURL_SSL 1

/* */
#define PHP_HTTP_HAVE_LIBCURL_TLSAUTH_TYPE 1

/* */
/* #undef PHP_HTTP_HAVE_LIBCURL_WOLFSSL */

/* */
#define PHP_HTTP_HAVE_LIBEVENT 1

/* */
#define PHP_HTTP_HAVE_LIBEVENT2 1

/* */
#define PHP_HTTP_HAVE_LIBICU 1

/* */
#define PHP_HTTP_HAVE_LIBIDN 1

/* */
#define PHP_HTTP_HAVE_LIBIDN2 1

/* */
#define PHP_HTTP_HAVE_LIBIDNKIT 1

/* */
/* #undef PHP_HTTP_HAVE_LIBIDNKIT2 */

/* */
#define PHP_HTTP_HAVE_PHP_PROPRO_H "/usr/include/php/ext/propro/php_propro.h"

/* */
#define PHP_HTTP_HAVE_PHP_RAPHF_H "/usr/include/php/ext/raphf/php_raphf.h"

/* */
#define PHP_HTTP_HAVE_ZLIB 1

/* */
#define PHP_HTTP_LIBCURL_TLSAUTH_DEF ""

/* */
#define PHP_HTTP_LIBCURL_TLSAUTH_SRP "SRP"

/* */
#define PHP_HTTP_LIBCURL_VERSION "7.50.3"

/* */
#define PHP_HTTP_LIBEVENT_VERSION "2.0.22-stable"

/* */
#define PHP_HTTP_LIBICU_VERSION "57.1"

/* */
#define PHP_HTTP_LIBIDN2_VERSION "0.9"

/* */
/* #undef PHP_HTTP_LIBIDNKIT2_VERSION */

/* */
#define PHP_HTTP_LIBIDNKIT_VERSION "1.0"

/* */
#define PHP_HTTP_LIBIDN_VERSION "1.33"

/* */
#define PHP_HTTP_ZLIB_VERSION "1.2.8"

/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1

/* missing event_assign() in libevent1 */
/* #undef event_assign */

/* missing event_base_new() in libevent1 */
/* #undef event_base_new */

/* Define to a type if <wchar.h> does not define. */
/* #undef mbstate_t */

/* Define to `long int' if <sys/types.h> does not define. */
/* #undef off_t */

Let me know if you need assistance on translating any of them!

Jan-E commented 8 years ago

If I look at the Makefile, mbstring defines /D HAVE_CONFIG_H for the oniguruma config.h (2) https://github.com/php/php-src/blob/master/ext/mbstring/oniguruma/config.h.in https://github.com/php/php-src/blob/master/ext/mbstring/oniguruma/win32/config.h

And pcre/pcrelib defines /D HAVE_CONFIG_H for this one: https://github.com/php/php-src/blob/master/ext/pcre/pcrelib/config.h

All 3 are from the core. I cannot change them.

Some other extensions bring their own config.h without defining HAVE_CONFIG_H. For instance: https://github.com/php/php-src/blob/master/ext/zip/lib/config.h

I cannot change them either.

Now what?

m6w6 commented 8 years ago

Sorry, the config.h is usually generated by running ./configure. I think the PHP build system on Windows does something along those lines, too, see the AC_DEFINE calls in config.w32.

Depending on the libraries and their features available on Windows the appropriate AC_DEFINE calls should be in config.w32.

E.g. if libcurl is available, AC_DEFINE("PHP_HTTP_HAVE_LIBCURL", 1), if it was built with SSL support, additionally, AC_DEFINE("PHP_HTTP_HAVE_LIBCURL_SSL", 1). If the SSL support in libcurl is provided by OpenSSL, AC_DEFINE("PHP_HTTP_HAVE_LIBCURL_OPENSSL", 1), etc.

Jan-E commented 8 years ago

The Windows build system does not generate any config.h when running 'cscript /nologo configure.js'. I checked that.

Besides that, the pecl_http extension does not have a flag /D HAVE_CONFIG_H. I assume this means that at compile time the extension does not include any config.h. If some defines are needed for pecl_http, they have to be included in its own config.w32.

Jan-E commented 8 years ago

The Windows build system adds the AC_DEFINE's to the CFLAGS for every externsion or to main/config.win32.h. These are the CFLAGS_HTTP

CFLAGS_HTTP=/D COMPILE_DL_HTTP /D HTTP_EXPORTS=1 /I "C:\php-sdk\win64build\include" /DHAVE_ZLIB_H=1 /I "ext\http..\hash" /DHTTP_HAVE_PHP_HASH_H=1 /DHAVE_CURL_CURL_H=1 /DHAVE_OPENSSL_CRYPTO_H=1 /Iext\http /DHAVE_EVENT2_EVENT_H=1

And here is a part of main/config.win32.h

/* Have extended HTTP support */
#define HAVE_HTTP 1

/* Depend on shared extensions */
#define HTTP_SHARED_DEPS 1

#define HAVE_GETHOSTNAME 1

/* Have zlib library */
#define HTTP_HAVE_ZLIB 1

/* Have CURL library */
#define PHP_HTTP_HAVE_CURL 1

/* Have SSL */
#define PHP_HTTP_HAVE_SSL 1

/*  */
#define PHP_HAVE_CURL_MULTI_STRERROR 1

/*  */
#define PHP_HAVE_CURL_SHARE_STRERROR 1

/*  */
#define PHP_HAVE_CURL_EASY_STRERROR 1

/*  */
#define PHP_HAVE_CURL_EASY_RESET 1

/*  */
#define PHP_HAVE_CURL_GETFORMDATA 1

/*  */
#define PHP_HAVE_CURL_FORMGET 1

/*  */
#define PHP_HAVE_CURL_MULTI_SETOPT 1

/*  */
#define PHP_HAVE_CURL_MULTI_TIMEOUT 1

/* Have HTTP client support */
#define PHP_HTTP_HAVE_CLIENT 1

#define PHP_HTTP_HAVE_EVENT 1

#define PHP_HTTP_HAVE_EVENT2 1

#define PHP_HTTP_EVENT_VERSION "2.0.21 or greater"
Jan-E commented 8 years ago

Which define(s) am I missing that causes the struct or union error?

Jan-E commented 8 years ago

OK, I am missing PHP_HTTP_HAVE_LIBCURL. In this line https://github.com/m6w6/ext-http/blob/master/config.w32#L106 PHP_HTTP_HAVE_CURL should be changed into PHP_HTTP_HAVE_LIBCURL

m6w6 commented 8 years ago

Yes, every CURL* should be changed to LIBCURL, and EVENT* to LIBEVENT\ etc...

Jan-E commented 8 years ago

Checks on IDN and ICU could be added:

capture

Jan-E commented 8 years ago

capture

Jan-E commented 8 years ago

I did not run the tests yet, but for anyone that wants to play with it:

https://phpdev.toolsforresearch.com/php-7.0.11-nts-Win32-VC14-x64.htm https://phpdev.toolsforresearch.com/php-7.0.11-nts-Win32-VC14-x64.zip

Jan-E commented 8 years ago

Tests:

=====================================================================
PHP         : /php-sdk/php70dev/x64/Release/php-7.0.11/php.exe
PHP_SAPI    : cli
PHP_VERSION : 7.0.11
ZEND_VERSION: 3.0.0
PHP_OS      : WINNT - Windows NT X220 6.1 build 7601 (Windows 7 Professional Edition Service Pack 1) AMD64
INI actual  : N:\php-sdk\php70dev\x64\Release\php-7.0.11\php.ini
More .INIs  :
CWD         : C:\php-sdk\php70dev\x64\Release\php-7.0.11
Extra dirs  :
VALGRIND    : Not used
=====================================================================
Running selected tests.
PASS url parser [/php-sdk/php70dev/ext/http/tests/urlparser001.phpt]
PASS url parser with paths [/php-sdk/php70dev/ext/http/tests/urlparser002.phpt]
PASS url parser with query [/php-sdk/php70dev/ext/http/tests/urlparser003.phpt]
SKIP url parser multibyte/locale [/php-sdk/php70dev/ext/http/tests/urlparser004.phpt]
    reason: need http\Url::PARSE_MBLOC support and LC_CTYPE=*.UTF-8
PASS url parser multibyte/utf-8 [/php-sdk/php70dev/ext/http/tests/urlparser005.phpt]
SKIP url parser multibyte/locale/idna [/php-sdk/php70dev/ext/http/tests/urlparser006.phpt]
    reason: need http\Url::PARSE_MBLOC|http\Url::PARSE_TOIDN_2003 support and LC_CTYPE=*.UTF-8
PASS url parser multibyte/utf-8/idna [/php-sdk/php70dev/ext/http/tests/urlparser007.phpt]
PASS url parser ipv6 [/php-sdk/php70dev/ext/http/tests/urlparser008.phpt]
PASS url parser userinfo [/php-sdk/php70dev/ext/http/tests/urlparser009.phpt]
SKIP url parser multibyte/locale/topct [/php-sdk/php70dev/ext/http/tests/urlparser010.phpt]
    reason: need http\Url::PARSE_MBLOC support and LC_CTYPE=*.UTF-8
PASS url parser multibyte/utf-8/topct [/php-sdk/php70dev/ext/http/tests/urlparser011.phpt]
SKIP url parser multibyte/locale/topct [/php-sdk/php70dev/ext/http/tests/urlparser012.phpt]
    reason: need http\Url::PARSE_MBLOC|http\Url::PARSE_TOIDN support and LC_CTYPE=*.UTF-8
PASS url parser multibyte/utf-8/topct [/php-sdk/php70dev/ext/http/tests/urlparser013.phpt]
=====================================================================
Number of tests :   13                 9
Tests skipped   :    4 ( 30.8%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    0 (  0.0%) (  0.0%)
Expected fail   :    0 (  0.0%) (  0.0%)
Tests passed    :    9 ( 69.2%) (100.0%)
---------------------------------------------------------------------
Time taken      :   28 seconds
=====================================================================
Jan-E commented 8 years ago

Not bad. @m6w6 Time to merge?

m6w6 commented 8 years ago

Awesome! Thanks a bunch!

m6w6 commented 8 years ago

WAT? 28 secs for 9 tests? o_O

Jan-E commented 8 years ago

Busy laptop, slow harddisk and loading far too many extensions. But even then php_http.dll is now dependent on

Module: php_http.dll
===========================
    icuuc57.dll
    ssleay32.dll
    libeay32.dll
    normaliz.dll
    vcruntime140.dll
    api-ms-win-crt-heap-l1-1-0.dll
    api-ms-win-crt-string-l1-1-0.dll
    api-ms-win-crt-convert-l1-1-0.dll
    api-ms-win-crt-runtime-l1-1-0.dll
    api-ms-win-crt-stdio-l1-1-0.dll
    api-ms-win-crt-utility-l1-1-0.dll
    api-ms-win-crt-time-l1-1-0.dll
    api-ms-win-crt-filesystem-l1-1-0.dll
    api-ms-win-crt-environment-l1-1-0.dll

And icuuc57.dl in its turn loads the 24,4 MB icudt57.dll

=====================================================================
PHP         : /php-sdk/php70dev/x64/Release/php-7.0.11/php.exe
PHP_SAPI    : cli
PHP_VERSION : 7.0.11
ZEND_VERSION: 3.0.0
PHP_OS      : WINNT - Windows NT X220 6.1 build 7601 (Windows 7 Professional Edition Service Pack 1) AMD64
INI actual  : N:\php-sdk\php70dev\x64\Release\php-7.0.11\php.ini
More .INIs  :
CWD         : C:\php-sdk\php70dev\x64\Release\php-7.0.11
Extra dirs  :
VALGRIND    : Not used
=====================================================================
Running selected tests.
PASS url parser [/php-sdk/php70dev/ext/http/tests/urlparser001.phpt]
PASS url parser with paths [/php-sdk/php70dev/ext/http/tests/urlparser002.phpt]
PASS url parser with query [/php-sdk/php70dev/ext/http/tests/urlparser003.phpt]
SKIP url parser multibyte/locale [/php-sdk/php70dev/ext/http/tests/urlparser004.phpt]
    reason: need http\Url::PARSE_MBLOC support and LC_CTYPE=*.UTF-8
PASS url parser multibyte/utf-8 [/php-sdk/php70dev/ext/http/tests/urlparser005.phpt]
SKIP url parser multibyte/locale/idna [/php-sdk/php70dev/ext/http/tests/urlparser006.phpt]
    reason: need http\Url::PARSE_MBLOC|http\Url::PARSE_TOIDN_2003 support and LC_CTYPE=*.UTF-8
PASS url parser multibyte/utf-8/idna [/php-sdk/php70dev/ext/http/tests/urlparser007.phpt]
PASS url parser ipv6 [/php-sdk/php70dev/ext/http/tests/urlparser008.phpt]
PASS url parser userinfo [/php-sdk/php70dev/ext/http/tests/urlparser009.phpt]
SKIP url parser multibyte/locale/topct [/php-sdk/php70dev/ext/http/tests/urlparser010.phpt]
    reason: need http\Url::PARSE_MBLOC support and LC_CTYPE=*.UTF-8
PASS url parser multibyte/utf-8/topct [/php-sdk/php70dev/ext/http/tests/urlparser011.phpt]
SKIP url parser multibyte/locale/topct [/php-sdk/php70dev/ext/http/tests/urlparser012.phpt]
    reason: need http\Url::PARSE_MBLOC|http\Url::PARSE_TOIDN support and LC_CTYPE=*.UTF-8
PASS url parser multibyte/utf-8/topct [/php-sdk/php70dev/ext/http/tests/urlparser013.phpt]
=====================================================================
Number of tests :   13                 9
Tests skipped   :    4 ( 30.8%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    0 (  0.0%) (  0.0%)
Expected fail   :    0 (  0.0%) (  0.0%)
Tests passed    :    9 ( 69.2%) (100.0%)
---------------------------------------------------------------------
Time taken      :    5 seconds
=====================================================================

BTW: this was after Remi's setlocale merge. It does not make any difference on Windows.