diff mbox series

[meta-oe,2/8] sysdig: Fix intermittent missing libsinsp/libscap headers on rebuild

Message ID 20260713004502.716970-2-khem.raj@oss.qualcomm.com
State New
Headers show
Series [meta-python,1/8] python3-dbus-deviation: Drop all setup_requires to fix build failure | expand

Commit Message

Khem Raj July 13, 2026, 12:44 a.m. UTC
do_compile could fail with many:

  fatal error: 'libsinsp/sinsp.h' file not found
  fatal error: 'sinsp.h' file not found
  fatal error: 'libscap/strl.h' file not found

across all userspace/sysdig objects, even though the headers exist in
the fetched falcosecurity-libs source.

The add_library de-duplication patch guarded the libscap/libsinsp
modules with a HAVE_LIBSCAP/HAVE_LIBSINSP flag set as CACHE INTERNAL.
Because that value persists in CMakeCache, ninja's build-time
regeneration rule (cmake --regenerate-during-build, which fires whenever
a CMake input's timestamp changes between do_configure and do_compile)
re-runs cmake with the flag already true. The libscap/libsinsp
add_subdirectory() is then skipped, dropping the scap/sinsp targets and
their PUBLIC include directories, so target_link_libraries(sysdig sinsp)
degrades to a bare -lsinsp with no header propagation.

Guard on target existence (if(NOT TARGET scap|sinsp)) instead. Target
existence is global within a single cmake run -- so it still prevents
the duplicate add_library -- but is not persisted across runs, so the
modules are correctly re-processed on every regeneration.

Verified: a build-time cmake regeneration now keeps the libsinsp/libscap
object rules and falcosecurity-libs include paths in build.ninja, and a
full clean build plus a post-touch recompile both succeed.

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
 ...-duplicate-operations-of-add_library.patch | 34 +++++++++++++------
 1 file changed, 23 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/meta-oe/recipes-extended/sysdig/sysdig/0001-Avoid-duplicate-operations-of-add_library.patch b/meta-oe/recipes-extended/sysdig/sysdig/0001-Avoid-duplicate-operations-of-add_library.patch
index b8ca7dd38b..ec9ca46269 100644
--- a/meta-oe/recipes-extended/sysdig/sysdig/0001-Avoid-duplicate-operations-of-add_library.patch
+++ b/meta-oe/recipes-extended/sysdig/sysdig/0001-Avoid-duplicate-operations-of-add_library.patch
@@ -9,36 +9,48 @@  To fix following configure error
 |   add_library cannot create target "scap_error" because another target with
 |   the same name already exists.  The existing target is a static library

+Guard the libscap/libsinsp modules on the existence of the "scap"/"sinsp"
+targets rather than on a cached HAVE_LIBSCAP/HAVE_LIBSINSP flag. A cached
+flag persists into the CMakeCache, so when Ninja re-runs CMake during the
+build (the "cmake --regenerate-during-build" RERUN rule fires whenever a
+CMake input's timestamp changes) the guard is already true and the
+add_subdirectory() for libscap/libsinsp is skipped. That drops the scap/
+sinsp targets and their PUBLIC include directories, and the userspace/
+sysdig targets then fail to compile with "'libsinsp/sinsp.h' file not
+found". Target existence is global within a single CMake run (so it still
+prevents the duplicate add_library) but is not persisted across runs, so
+the modules are re-processed on every regeneration.
+
 Upstream-Status: Inappropriate [oe-specific]
 Signed-off-by: Liu Yiding <liuyd.fnst@fujitsu.com>
 ---
- cmake/modules/libscap.cmake  | 2 +-
- cmake/modules/libsinsp.cmake | 2 +-
- 2 files changed, 2 insertions(+), 2 deletions(-)
+ cmake/modules/libscap.cmake  | 3 +--
+ cmake/modules/libsinsp.cmake | 3 +--
+ 2 files changed, 2 insertions(+), 4 deletions(-)

 diff --git a/cmake/modules/libscap.cmake b/cmake/modules/libscap.cmake
-index b41b12ff3..1753598e9 100644
 --- a/cmake/modules/libscap.cmake
 +++ b/cmake/modules/libscap.cmake
-@@ -14,7 +14,7 @@
+@@ -13,8 +13,7 @@
+ # the License.
  #

- if(NOT HAVE_LIBSCAP)
+-if(NOT HAVE_LIBSCAP)
 -	set(HAVE_LIBSCAP On)
-+        set(HAVE_LIBSCAP On CACHE INTERNAL "Flag to indicate libscap has been processed")
++if(NOT TARGET scap)

  	if(NOT LIBS_DIR)
  		get_filename_component(LIBS_DIR ${CMAKE_CURRENT_LIST_DIR}/../.. ABSOLUTE)
 diff --git a/cmake/modules/libsinsp.cmake b/cmake/modules/libsinsp.cmake
-index ff336e27f..0fdd2d4a9 100644
 --- a/cmake/modules/libsinsp.cmake
 +++ b/cmake/modules/libsinsp.cmake
-@@ -14,7 +14,7 @@
+@@ -13,8 +13,7 @@
+ # the License.
  #

- if(NOT HAVE_LIBSINSP)
+-if(NOT HAVE_LIBSINSP)
 -	set(HAVE_LIBSINSP On)
-+        set(HAVE_LIBSINSP On CACHE INTERNAL "Flag to indicate libsinsp has been processed")
++if(NOT TARGET sinsp)

  	if(NOT LIBS_DIR)
  		get_filename_component(LIBS_DIR ${CMAKE_CURRENT_LIST_DIR}/../.. ABSOLUTE)