size_t cross-compilation issue
alsora opened this issue · comments
Bug report
I'm trying to cross-compile this repository for RaspberryPi (32 bit)
The cross-compilation of this package fails because deserializeSequenceSize
function takes a size_t
argument and then converts it into `uint64_t.
https://github.com/ros2/rmw_dps/blob/master/rmw_dps_cpp/include/rmw_dps_cpp/CborStream.hpp#L444
error: cannot convert ‘size_t* {aka unsigned int*}’ to ‘uint64_t* {aka long long unsigned int*}’ for argument ‘3’ to ‘DPS_Status CBOR_Peek(DPS_RxBuffer*, uint8_t*, uint64_t*)’
DPS_Status ret = CBOR_Peek(&buffer_, &maj, size);
Do you think that it is possible to change the GenericCSequence
object to directly use the proper type?
The rosidl_generator_c__ functions are defined elsewhere, so it'd probably be more straightforward to have a local uint64_t for the argument, then assign that to the size_t out argument, after some range checking depending on how paranoid you are.
Longer term, it appears that CBOR_Peek is not consistent with other CBOR functions from DPS that take a size_t instead of a uint64_t (i.e. CBOR_DecodeArray). I filed intel/dps-for-iot#96 to track this.
Can you provide me some pointers on how to configure ros2 to cross-compile for RaspberryPi? I see a handful of questions and answers online, but I'm not finding anything definitive looking.
Yes, you are right.
This is a PR I opened to add RaspberryPi cross-compilation support to the OSRF tools ros-tooling/cross_compile#15
NOTE:
- When cross-compiling the whole ROS2 workspace, it's necessary to find a way to pass the compiler flags to the DPS Sconstruct file. This is an example for a ROS2 vendor package https://github.com/ros2/tinyxml_vendor/blob/master/CMakeLists.txt#L14
I'm no expert of Scons, so for my tests I simply tried to build the DPS library directly on RaspberryPi
@malsbat I tested your new branch https://github.com/intel/dps-for-iot/tree/x86 and it works!
I haven't been able to cross-compile it, but this can be fixed by passing the compilation flags as done in the example I posted above.
However, the changes you did to the source code are enough for building it on 32 bit platforms.
This is what I did in order to test it:
-
On a RaspberryPi ->
git clone https://github.com/intel/dps-for-iot.git
cd dps-for-iot
git checkout x86
scons variant=release transport=udp bindings=none DEF_FILE=~/rmw_dps/dps_for_iot_cmake_module/librmw_dps_shared.map
-
Copy the
~/dps-for-iot
directory to the laptop -
On the laptop ->
create a ROS2 workspace
mkdir -p build/dps_for_iot_cmake_module
mkdir -p install/lib
cp ~/dps-for-iot/build/dist/lib/libdps* install/lib
cp -r ~/dps-for-iot build/dps_for_iot_cmake_module
touch src/rmw_dps/dps_for_iot_cmake_module/COLCON_IGNORE
-
Cross-Compile the ROS2 workspace
@alsora Great, I'm going to do a bit more testing with the x86 branch before I merge it. I need to make sure it works on Windows and I'd like to verify your RPi build as well on my end.
I did not intend merging PR #9 to close this issue. I want to continue to track the general cross-compilation here.
@alsora, I had trouble with the instructions at ros-tooling/cross_compile#15, however I was able to verify PR #33 with the instructions at https://index.ros.org/doc/ros2/Tutorials/Cross-compilation/#cross-compiling-examples-for-arm.
I believe this can be closed now with the merge of intel/dps-for-iot#108 and #33.