Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wUQvO-0019T4-0J for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Jun 2026 15:21:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wUQvM-00EvEh-0m for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Jun 2026 15:21:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wUQvL-00EvES-34 for pgsql-hackers@lists.postgresql.org; Tue, 02 Jun 2026 15:20:59 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wUQvJ-00000000sXr-3lAN for pgsql-hackers@postgresql.org; Tue, 02 Jun 2026 15:20:59 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 652FKk3j2927613; Tue, 2 Jun 2026 11:20:46 -0400 From: Tom Lane To: Tobias Bussmann cc: John Naylor , Lukas Fittl , Jakob Egger , pgsql-hackers , Andres Freund , Sandeep Thakkar Subject: Re: Broken build on macOS (Universal / Intel): cpuid instruction not available In-reply-to: <2925608.1780411691@sss.pgh.pa.us> References: <223EA201-A0E8-4A13-B220-EB903E8DF817@eggerapps.at> <871806.1778168884@sss.pgh.pa.us> <873909.1778170924@sss.pgh.pa.us> <471E4CB3-1690-4168-9A99-5F83D97C12AF@gmx.net> <15574903-87C9-478A-B2D7-CC8F4C275DBB@gmx.net> <2925608.1780411691@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Tue, 02 Jun 2026 10:48:11 -0400" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <2927534.1780413586.0@sss.pgh.pa.us> Date: Tue, 02 Jun 2026 11:20:46 -0400 Message-ID: <2927612.1780413646@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2927534.1780413586.1@sss.pgh.pa.us> 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 ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="quick-fix.patch"; charset="us-ascii" Content-ID: <2927534.1780413586.2@sss.pgh.pa.us> Content-Description: quick-fix.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/storage/page/checksum.c b/src/backend/storage/pag= e/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 si= de */ +#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 { ------- =_aaaaaaaaaa0--