Обсуждение: Compile error on the aarch64 platform: Missing asm/hwcap.h

Поиск
Список
Период
Сортировка

Compile error on the aarch64 platform: Missing asm/hwcap.h

От
高增琦
Дата:
Hi,

Compile error on CentOS Linux release 7.6.1810 (AltArch) with the message “‘HWCAP_CRC32’ undeclared”.

Relevant code from discussion: https://www.postgresql.org/message-id/4496616.iHFcN1HehY%40portable-bastien
It mentions: "It doesn't look like I need to include <asm/hwcap.h> from Bastien's
original message, because <sys/auxv.h> pulls in <bits/hwcap.h>
already."

However, the bits/hwcap.h file included with glibc in CentOS 7.6 lacks these symbol definitions (the file is nearly empty). This file appears to be an internal glibc dependency, so it's preferable to directly use asm/hwcap.h for the required symbol definitions.

After modifying the code to add `include <asm/hwcap.h>`, the compilation succeeded.

--

Re: Compile error on the aarch64 platform: Missing asm/hwcap.h

От
John Naylor
Дата:
On Fri, Nov 14, 2025 at 11:02 AM 高增琦 <pgf00a@gmail.com> wrote:
> Compile error on CentOS Linux release 7.6.1810 (AltArch) with the message “‘HWCAP_CRC32’ undeclared”.

We still have at least one CentOS 7 aarch64 machine that gets regular
testing (not sure of the reason, since it's been EOL for a year and a
half IIUC), and it builds fine:

https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=arowana&dt=2025-11-04%2004%3A56%3A57

> After modifying the code to add `include <asm/hwcap.h>`, the compilation succeeded.

We already have the following, so I'm not sure what you mean (or even
what architecture you're running on):

#if defined(HAVE_ELF_AUX_INFO) || defined(HAVE_GETAUXVAL)
#include <sys/auxv.h>
#if defined(__linux__) && !defined(__aarch64__) && !defined(HWCAP2_CRC32)
#include <asm/hwcap.h>
#endif
#endif

--
John Naylor
Amazon Web Services



Re: Compile error on the aarch64 platform: Missing asm/hwcap.h

От
Tom Lane
Дата:
John Naylor <johncnaylorls@gmail.com> writes:
> We already have the following, so I'm not sure what you mean (or even
> what architecture you're running on):

> #if defined(HAVE_ELF_AUX_INFO) || defined(HAVE_GETAUXVAL)
> #include <sys/auxv.h>
> #if defined(__linux__) && !defined(__aarch64__) && !defined(HWCAP2_CRC32)
> #include <asm/hwcap.h>
> #endif
> #endif

I wonder if the "&& !defined(__aarch64__)" bit needs to be removed.
But yeah, the real question is what is the difference between the
OP's machine and everyplace else where this code works fine ...

            regards, tom lane



Re: Compile error on the aarch64 platform: Missing asm/hwcap.h

От
Tom Lane
Дата:
I wrote:
> I wonder if the "&& !defined(__aarch64__)" bit needs to be removed.

No, that idea is off-track.  Looking at the following code, the
HWCAP2_CRC32 flag is only relevant on ARM32, so we don't need to
worry about obtaining a definition for it on aarch64 (and we'd likely
not find one anyway).  The OP is seemingly building on ARM32, else
it shouldn't try to reference this symbol.

I checked an old ARM32 Red Hat installation (Fedora 30, so it's
not as old as RHEL7, but it's the oldest image I've got) and
verified that <asm/hwcap.h> exists, and it defines HWCAP2_CRC32,
and our current code builds fine on it.

> But yeah, the real question is what is the difference between the
> OP's machine and everyplace else where this code works fine ...

After staring at the code for awhile, it appears to me that the
only way to explain this report is that "defined(__linux__)"
isn't true on the OP's machine.  Which is quite hard to believe,
and if it's the case then it's not something to fix on our side.

            regards, tom lane