eigeniar

Trying to compile eigen example on IAR


I have been tasked with pulling in Eigen into an embedded project built using IAR that will run on an STM32 MCU.

Due to the various compiler checks in the cmake files in Eigen version 3.4 - which seemingly are not working for the IAR toolchain - I was forced to clone master from gitlab where these checks have been removed.
The SHA of my clone is ff174f79264d3f8dc0115dea7a288f98208b694f. It it therefore quite possible that the issues below are due to using a development build.

When I try to build this example, I get build errors.

      internal::stable_norm_kernel(SegmentWrapper(copy.segment(bi, numext::mini(blockSize, n - bi))), ssq, scale,
                                   ^
"E:\Projects\xxx\third_party\eigen\Eigen\src\Core\StableNorm.h",77  Error[Ta121]:
          Auto variable "<unnamed>" cannot have a stricter alignment than the
          stack

I get the same errors levelled at other parts of the eigen code. One such recurring instance is

    Matrix<Scalar, SmallPanelWidth, SmallPanelWidth, LhsStorageOrder> triangularBuffer(a);
                                                                      ^
"E:\Projects\xxx\third_party\eigen\Eigen\src\Core\products\TriangularMatrixMatrix.h",122  Error[Ta121]:
          Auto variable "triangularBuffer" cannot have a stricter alignment
          than the stack

I have no idea what this means, but I suspect that it is perhaps a misconfiguration of my build. Can someone nudge me in the right direction or suggest things to try?


Solution

  • Using the preprocessor flag EIGEN_MAX_ALIGN_BYTES you can control how much objects can be aligned. If you compile with -DEIGEN_MAX_ALIGN_BYTES=0 alignment will be disabled altogether. For supported compilers this flag should be set automatically, but your toolchain appears to not be supported.

    You can search for any flags containing ALIGN in Eigen's list of Preprocessor directives for a finer control what shall be aligned (probably dynamic alignment does work, but it probably will not be beneficial on your platform anyways).