0

I'm trying to compile Cobalt and getting errors building cpu_features_get.cc. The specific version I'm building is here: https://github.com/Metrological/cobalt/blob/master/src/starboard/shared/linux/cpu_features_get.cc and it appears to be based on Cobalt 22. I'm building using stbgcc-6.3.18, only Ubuntu 20.04. Sysroot is set to the cross compiler. And I'm building the starboard port at https://github.com/Metrological/cobalt/tree/master/src/third_party/starboard/wpe/brcm/arm, for ARM64.

An example of the error:

cpu_features_get.cc:381:12: error: 'HWCAP_SET_FOR_ARMV8' was not declared in this scope

There follow others, all related to HWCAP #defines.

As far as I can tell, the file defines these values if:

53: #if SB_IS(32_BIT) || defined(ANDROID)

Neither of these is true - I am compiling for ARM64 on Linux.

The code using HWCAP_SET_FOR_ARMV8 and the other missing defines is conditionally compiled as well:

340: #if SB_IS(ARCH_ARM) || SB_IS(ARCH_ARM64)
...
// Construct hwcap bitmask by the feature flags in /proc/cpuinfo
uint32_t ConstructHwcapFromCPUInfo(ProcCpuInfo* cpu_info,
                                   int16_t architecture_generation,
                                   uint32_t hwcap_type) {
  if (hwcap_type == AT_HWCAP && architecture_generation >= 8) {
    // This is a 32-bit ARM binary running on a 64-bit ARM64 kernel.
    // The 'Features' line only lists the optional features that the
    // device's CPU supports, compared to its reference architecture
    // which are of no use for this process.
    SB_LOG(INFO) << "Faking 32-bit ARM HWCaps on ARMv"
                 << architecture_generation;
    return HWCAP_SET_FOR_ARMV8;
  }
...
...

So ARCH_ARM64 is true, and this code is compiled. But the defines are missing because it's not 32-bit. This seems contradictory and to my eyes could never have worked. How is it possible to compile Cobalt for ARM64?

dscrdia
  • 1
  • 1
  • I've noticed that ConstructHwcapFromCPUInfo() is only called if SB_IS(32_BIT), so I've wrapped the definition of this function in that #if. It compiles fine now, but it would be good to know from a Cobalt dev if this is a bug I should report and/or contribute a patch for? – dscrdia Sep 14 '22 at 11:09

1 Answers1

0

Apologies for a very delayed response - this looks like a possible bug in how the conditionals are set in Cobalt code. Note that the build is tested with a limited set of compilers / architectures, not all issues like these would be caught.

Please also check the latest guidance as to where to file the bugs on cobalt.dev, we currently recommend filing issues in our Issue Tracker.

kert
  • 2,161
  • 21
  • 22