Fix ODR violations

Compiling Ceres with Schur specializations and Link Time Optimization
(LTO) results in warnings such as

    /usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:31:8: warning: type ‘struct evaluator’ violates the C++ One Definition Rule [-Wodr]
       31 | struct evaluator<Product<Lhs, Rhs, Options>> : public product_evaluator<Product<Lhs, Rhs, Options>> {
          |        ^

due to the redefinition of EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD which
alters internal Eigen class definitions and consequently results in ODR
violations.

Avoid the ODR violation by renaming the Eigen namespace in translation
units that redefine EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD.

While the issue is diagnosed in LTO builds of Ceres only, the problem
exists in non-LTO builds as well and per standard the compiler is not
even required to diagnose ODR issues. ODR violations constitute
undefined behavior.

Change-Id: Idf7c7a30cc8d3a86b0d62cbd33bef58783a62ee4
2 files changed
tree: 8cd649e1ef29d5ab959691d60722190e7bba225d
  1. .github/
  2. bazel/
  3. cmake/
  4. config/
  5. data/
  6. docs/
  7. examples/
  8. include/
  9. internal/
  10. scripts/
  11. third_party/
  12. .clang-format
  13. .gitignore
  14. .gitmodules
  15. .readthedocs.yaml
  16. BUILD
  17. CITATION.cff
  18. CMakeLists.txt
  19. CONTRIBUTING.md
  20. LICENSE
  21. MODULE.bazel
  22. package.xml
  23. README.md
  24. WORKSPACE
README.md

Android Linux macOS Windows

Ceres Solver

Ceres Solver is an open source C++ library for modeling and solving large, complicated optimization problems. It is a feature rich, mature and performant library which has been used in production at Google since 2010. Ceres Solver can solve two kinds of problems.

  1. Non-linear Least Squares problems with bounds constraints.
  2. General unconstrained optimization problems.

Please see ceres-solver.org for more information.