Re: git: 96e53c0c65fa - main - archivers/libunrar: Support crc and crypto flags on aarch64

From: Jason E. Hale <jhale_at_freebsd.org>
Date: Wed, 19 Feb 2025 11:06:20 UTC
On Wed, Feb 19, 2025 at 4:34 AM Robert Clausecker <fuz@fuz.su> wrote:
>
> Hi Jason,
>
> Am Wed, Feb 19, 2025 at 08:37:36AM +0000 schrieb Jason E. Hale:
> > The branch main has been updated by jhale:
> >
> > URL: https://cgit.FreeBSD.org/ports/commit/?id=96e53c0c65faa691e18c0a5558d8f445e6010a70
> >
> > commit 96e53c0c65faa691e18c0a5558d8f445e6010a70
> > Author:     Jason E. Hale <jhale@FreeBSD.org>
> > AuthorDate: 2025-02-19 07:09:07 +0000
> > Commit:     Jason E. Hale <jhale@FreeBSD.org>
> > CommitDate: 2025-02-19 08:36:56 +0000
> >
> >     archivers/libunrar: Support crc and crypto flags on aarch64
> >
> >     If CPU flags crc or crytpo are set, e.g. -march=armv8-a+crc+crypto, build
> >     would fail with missing headers because this was only implemented for
> >     glibc and Apple.
> > ---
> >  archivers/libunrar/files/patch-crc.cpp      | 22 ++++++++++++++++
> >  archivers/libunrar/files/patch-os.hpp       | 25 ++++++++++++++----
> >  archivers/libunrar/files/patch-rijndael.cpp | 40 ++++++++++++++++++++++-------
> >  3 files changed, 73 insertions(+), 14 deletions(-)
> >
> > diff --git a/archivers/libunrar/files/patch-crc.cpp b/archivers/libunrar/files/patch-crc.cpp
> > new file mode 100644
> > index 000000000000..131c7dc158fb
> > --- /dev/null
> > +++ b/archivers/libunrar/files/patch-crc.cpp
> > @@ -0,0 +1,22 @@
> > +--- crc.cpp.orig     2025-02-12 14:05:26 UTC
> > ++++ crc.cpp
> > +@@ -42,12 +42,18 @@ void InitCRC32(uint *CRCTab)
> > +   }
> > +
> > + #ifdef USE_NEON_CRC32
> > +-  #ifdef _APPLE
> > ++  #if defined(_APPLE)
> > +     // getauxval isn't available in OS X
> > +     uint Value=0;
> > +     size_t Size=sizeof(Value);
> > +     int RetCode=sysctlbyname("hw.optional.armv8_crc32",&Value,&Size,NULL,0);
> > +     CRC_Neon=RetCode==0 && Value!=0;
> > ++  #elif defined(__FreeBSD__)
> > ++    // getauxval isn't available on FreeBSD
> > ++    uint64 Reg=READ_SPECIALREG(id_aa64isar0_el1);
> > ++    if (ID_AA64ISAR0_CRC32_VAL(Reg) == ID_AA64ISAR0_CRC32_BASE) {
> > ++      CRC_Neon=true;
> > ++    }
> > +   #else
> > +     CRC_Neon=(getauxval(AT_HWCAP) & HWCAP_CRC32)!=0;
> > +   #endif

> Note that we do have the same interface, the function is just spelled
> elf_aux_info() and has a slightly different interface.
>

Thanks, I'm open to better, more canonical methods. I'm not an aarch64
expert by any means. Just trying to make this stuff work. :)

> Yours,
> Robert Clausecker
>
> --
> ()  ascii ribbon campaign - for an encoding-agnostic world
> /\  - against html email  - against proprietary attachments