Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing issue with Eigen in Ubuntu Jammy on ARM #378

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions fuse_constraints/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ else()
add_compile_options(-Wall -Werror)
endif()

# On ARM, the use of Eigen 3.4 with g++11 (both the versions in Jammy) causes a warning, which in turn causes
# the build to fail. Details are here: https://gitlab.com/libeigen/eigen/-/issues/2326. We can suppress the warning
# for ARM builds here.
if(Eigen3_VERSION VERSION_EQUAL 3.4 AND
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11.0 AND
CMAKE_LIBRARY_ARCHITECTURE STREQUAL "aarch64-linux-gnu")
add_compile_options(-Wno-class-memaccess)
endif()

# fuse_constraints library
add_library(${PROJECT_NAME}
src/absolute_constraint.cpp
Expand Down
9 changes: 9 additions & 0 deletions fuse_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ catkin_package(
###########
add_compile_options(-Wall -Werror)

# On ARM, the use of Eigen 3.4 with g++11 (both the versions in Jammy) causes a warning, which in turn causes
# the build to fail. Details are here: https://gitlab.com/libeigen/eigen/-/issues/2326. We can suppress the warning
# for ARM builds here.
if(Eigen3_VERSION VERSION_EQUAL 3.4 AND
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11.0 AND
CMAKE_LIBRARY_ARCHITECTURE STREQUAL "aarch64-linux-gnu")
add_compile_options(-Wno-class-memaccess)
endif()

## fuse_core library
add_library(${PROJECT_NAME}
src/async_motion_model.cpp
Expand Down
9 changes: 9 additions & 0 deletions fuse_models/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ roslint_cpp()
###########
add_compile_options(-Wall -Werror)

# On ARM, the use of Eigen 3.4 with g++11 (both the versions in Jammy) causes a warning, which in turn causes
# the build to fail. Details are here: https://gitlab.com/libeigen/eigen/-/issues/2326. We can suppress the warning
# for ARM builds here.
if(Eigen3_VERSION VERSION_EQUAL 3.4 AND
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11.0 AND
CMAKE_LIBRARY_ARCHITECTURE STREQUAL "aarch64-linux-gnu")
add_compile_options(-Wno-class-memaccess)
endif()

## Declare a C++ library
add_library(${PROJECT_NAME}
src/acceleration_2d.cpp
Expand Down
9 changes: 9 additions & 0 deletions fuse_publishers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ catkin_package(
###########
add_compile_options(-Wall -Werror)

# On ARM, the use of Eigen 3.4 with g++11 (both the versions in Jammy) causes a warning, which in turn causes
# the build to fail. Details are here: https://gitlab.com/libeigen/eigen/-/issues/2326. We can suppress the warning
# for ARM builds here.
if(Eigen3_VERSION VERSION_EQUAL 3.4 AND
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually a bit trickier than I thought.

This package itself has no direct dependency on Eigen, but it includes files that eventually include Eigen, and so we end up with the same build error.

However, because we don't directly depend on Eigen here, the variable Eigen3_VERSION isn't even declared, so we'll never enter this block.

Does anyone know if there's a way for packages that we include to export their build settings so that downstream packages pick them up? Ideally, any package that depends on, e.g., fuse_core would automatically get the -Wno-class-memaccess flag.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.ros.org/en/api/catkin/html/dev_guide/generated_cmake_api.html#catkin_package

In the docs for the catkin_package() command:

DEPENDS (list of strings) – a list of CMake projects which this project depends on. Since they might not be find_packagable or lack a pkg-config file their INCLUDE_DIRS and LIBRARIES are passed directly. This requires that it has been find_package-ed before and all variables (_FOUND, _INCLUDE_DIRS, etc.) have the same case as this argument.

Based on that description, I would have expected dependent packages would have had access to the Eigen3_FOUND and similar variables after calling find_package(catkin REQUIRED COMPONENTS fuse_core).

But it does say the string case used in catkin_package(DEPENDS) must match the case of the CMake variables. In fuse_core I have a depend on EIGEN3 all caps:
https://github.com/locusrobotics/fuse/blob/devel/fuse_core/CMakeLists.txt#L29

Is that what the problem is? Just a case mismatch between fuse_core and this new if-block?

Barring that, using the CFG_EXTRAS parameter might be another way to make this work. If fuse_core exports some build flags using CFG_EXTRAS, dependent packages should pick that up, right? If their CMake files are written correctly. I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the all-caps version is empty even in packages that use Eigen directly. I had to print out all the available variables to figure that one out.

I'll try your other suggestion, thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So maybe the fuse_core package is wrong, and it should be Eigen3 instead of EIGEN3?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11.0 AND
CMAKE_LIBRARY_ARCHITECTURE STREQUAL "aarch64-linux-gnu")
add_compile_options(-Wno-class-memaccess)
endif()

# fuse_publishers library
add_library(${PROJECT_NAME}
src/path_2d_publisher.cpp
Expand Down
9 changes: 9 additions & 0 deletions fuse_viz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ add_definitions(-DQT_NO_KEYWORDS)
###########
add_compile_options(-Wall -Werror)

# On ARM, the use of Eigen 3.4 with g++11 (both the versions in Jammy) causes a warning, which in turn causes
# the build to fail. Details are here: https://gitlab.com/libeigen/eigen/-/issues/2326. We can suppress the warning
# for ARM builds here.
if(Eigen3_VERSION VERSION_EQUAL 3.4 AND
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11.0 AND
CMAKE_LIBRARY_ARCHITECTURE STREQUAL "aarch64-linux-gnu")
add_compile_options(-Wno-class-memaccess)
endif()

catkin_package(
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
Expand Down
Loading