[PATCH 3 of 4] Win32: i386 now assumed when crossbuilding (ticket #2416)

Maxim Dounin mdounin at mdounin.ru
Fri Feb 10 21:15:39 UTC 2023


Hello!

On Fri, Feb 10, 2023 at 04:13:18PM +0400, Sergey Kandaurov wrote:

> 
> > On 20 Dec 2022, at 17:30, Maxim Dounin <mdounin at mdounin.ru> wrote:
> > 
> > # HG changeset patch
> > # User Maxim Dounin <mdounin at mdounin.ru>
> > # Date 1671542876 -10800
> > #      Tue Dec 20 16:27:56 2022 +0300
> > # Node ID 6606ed21a7091b060ebec0d082876ddbbbe0ea79
> > # Parent  43098cb134a87a404b70fcc77ad01ca343cba969
> > Win32: i386 now assumed when crossbuilding (ticket #2416).
> > 
> > Previously, NGX_MACHINE was not set when crossbuilding, resulting in
> > NGX_ALIGNMENT=16 being used in 32-bit builds (if not explicitly set to a
> > correct value).  This in turn might result in memory corruption in
> > ngx_palloc() (as there are no usable aligned allocator on Windows, and
> > normal malloc() is used instead, which provides 8 byte alignment on
> > 32-bit platforms).
> > 
> > To fix this, now i386 machine is set when crossbuilding, so nginx won't
> > assume strict alignment requirements.
> > 
> > diff -r 43098cb134a8 -r 6606ed21a709 auto/configure
> > --- a/auto/configure	Tue Dec 20 15:57:58 2022 +0300
> > +++ b/auto/configure	Tue Dec 20 16:27:56 2022 +0300
> > @@ -44,6 +44,7 @@ if test -z "$NGX_PLATFORM"; then
> > else
> >     echo "building for $NGX_PLATFORM"
> >     NGX_SYSTEM=$NGX_PLATFORM
> > +    NGX_MACHINE=i386
> > fi
> > 
> > . auto/cc/conf
> 
> Don't you want to put the assignment under this test?
> [ "$NGX_PLATFORM" = win32 ]
> 
> There are numerous examples in the wild of using
> the --crossbuild option with other values, despite
> statements that crossbuilds aren't really supported.
> 
> If we'd like to insist crossbuilding is win32 only,
> then it makes sense to have an explicit restriction,
> e.g. by rejecting --crossbuild values other than win32.

Using --crossbuild for anything isn't really suppported at all, 
even for win32, see comments to the ticket mentioned.  It mostly 
works for win32 though, but does not work at all for other 
platforms.

Examples you've seen are likely about using 3rd party crossbuild 
patches, and it's up to the patches to set appropriate 
NGX_MACHINE.

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx-devel mailing list