Skip to content

Eigen 3.4.0 compile error on ARM32v7 + neon in macro EIGEN_OPTIMIZATION_BARRIER

Summary

Eigen 3.4.0 on armhf (arm32v7) with enabled neon-fpu (CXX flag -mfpu=neon-vfpv4) in Debug build causes a compile time error in the macro EIGEN_OPTIMIZATION_BARRIER in the unittest packetmath_4

Environment

  • Operating System : Linux
  • Architecture : ARM32v7
  • Eigen Version : 3.4.0
  • Compiler Version : Gcc4.8.4
  • Compile Flags : -mfpu=neon-vfpv4 -DCMAKE_BUILD_TYPE=Debug
  • Vector Extension : NEON

Minimal Example

Compile the unittest packetmath_4 with an arm32v7 compiler in debug mode with neon-fpu enabled

Steps to reproduce

Note: I'm using a cross compiler as it is easier reproducible this way. But it also happens on ARM hardware

  1. Start an Ubuntu 14.04 trusty amd64 container
docker run -it --rm -v ${PWD}:/eigen-3.4.0 ubuntu:trusty bash
cd /eigen-3.4.0
  1. install cmake3 and g++-arm-linux-gnueabihf (arm cross compiler) packages
sudo apt-get update -qq && sudo apt-get install -yq cmake3 g++-arm-linux-gnueabihf
  1. configure the repo with cmake to use the arm32v7 cross compiler, enable NEON-fpu and make a Debug-build
cmake -H. -B_build_trusty_armhf -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ -DCMAKE_CXX_FLAGS="-mfpu=neon-vfpv4" -DCMAKE_BUILD_TYPE=Debug
  1. tell cmake to compile the unittest packetmath_4
cmake --build _build_trusty_armhf --target packetmath_4
  1. Watch as the compiler throws the EIGEN_OPTIMIZATION_BARRIER error

In the following a short script, which can be run inside the Eigen 3.4.0 code-base to trigger the compile error:

#!/bin/bash
set -ex
sudo apt-get update -qq 
sudo apt-get install -yq cmake3 g++-arm-linux-gnueabihf
cmake -H. -B_build_trusty_armhf -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ -DCMAKE_CXX_FLAGS="-mfpu=neon-vfpv4" -DCMAKE_BUILD_TYPE=Debug
cmake --build _build_trusty_armhf --target packetmath_4

What is the current bug behavior?

compile time error in macro EIGEN_OPTIMIZATION_BARRIER

What is the expected correct behavior?

no compile time error

Relevant logs

cmake --build _build_trusty_armhf --target packetmath_4
Scanning dependencies of target packetmath_4
Building CXX object test/CMakeFiles/packetmath_4.dir/packetmath.cpp.o
In file included from /eigen-3.4.0/Eigen/Core:214:0,
                 from /eigen-3.4.0/Eigen/QR:11,
                 from /eigen-3.4.0/test/main.h:360,
                 from /eigen-3.4.0/test/packetmath_test_shared.h:11,
                 from /eigen-3.4.0/test/packetmath.cpp:11:
/eigen-3.4.0/Eigen/src/Core/arch/NEON/PacketMath.h:158:7: warning: "EIGEN_ARCH_ARM32" is not defined [-Wundef]
 #elif EIGEN_ARCH_ARM32
       ^
In file included from /eigen-3.4.0/Eigen/Core:214:0,
                 from /eigen-3.4.0/Eigen/QR:11,
                 from /eigen-3.4.0/test/main.h:360,
                 from /eigen-3.4.0/test/packetmath_test_shared.h:11,
                 from /eigen-3.4.0/test/packetmath.cpp:11:
/eigen-3.4.0/Eigen/src/Core/arch/NEON/PacketMath.h:3924:5: warning: "EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC" is not defined [-Wundef]
 #if EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC
     ^
In file included from /eigen-3.4.0/Eigen/Core:19:0,
                 from /eigen-3.4.0/Eigen/QR:11,
                 from /eigen-3.4.0/test/main.h:360,
                 from /eigen-3.4.0/test/packetmath_test_shared.h:11,
                 from /eigen-3.4.0/test/packetmath.cpp:11:
/eigen-3.4.0/test/packetmath.cpp: In static member function 'static void eigen_optimization_barrier_test<Packet, typename Eigen::internal::enable_if<(((! Eigen::NumTraits<T>::IsComplex) && (! Eigen::internal::is_same<Scalar, Eigen::half>::value)) && (! Eigen::internal::is_same<Scalar, Eigen::bfloat16>::value))>::type>::run() [with Packet = __vector(16) __builtin_neon_uqi]':
/eigen-3.4.0/Eigen/src/Core/util/Macros.h:1134:72: error: 'asm' operand requires impossible reload
       #define EIGEN_OPTIMIZATION_BARRIER(X)  __asm__  ("" : "+g,w" (X));
                                                                        ^
/eigen-3.4.0/test/packetmath.cpp:386:5: note: in expansion of macro 'EIGEN_OPTIMIZATION_BARRIER'
     EIGEN_OPTIMIZATION_BARRIER(barrier);
     ^
make[3]: *** [test/CMakeFiles/packetmath_4.dir/packetmath.cpp.o] Error 1
make[2]: *** [test/CMakeFiles/packetmath_4.dir/all] Error 2
make[1]: *** [test/CMakeFiles/packetmath_4.dir/rule] Error 2
make: *** [packetmath_4] Error 2

/cc @norbertwenzel