From 6ef1ce03a44ff3ab6a65639146c30130f2e8ed30 Mon Sep 17 00:00:00 2001 From: Beniamino Pozzan Date: Sun, 25 Oct 2026 21:47:28 +0000 Subject: [PATCH] build(zenoh): fix the -O0 sanitizer and coverage builds The sanitizer and coverage build types compile at -O0, which first reached zenoh-pico and cdrstream once px4_sitl_default included Zenoh. GCC with ThreadSanitizer then misses that zenoh-pico's do { return ... } while (false) error macro returns and fails with -Werror=return-type, so silence that warning for the library. The CycloneDDS byte-swap helpers are C99 inline functions: when they are not inlined the link needs their external definitions, which ddsrt/src/bswap.c provides. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Beniamino Pozzan --- src/lib/cdrstream/CMakeLists.txt | 6 +++++- src/modules/zenoh/CMakeLists.txt | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/cdrstream/CMakeLists.txt b/src/lib/cdrstream/CMakeLists.txt index cfdb6ab0902..1e978baa56b 100644 --- a/src/lib/cdrstream/CMakeLists.txt +++ b/src/lib/cdrstream/CMakeLists.txt @@ -44,6 +44,10 @@ if(CONFIG_LIB_CDRSTREAM) px4_add_git_submodule(TARGET git_cyclonedds PATH "cyclonedds") px4_add_git_submodule(TARGET git_rosidl PATH "rosidl") add_dependencies(cdr git_cyclonedds git_rosidl uorb_headers parameters px4_platform) - target_sources(cdr PRIVATE dds_serializer.c) + # bswap.c holds the external definitions of the inline byte-swap helpers, + # needed when they are not inlined (e.g. -O0 sanitizer builds) + target_sources(cdr PRIVATE + dds_serializer.c + ${CMAKE_CURRENT_LIST_DIR}/cyclonedds/src/ddsrt/src/bswap.c) target_include_directories(cdr PUBLIC ${CMAKE_CURRENT_LIST_DIR}) endif() diff --git a/src/modules/zenoh/CMakeLists.txt b/src/modules/zenoh/CMakeLists.txt index cb6908d977b..60ae506dad0 100644 --- a/src/modules/zenoh/CMakeLists.txt +++ b/src/modules/zenoh/CMakeLists.txt @@ -77,7 +77,8 @@ target_compile_options(zenohpico_static PUBLIC -Wno-cast-align -Wno-conversion -Wno-float-equal) -target_compile_options(zenohpico_static PRIVATE -Wno-missing-prototypes) +target_compile_options(zenohpico_static PRIVATE -Wno-missing-prototypes + -Wno-return-type) # false positive at -O0 (sanitizer builds) if(CONFIG_PLATFORM_NUTTX) target_compile_options(zenohpico_static PRIVATE -DUNIX_NO_MULTICAST_IF) endif()