public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: Tobias Bussmann <[email protected]>
Cc: John Naylor <[email protected]>
Cc: Lukas Fittl <[email protected]>
Cc: Jakob Egger <[email protected]>
Cc: pgsql-hackers <[email protected]>
Cc: Andres Freund <[email protected]>
Cc: Sandeep Thakkar <[email protected]>
Subject: Re: Broken build on macOS (Universal / Intel): cpuid instruction not available
Date: Tue, 02 Jun 2026 11:20:46 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
<CAP53PkzLmeNUiNtcOyw62KkD7OzthdCbkwGTyAk+Lu3LKsmOcg@mail.gmail.com>
<CANWCAZa5TEmjLy0xtBjP9NyuVCJpCOpVkBSzw-fqmH8D9tFzDg@mail.gmail.com>
<[email protected]>
<CANWCAZZNu5nLzeeNs8TyC6Xs4HKzHni=yeTqCH7_QNpktR2nMQ@mail.gmail.com>
<[email protected]>
<[email protected]>
I wrote:
> However, it definitely is a regression that the build fails
> altogether. Too bad nobody tried the x86 -> ARM case earlier.
I replicated this on longfin's host (x86_64 mac mini).
It seems there are two problems:
1. pg_cpu.h believes that x86-specific code can be conditional on
#if defined(USE_SSE2) || defined(__i386__)
but macOS doesn't define __i386__, only __x86_64__. It works
anyway on single-arch builds because the test to set USE_SSE2
succeeds, but not on multi-arch builds.
2. checksum.c believes that it's okay to call x86_feature_available
if USE_AVX2_WITH_RUNTIME_CHECK is set. I didn't track down just
why that's getting set in a multi-arch build when USE_SSE2 is not,
but it is, and that's probably good since it means we get at least
some optimization for x86 Macs. But we have to disregard it when
we're doing the ARM side.
The attached quick hack makes the build work on my machine.
I'm hesitant to shove it into the tree though because I'm
not too certain whether there could be side-effects on
other platforms. I think the way to proceed for now is for
EDB to apply this patch in their build of beta1, and we can
review the patch at leisure afterwards.
regards, tom lane
Attachments:
[text/x-diff] quick-fix.patch (945B, 2-quick-fix.patch)
download | inline diff:
diff --git a/src/backend/storage/page/checksum.c b/src/backend/storage/page/checksum.c
index 030c44f7308..db8544bca01 100644
--- a/src/backend/storage/page/checksum.c
+++ b/src/backend/storage/page/checksum.c
@@ -26,6 +26,12 @@
#define PG_CHECKSUM_INTERNAL
#include "storage/checksum_impl.h" /* IWYU pragma: keep */
+/* In universal macOS builds, don't try to compile AVX code on the ARM side */
+#if defined(__i386__) || defined(__x86_64__)
+#else
+#undef USE_AVX2_WITH_RUNTIME_CHECK
+#endif
+
static uint32
pg_checksum_block_fallback(const PGChecksummablePage *page)
diff --git a/src/include/port/pg_cpu.h b/src/include/port/pg_cpu.h
index 566ed7a16e3..b276d7f1a4e 100644
--- a/src/include/port/pg_cpu.h
+++ b/src/include/port/pg_cpu.h
@@ -13,7 +13,7 @@
#ifndef PG_CPU_H
#define PG_CPU_H
-#if defined(USE_SSE2) || defined(__i386__)
+#if defined(USE_SSE2) || defined(__i386__) || defined(__x86_64__)
typedef enum X86FeatureId
{
view thread (24+ 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]
Subject: Re: Broken build on macOS (Universal / Intel): cpuid instruction not available
In-Reply-To: <[email protected]>
* 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