public inbox for [email protected]
help / color / mirror / Atom feedFrom: Dave Cramer <[email protected]>
To: Andrew Dunstan <[email protected]>
Cc: Michael Paquier <[email protected]>
Cc: Anthony Roberts <[email protected]>
Cc: Peter Eisentraut <[email protected]>
Cc: Daniel Gustafsson <[email protected]>
Cc: Tom Lane <[email protected]>
Cc: Mike Holmes <[email protected]>
Cc: Andres Freund <[email protected]>
Cc: Thomas Munro <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Cc: Lina Iyer <[email protected]>
Subject: Re: [PATCH] Add native windows on arm64 support
Date: Tue, 30 Jan 2024 09:50:10 -0500
Message-ID: <CADK3HHK1e2CEa5fYReZHt-iKcZtEMTZUnNxXoeTCnzyCfcG9Ew@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CADK3HH+T0rQ58sYp0NnvkvopcEHA74Zmg=z7J5=skRrX+odnYw@mail.gmail.com>
<[email protected]>
<CADK3HHJ4uCsw0b5-c_HvYebHn1jQB-hV007Jf5c7FwGrCvDNSg@mail.gmail.com>
<[email protected]>
<[email protected]>
<CADK3HHK4RVz8oQXiQ_bYiUx1ZXWNbfF+=r5kJ8hhfU8+MD1DOQ@mail.gmail.com>
<CAC1bJ4-tu8Ea0+D6sHdC_HuOSGbw6upFkr5B=eq_m0-2yf_-cg@mail.gmail.com>
<CADK3HHJXwHLHk12m99TQ+cOF5BuJr2=C4xOhVFXmGEPLfC+7XA@mail.gmail.com>
<[email protected]>
<CADK3HHKs8PkPSU7vGKxcVq3qcHv95YDyOXz6DEGoS1o=tz7QRQ@mail.gmail.com>
<[email protected]>
<[email protected]>
<CADK3HHJgTqi7ZeKhBvegTk1=rzDYfGgEJqZN-hNMvQPAJ6R3PA@mail.gmail.com>
<[email protected]>
<CADK3HH+0A19mqiOutuGHH-jWWdeobcenK+v2cc5uDRuvZW5MOw@mail.gmail.com>
<[email protected]>
On Tue, 30 Jan 2024 at 08:38, Andrew Dunstan <[email protected]> wrote:
>
> On 2024-01-29 Mo 11:20, Dave Cramer wrote:
>
>
> Dave Cramer
> www.postgres.rocks
>
>
> On Mon, 29 Jan 2024 at 11:16, Andrew Dunstan <[email protected]> wrote:
>
>>
>> On 2024-01-26 Fr 09:18, Dave Cramer wrote:
>>
>>
>>
>> On Fri, 26 Jan 2024 at 07:36, Andrew Dunstan <[email protected]> wrote:
>>
>>>
>>> On 2024-01-25 Th 20:32, Michael Paquier wrote:
>>> > On Thu, Jan 25, 2024 at 04:52:30PM -0500, Dave Cramer wrote:
>>> >> On Thu, 25 Jan 2024 at 16:32, Andrew Dunstan <[email protected]>
>>> wrote:
>>> >>> On 2024-01-25 Th 16:17, Dave Cramer wrote:
>>> >>> Yeah, I think the default Developer Command Prompt for VS2022 is set
>>> up
>>> >>> for x86 builds. AIUI you should start by executing "vcvarsall
>>> x64_arm64".
>>> >> Yup, now I'm in the same state you are
>>> > Wait a minute here. Based on [1], x64_arm64 means you can use a x64
>>> > host and you'll be able to produce ARM64 builds, still these will not
>>> > be able to run on the host where they were built. How much of the
>>> > patch posted upthread is required to produce such builds? Basically
>>> > everything from it, I guess, so as build dependencies can be
>>> > satisfied?
>>> >
>>> > [1]:
>>> https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170
>>>
>>>
>>> If you look at the table here x86 and x64 are the only supported host
>>> architectures. But that's OK, the x64 binaries will run on arm64 (W11
>>> ARM64 has x64 emulation builtin). If that didn't work Dave and I would
>>> not have got as far as we have. But you want the x64_arm64 argument to
>>> vcvarsall so you will get ARM64 output.
>>>
>>
>> I've rebuilt it using x64_arm64 and with the attached (very naive patch)
>> and I still get an x64 binary :(
>>
>>
>> With this patch I still get a build error, but it's different :-)
>>
>>
>> [1406/2088] "link" @src/backend/postgres.exe.rsp
>> FAILED: src/backend/postgres.exe src/backend/postgres.pdb
>> "link" @src/backend/postgres.exe.rsp
>> Creating library src\backend\postgres.exe.lib
>>
>> storage_lmgr_s_lock.c.obj : error LNK2019: unresolved external symbol
>> spin_delay referenced in function perform_spin_delay
>>
>> src\backend\postgres.exe : fatal error LNK1120: 1 unresolved externals
>>
>
> Did you add the latest lock.patch ?
>
>
>
>
> I'm a bit confused about exactly what needs to be applied. Can you supply
> a complete patch to be applied to a pristine checkout that will let me
> build?
>
>
> cheers
>
See attached.
Dave
Attachments:
[application/octet-stream] 0001-fix-build-for-arm.patch (2.2K, ../CADK3HHK1e2CEa5fYReZHt-iKcZtEMTZUnNxXoeTCnzyCfcG9Ew@mail.gmail.com/3-0001-fix-build-for-arm.patch)
download | inline diff:
From 19284a00142a1d3854d89b60e641e2048cbf1bb1 Mon Sep 17 00:00:00 2001
From: davecramer <[email protected]>
Date: Tue, 23 Jan 2024 13:29:48 -0500
Subject: [PATCH 1/2] fix build for arm
---
doc/src/sgml/installation.sgml | 2 +-
src/tools/msvc_gendef.pl | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index e73902b3f8..686a342150 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -4150,7 +4150,7 @@ make: *** [postgres] Error 1
<sect3 id="install-windows-full-64-bit">
<title>Special Considerations for 64-Bit Windows</title>
<para>
- PostgreSQL will only build for the x64 architecture on 64-bit Windows.
+ PostgreSQL will only build for the x64 and ARM64 architecture on 64-bit Windows.
</para>
<para>
Mixing 32- and 64-bit versions in the same build tree is not supported.
diff --git a/src/tools/msvc_gendef.pl b/src/tools/msvc_gendef.pl
index 12c49ed265..dfb26916bd 100644
--- a/src/tools/msvc_gendef.pl
+++ b/src/tools/msvc_gendef.pl
@@ -120,9 +120,9 @@ sub writedef
{
my $isdata = $def->{$f} eq 'data';
- # Strip the leading underscore for win32, but not x64
+ # Strip the leading underscore for win32, but not x64 and aarch64
$f =~ s/^_//
- unless ($arch eq "x86_64");
+ unless ($arch eq "x86_64" || $arch eq "aarch64");
# Emit just the name if it's a function symbol, or emit the name
# decorated with the DATA option for variables.
@@ -143,7 +143,7 @@ sub writedef
sub usage
{
die("Usage: msvc_gendef.pl --arch <arch> --deffile <deffile> --tempdir <tempdir> files-or-directories\n"
- . " arch: x86 | x86_64\n"
+ . " arch: x86 | x86_64 | aarch64\n"
. " deffile: path of the generated file\n"
. " tempdir: directory for temporary files\n"
. " files or directories: object files or directory containing object files\n"
@@ -160,7 +160,7 @@ GetOptions(
'tempdir:s' => \$tempdir,) or usage();
usage("arch: $arch")
- unless ($arch eq 'x86' || $arch eq 'x86_64');
+ unless ($arch eq 'x86' || $arch eq 'x86_64' || $arch eq 'aarch64');
my @files;
--
2.43.0.windows.1
[application/octet-stream] 0002-naive-patch-to-fix-locking-for-arm64.patch (1.9K, ../CADK3HHK1e2CEa5fYReZHt-iKcZtEMTZUnNxXoeTCnzyCfcG9Ew@mail.gmail.com/4-0002-naive-patch-to-fix-locking-for-arm64.patch)
download | inline diff:
From 0661774349f2a96c7aa4aaac328aca4118857f4a Mon Sep 17 00:00:00 2001
From: davecramer <[email protected]>
Date: Tue, 30 Jan 2024 09:47:25 -0500
Subject: [PATCH 2/2] naive patch to fix locking for arm64
---
src/include/storage/s_lock.h | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index aa06e49da2..61f365d0f5 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -256,8 +256,8 @@ spin_delay(void)
* We use the int-width variant of the builtin because it works on more chips
* than other widths.
*/
-#if defined(__arm__) || defined(__arm) || defined(__aarch64__)
-#ifdef HAVE_GCC__SYNC_INT32_TAS
+#if defined(__arm__) || defined(__arm) || defined(__aarch64__) || defined(_M_ARM64)
+//#ifdef HAVE_GCC__SYNC_INT32_TAS
#define HAS_TEST_AND_SET
#define TAS(lock) tas(lock)
@@ -277,7 +277,7 @@ tas(volatile slock_t *lock)
* high-core-count ARM64 processors. It seems mostly a wash for smaller gear,
* and ISB doesn't exist at all on pre-v7 ARM chips.
*/
-#if defined(__aarch64__)
+#if defined(__aarch64__) || defined(_M_ARM64)
#define SPIN_DELAY() spin_delay()
@@ -288,9 +288,9 @@ spin_delay(void)
" isb; \n");
}
-#endif /* __aarch64__ */
-#endif /* HAVE_GCC__SYNC_INT32_TAS */
-#endif /* __arm__ || __arm || __aarch64__ */
+#endif /* __aarch64__ _M_ARM64 */
+//#endif /* HAVE_GCC__SYNC_INT32_TAS */
+#endif /* __arm__ || __arm || __aarch64__ _M_ARM64 */
/* S/390 and S/390x Linux (32- and 64-bit zSeries) */
@@ -710,6 +710,7 @@ typedef LONG slock_t;
/* If using Visual C++ on Win64, inline assembly is unavailable.
* Use a _mm_pause intrinsic instead of rep nop.
*/
+#if !defined(_M_ARM64)
#if defined(_WIN64)
static __forceinline void
spin_delay(void)
@@ -724,6 +725,7 @@ spin_delay(void)
__asm rep nop;
}
#endif
+#endif
#include <intrin.h>
#pragma intrinsic(_ReadWriteBarrier)
--
2.43.0.windows.1
view thread (120+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: [PATCH] Add native windows on arm64 support
In-Reply-To: <CADK3HHK1e2CEa5fYReZHt-iKcZtEMTZUnNxXoeTCnzyCfcG9Ew@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox