From 0b785f5b063690f29d091198f9632f0c6b680909 Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Tue, 31 Dec 2024 16:05:08 +0100 Subject: [PATCH] package/libzenoh-pico: fix debug+fortify glibc builds The configurations that have: - BR2_ENABLE_RUNTIME_DEBUG=y - One of BR2_FORTIFY_SOURCE_xyz=y Currently fail to build, as libzenoh-pico's build system forces -O0 when BR2_ENABLE_RUNTIME_DEBUG=y, but -O0 builds aren't compatible with _FORTIFY_SOURCE, causing: ../../../per-package/libzenoh-pico/host/mips64-buildroot-linux-gnu/sysroot/usr/include/features.h:422:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] 422 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O) | ^~~~~~~ cc1: all warnings being treated as errors We fix this by adding a patch that drops the forced -O3 (release builds) and -O0 (debug builds) from the project CMakeLists.txt. This issue exists since libzenoh-pico was introduced in Buildroot in commit a96361901dcc7b962a0c43f163e97a2de65687f3 ("package/libzenoh-pico: new package"), but was hidden by other issues until a first occurence in November 2024 right after the bump to 1.0.1: http://autobuild.buildroot.net/results/f109e8b4aba0286dcaac5cb6d4579e6d91c492f8/ Fixes: http://autobuild.buildroot.net/results/f109e8b4aba0286dcaac5cb6d4579e6d91c492f8/ Signed-off-by: Thomas Petazzoni Signed-off-by: Julien Olivain --- ...on-t-override-the-optimization-level.patch | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 package/libzenoh-pico/0001-CMakeLists.txt-don-t-override-the-optimization-level.patch diff --git a/package/libzenoh-pico/0001-CMakeLists.txt-don-t-override-the-optimization-level.patch b/package/libzenoh-pico/0001-CMakeLists.txt-don-t-override-the-optimization-level.patch new file mode 100644 index 0000000000..9f911a750b --- /dev/null +++ b/package/libzenoh-pico/0001-CMakeLists.txt-don-t-override-the-optimization-level.patch @@ -0,0 +1,64 @@ +From 32d087860abaf5b2374043db7034174aec06b885 Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Tue, 31 Dec 2024 15:52:57 +0100 +Subject: [PATCH] CMakeLists.txt: don't override the optimization level + +zenoh-pico's CMakeLists.txt has some logic to provide its own compiler +optimization level: -O3 for release builds, -O0 for debug builds. + +Unfortunately, using add_compile_options() means that those settings +take precedence over what the user can pass as custom compiler +flags. And this causes issues for example when doing a debug build +with _FORTIFY_SOURCE enabled, as _FORTIFY_SOURCE support in glibc is +incompatible with unoptimized builds causing this build failure: + +/home/thomas/projets/buildroot/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/include/features.h:414:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] + 414 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O) + | ^~~~~~~ + +which is a warning, but as zenoh-pico builds with -Werror, it turns +into a build failure. + +As it is unclear how CMakeLists.txt can pass a default -O level, while +allowing it to be overridden by the user, we simply remove those +optimization level options. + +Signed-off-by: Thomas Petazzoni +Upstream: https://github.com/eclipse-zenoh/zenoh-pico/pull/847 +--- + CMakeLists.txt | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7a9fb6d1..97fba56a 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -85,13 +85,13 @@ string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE) + # Compile options + if(CMAKE_BUILD_TYPE MATCHES "RELEASE" OR "Release") + if(UNIX) +- add_compile_options(-pipe -O3) ++ add_compile_options(-pipe) + elseif(CMAKE_SYSTEM_NAME MATCHES "Generic") +- add_compile_options(-pipe -O3) ++ add_compile_options(-pipe) + endif() + else() + if(UNIX) +- add_compile_options(-c -Wall -Wextra -Werror -Wshadow -Wunused -Wstrict-prototypes -pipe -g -O0) ++ add_compile_options(-c -Wall -Wextra -Werror -Wshadow -Wunused -Wstrict-prototypes -pipe -g) + # C99 pedantic doesn't like struct anonymous in unix header + if (NOT CMAKE_C_STANDARD STREQUAL "99") + add_compile_options(-Wpedantic) +@@ -100,7 +100,7 @@ else() + elseif(MSVC) + add_compile_options(/W4 /WX /Od /wd4127) + elseif(CMAKE_SYSTEM_NAME MATCHES "Generic") +- add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes -pipe -g -O0) ++ add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes -pipe -g) + endif() + endif() + +-- +2.47.1 +