Skip to content

Fix portability landmines in the std::pmr conversion / build - #18

Open
pete-tempo wants to merge 1 commit into
fix/pmr-conversion-defectsfrom
fix/pmr-portability
Open

Fix portability landmines in the std::pmr conversion / build#18
pete-tempo wants to merge 1 commit into
fix/pmr-conversion-defectsfrom
fix/pmr-portability

Conversation

@pete-tempo

Copy link
Copy Markdown
Contributor

These do not affect the current clang+libc++ build but would break a libstdc++ build, a standalone package build, or are latent copy-paste bugs:

  1. Fast-CDR.patch (Cdr.h, Cdr.cpp): the std::pmr serialize/deserialize sequence overloads were gated on _LIBCPP_STD_VER >= 17, a libc++-internal macro that is undefined (0) on libstdc++, which would drop the overloads while the templated std::pmr::vector/string-sequence callers still reference them. Changed to the portable __cplusplus >= 201703L (the defined(_MSC_VER) || prefix still covers MSVC's lagging __cplusplus).

  2. common_interfaces.patch (point_cloud2_iterator.hpp): a concrete std::vector<...>::const_iterator over a now-pmr fields vector compiles on libc++ (__wrap_iter) but not on libstdc++ (allocator-parameterized iterator). Use auto.

  3. geometry2.patch (tf2), vision_opencv.patch (cv_bridge, image_geometry): these packages now include pmr message headers (which need <memory_resource>, C++17) but had no explicit CMAKE_CXX_STANDARD, so they only built because a global standard leaked in -- a standalone build would fail. Set CMAKE_CXX_STANDARD 20 to match their already-bumped siblings (tf2_ros, the image_transport packages).

  4. build_rclcpp_mac.sh: -DPYTHON_INCLUDE_DIR pointed at the Python3/Linux include dir in the Mac build (copy-paste); now Python3/Mac.

Not changed: -Wl,--allow-shlib-undefined in linux.toolchain.cmake. Removing it would catch missing symbols at link time, but ROS resolves rmw/typesupport symbols at runtime via dlopen, so it is plausibly load-bearing; dropping it needs a full link test, not a mechanical edit.

Each patch was regenerated from source and verified to apply cleanly to a pristine submodule checkout.

These do not affect the current clang+libc++ build but would break a
libstdc++ build, a standalone package build, or are latent copy-paste bugs:

1. Fast-CDR.patch (Cdr.h, Cdr.cpp): the std::pmr serialize/deserialize
   sequence overloads were gated on `_LIBCPP_STD_VER >= 17`, a libc++-internal
   macro that is undefined (0) on libstdc++, which would drop the overloads
   while the templated std::pmr::vector<bool>/string-sequence callers still
   reference them. Changed to the portable `__cplusplus >= 201703L`
   (the `defined(_MSC_VER) ||` prefix still covers MSVC's lagging __cplusplus).

2. common_interfaces.patch (point_cloud2_iterator.hpp): a concrete
   `std::vector<...>::const_iterator` over a now-pmr `fields` vector compiles
   on libc++ (__wrap_iter) but not on libstdc++ (allocator-parameterized
   iterator). Use `auto`.

3. geometry2.patch (tf2), vision_opencv.patch (cv_bridge, image_geometry):
   these packages now include pmr message headers (which need <memory_resource>,
   C++17) but had no explicit CMAKE_CXX_STANDARD, so they only built because a
   global standard leaked in -- a standalone build would fail. Set
   CMAKE_CXX_STANDARD 20 to match their already-bumped siblings (tf2_ros, the
   image_transport packages).

4. build_rclcpp_mac.sh: -DPYTHON_INCLUDE_DIR pointed at the Python3/Linux
   include dir in the Mac build (copy-paste); now Python3/Mac.

Not changed: -Wl,--allow-shlib-undefined in linux.toolchain.cmake. Removing it
would catch missing symbols at link time, but ROS resolves rmw/typesupport
symbols at runtime via dlopen, so it is plausibly load-bearing; dropping it
needs a full link test, not a mechanical edit.

Each patch was regenerated from source and verified to apply cleanly to a
pristine submodule checkout.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant