Some recent work involving SIMD instructions on AArch64 made me wonder
whether we support $SUBJECT.  For reference, AArch64 is bi-endian, but
AFAICT all current AAarch64 buildfarm machines are on macOS, Linux, or
FreeBSD, which appear to require little-endian [0] [1] [2].  I know there
are efforts to support Windows on AAarch64, but that requires
little-endian, too [3].  Given the apparent convergence on little-endian,
IMHO we should require it for Postgres, too.  The attached patch adds some
configure-time checks for this.

[0] 
https://developer.apple.com/documentation/apple-silicon/porting-your-macos-apps-to-apple-silicon#Address-Architectural-Differences
[1] https://github.com/torvalds/linux/commit/1cf89b6b
[2] https://github.com/freebsd/freebsd-src/commit/ad0a6546
[3] 
https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#endianness

-- 
nathan
>From 0bccd2d7e777ab5bd758b5e07e1917872876660d Mon Sep 17 00:00:00 2001
From: Nathan Bossart <[email protected]>
Date: Thu, 2 Oct 2025 15:00:56 -0500
Subject: [PATCH v1 1/1] disallow big endian on aarch64

---
 configure    | 7 +++++++
 configure.ac | 7 +++++++
 meson.build  | 4 ++++
 3 files changed, 18 insertions(+)

diff --git a/configure b/configure
index 22cd866147b..249474ac891 100755
--- a/configure
+++ b/configure
@@ -14999,6 +14999,13 @@ _ACEOF
 fi
 
 
+# AArch64 is bi-endian, but we require little
+if test x"$host_cpu" = x"aarch64"; then
+  if test x"$ac_cv_c_bigendian" = x"yes"; then
+    as_fn_error $? "big endian is not supported for aarch64" "$LINENO" 5
+  fi
+fi
+
 # MSVC doesn't cope well with defining restrict to __restrict, the
 # spelling it understands, because it conflicts with
 # __declspec(restrict). Therefore we define pg_restrict to the
diff --git a/configure.ac b/configure.ac
index e44943aa6fe..5b95a0adf5c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1685,6 +1685,13 @@ PGAC_UNION_SEMUN
 AC_CHECK_TYPES(socklen_t, [], [], [#include <sys/socket.h>])
 PGAC_STRUCT_SOCKADDR_SA_LEN
 
+# AArch64 is bi-endian, but we require little
+if test x"$host_cpu" = x"aarch64"; then
+  if test x"$ac_cv_c_bigendian" = x"yes"; then
+    AC_MSG_ERROR([big endian is not supported for aarch64])
+  fi
+fi
+
 # MSVC doesn't cope well with defining restrict to __restrict, the
 # spelling it understands, because it conflicts with
 # __declspec(restrict). Therefore we define pg_restrict to the
diff --git a/meson.build b/meson.build
index 395416a6060..35f2580d8ef 100644
--- a/meson.build
+++ b/meson.build
@@ -1731,6 +1731,10 @@ endif
 ###############################################################
 
 if host_machine.endian() == 'big'
+  # AArch64 is bi-endian, but we require little
+  if host_cpu == 'aarch64'
+    error('big endian is not supported for aarch64')
+  endif
   cdata.set('WORDS_BIGENDIAN', 1)
 endif
 
-- 
2.39.5 (Apple Git-154)

Reply via email to