rosidl injects absolute paths to python3.so into packages INTERFACE_LINK_LIBRARIES breaking cross compile
Generated by Generative AI
Not AI
Operating System:
Ubuntu 22 in docker
ROS version or commit hash:
humble (using docker)
RMW implementation (if applicable):
N/A
RMW Configuration (if applicable):
N/A
Client library (if applicable):
N/A
'ros2 doctor --report' output
N/A this is a build issue
Steps to reproduce issue
- Create a ROS message package such as rclpy_message_converter_msgs
- Compile the package in a CMake sysroot
- Put the cross-compiled ROS installation onto target hardware
- Try to compile an application that depends on the message package without the sysroot, such as in QEMU or on target hardware
Expected behavior
When you call find_package(rclpy_message_converter_msgs REQUIRED), all linked libraries can be resolved
Actual behavior
We observe build errors such as this:
21.31 ninja: Entering directory `/mnt/sdk/packaging/arm64/build'
21.34 ninja: error: '/builds/2NK-U5XjT/0/myproject/docker/sysroot/usr/lib/aarch64-linux-gnu/libpython3.10.so', needed by 'myCustomPackage', missing and no known rule to make it
You can see when looking through the install directory of a package compiled with rosidl, that the path to the python3 shared library is an absolute path, which is not relocateable.
grep -R '/builds/2NK-U5XjT/0/myproject/docker/sysroot/usr/lib/aarch64-linux-gnu/libpython3.10.so' /opt
/myproject/install
/opt
/myproject/install/rclpy_message_converter_msgs/share/rclpy_message_converter_msgs/cmake/export_rclpy_message_converter_msgs__rosidl_generator_pyExport.cmake: INTERFACE_LINK_LIBRARIES "rclpy_message_converter_msgs::rclpy_message_converter_msgs__rosidl_generator_c;/builds/2NK-U5XjT/0/av-autonomy/stack/docker/sysroot/usr/lib/aarch64-linux-gnu/libpython3.10.so;rclpy_message_converter_msgs::rclpy_message_converter_msgs__rosidl_typesupport_c;builtin_interfaces::builtin_interfaces__rosidl_generator_py"
You can see that '/builds/2NK-U5XjT/0/ is a directory created by CI, and will not persist if you move the installation to another host.
Additional information
We have only tested on humble so far. This touches a lot of build tooling. I don't have time to create a minimum reproducible example at this point without open sourcing our cross compile tooling. It should be possible to see on amd64 without cross compiling.
Any CMake package should know better than to use absolute paths to files when a sysroot is involved.
As a workaround, we can use a sed operation to strip the absolute paths.