[PATCH] Support cross compiling with MinGW-w64 on Debian GNU/Linux
Kouhei Sutou
kou at cozmixng.org
Tue Oct 14 13:42:33 UTC 2014
Hi,
In <20141014002218.GH31276 at mdounin.ru>
"Re: [PATCH] Support cross compiling with MinGW-w64 on Debian GNU/Linux" on Tue, 14 Oct 2014 04:22:18 +0400,
Maxim Dounin <mdounin at mdounin.ru> wrote:
>> >> diff --git a/src/event/modules/ngx_iocp_module.c b/src/event/modules/ngx_iocp_module.c
>> >> --- a/src/event/modules/ngx_iocp_module.c
>> >> +++ b/src/event/modules/ngx_iocp_module.c
>> ...
>> >
>> > Looks fine, though I think it should be a separate patch.
>>
>> I see!
>> I did: http://mailman.nginx.org/pipermail/nginx-devel/2014-October/006072.html
>
> This and ngx_wsasend_chain.c patches committed (with minor changes
> to commit logs), thanks.
Thanks!
>> Compiler:
>>
>> % x86_64-w64-mingw32-gcc --version
>> x86_64-w64-mingw32-gcc (GCC) 4.9.1
>
> While this patch fixes compilation with MinGW-w64 gcc, it breaks
> compilation with MinGW gcc, which isn't good.
Oh...
Could you show me the build errors? I don't have MinGW on my
machine.
>> #include <stdio.h>
>> #include <stdlib.h>
>> #include <stdarg.h>
>> +#ifdef __GNUC__
>> +#include <stdint.h> /* intptr_t and uintptr_t */
>> +#endif
>> #include <ctype.h>
>> #include <locale.h>
>
> Minor nit: the comment here looks unneeded.
OK. I removed it in the attached patch.
>> typedef __int64 int64_t;
>> typedef unsigned __int64 uint64_t;
>>
>> -#ifndef __WATCOMC__
>> +#if defined(__WATCOMC__) || defined(__GNUC__)
>> +/* do nothing */
>> +#else
>> typedef int intptr_t;
>> typedef u_int uintptr_t;
>> #endif
>
> The construction looks awfull, it should be
>
> #if !defined(...) && !defined(...)
> ...
> #endif
>
> instead.
I used the style in the attached patch.
> [...]
>
>> #define NGX_PTR_SIZE 4
>> #define NGX_SIZE_T_LEN (sizeof("-2147483648") - 1)
>> #define NGX_MAX_SIZE_T_VALUE 2147483647
>
> Note well: the ngx_win32_config.h defines various constants,
> including ones quoted, assuming 32-bit build. 64-bit build will
> be flawed unless these constands are changed appropriately.
I confirmed size of them with the following change:
diff -r 9d6d7b34f93b src/core/nginx.c
--- a/src/core/nginx.c Tue Oct 14 22:36:23 2014 +0900
+++ b/src/core/nginx.c Tue Oct 14 22:36:23 2014 +0900
@@ -201,16 +201,21 @@ static char **ngx_os_environ;
int ngx_cdecl
main(int argc, char *const *argv)
{
ngx_int_t i;
ngx_log_t *log;
ngx_cycle_t *cycle, init_cycle;
ngx_core_conf_t *ccf;
+ printf("%Iu:%Iu:%Iu\n",
+ sizeof(size_t),
+ sizeof(void *),
+ sizeof(time_t));
+
ngx_debug_init();
if (ngx_strerror_init() != NGX_OK) {
return 1;
}
if (ngx_get_options(argc, argv) != NGX_OK) {
return 1;
I run objs/nginx on Wine and got the following output:
8:8:8
So I added the following change to the attached patch:
+#if defined(__GNUC__) && defined(_WIN64)
+#define NGX_PTR_SIZE 8
+#define NGX_SIZE_T_LEN (sizeof("-9223372036854775808") - 1)
+#define NGX_MAX_SIZE_T_VALUE 9223372036854775807
+#define NGX_TIME_T_LEN (sizeof("-9223372036854775808") - 1)
+#define NGX_TIME_T_SIZE 8
+#else
Could you review my new patch?
Thanks,
--
kou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: win32-made-build-able-with-mingw-w64-v2.patch
Type: text/x-patch
Size: 7549 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20141014/565121f2/attachment.bin>
More information about the nginx-devel
mailing list