[PATCH] Support cross compiling with MinGW-w64 on Debian GNU/Linux

Kouhei Sutou kou at cozmixng.org
Tue Oct 14 15:23:33 UTC 2014


Thanks for reviewing. I've updated my patch.

In <20141014141022.GL31276 at mdounin.ru>
  "Re: [PATCH] Support cross compiling with MinGW-w64 on Debian GNU/Linux" on Tue, 14 Oct 2014 18:10:22 +0400,
  Maxim Dounin <mdounin at mdounin.ru> wrote:

>> > 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.
> It ends up using 32-bit off_t as it doesn't understand 
> _FILE_OFFSET_BITS, and then build fails due to this.
> No exact error message as I've already reverted VM where MinGW gcc 
> was installed to a previous state, sorry.

Thanks for the information.
I changed my patch to apply for MinGW-w64 gcc.

But there is no macro to distinguish MinGW-w64 gcc and MinGW
gcc... So I added MGX_MINGW_W64 and MGX_MINGW macros by
auto/define and use ngx_auto_config.h in ngx_win32_config.h.

How do you think about this approach?

Other ngx_*_config.h include ngx_auto_config.h after some
"#include"s but now ngx_win32_config.h includes
ngx_auto_config.h *before* some "#include"s. Because I want
to use NGX_MINGW_W64 macro to change "#include".

>> Win32: made build-able with MinGW-w64
> It should be fine to add a dot to the first line (and probably 
> "gcc"), and drop everything else.  I.e.,
> Win32: made build-able with MinGW-w64 gcc.

OK! I've changed it.

>> +#if defined(__GNUC__) && defined(_WIN64)
> Shouldn't it be for all compilers, not just gcc?

I don't know about it because I didn't check it on Visual
C++... But I removed "defined(__GNUC__)" check.

>> +#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
>>  #define NGX_PTR_SIZE            4
>>  #define NGX_SIZE_T_LEN          (sizeof("-2147483648") - 1)
>>  #define NGX_MAX_SIZE_T_VALUE    2147483647
>>  #define NGX_TIME_T_LEN          (sizeof("-2147483648") - 1)
>>  #define NGX_TIME_T_SIZE         4
>> +#endif
>>  #define NGX_OFF_T_LEN           (sizeof("-9223372036854775807") - 1)
>>  #define NGX_MAX_OFF_T_VALUE     9223372036854775807
>>  #define NGX_SIG_ATOMIC_T_SIZE   4
> Style nit: this needs more empty lines before/after preprocessor 
> directives.

It means the following?

  #ifdef XXX

  #define A
  #define B


  #define C
  #define D


Or the following?

  #ifdef XXX
  #define A
  #define B

  #define C
  #define D


Other codes use the latter in the file, so I used the latter

-------------- next part --------------
A non-text attachment was scrubbed...
Name: win32-made-build-able-with-mingw-w64-v3.patch
Type: text/x-patch
Size: 9090 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20141015/28ec2c58/attachment.bin>

More information about the nginx-devel mailing list