ros2 / rclpy

rclpy (ROS Client Library for Python)
Apache License 2.0
267 stars 220 forks source link

aarch64 cross compiling #1282

Open XQSwx opened 1 month ago

XQSwx commented 1 month ago

Bug report

Required Info:

Steps to reproduce issue

"When cross-compiling with aarch64, it was found that the generated .so file is for the X86 platform instead of aarch64. Other ROS2-generated files are for the aarch64 platform."

Expected behavior

Actual behavior

Additional information

Summary: 1 package finished [22.6s]

Feature request

Feature description

Implementation considerations

XQSwx commented 1 month ago

Can you help me? thank you

fujitatomoya commented 1 month ago

@XQSwx thanks for creating issue.

unfortunately, cross-compile is not supported anymore? https://docs.ros.org/en/humble/How-To-Guides/Cross-compilation.html, https://github.com/ros-tooling/cross_compile repo has been archived.

XQSwx commented 1 month ago

"I know that I compiled this using the Buildroot from Rockchip, so I can only work based on this compiled base."

XQSwx commented 1 month ago

Ultimately, there's a bug here, unable to generate cross-compilation chain's link libraries. Only x86 ones can be generated.

XQSwx commented 1 month ago

I just need to add the line 'SUFFIX ".cpython-38-aarch64-linux-gnu.so"' after 'set_target_properties(${_library_name} PROPERTIES', but I've broken the build chain dependency. My understanding of CMake is not very deep.

Starting >>> rclpy --- output: rclpy Not searching for unused variables given on the command line. -- Found ament_cmake: 1.3.8 (/buildroot/host/aarch64-buildroot-linux-gnu/sysroot/opt/share/ament_cmake/cmake) -- Found Python3: /usr/bin/python3 (found version "3.10.12") found components: Interpreter -- Found lifecycle_msgs: 1.2.1 (/buildroot/host/aarch64-buildroot-linux-gnu/sysroot/opt/share/lifecycle_msgs/cmake) -- Found rosidl_generator_c: 3.1.5 (/buildroot/host/aarch64-buildroot-linux-gnu/sysroot/opt/share/rosidl_generator_c/cmake) -- Found rosidl_adapter: 3.1.5 (/buildroot/host/aarch64-buildroot-linux-gnu/sysroot/opt/share/rosidl_adapter/cmake) -- Found rosidl_generator_cpp: 3.1.5 (/buildroot/host/aarch64-buildroot-linux-gnu/sysroot/opt/share/rosidl_generator_cpp/cmake) -- Using all available rosidl_typesupport_c: rosidl_typesupport_fastrtps_c;rosidl_typesupport_introspection_c -- Using all available rosidl_typesupport_cpp: rosidl_typesupport_fastrtps_cpp;rosidl_typesupport_introspection_cpp -- Found rcl: 5.3.7 (/buildroot/host/aarch64-buildroot-linux-gnu/sysroot/opt/share/rcl/cmake) -- Found rmw_implementation_cmake: 6.1.1 (/buildroot/host/aarch64-buildroot-linux-gnu/sysroot/opt/share/rmw_implementation_cmake/cmake) -- Found rmw_fastrtps_cpp: 6.2.6 (/buildroot/host/aarch64-buildroot-linux-gnu/sysroot/opt/share/rmw_fastrtps_cpp/cmake) -- Using RMW implementation 'rmw_fastrtps_cpp' as default -- Found rcl_action: 5.3.7 (/buildroot/host/aarch64-buildroot-linux-gnu/sysroot/opt/share/rcl_action/cmake) -- Found rcl_lifecycle: 5.3.7 (/buildroot/host/aarch64-buildroot-linux-gnu/sysroot/opt/share/rcl_lifecycle/cmake) -- Found Python3: /usr/bin/python3 (found version "3.10.12") found components: Interpreter Development Development.Module Development.Embed -- Found pybind11_vendor: 2.4.2 (/buildroot/host/aarch64-buildroot-linux-gnu/sysroot/opt/share/pybind11_vendor/cmake) -- Found pybind11: /buildroot/host/aarch64-buildroot-linux-gnu/sysroot/opt/include/pybind11_vendor (found version "2.9.1") -- Found ament_lint_auto: 0.12.10 (/buildroot/host/aarch64-buildroot-linux-gnu/sysroot/opt/share/ament_lint_auto/cmake) -- Found gtest sources under '/buildroot/host/aarch64-buildroot-linux-gnu/sysroot/opt/src/gtest_vendor': C++ tests using 'Google Test' will be built -- Added test 'copyright' to check source files copyright and LICENSE -- Added test 'cpplint' to check C / C++ code against the Google style -- Configured cpplint exclude dirs and/or files: -- Added test 'flake8' to check Python code syntax and style conventions -- Added test 'lint_cmake' to check CMake code style -- Added test 'pep257' to check Python code against some of the docstring style conventions in PEP 257 -- Added test 'uncrustify' to check C / C++ code style -- Configured uncrustify additional arguments: -- Added test 'xmllint' to check XML markup files -- Configuring done -- Generating done -- Build files have been written to: /buildroot/build/ros/rclpy Consolidate compiler generated dependencies of target gtest_main Consolidate compiler generated dependencies of target gtest Consolidate compiler generated dependencies of target _rclpy_pybind11 [ 5%] Built target gtest_main [ 10%] Built target gtest [ 10%] Built target ament_cmake_python_copy_rclpy Consolidate compiler generated dependencies of target test_python_allocator [ 16%] Built target test_python_allocator [ 18%] Linking CXX shared library test_rclpy/_rclpy_pybind11.cpython-38-aarch64-linux-gnu.so running egg_info writing rclpy.egg-info/PKG-INFO writing dependency_links to rclpy.egg-info/dependency_links.txt writing top-level names to rclpy.egg-info/top_level.txt reading manifest file 'rclpy.egg-info/SOURCES.txt' writing manifest file 'rclpy.egg-info/SOURCES.txt' [ 18%] Built target ament_cmake_python_build_rclpy_egg [100%] Built target _rclpy_pybind11 -- Install configuration: "" -- Up-to-date: /buildroot/target/opt/ros/share/rclpy/environment/pythonpath.sh -- Installing: /buildroot/target/opt/ros/share/rclpy/environment/pythonpath.dsv -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy-3.3.12-py3.10.egg-info -- Installing: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy-3.3.12-py3.10.egg-info/SOURCES.txt -- Installing: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy-3.3.12-py3.10.egg-info/PKG-INFO -- Installing: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy-3.3.12-py3.10.egg-info/top_level.txt -- Installing: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy-3.3.12-py3.10.egg-info/dependency_links.txt -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/node.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/validate_topic_name.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/publisher.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/topic_or_service_is_hidden.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/validate_namespace.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/constants.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/logging.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/parameter_service.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/service.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/client.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/subscription.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/timer.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/callback_groups.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/duration.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/qos_overriding_options.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/type_support.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/qos.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/validate_parameter_name.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/signals.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/task.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/expand_topic_name.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/guard_condition.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/time_source.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/qos_event.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/time.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/parameter.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/topic_endpoint_info.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/action -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/action/client.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/action/server.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/action/init.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/action/graph.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/utilities.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/validate_node_name.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/clock.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/init.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/context.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/waitable.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/validate_full_topic_name.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/impl -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/impl/logging_severity.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/impl/rcutils_logger.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/impl/implementation_singleton.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/impl/init.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/lifecycle -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/lifecycle/node.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/lifecycle/publisher.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/lifecycle/init.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/lifecycle/managed_entity.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/executors.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/exceptions.py -- Up-to-date: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/serialization.py Listing '/buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy'... Listing '/buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/action'... Listing '/buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/impl'... Listing '/buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/lifecycle'... -- Installing: /buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/_rclpy_pybind11.cpython-38-aarch64-linux-gnu.so -- Set runtime path of "/buildroot/target/opt/ros/local/lib/python3.10/dist-packages/rclpy/_rclpy_pybind11.cpython-38-aarch64-linux-gnu.so" to "/buildroot/target/opt/ros:/opt/lib" -- Up-to-date: /buildroot/target/opt/ros/share/rclpy/environment/library_path.sh -- Installing: /buildroot/target/opt/ros/share/rclpy/environment/library_path.dsv -- Up-to-date: /buildroot/target/opt/ros/share/ament_index/resource_index/package_run_dependencies/rclpy -- Up-to-date: /buildroot/target/opt/ros/share/ament_index/resource_index/parent_prefix_path/rclpy -- Up-to-date: /buildroot/target/opt/ros/share/rclpy/environment/ament_prefix_path.sh -- Installing: /buildroot/target/opt/ros/share/rclpy/environment/ament_prefix_path.dsv -- Up-to-date: /buildroot/target/opt/ros/share/rclpy/environment/path.sh -- Installing: /buildroot/target/opt/ros/share/rclpy/environment/path.dsv -- Up-to-date: /buildroot/target/opt/ros/share/rclpy/local_setup.bash -- Up-to-date: /buildroot/target/opt/ros/share/rclpy/local_setup.sh -- Up-to-date: /buildroot/target/opt/ros/share/rclpy/local_setup.zsh -- Installing: /buildroot/target/opt/ros/share/rclpy/local_setup.dsv -- Installing: /buildroot/target/opt/ros/share/rclpy/package.dsv -- Up-to-date: /buildroot/target/opt/ros/share/ament_index/resource_index/packages/rclpy -- Up-to-date: /buildroot/target/opt/ros/share/rclpy/cmake/rclpyConfig.cmake -- Up-to-date: /buildroot/target/opt/ros/share/rclpy/cmake/rclpyConfig-version.cmake -- Up-to-date: /buildroot/target/opt/ros/share/rclpy/package.xml

Finished <<< rclpy [21.8s]

XQSwx commented 1 month ago

Maybe my understanding is incorrect, I suspect that the CMakeLists file does not match the generation of linked libraries for cross-compilation.

clalancette commented 1 month ago

unfortunately, cross-compile is not supported anymore? https://docs.ros.org/en/humble/How-To-Guides/Cross-compilation.html, https://github.com/ros-tooling/cross_compile repo has been archived.

You are right that it is currently not a supported configuration. Because of that, there may indeed be a bug here.

That said, if @XQSwx can find and fix a bug here, we'd be very happy to review a PR to make fixes.

XQSwx commented 1 month ago

Although cross compile is not supported, every compilation passes the cmake parameter. Can we obtain these parameters to generate a linked library. I have compiled all packages for ROS2, and only this package and ROSBAG2 have encountered this issue. Although I used some clever methods to compile it. But if others use this cmakelist, they may still encounter these issues cmake-args:

XQSwx commented 1 month ago

@clalancette Others should use the following two parameters passed by colcon to define the generated file "-DCMAKE_SYSTEM_PROCESSOR=aarch64" “-DPYTHON_SOABI=cpython-36m-aarch64-linux-gnu”