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 <beniamino.pozzan@gmail.com>
This commit is contained in:
Beniamino Pozzan committed 2026-11-04 15:51:34 +00:00
1 parent 4412069de6
commit 6ef1ce03a4
2 files changed
+7 -2

No files matched your search

+5 -1
View File
@@ -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()
+2 -1
View File
@@ -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()