libretro / libretro-common

Reusable coding blocks useful for libretro core and frontend development, written primarily in C. Permissively licensed.
146 stars 76 forks source link

Detect `ARM` rather than exclude `x86` for `ARM` specific code #200

Closed SpriteOvO closed 2 years ago

SpriteOvO commented 2 years ago

I'm compiling a project for RISC-V 64-bit that depends on libretro-common, and I got errors:

../desmume/desmume/src/libretro-common/features/features_cpu.c:321:31: error: ‘AT_HWCAP’ undeclared (first use in this function)
  321 |    uint64_t hwcap = getauxval(AT_HWCAP);
      |                               ^~~~~~~~
../desmume/desmume/src/libretro-common/features/features_cpu.c:321:31: note: each undeclared identifier is reported only once for each function it appears in
../desmume/desmume/src/libretro-common/features/features_cpu.c:323:23: error: ‘HWCAP_ARM_NEON’ undeclared (first use in this function)
  323 |       return (hwcap & HWCAP_ARM_NEON) != 0;
      |                       ^~~~~~~~~~~~~~
../desmume/desmume/src/libretro-common/features/features_cpu.c:325:23: error: ‘HWCAP_ARM_VFPv3’ undeclared (first use in this function)
  325 |       return (hwcap & HWCAP_ARM_VFPv3) != 0;
      |                       ^~~~~~~~~~~~~~~
../desmume/desmume/src/libretro-common/features/features_cpu.c:327:23: error: ‘HWCAP_ARM_VFPv4’ undeclared (first use in this function)
  327 |       return (hwcap & HWCAP_ARM_VFPv4) != 0;
      |                       ^~~~~~~~~~~~~~~

It indicates that it is incorrectly entering an ARM specific code path.

This PR changed the macro condition of ARM specific code from !defined(CPU_X86) to defined(CPU_ARM) to support it compiling for more other architectures.

The ARM detection code is referenced from https://github.com/boostorg/predef/blob/499d28e34f78950ede62fdb9b74cbe06eb5fdf96/include/boost/predef/architecture/arm.h#L73-L83.

LibretroAdmin commented 2 years ago

Unfortunately I have to revert this, this broke all RetroArch builds. Please be more careful in the future when making these changes.

LibretroAdmin commented 2 years ago

https://github.com/libretro/RetroArch/commit/6b9a382f2e90923b38fcca1f5a0d11ffe391e3fe

You can see the build failures here.

Send these libretro-common PRs to RetroArch next time, at least there are CI jobs there that can detect build failures for all the platforms we support.

SpriteOvO commented 2 years ago

libretro/RetroArch@6b9a382

You can see the build failures here.

Send these libretro-common PRs to RetroArch next time, at least there are CI jobs there that can detect build failures for all the platforms we support.

Sorry this broke the build, I'll try to fix it later and reopen a PR over there.