Skip to content

refactor: build bundled zlib via CMake instead of CONFIGURE_COMMAND - #3020

Open
mvanhorn wants to merge 4 commits into
falcosecurity:masterfrom
mvanhorn:refactor/2584-zlib-cmake
Open

refactor: build bundled zlib via CMake instead of CONFIGURE_COMMAND#3020
mvanhorn wants to merge 4 commits into
falcosecurity:masterfrom
mvanhorn:refactor/2584-zlib-cmake

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Jun 9, 2026

Copy link
Copy Markdown

Summary

Build the bundled zlib dependency on non-Windows via zlib's own CMake build instead of
invoking its hand-written ./configure script through ExternalProject_Add's
CONFIGURE_COMMAND. zlib v1.3.1 ships a first-class CMakeLists.txt, so the bundled dep is now
configured and built with CMake (mirroring the existing Windows branch and the
jsoncpp/re2/tbb modules), with build settings passed via CMAKE_ARGS and the toolchain
forwarded through the shared falcosecurity_external_project_cache_args mechanism.

Why this matters

Issue #2584 tracks this as a build-system maintainability cleanup. Using zlib's own CMake build
drops the bespoke ./configure + make + CFLAGS plumbing (-O3/-g, -fPIC, and toolchain
flag accumulation) in favor of standard CMake cache vars (CMAKE_BUILD_TYPE,
CMAKE_POSITION_INDEPENDENT_CODE, CMAKE_C_FLAGS), and unifies how the bundled dependency
toolchain is propagated with the rest of the bundled deps.

Changes

  • cmake/modules/zlib.cmake (non-Windows branch): replace CONFIGURE_COMMAND ./configure /
    BUILD_COMMAND make / BUILD_IN_SOURCE 1 with a CMake configure+build via CMAKE_ARGS and
    CMAKE_CACHE_ARGS ${ZLIB_EXTERNAL_PROJECT_CACHE_ARGS}.
  • Build only the library type that is actually consumed (zlibstatic for static builds, zlib
    for shared) so the unused target is never compiled — preserving the old ./configure --static
    behavior and keeping static-only / cross toolchains working.
  • -DZLIB_BUILD_EXAMPLES=OFF so the bundled sub-build skips zlib's example/test executables.
  • ZLIB_INCLUDE / ZLIB_LIB / ZLIB_HEADERS continue to point at the produced library and
    headers, so downstream consumers (libscap, libsinsp, libpman, libbpf) see no interface
    change.

Testing

The cmake/modules/zlib.cmake module is syntactically valid and the ExternalProject_Add
arguments are internally consistent (verified by configuring the module in isolation and by
building the bundled zlib sub-project directly for static and shared, single- and multi-config
generators). A full falcosecurity/libs build was not run locally as it requires the complete
dependency set; CI exercises the end-to-end bundled build.

Fixes #2584


AI was used for assistance.

Does this PR introduce a user-facing change?:

NONE

@poiana

poiana commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Welcome @mvanhorn! It looks like this is your first PR to falcosecurity/libs 🎉

@poiana poiana added the size/L label Jun 9, 2026
@poiana
poiana requested review from hbrueckner and terror96 June 9, 2026 11:02
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.56%. Comparing base (1a1d1e7) to head (d8d3176).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3020   +/-   ##
=======================================
  Coverage   76.56%   76.56%           
=======================================
  Files         301      301           
  Lines       33693    33693           
  Branches     5038     5041    +3     
=======================================
  Hits        25797    25797           
  Misses       7896     7896           
Flag Coverage Δ
libsinsp 76.56% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown

Perf diff from master - unit tests

    10.75%    +10.53%  [.] sinsp_thread_manager::create_thread_dependencies(std::shared_ptr<sinsp_threadinfo> const&)
    18.94%     -9.18%  [.] std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_add_ref_lock_nothrow()
    19.87%     -8.02%  [.] sinsp_threadinfo::get_main_thread()
    14.29%     +5.58%  [.] std::__shared_ptr<sinsp_threadinfo, (__gnu_cxx::_Lock_policy)2>::__shared_ptr(std::__weak_ptr<sinsp_threadinfo, (__gnu_cxx::_Lock_policy)2> const&, std::nothrow_t)
     4.60%     +4.67%  [.] std::__shared_count<(__gnu_cxx::_Lock_policy)2>::_M_get_use_count() const
     7.25%     -1.91%  [.] std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count(std::__weak_count<(__gnu_cxx::_Lock_policy)2> const&, std::nothrow_t)
     9.28%     -0.45%  [.] std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release()
     4.54%     -0.43%  [.] thread_group_info::get_first_thread() const
     0.50%     -0.17%  [.] scap_event_encode_params_v
     3.64%     -0.16%  [.] sinsp_threadinfo::get_fd_table() const

Heap diff from master - unit tests

peak heap memory consumption: 0B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Heap diff from master - scap file

peak heap memory consumption: 0B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Benchmarks diff from master

Comparing gbench_data.json to /root/actions-runner/_work/libs/libs/build/gbench_data.json
Benchmark                                                                             Time             CPU      Time Old      Time New       CPU Old       CPU New
------------------------------------------------------------------------------------------------------------------------------------------------------------------
BM_sinsp_split_mean                                                                +0.0157         +0.0157           288           293           288           292
BM_sinsp_split_median                                                              +0.0182         +0.0182           287           292           287           292
BM_sinsp_split_stddev                                                              -0.6154         -0.6149             5             2             5             2
BM_sinsp_split_cv                                                                  -0.6214         -0.6209             0             0             0             0
BM_sinsp_concatenate_paths_relative_path_mean                                      -0.0725         -0.0725            67            63            67            62
BM_sinsp_concatenate_paths_relative_path_median                                    -0.0737         -0.0735            67            62            67            62
BM_sinsp_concatenate_paths_relative_path_stddev                                    +1.5203         +1.5026             0             0             0             0
BM_sinsp_concatenate_paths_relative_path_cv                                        +1.7174         +1.6983             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_mean                                         +0.0718         +0.0719            45            48            45            48
BM_sinsp_concatenate_paths_empty_path_median                                       +0.0826         +0.0824            44            48            44            48
BM_sinsp_concatenate_paths_empty_path_stddev                                       -0.9406         -0.9409             1             0             1             0
BM_sinsp_concatenate_paths_empty_path_cv                                           -0.9446         -0.9449             0             0             0             0
BM_sinsp_concatenate_paths_absolute_path_mean                                      -0.0986         -0.0986            66            60            66            60
BM_sinsp_concatenate_paths_absolute_path_median                                    -0.1006         -0.1006            66            60            66            60
BM_sinsp_concatenate_paths_absolute_path_stddev                                    +0.4801         +0.4669             0             0             0             0
BM_sinsp_concatenate_paths_absolute_path_cv                                        +0.6420         +0.6274             0             0             0             0
BM_sinsp_utf8_sanitize_fast_path_ascii_short_mean                                  +0.0013         +0.0013            15            15            15            15
BM_sinsp_utf8_sanitize_fast_path_ascii_short_median                                -0.0003         -0.0003            15            15            15            15
BM_sinsp_utf8_sanitize_fast_path_ascii_short_stddev                               +12.8276        +12.7034             0             0             0             0
BM_sinsp_utf8_sanitize_fast_path_ascii_short_cv                                   +12.8094        +12.6854             0             0             0             0
BM_sinsp_utf8_sanitize_fast_path_ascii_long_mean                                   -0.0004         -0.0004            87            87            87            87
BM_sinsp_utf8_sanitize_fast_path_ascii_long_median                                 -0.0004         -0.0003            87            87            87            87
BM_sinsp_utf8_sanitize_fast_path_ascii_long_stddev                                 -0.3005         -0.3338             0             0             0             0
BM_sinsp_utf8_sanitize_fast_path_ascii_long_cv                                     -0.3003         -0.3336             0             0             0             0
BM_sinsp_utf8_sanitize_fast_path_multibyte_short_mean                              +0.0213         +0.0213            12            13            12            13
BM_sinsp_utf8_sanitize_fast_path_multibyte_short_median                            +0.0015         +0.0015            12            12            12            12
BM_sinsp_utf8_sanitize_fast_path_multibyte_short_stddev                           +88.7654        +87.3539             0             0             0             0
BM_sinsp_utf8_sanitize_fast_path_multibyte_short_cv                               +86.8919        +85.5092             0             0             0             0
BM_sinsp_utf8_sanitize_fast_path_multibyte_long_mean                               +0.2402         +0.2401          3801          4714          3800          4713
BM_sinsp_utf8_sanitize_fast_path_multibyte_long_median                             +0.2401         +0.2403          3801          4714          3800          4713
BM_sinsp_utf8_sanitize_fast_path_multibyte_long_stddev                             +0.7133         +0.1442             1             1             1             1
BM_sinsp_utf8_sanitize_fast_path_multibyte_long_cv                                 +0.3815         -0.0774             0             0             0             0
BM_sinsp_utf8_sanitize_fast_path_mixed_long_mean                                   +0.3245         +0.3245          1676          2220          1675          2219
BM_sinsp_utf8_sanitize_fast_path_mixed_long_median                                 +0.3184         +0.3185          1683          2219          1683          2218
BM_sinsp_utf8_sanitize_fast_path_mixed_long_stddev                                 -0.7225         -0.7199            25             7            25             7
BM_sinsp_utf8_sanitize_fast_path_mixed_long_cv                                     -0.7905         -0.7885             0             0             0             0
BM_sinsp_utf8_sanitize_slow_path_c1_controls_long_alloc_mean                       +0.3252         +0.3252          1115          1477          1114          1477
BM_sinsp_utf8_sanitize_slow_path_c1_controls_long_alloc_median                     +0.3697         +0.3696          1114          1526          1114          1525
BM_sinsp_utf8_sanitize_slow_path_c1_controls_long_alloc_stddev                    +78.2248        +80.9387             2           128             2           128
BM_sinsp_utf8_sanitize_slow_path_c1_controls_long_alloc_cv                        +58.7833        +60.8325             0             0             0             0
BM_sinsp_utf8_sanitize_slow_path_c1_controls_long_noalloc_mean                     +0.0026         +0.0024          1112          1115          1111          1114
BM_sinsp_utf8_sanitize_slow_path_c1_controls_long_noalloc_median                   +0.0013         +0.0011          1111          1113          1111          1112
BM_sinsp_utf8_sanitize_slow_path_c1_controls_long_noalloc_stddev                   +4.1784         +4.0561             1             5             1             5
BM_sinsp_utf8_sanitize_slow_path_c1_controls_long_noalloc_cv                       +4.1652         +4.0443             0             0             0             0
BM_sinsp_utf8_sanitize_slow_path_sparse_invalid_long_alloc_mean                    +0.0213         +0.0212           235           240           235           240
BM_sinsp_utf8_sanitize_slow_path_sparse_invalid_long_alloc_median                  +0.0207         +0.0208           234           239           234           238
BM_sinsp_utf8_sanitize_slow_path_sparse_invalid_long_alloc_stddev                  +0.9221         +0.9220             4             7             4             7
BM_sinsp_utf8_sanitize_slow_path_sparse_invalid_long_alloc_cv                      +0.8820         +0.8821             0             0             0             0
BM_sinsp_utf8_sanitize_slow_path_sparse_invalid_long_noalloc_mean                  +0.0266         +0.0268           143           147           143           147
BM_sinsp_utf8_sanitize_slow_path_sparse_invalid_long_noalloc_median                +0.0451         +0.0453           142           148           142           148
BM_sinsp_utf8_sanitize_slow_path_sparse_invalid_long_noalloc_stddev                +0.0190         +0.0273             2             2             2             2
BM_sinsp_utf8_sanitize_slow_path_sparse_invalid_long_noalloc_cv                    -0.0074         +0.0005             0             0             0             0
BM_sinsp_utf8_sanitize_slow_path_all_invalid_long_alloc_mean                       +0.0055         +0.0056         11817         11882         11812         11878
BM_sinsp_utf8_sanitize_slow_path_all_invalid_long_alloc_median                     +0.0137         +0.0137         11749         11909         11744         11905
BM_sinsp_utf8_sanitize_slow_path_all_invalid_long_alloc_stddev                     -0.5574         -0.5565           187            83           186            83
BM_sinsp_utf8_sanitize_slow_path_all_invalid_long_alloc_cv                         -0.5598         -0.5589             0             0             0             0
BM_sinsp_utf8_sanitize_slow_path_all_invalid_long_noalloc_mean                     +0.0343         +0.0344         11311         11699         11307         11695
BM_sinsp_utf8_sanitize_slow_path_all_invalid_long_noalloc_median                   +0.0478         +0.0477         11178         11712         11174         11706
BM_sinsp_utf8_sanitize_slow_path_all_invalid_long_noalloc_stddev                   -0.9662         -0.9661          1056            36          1056            36
BM_sinsp_utf8_sanitize_slow_path_all_invalid_long_noalloc_cv                       -0.9674         -0.9672             0             0             0             0

@terror96

Copy link
Copy Markdown
Contributor

Ping @irozzo-1A ... do I remember correctly that you did makefile changes before, and could have a better view on this? looks good to me, though.

@irozzo-1A irozzo-1A left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @mvanhorn, thanks for your contribution.
Just a potential issue and a nit.

Comment thread cmake/modules/zlib.cmake Outdated
-DCMAKE_INSTALL_LIBDIR=lib
CMAKE_CACHE_ARGS ${ZLIB_EXTERNAL_PROJECT_CACHE_ARGS}
# Build only the target we need so the unused library type is never compiled.
BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --config $<CONFIG> --target

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--config $<CONFIG> looks risky here because this branch also supports single-config generators. If $<CONFIG> expands to an empty value, the build command may still be invoked with a bare --config, which can break the external project build.

Could we make --config conditional on GENERATOR_IS_MULTI_CONFIG, similar to how ZLIB_BUILD_CONFIG_SUBDIR is handled above?

Comment thread cmake/modules/zlib.cmake Outdated
Comment on lines +34 to +48
set(ZLIB_HEADERS "")
list(
APPEND
ZLIB_HEADERS
"${ZLIB_INCLUDE}/crc32.h"
"${ZLIB_INCLUDE}/deflate.h"
"${ZLIB_INCLUDE}/gzguts.h"
"${ZLIB_INCLUDE}/inffast.h"
"${ZLIB_INCLUDE}/inffixed.h"
"${ZLIB_INCLUDE}/inflate.h"
"${ZLIB_INCLUDE}/inftrees.h"
"${ZLIB_INCLUDE}/trees.h"
"${ZLIB_SOURCE_DIR}/crc32.h"
"${ZLIB_SOURCE_DIR}/deflate.h"
"${ZLIB_SOURCE_DIR}/gzguts.h"
"${ZLIB_SOURCE_DIR}/inffast.h"
"${ZLIB_SOURCE_DIR}/inffixed.h"
"${ZLIB_SOURCE_DIR}/inflate.h"
"${ZLIB_SOURCE_DIR}/inftrees.h"
"${ZLIB_SOURCE_DIR}/trees.h"
"${ZLIB_INCLUDE}/zconf.h"
"${ZLIB_INCLUDE}/zlib.h"
"${ZLIB_INCLUDE}/zutil.h"
"${ZLIB_SOURCE_DIR}/zlib.h"
"${ZLIB_SOURCE_DIR}/zutil.h"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this seems to change the semantic of ZLIB_HEADERS, it does not seem to be a problem,
Would it make sense to rename it to something like _zlib_headers to avoid confusion ? In such case we should apply the same convention to other internal variables for consistency e.g.

  • ZLIB_SOURCE_DIR
  • ZLIB_BUILD_DIR
  • ZLIB_BUILD_TARGET
  • ZLIB_LIBRARY_INSTALL_TYPE
  • ZLIB_BUILD_CONFIG_SUBDIR
  • ZLIB_BUILT_LIB
  • ZLIB_INSTALL_SCRIPT
  • ZLIB_EXTERNAL_PROJECT_CACHE_ARGS
  • ZLIB_IS_MULTI_CONFIG

I don't consider this as a blocker for this PR though.

@mvanhorn

Copy link
Copy Markdown
Author

Addressed both points in ca60fa1: the external zlib build now passes --config $<CONFIG> only when GENERATOR_IS_MULTI_CONFIG is set (single-config generators get no bare --config), and the internal helper variables are renamed to the _zlib_* convention as suggested. Verified the single/multi-config build graph generation and ran cmake-format 0.6.13 with the repo config.

Comment thread cmake/modules/zlib.cmake
set(ZLIB_SRC "${PROJECT_BINARY_DIR}/zlib-prefix/src/zlib")
set(ZLIB_INCLUDE "${ZLIB_SRC}")
set(ZLIB_HEADERS "")
set(ZLIB_SRC "${PROJECT_BINARY_DIR}/zlib-prefix/src")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aligning ZLIB_SRC with the jsoncpp convention SGTM. However, ZLIB_SRC is not private to this module, so re-pointing it has two side effects.

First, cmake/modules/libbpf.cmake:71 passes -L${ZLIB_SRC} to libbpf's make. That directory used to hold libz.a directly, now the library lives in ${ZLIB_SRC}/lib, so the flag points at a dir with no zlib in it. It is inert atm, since EXTRA_LDFLAGS only feeds the shared-object link rule that libbpf skips under BUILD_STATIC_ONLY=y. Still, may you fix it to -L${ZLIB_SRC}/lib here, before it bites us later? 🙏

Second, Falco reuses this very module and passes --with-zlib=${ZLIB_SRC} in its own cmake/modules/curl.cmake. curl's configure expands that to -I$OPT_ZLIB/include -L$OPT_ZLIB/lib 👉 https://github.com/curl/curl/blob/curl-8_7_1/configure.ac#L1320-L1322

Pre-PR neither of those dirs existed (the old build was in-source with INSTALL_COMMAND ""), so Falco's bundled curl was silently falling back to the system zlib. With this PR both exist, so curl will finally pick the bundled one. That is a fix rather than a regression, but it is still a behavior change downstream, so I'd prefer to see a Falco build green before we merge this.

Comment thread cmake/modules/zlib.cmake
ExternalProject_Add(
zlib
PREFIX "${PROJECT_BINARY_DIR}/zlib-prefix"
SOURCE_DIR "${_zlib_source_dir}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SOURCE_DIR "${_zlib_source_dir}"
SOURCE_DIR "${_zlib_source_dir}"
BINARY_DIR "${_zlib_build_dir}"

Nit. _zlib_build_dir (line 69) hardcodes ExternalProject's default binary dir, and the install script turns any mismatch into a FATAL_ERROR. Declaring BINARY_DIR explicitly drops that implicit coupling, and it is what re2.cmake already does.

Also, the file(MAKE_DIRECTORY ...) at line 83 can go, since file(WRITE ...) creates the parent dirs on its own.

Comment thread cmake/modules/zlib.cmake Outdated
Comment on lines +122 to +123
-DCMAKE_INSTALL_PREFIX=${ZLIB_SRC}
-DCMAKE_INSTALL_LIBDIR=lib

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-DCMAKE_INSTALL_PREFIX=${ZLIB_SRC}
-DCMAKE_INSTALL_LIBDIR=lib
-DCMAKE_INSTALL_PREFIX=${ZLIB_SRC}

Nit. zlib 1.3.1 does not use GNUInstallDirs, it hardcodes INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib", so CMAKE_INSTALL_LIBDIR is ignored and every configure of the sub-build warns about it:

CMake Warning (unused-cli):
  Manually-specified variables were not used by the project:

    CMAKE_INSTALL_LIBDIR

The layout is already lib/, so dropping it changes nothing. Same for line 172 in the Windows branch.

@mvanhorn

mvanhorn commented Aug 2, 2026

Copy link
Copy Markdown
Author

All three applied in f0ed401.

BINARY_DIR is now declared explicitly, so the implicit coupling to _zlib_build_dir is gone, and the file(MAKE_DIRECTORY) above it is removed — I checked with a fresh configure from an empty build dir that file(WRITE ...) does create zlib-prefix/src itself.

Dropped CMAKE_INSTALL_LIBDIR from both the non-Windows and Windows argument lists, keeping -DCMAKE_INSTALL_PREFIX=${ZLIB_SRC}. The installed layout stays ${ZLIB_SRC}/lib either way, since that is what zlib 1.3.1 derives from the prefix.

libbpf.cmake now passes -L${ZLIB_SRC}/lib. I grepped ZLIB_SRC across the tree for other consumers of the old flat layout and found none — the remaining link sites go through ZLIB_LIB, which already points under ${ZLIB_SRC}/lib.

On your downstream point: I can't produce a green Falco build from here. Agreed it should gate the merge given curl will now pick up the bundled zlib where it previously fell back to the system one. Happy to open the Falco-side PR to test it if that's useful, or leave it to you.

@poiana poiana added the size/L label Aug 2, 2026
mvanhorn and others added 3 commits August 2, 2026 08:56
…alcosecurity#2584)

zlib v1.3.1 ships a first-class CMakeLists.txt, so build the bundled
dependency on non-Windows with its own CMake build (via CMAKE_ARGS and the
shared falcosecurity_external_project_cache_args toolchain mechanism) instead
of invoking the hand-written ./configure script through CONFIGURE_COMMAND.

Only the library type actually consumed is built (zlibstatic for static,
zlib for shared), preserving the previous './configure --static' behavior and
keeping static-only / cross toolchains working. The install step is
config-aware (handles multi-config generators) and preserves the shared
library SOVERSION symlink chain. ZLIB_INCLUDE / ZLIB_LIB / ZLIB_HEADERS are
unchanged for downstream consumers.

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
(cherry picked from commit 3cc133a)
Signed-off-by: Matt Van Horn <mvanhorn@gmail.com>
…internal vars

Per review from @irozzo-1A: pass --config $<CONFIG> to the external zlib build only on multi-config generators (a single-config generator would expand to a bare --config and break the build), and rename the internal helper variables to the _zlib_* convention to avoid clashing with the public ZLIB_* cache variables.

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
(cherry picked from commit dc1e7d9)
Signed-off-by: Matt Van Horn <mvanhorn@gmail.com>
…, fix libbpf -L path

Per review:
- Declare BINARY_DIR explicitly so ExternalProject's default is no longer
  implicitly coupled to _zlib_build_dir, and drop the now-redundant
  file(MAKE_DIRECTORY): file(WRITE ...) creates its parent dirs.
- zlib 1.3.1 hardcodes INSTALL_LIB_DIR from CMAKE_INSTALL_PREFIX and ignores
  GNUInstallDirs, so CMAKE_INSTALL_LIBDIR was unused and warned on every
  sub-build configure.
- libbpf's EXTRA_LDFLAGS pointed at ${ZLIB_SRC}, which no longer holds libz.a
  now that the build installs under ${ZLIB_SRC}/lib.

Signed-off-by: Matt Van Horn <mvanhorn@gmail.com>
(cherry picked from commit deaaba6)
Signed-off-by: Matt Van Horn <mvanhorn@gmail.com>
Comment thread cmake/modules/libbpf.cmake Outdated
Comment on lines 71 to 72
"LDFLAGS=-Wl,-Bstatic" "EXTRA_LDFLAGS=-L${LIBELF_SRC}/libelf/libelf -L${ZLIB_SRC}/lib" -C
${LIBBPF_SRC}/libbpf/src install install_uapi_headers

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"LDFLAGS=-Wl,-Bstatic" "EXTRA_LDFLAGS=-L${LIBELF_SRC}/libelf/libelf -L${ZLIB_SRC}/lib" -C
${LIBBPF_SRC}/libbpf/src install install_uapi_headers
"LDFLAGS=-Wl,-Bstatic" "EXTRA_LDFLAGS=-L${LIBELF_SRC}/libelf/libelf -L${ZLIB_SRC}/lib"
-C ${LIBBPF_SRC}/libbpf/src install install_uapi_headers

This is what format code is failing on. Adding /lib took the line to 101 columns, one over the line_width: 100 in .cmake-format.json, so cmake-format wants -C wrapped down.

May you run cmake-format -i cmake/modules/libbpf.cmake (0.6.13, with the repo config) just to be safe? The patch is downloadable from the failing job too 👉 https://github.com/falcosecurity/libs/actions/runs/30755533927

Thanks 🙏

Adding the /lib suffix pushed the EXTRA_LDFLAGS line to 101 columns, one
over line_width in .cmake-format.json, so cmake-format 0.6.13 wraps -C
down. Both file(INSTALL DESTINATION ...) calls create their own
destination, so the MAKE_DIRECTORY ahead of them is redundant.

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
@mvanhorn

mvanhorn commented Aug 7, 2026

Copy link
Copy Markdown
Author

Thanks for the thorough pass, and for pinpointing the format failure.

  • libbpf.cmake: ran cmake-format -i with 0.6.13 and the repo config. Output matches your suggestion exactly, and --check is clean on both files now.
  • Dropped the file(MAKE_DIRECTORY ...). You're right that it is redundant, though for a slightly different reason than stated: both directories are file(INSTALL DESTINATION ...) targets further down, and file(INSTALL) creates its destination.
  • The --config $<CONFIG> gating, the _zlib_* renames, BINARY_DIR, and dropping CMAKE_INSTALL_LIBDIR all landed in c669940 and f5ddc15, which is why those threads show as outdated.

On the Falco side effect: agreed that curl picking up the bundled zlib rather than silently falling back to the system one is the point, but it is still a downstream behaviour change. I cannot run a Falco build myself, so I will leave that gate to you.

@poiana

poiana commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: leogr, mvanhorn

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana

poiana commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: 9856094e006e98fb9f84be356e9ec262d703f003

Comment thread cmake/modules/zlib.cmake
# Build only the target we need so the unused library type is never compiled.
BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> ${_zlib_build_config_args}
--target ${_zlib_build_target}
# zlib's own install() installs both targets together, which would fail for the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zlib 1.3.2 added ZLIB_BUILD_SHARED and ZLIB_BUILD_STATIC CMake options, so it might make sense to update to that version instead of creating a custom installation script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

(cmake) zlib bundled dep should use zlib cmake directly instead of CONFIGURE_COMMAND

6 participants