Re: Broken ./configure checks for __cpuid() and __cpuidex() - Mailing list pgsql-hackers

From Lukas Fittl
Subject Re: Broken ./configure checks for __cpuid() and __cpuidex()
Date
Msg-id CAP53PkyKyDMzrjKepMoeECQ90ay2dRjh38+cqFb0EFdHsfpzJQ@mail.gmail.com
Whole thread Raw
In response to Re: Broken ./configure checks for __cpuid() and __cpuidex()  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Broken ./configure checks for __cpuid() and __cpuidex()
List pgsql-hackers
On Mon, Jul 28, 2025 at 8:40 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

> How isn't that a bug in MinGW itself?  I'm puzzled my the macro
> definition of __cpuid() that reports a conflict.  __cpuidex() and
> __cpuid() are both detected by ./configure, the PG use of __cpuid() in
> pg_crc32c_sse42_choose.c causes a failure.

Why is the configure probe succeeding?  Maybe pg_crc32c_sse42_choose.c
is including something the configure check isn't?

Could it be that the problem only happens when including both cpuid.h and intrin.h, because they both define __cpuid? (the configure check only includes intrin.h)

My theory when I worked on the patch that Michael referenced in the original email was that intrin.h is only for MSVC (for GCC at least, __cpuidex is defined in cpuid.h).

I'm not sure how to get CI to run MinGW (it appears paused for me?), so I can't test this myself easily.

But the relevant change would be to change "defined(HAVE__CPUIDEX)" to "(defined(HAVE__CPUIDEX) && defined(_MSC_VER))" for the guard on both intrin.h includes.

Thanks,
Lukas

--
Lukas Fittl

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Broken ./configure checks for __cpuid() and __cpuidex()
Next
From: "David G. Johnston"
Date:
Subject: Re: implement CAST(expr AS type FORMAT 'template')