Unconditional use of VSX causes failure on ppc64 (big-endian)

Summary

Eigen 3.4.0 uses VSX unconditionally, which causes build failures on ppc64 (big-endian). Adding -mvsx to compilation flags fixes the build, but will make the built binaries fail to work on pre-VSX hardware.

Environment

  • Operating System : FreeBSD
  • Architecture : powerpc64
  • Eigen Version : 3.4.0
  • Compiler Version : clang 13.0.0
  • Compile Flags : -MMD -MP -Wall -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -std=gnu++11 -fvisibility-inlines-hidden -I/usr/src/gtest/include -I/usr/local/include/eigen3 -I/usr/local/include -I/usr/local/include -fPIC -DPIC
  • Vector Extension : AltiVec

Minimal Example

The following line causes build error: https://gitlab.com/libeigen/eigen/-/blob/master/Eigen/src/Core/arch/AltiVec/PacketMath.h#L1706

#include <Eigen/Core>

Steps to reproduce

  1. Build some software that uses eigen on ppc64.

What is the current bug behavior?

In file included from effect_util.cpp:2:
In file included from /usr/local/include/eigen3/Eigen/Core:210:
/usr/local/include/eigen3/Eigen/src/Core/arch/AltiVec/PacketMath.h:1345:32: error: use of undeclared identifier 'vec_sqrt'; did you mean 'vec_rsqrt'?
  BF16_TO_F32_UNARY_OP_WRAPPER(vec_sqrt, a);
                               ^~~~~~~~
                               vec_rsqrt
/usr/local/include/eigen3/Eigen/src/Core/arch/AltiVec/PacketMath.h:1302:22: note: expanded from macro 'BF16_TO_F32_UNARY_OP_WRAPPER'
  Packet4f op_even = OP(a_even);\
                     ^
/usr/lib/clang/13.0.0/include/altivec.h:8472:34: note: 'vec_rsqrt' declared here
static vector float __ATTRS_o_ai vec_rsqrt(vector float __a) {
                                 ^

What is the expected correct behavior?

Should build fine.