Weak symbol resolving breaks SIMD platform specification?

28 views Asked by At

Our product consists of two parts:

  • a runtime-switching part that is implemented in SSE4.2/AVX1/AVX2, and it determines the actual implementation to use at runtime by cpuid. It mostly contains calculation-dense DSP algorithms.
  • a fixed part that contains most common logics, such as GUI. By design, it should contain SIMD instructions no newer than SSE4.2, otherwise old machines and Apple Rosseta translator will be unhappy.

However, running the product in a Rosseta-translated Apple M1 machine always raise illegal instruction error on specific operation. Disassembly shows an instruction vmovsd which belongs to AVX is called, and it is compiled from an call to std::complex<double>::real(). I then find the nearest cpp file in call stack, and disassembled the object file compiled from it, especially those function implementations of std::complex<double> types, but did not find vmovsd in it.

I strongly suspect that this issue is caused by resolving inlineed weak symbols, and it is resolved to an AVX-enabled compilation unit. At least, theoretically it is possible to occur. So is there any way to "separate" compilation units that have different SIMD version?

0

There are 0 answers