| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Steven Niu <niushiji(at)gmail(dot)com> |
| Cc: | John Naylor <johncnaylorls(at)gmail(dot)com>, 高增琦 <pgf00a(at)gmail(dot)com>, "tmunro(at)postgresql(dot)org" <tmunro(at)postgresql(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Compile error on the aarch64 platform: Missing asm/hwcap.h |
| Date: | 2025-11-17 19:52:39 |
| Message-ID: | 952903.1763409159@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Steven Niu <niushiji(at)gmail(dot)com> writes:
> IvorySQL team found the same build issue on our building machine when we built IvorySQL code which is based on PG 18.0.
> pg_crc32c_armv8_choose.c:58:32:error:'HWCAP CRC32' undeclared(first use in this function)
> 58 | return (getauxval(AT_HWCAP) & HWCAP_CRC32) != θ;
> | ^~~~~~~~~~~
Bleah ... I confess to having misread the initial message as being a
complaint about HWCAP2_CRC32 not HWCAP_CRC32. -ENOCAFFEINE I guess.
So what we've got here is that somewhere along the line glibc decided
that sys/auxv.h should duplicate the HWCAPxxx macros from the kernel's
header. On recent (and even not so recent) aarch64 Fedora,
/usr/include/bits/hwcap.h has
/* The following must match the kernel's <asm/hwcap.h> and update the
list together with sysdeps/unix/sysv/linux/aarch64/dl-procinfo.c. */
#define HWCAP_FP (1 << 0)
...
but that is not the case if you go back as far as RHEL7.
A minimal fix might be to change
#if defined(HAVE_ELF_AUX_INFO) || defined(HAVE_GETAUXVAL)
#include <sys/auxv.h>
-#if defined(__linux__) && !defined(__aarch64__) && !defined(HWCAP2_CRC32)
+#if defined(__linux__)
#include <asm/hwcap.h>
#endif
#endif
but that risks compiler warnings if there are any macro discrepancies
at all between bits/hwcap.h and asm/hwcap.h. I'm inclined to think
it's better to do something like
+#if defined(__linux__) && (defined(__aarch64__) ? !defined(HWCAP_CRC32) : !defined(HWCAP2_CRC32))
or perhaps that's too unreadable and we should break it out into
multiple #if's.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Noah Misch | 2025-11-17 20:22:25 | Re: Updating IPC::Run in CI? |
| Previous Message | Masahiko Sawada | 2025-11-17 19:32:21 | Re: POC: enable logical decoding when wal_level = 'replica' without a server restart |