From 0b40585124d517c07cee65af1390719ce7c78cd0 Mon Sep 17 00:00:00 2001 From: Cole Munz Date: Mon, 17 Aug 2026 12:23:59 -0500 Subject: [PATCH] Set the stringop-overflow flags before add_subdirectory(deps) With the linker pin in place the proxspace job gets past the bootrom and dies later instead, in the cmake build: client/deps/jansson/load.c:193:35: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=] client/CMakeLists.txt already turns that false positive off for GCC 10 and newer, but it does it at line 876 while add_subdirectory(deps) runs at line 295. CMake copies the calling scope into a subdirectory at the add_subdirectory call, so anything set afterwards never reaches the bundled deps, and jansson is built without the suppression that the rest of the client gets. Move the block above the add_subdirectory call in both client and experimental_lib. Checked by configuring before and after: 0 of 17 deps targets carried -Wno-error=stringop-overflow in their flags.make before, 17 of 17 after. ubuntu-cmake and macos-cmake stay green either way; their compilers do not emit this particular false positive, which is why the gap went unnoticed while the bootrom link was failing first. Signed-off-by: Cole Munz --- client/CMakeLists.txt | 26 +++++++++++++++----------- client/experimental_lib/CMakeLists.txt | 26 +++++++++++++++----------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index aaa22bd9a..5cdc633b3 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -292,6 +292,21 @@ if (NOT SKIPWHEREAMISYSTEM EQUAL 1) endif (WHEREAMI_INCLUDE_DIRS AND WHEREAMI_LIBRARIES) endif (NOT SKIPWHEREAMISYSTEM EQUAL 1) +# These must be set BEFORE add_subdirectory(deps): CMake copies the +# current variable scope into a subdirectory at that point, so flags set +# further down never reach the bundled deps and jansson fails the +# -Werror=stringop-overflow false positive on its own. +# GCC 10 has issues with false positives on stringop-overflow, +# let's disable them for now (cf https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92955, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94335) +# beware these flags didn't exist for GCC < 7 +if(CMAKE_COMPILER_IS_GNUCXX) + execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) + if (GCC_VERSION VERSION_GREATER 10.0 OR GCC_VERSION VERSION_EQUAL 10.0) + set(CMAKE_C_FLAGS "-Wno-stringop-overflow -Wno-error=stringop-overflow ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "-Wno-stringop-overflow -Wno-error=stringop-overflow ${CMAKE_CXX_FLAGS}") + endif() +endif(CMAKE_COMPILER_IS_GNUCXX) + add_subdirectory(${PM3_ROOT}/client/deps deps) set (TARGET_SOURCES @@ -874,17 +889,6 @@ if (MINGW) set(ADDITIONAL_LNK ws2_32 ${ADDITIONAL_LNK}) endif (MINGW) -# GCC 10 has issues with false positives on stringop-overflow, -# let's disable them for now (cf https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92955, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94335) -# beware these flags didn't exist for GCC < 7 -if(CMAKE_COMPILER_IS_GNUCXX) - execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) - if (GCC_VERSION VERSION_GREATER 10.0 OR GCC_VERSION VERSION_EQUAL 10.0) - set(CMAKE_C_FLAGS "-Wno-stringop-overflow -Wno-error=stringop-overflow ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "-Wno-stringop-overflow -Wno-error=stringop-overflow ${CMAKE_CXX_FLAGS}") - endif() -endif(CMAKE_COMPILER_IS_GNUCXX) - target_include_directories(proxmark3 PRIVATE ${PM3_ROOT}/common ${PM3_ROOT}/common_fpga diff --git a/client/experimental_lib/CMakeLists.txt b/client/experimental_lib/CMakeLists.txt index 0ebb32882..f6e8e89b8 100644 --- a/client/experimental_lib/CMakeLists.txt +++ b/client/experimental_lib/CMakeLists.txt @@ -212,6 +212,21 @@ if (NOT SKIPWHEREAMISYSTEM EQUAL 1) endif (WHEREAMI_INCLUDE_DIRS AND WHEREAMI_LIBRARIES) endif (NOT SKIPWHEREAMISYSTEM EQUAL 1) +# These must be set BEFORE add_subdirectory(deps): CMake copies the +# current variable scope into a subdirectory at that point, so flags set +# further down never reach the bundled deps and jansson fails the +# -Werror=stringop-overflow false positive on its own. +# GCC 10 has issues with false positives on stringop-overflow, +# let's disable them for now (cf https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92955, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94335) +# beware these flags didn't exist for GCC < 7 +if(CMAKE_COMPILER_IS_GNUCXX) + execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) + if (GCC_VERSION VERSION_GREATER 10.0 OR GCC_VERSION VERSION_EQUAL 10.0) + set(CMAKE_C_FLAGS "-Wno-stringop-overflow -Wno-error=stringop-overflow ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "-Wno-stringop-overflow -Wno-error=stringop-overflow ${CMAKE_CXX_FLAGS}") + endif() +endif(CMAKE_COMPILER_IS_GNUCXX) + add_subdirectory(${PM3_ROOT}/client/deps deps) set (TARGET_SOURCES @@ -707,17 +722,6 @@ if (MINGW) set(ADDITIONAL_LNK ws2_32 ${ADDITIONAL_LNK}) endif (MINGW) -# GCC 10 has issues with false positives on stringop-overflow, -# let's disable them for now (cf https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92955, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94335) -# beware these flags didn't exist for GCC < 7 -if(CMAKE_COMPILER_IS_GNUCXX) - execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) - if (GCC_VERSION VERSION_GREATER 10.0 OR GCC_VERSION VERSION_EQUAL 10.0) - set(CMAKE_C_FLAGS "-Wno-stringop-overflow -Wno-error=stringop-overflow ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "-Wno-stringop-overflow -Wno-error=stringop-overflow ${CMAKE_CXX_FLAGS}") - endif() -endif(CMAKE_COMPILER_IS_GNUCXX) - target_include_directories(pm3rrg_rdv4 PRIVATE ${PM3_ROOT}/common ${PM3_ROOT}/common_fpga