| From: | Tobias Bussmann <t(dot)bussmann(at)gmx(dot)net> |
|---|---|
| To: | John Naylor <johncnaylorls(at)gmail(dot)com> |
| Cc: | Lukas Fittl <lukas(at)fittl(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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-02 12:49:54 |
| Message-ID: | 15574903-87C9-478A-B2D7-CC8F4C275DBB@gmx.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> Am 08.05.2026 um 12:04 schrieb John Naylor <johncnaylorls(at)gmail(dot)com>:
>
> Taking a quick look at the configure output you provided, certain
> optimizations will be lacking on both architectures:
Indeed. The universal builds seem to disable optimisations that are supported
natively. I did a comparison on the attached configure outputs with different
CFLAGS on arm64 - the first three ran the compiler in x86_64 emulation. I'd expect
this to be similar to a native x86_64 environment, but need to verify.
1. configure.x86_64.out: -arch x86_64 using rosetta2
2. configure.universal-cross.out: -arch arm64 -arch x86_64 using rosetta2
3. configure.arm64-cross.out: -arch arm64 using rosetta2
4. configure.x86_64-cross.out: -arch x86_64
5. configure.universal.out: -arch arm64 -arch x86_64
6. configure.arm64.out: -arch arm64
The difference on active features in detail are:
Only with arm64 native (6):
* svcnt_x
* pmull and pmull2
Both with arm64 native (6) and cross (3):
* __crc32cb, __crc32ch, __crc32cw, and __crc32cd with CFLAGS
Only with x86_64 emulation (1):
* assembler supports x86_64 popcntq
* _mm512_popcnt_epi64
* _mm512_clmulepi64_epi128
Both with x86_64 emulation/native (1) and arm64 cross (3) and universal cross (2)
* AVX2 target attribute support
Both with x86_64 cross (4) and emulation (1):
* __get_cpuid
* __get_cpuid_count
* _xgetbv
* _mm_crc32_u8 and _mm_crc32_u32
This results in the following CRC-32 decisions:
CRC-32C implementation:
1. x86_64 emulation: SSE 4.2 with runtime check
2. universal emulation: slicing-by-8
3. arm64 cross emulation: ARMv8 CRC instructions
4. x86_64 cross: SSE 4.2 with runtime check
5. universal: slicing-by-8
6. arm64: ARMv8 CRC instructions
Vectorized CRC-32C:
1. x86_64 emulation: AVX-512 with runtime check
2. universal emulation: none
3. arm64 cross emulation: none
4. x86_64 cross: none
5. universal: none
6. arm64: CRYPTO PMULL with runtime check
The differences between cross compilation and emulation(native) may be
worth looking into.
Cross-compiling arm64 or universal from x86_64 does not work, however:
checksum.c:57:6: error: call to undeclared function 'x86_feature_available'
if (x86_feature_available(PG_AVX2))
^
checksum.c:57:28: error: use of undeclared identifier 'PG_AVX2'
if (x86_feature_available(PG_AVX2))
This may have to do with the detection of "AVX2 target attribute support"
As Sandeep Thakkar just confirmed on the packagers list, this also affects bulding on a native x86_64 host not only an emulated one. The AVX2 target attribute support when ran on x86_64 cross compiling to arm64 (3) (or universal (2)) seems to be wrong.
Best regards
Tobias
| Attachment | Content-Type | Size |
|---|---|---|
| configure.x86_64.out | application/octet-stream | 19.0 KB |
| configure.universal-cross.out | application/octet-stream | 19.0 KB |
| configure.arm64-cross.out | application/octet-stream | 18.8 KB |
| configure.x86_64-cross.out | application/octet-stream | 18.9 KB |
| configure.universal.out | application/octet-stream | 18.9 KB |
| configure.arm64.out | application/octet-stream | 18.7 KB |
| unknown_filename | text/plain | 2 bytes |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chao Li | 2026-06-02 13:42:23 | SERVICEFILE shows wrong file after servicefile fallback |
| Previous Message | Nikita Malakhov | 2026-06-02 12:31:40 | Re: problems with toast.* reloptions |