Bug 277636

Summary: archivers/unrar build error on arm64 with hardware CRC or AES
Product: Ports & Packages Reporter: John F. Carr <jfc>
Component: Individual Port(s)Assignee: Po-Chuan Hsieh <sunpoet>
Status: New ---    
Severity: Affects Only Me Flags: bugzilla: maintainer-feedback? (sunpoet)
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   

Description John F. Carr 2024-03-11 18:33:22 UTC
Make /etc/make.conf has

  CPUTYPE?=cortex-a57

This causes a build error in archivers/unrar:

  ===>  Building for unrar-7.00,6
  c++ -DOPENSSL_AES -I/usr/include -O2 -pipe -mcpu=cortex-a57 -fstack-protector-strong -fno-strict-aliasing   -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DRAR_SMP -DUNRAR -c rar.cpp
  In file included from rar.cpp:1:
  In file included from ./rar.hpp:6:
  ./os.hpp:158:10: fatal error: 'asm/hwcap.h' file not found
    158 | #include <asm/hwcap.h>
        |          ^~~~~~~~~~~~~
  1 error generated.
  *** Error code 1

My CPU setting enables the __ARM_FEATURE macros tested in this part of os.hpp added in unrar7.

  #if defined(__aarch64__) && (defined(__ARM_FEATURE_CRYPTO) || defined(__ARM_FEATURE_CRC32))
  #include <arm_neon.h>
  #ifndef _APPLE
  #include <sys/auxv.h>
  #include <asm/hwcap.h>
  #endif
  #ifdef __ARM_FEATURE_CRYPTO
  #define USE_NEON_AES
  #endif
  #ifdef __ARM_FEATURE_CRC32
  #define USE_NEON_CRC32
  #endif
  #endif

The header file assumes the 64 bit world consists entirely of Apple and Linux.