Re: [PATCH] Add native windows on arm64 support

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: Andrew Dunstan <andrew@dunslane.net>
Cc: Dave Cramer <davecramer@postgres.rocks>, Michael Paquier <michael@paquier.xyz>, Anthony Roberts <anthony.roberts@linaro.org>, Daniel Gustafsson <daniel@yesql.se>, Lina Iyer <lina.iyer@linaro.org>, Mike Holmes <mike.holmes@linaro.org>, Peter Eisentraut <peter@eisentraut.org>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Thomas Munro <thomas.munro@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>
Date: 2024-02-12T21:19:15Z
Lists: pgsql-hackers
Hi,

On 2024-02-12 12:50:12 -0800, Andres Freund wrote:
> On 2024-02-12 13:28:40 -0500, Andrew Dunstan wrote:
> I wonder if this indicates that we are either missing memory barriers
> somewhere or that the memory barriers we end up with on msvc + arm aren't
> correct?  Either could explain why the problem doesn't occur when building
> with optimizations.

I think I might have been on to something - if my human emulation of a
preprocessor isn't wrong, we'd end up with

#define S_UNLOCK(lock)	\
	do { _ReadWriteBarrier(); (*(lock)) = 0; } while (0)

on msvc + arm. And that's entirely insufficient - _ReadWriteBarrier() just
limits *compiler* level reordering, not CPU level reordering.  I think it's
even insufficient on x86[-64], but it's definitely insufficient on arm.



Another issue I see is that we have a bunch of code that's dependant on
__aarch64__ being set - but it doesn't look to me that it is set on msvc. One
obvious consequence of that is that 64bit atomics won't be used (see
src/include/port/atomics/arch-arm.h) - but that shouldn't cause this issue.


Greetings,

Andres Freund



Commits

  1. MSVC: Support building for AArch64.

  2. Remove "#ifdef WIN32" guards from src/port/win32*.c

  3. Adjust XML test case to avoid unstable behavior.

  4. Enable RandomizedBaseAddress (ASLR) on Windows with MSVC builds