Re: Broken build on macOS (Universal / Intel): cpuid instruction not available

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tobias Bussmann <t(dot)bussmann(at)gmx(dot)net>
Cc: John Naylor <johncnaylorls(at)gmail(dot)com>, Lukas Fittl <lukas(at)fittl(dot)com>, Jakob Egger <jakob(at)eggerapps(dot)at>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Sandeep Thakkar <sandeep(dot)thakkar(at)enterprisedb(dot)com>
Subject: Re: Broken build on macOS (Universal / Intel): cpuid instruction not available
Date: 2026-06-03 20:23:03
Message-ID: 3114170.1780518183@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> Also, the reason we manage to set USE_AVX2_WITH_RUNTIME_CHECK
> in a multi-arch build is that what configure actually tests
> is (a) is $host_cpu x86_64 and (b) does the compiler accept
> __attribute__((target("avx2"))). On a multi-arch build,
> the ARM side spits out a warning
> '+avx2' is not a recognized feature for this target (ignoring feature)
> but it doesn't actually fail, so configure thinks that's a success.

After further contemplation, I think the best fix for this problem
is to undo configure's mistake globally, not just in checksum.c.
checksum.c is the only file using USE_AVX2_WITH_RUNTIME_CHECK today,
but that might not be true forever. Also, I think it's pure chance
that the test for that symbol succeeds in a universal build while
other similar tests don't. So what the attached v2 does is to
#undef USE_AVX2_WITH_RUNTIME_CHECK as well as the USE_AVX512
symbols in c.h, if we're not in fact building for x86_64 hardware.
We could extend the list of things to #undef there later, if it
proves necessary.

The shape of this patch is partially dictated by not wanting to
create problems for Munro's pending patch [1], but I think it's
a reasonable solution even without that consideration.

regards, tom lane

[1] https://www.postgresql.org/message-id/flat/CA%2BhUKGL8Hs-phHPugrWM%3D5dAkcT897rXyazYzLw-Szxnzgx-rA%40mail.gmail.com

Attachment Content-Type Size
v2-fix-macos-universal-build.patch text/x-diff 1.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-06-03 21:08:55 Re: Centralised architecture detection
Previous Message Andres Freund 2026-06-03 19:56:59 Re: Heads Up: cirrus-ci is shutting down June 1st