Monthly Summary: Broken macOS Universal/Intel Builds — cpuid Instruction Not Available (May 2026)
Overview
A build regression introduced by the centralization of x86 CPU feature detection in PostgreSQL 19 was reported, diagnosed, and resolved within the first week of May. The fix — making pg_cpuid() fail soft by returning zeros when no cpuid intrinsic is available — was committed on 2026-05-08, restoring universal build support with the expected caveat that x86 optimizations are silently disabled.
Root Cause
Two commits created the problem:
- 16743db ("Centralize detection of x86 CPU features") introduced a unified
pg_cpu_x86.cmodule replacing scattered per-feature probes. - 5e13b0f ("Use AVX2 for calculating page checksums") added a new consumer that assumes the centralized API is always compilable on x86 targets.
The old code used defensive #ifdef guards that ensured cpuid-dependent paths were only compiled when configure detected a working intrinsic. The centralized replacement dropped those guards, changing the failure mode from silent performance degradation to hard compile error when cpuid intrinsics are unavailable — which happens in macOS universal builds (-arch arm64 -arch x86_64) because configure runs a single probe pass that can only succeed for one architecture.
Resolution
John Naylor posted, tested, and committed a patch making pg_cpuid() return zeros when neither HAVE__GET_CPUID nor HAVE__CPUID is defined — mirroring the existing pg_cpuid_subleaf() behavior. All consumers (popcount, AVX2 checksums, TSC timing) already have scalar fallback paths that activate when no features are advertised.
Tobias Bussmann verified the fix resolves the universal build regression and make check passes for both arm64 and x86_64 slices.
Performance Implications for Universal Builds
Post-fix inspection of configure output revealed that universal builds also lose hardware CRC-32C on both slices (falling back to slicing-by-8) because the arch-specific -march flags needed for CRC probes are incompatible with simultaneous multi-arch compilation. The full list of lost optimizations:
- x86 slice: No AVX2 checksums, no popcount-q, no TSC timing, no SSE 4.2 CRC
- arm64 slice: No ARMv8 CRC extension
Tom Lane noted this matches pre-v19 behavior — universal builds were always silently degraded — and the project will not invest in per-arch configure passes to recover these optimizations.
Policy Decisions
- Universal builds are not formally supported but will compile and run correctly with degraded performance.
- No per-arch configure machinery will be built — proper fat-binary support would require two independent probe passes, which nobody wants to maintain given Apple's trajectory away from x86.
- Buildfarm coverage is the path to keeping edge cases working long-term — Tobias offered to host macOS VMs.
- Meson transition was flagged as the appropriate venue for any future multi-arch probe work (not autotools).
Secondary Issue: Xcode 26.2 Under Rosetta
A separate report of x86_feature_available being undeclared on Intel was traced to a specific Xcode 26.2 toolchain quirk when invoked via Rosetta — switching to Command Line Tools 26.4 resolved it. Native Intel builds (buildfarm animal longfin, Daniel Gustafsson's Intel MBP) are unaffected.