From 7498e8d8c0eb313fffa1d86724396cbd308a7580 Mon Sep 17 00:00:00 2001 From: Victor Moene Date: Tue, 2 Sep 2025 12:19:31 +0200 Subject: [PATCH 1/8] macos_unit_tests.yml: specified the deployment target to be macOS 15.4 The function 'strchrnul' has been marked as being introduced in macOS 15.4, although it seems to have been working for as long as we have been testing on macOS. Since warnings are treated as errors, the build will fail. Hence, the simplest way to silence the warning is, it to specify the deployment target to be a minimum of macOS 15.4. ``` logging.c:651:28: error: 'strchrnul' is only available on macOS 15.4 or newer [-Werror,-Wunguarded-availability-new] 651 | char *next_token = strchrnul(token, ','); CC queue.lo | ^~~~~~~~~ /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_string.h:198:9: note: 'strchrnul' has been marked as being introduced in macOS 15.4 here, but the deployment target is macOS 15.0.0 198 | strchrnul(const char *__s, int __c); CC rb-tree.lo | ^ logging.c:651:28: note: enclose 'strchrnul' in a __builtin_available check to silence this warning 651 | char *next_token = strchrnul(token, ','); | ^~~~~~~~~ 1 error generated. ``` It has been done similarly here: https://github.com/NorthernTechHQ/libntech/pull/255 Signed-off-by: Victor Moene (cherry picked from commit f1c9a913893bf7e5b72c1223ccaa94e2b928e7fc) (cherry picked from commit 6ae1a56d4313ea20d968098a74e66331a2468802) --- .github/workflows/macos_unit_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/macos_unit_tests.yml b/.github/workflows/macos_unit_tests.yml index 913f21b405..86de8343cb 100644 --- a/.github/workflows/macos_unit_tests.yml +++ b/.github/workflows/macos_unit_tests.yml @@ -23,6 +23,6 @@ jobs: PATH="/opt/homebrew/opt/libtool/libexec/gnubin:$PATH" ./autogen.sh --enable-debug - name: Compile and link - run: make -j8 CFLAGS="-Werror -Wall" + run: MACOSX_DEPLOYMENT_TARGET=15.4 make -j8 CFLAGS="-Werror -Wall" - name: Run unit tests run: make -C tests/unit check From dd4037e10173ecc6acecaa69c151ff21b4e2dee8 Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Fri, 28 Mar 2025 14:00:50 +0100 Subject: [PATCH 2/8] GH Actions: Installed libyaml on macOS to fix build errors Signed-off-by: Ole Herman Schumacher Elgesem (cherry picked from commit 1486c243ca6811468d0519c0011fcf11ba48040c) Conflicts: .github/workflows/macos_unit_tests.yml Use of librsync (https://github.com/cfengine/core/pull/5629) was not cherry picked to 3.24.x (cherry picked from commit d91eebd4ac5a9bb2c00b31c1b3f53bcc820fea29) Conflicts: .github/workflows/macos_unit_tests.yml Had to adjust as 3.21 uses pcre not pcre2 as the commit from newer branch had. --- .github/workflows/macos_unit_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/macos_unit_tests.yml b/.github/workflows/macos_unit_tests.yml index 86de8343cb..13f7b40599 100644 --- a/.github/workflows/macos_unit_tests.yml +++ b/.github/workflows/macos_unit_tests.yml @@ -11,7 +11,7 @@ jobs: with: submodules: recursive - name: Install dependencies - run: brew install lmdb automake openssl pcre autoconf libtool + run: brew install lmdb automake openssl pcre autoconf libtool libyaml - name: Check tools run: command -v libtool && command -v automake && command -v autoconf - name: Check tools versions From a2b60e1f86e8464dcd2226ca6fe6a0287c771bc6 Mon Sep 17 00:00:00 2001 From: Bastian Triller Date: Wed, 26 Mar 2025 18:15:21 +0100 Subject: [PATCH 3/8] CFE-4385: Fix build on macOS Check for Homebrew if we're on Darwin and use brew's --prefix. Ticket: CFE-4385 (cherry picked from commit 7e88d4bd99fcddd66fdbee1a9f2dc65d15c411c0) Conflicts: .github/workflows/macos_unit_tests.yml configure.ac using librsync (https://github.com/cfengine/core/pull/5629) was not cherry-picked to 3.24.x so adjustments were needed. (cherry picked from commit faf08d9aabb965a151ac95721495b953f476514c) Conflicts: .github/workflows/macos_unit_tests.yml configure.ac Needed some finesse as rsync and pcre2 were in commit and not used in 3.21. --- .github/workflows/macos_unit_tests.yml | 3 --- configure.ac | 37 ++++++++++++++++++++------ libcfnet/Makefile.am | 1 + tests/acceptance/Makefile.am | 6 ++--- 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/.github/workflows/macos_unit_tests.yml b/.github/workflows/macos_unit_tests.yml index 13f7b40599..8abf57cb72 100644 --- a/.github/workflows/macos_unit_tests.yml +++ b/.github/workflows/macos_unit_tests.yml @@ -18,9 +18,6 @@ jobs: run: libtool -V && automake --version && autoconf --version - name: Run autotools / configure run: > - LDFLAGS="-L`brew --prefix lmdb`/lib -L`brew --prefix openssl`/lib -L`brew --prefix pcre`/lib" - CPPFLAGS="-I`brew --prefix lmdb`/include -I`brew --prefix openssl`/include -I`brew --prefix pcre`/include" - PATH="/opt/homebrew/opt/libtool/libexec/gnubin:$PATH" ./autogen.sh --enable-debug - name: Compile and link run: MACOSX_DEPLOYMENT_TARGET=15.4 make -j8 CFLAGS="-Werror -Wall" diff --git a/configure.ac b/configure.ac index 932e22f18b..5a782d8d67 100644 --- a/configure.ac +++ b/configure.ac @@ -119,6 +119,17 @@ AC_PROG_CC AC_PROG_MKDIR_P AC_EXEEXT +AS_CASE([${target_os}], +[darwin*], [ + AC_CHECK_PROG([BREW], [brew], [brew]) + AC_MSG_CHECKING([for OS X Homebrew]) + AS_IF([test "x$BREW" = "xbrew"], [ + have_brew=yes + AC_MSG_RESULT([OS X Homebrew detected]) + ], + [have_brew=]) +]) + dnl GCC specific flags m4_include([m4/cf3_gcc_flags.m4]) @@ -369,6 +380,8 @@ then fi fi + AS_IF([test "x$have_brew" = "xyes" && test -d $(brew --prefix mysql)/], [with_mysql=$(brew --prefix mysql)]) + CF3_WITH_LIBRARY(mysql, [AC_CHECK_LIB(mysqlclient, mysql_real_connect, [], @@ -432,6 +445,8 @@ AC_ARG_WITH([lmdb], AS_IF([test $WITH_TOKYO -eq 0 && test $WITH_QDBM -eq 0 && (! test -n "$with_lmdb" || test "x$with_lmdb" != "xno")], [WITH_LMDB=1], [WITH_LMDB=0]) if test $WITH_LMDB = 1; then + AS_IF([test "x$have_brew" = "xyes" && test -d $(brew --prefix lmdb)/], [with_lmdb=$(brew --prefix lmdb)]) + CF3_WITH_LIBRARY(lmdb, [ AC_CHECK_LIB(lmdb, mdb_dbi_open, [], [AC_MSG_ERROR(Cannot find Lightning MDB)]) AC_CHECK_HEADERS(lmdb.h, [], [AC_MSG_ERROR(Cannot find Lightning MDB)]) @@ -455,13 +470,7 @@ if test x"$with_openssl" = xno ; then AC_MSG_ERROR([This release of CFEngine requires OpenSSL >= 0.9.7]) fi -if test -d /usr/local/Cellar/ && \ - test -d /usr/local/opt/openssl/ && \ - test "x$with_openssl" = "xyes" ; then - with_openssl=$(brew --prefix openssl) - echo "OS X Homebrew detected" - echo "Defaulting to: --with-openssl=$with_openssl" -fi +AS_IF([test "x$have_brew" = "xyes" && test -d $(brew --prefix openssl)/], [with_openssl=$(brew --prefix openssl)]) CF3_WITH_LIBRARY(openssl, [ AC_CHECK_LIB(crypto, RSA_generate_key_ex, [], []) @@ -523,6 +532,8 @@ AC_ARG_WITH([libvirt], if test "x$with_libvirt" != xno then + AS_IF([test "x$have_brew" = "xyes" && test -d $(brew --prefix libvirt)/], [with_libvirt=$(brew --prefix libvirt)]) + CF3_WITH_LIBRARY(libvirt, [ AC_CHECK_LIB(virt, virConnectOpen, [], [if test "x$with_libvirt" != xcheck; then AC_MSG_ERROR(Cannot find libvirt library); fi]) AC_CHECK_HEADERS(libvirt/libvirt.h, [], [if test "x$with_libvirt" != xcheck; then AC_MSG_ERROR(Cannot find libvirt library headers); fi]) @@ -562,6 +573,8 @@ AC_ARG_WITH([libcurl], if test "x$with_libcurl" != xno then + AS_IF([test "x$have_brew" = "xyes" && test -d $(brew --prefix curl)/], [with_libcurl=$(brew --prefix curl)]) + CF3_WITH_LIBRARY(libcurl, [ AC_CHECK_LIB(curl, curl_global_init, [], @@ -587,6 +600,8 @@ AC_ARG_WITH([libyaml], if test "x$with_libyaml" != xno then + AS_IF([test "x$have_brew" = "xyes" && test -d $(brew --prefix libyaml)/], [with_libyaml=$(brew --prefix libyaml)]) + CF3_WITH_LIBRARY(libyaml, [ AC_CHECK_LIB(yaml, yaml_parser_initialize, [], @@ -609,7 +624,13 @@ AC_ARG_WITH([libxml2], have_libxml2="no" if test "x$with_libxml2" != "xno"; then - if test -n "$PKG_CONFIG"; then + if test "x$have_brew" = "xyes" && \ + test -d $(brew --prefix libxml2)/; then + with_libxml2=$(brew --prefix libxml2) + echo "OS X Homebrew detected" + echo "Defaulting to: --with-libxml2=$with_libxml2" + have_libxml2="yes" + elif test -n "$PKG_CONFIG"; then AC_MSG_CHECKING([for libxml2 via pkg-config]) if `$PKG_CONFIG --exists libxml-2.0`; then LIBXML2_CFLAGS=`$PKG_CONFIG --cflags libxml-2.0` diff --git a/libcfnet/Makefile.am b/libcfnet/Makefile.am index e0c1a65b9f..4bc182d1bb 100644 --- a/libcfnet/Makefile.am +++ b/libcfnet/Makefile.am @@ -27,6 +27,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/libntech/libutils \ -I$(top_srcdir)/libpromises \ $(PCRE_CPPFLAGS) \ $(SYSTEMD_SOCKET_CPPFLAGS) \ + $(LIBRSYNC_CPPFLAGS) \ $(OPENSSL_CPPFLAGS) libcfnet_la_SOURCES = \ diff --git a/tests/acceptance/Makefile.am b/tests/acceptance/Makefile.am index 5a00fc76a9..4fe4e8a097 100644 --- a/tests/acceptance/Makefile.am +++ b/tests/acceptance/Makefile.am @@ -63,9 +63,9 @@ xml_c14nize_CPPFLAGS = \ -I$(srcdir)/../../libntech/libutils \ $(LIBXML2_CPPFLAGS) -xml_c14nize_CFLAGS = $(LIBXML2_CFLAGS) -xml_c14nize_LDFLAGS = $(LIBXML2_LDFLAGS) -xml_c14nize_LDADD = ../../libntech/libutils/libutils.la $(LIBXML2_LIBS) +xml_c14nize_CFLAGS = $(LIBXML2_CFLAGS) $(LMDB_CFLAGS) $(LIBRSYNC_CFLAGS) +xml_c14nize_LDFLAGS = $(LIBXML2_LDFLAGS) $(LMDB_LDFLAGS) $(LIBRSYNC_LDFLAGS) +xml_c14nize_LDADD = ../../libntech/libutils/libutils.la $(LIBXML2_LIBS) $(LMDB_LIBS) $(LIBRSYNC_LIBS) endif TESTS = From 01b4f696cdbcafd9baeec6da3030a9ff7f43e4cb Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Tue, 23 Sep 2025 10:38:03 -0500 Subject: [PATCH 4/8] Adjusted curl_easy_setopt() calls to use long argument The argument checking has been present for a while. Interestingly 3 days ago there was a commit to silence many of these warnings: https://github.com/curl/curl/commit/92f215fea1aa8bd5b1709d38f42aab77ab3fc662 Ticket: CFE-3429 Changelog: none (cherry picked from commit c95296962f57223e500dbfabad23903bf3441b17) --- libpromises/evalfunction.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libpromises/evalfunction.c b/libpromises/evalfunction.c index 49aceeed68..e747b7ab07 100644 --- a/libpromises/evalfunction.c +++ b/libpromises/evalfunction.c @@ -2704,9 +2704,9 @@ static FnCallResult FnCallUrlGet(ARG_UNUSED EvalContext *ctx, Buffer *content = BufferNew(); Buffer *headers = BufferNew(); curl_easy_setopt(curl, CURLOPT_URL, url); - curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); // do not use signals + curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L); // do not use signals curl_easy_setopt(curl, CURLOPT_TIMEOUT, 3L); // set default timeout - curl_easy_setopt(curl, CURLOPT_VERBOSE, 0); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L); curl_easy_setopt(curl, CURLOPT_PROTOCOLS, From 0e9bac26a59c90b1ad49b650186325cc5a84b0e7 Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Tue, 23 Sep 2025 11:47:51 -0500 Subject: [PATCH 5/8] squash, remove rsync refs --- libcfnet/Makefile.am | 1 - 1 file changed, 1 deletion(-) diff --git a/libcfnet/Makefile.am b/libcfnet/Makefile.am index 4bc182d1bb..e0c1a65b9f 100644 --- a/libcfnet/Makefile.am +++ b/libcfnet/Makefile.am @@ -27,7 +27,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/libntech/libutils \ -I$(top_srcdir)/libpromises \ $(PCRE_CPPFLAGS) \ $(SYSTEMD_SOCKET_CPPFLAGS) \ - $(LIBRSYNC_CPPFLAGS) \ $(OPENSSL_CPPFLAGS) libcfnet_la_SOURCES = \ From d8bc9daa92fc695d623434a42af42d0cdc249961 Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Tue, 23 Sep 2025 11:49:36 -0500 Subject: [PATCH 6/8] squash, remove rsync refs --- tests/acceptance/Makefile.am | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/acceptance/Makefile.am b/tests/acceptance/Makefile.am index 4fe4e8a097..5a00fc76a9 100644 --- a/tests/acceptance/Makefile.am +++ b/tests/acceptance/Makefile.am @@ -63,9 +63,9 @@ xml_c14nize_CPPFLAGS = \ -I$(srcdir)/../../libntech/libutils \ $(LIBXML2_CPPFLAGS) -xml_c14nize_CFLAGS = $(LIBXML2_CFLAGS) $(LMDB_CFLAGS) $(LIBRSYNC_CFLAGS) -xml_c14nize_LDFLAGS = $(LIBXML2_LDFLAGS) $(LMDB_LDFLAGS) $(LIBRSYNC_LDFLAGS) -xml_c14nize_LDADD = ../../libntech/libutils/libutils.la $(LIBXML2_LIBS) $(LMDB_LIBS) $(LIBRSYNC_LIBS) +xml_c14nize_CFLAGS = $(LIBXML2_CFLAGS) +xml_c14nize_LDFLAGS = $(LIBXML2_LDFLAGS) +xml_c14nize_LDADD = ../../libntech/libutils/libutils.la $(LIBXML2_LIBS) endif TESTS = From dba72811e69bc5c2211aa037684d977373bf1e6e Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Tue, 23 Sep 2025 11:51:15 -0500 Subject: [PATCH 7/8] squashme, fixup pcre vs pcre2 --- configure.ac | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure.ac b/configure.ac index 5a782d8d67..0bef65a0ad 100644 --- a/configure.ac +++ b/configure.ac @@ -516,6 +516,11 @@ if test "x$with_pcre" = "xno"; then AC_MSG_ERROR([PCRE is required]) fi +AS_IF( + [(test "x$with_pcre" = xyes || test "x$with_pcre" = xcheck) \ + && test "x$have_brew" = "xyes" && test -d $(brew --prefix pcre)/], + [with_pcre=$(brew --prefix pcre)]) + CF3_WITH_LIBRARY(pcre, [ AC_CHECK_LIB(pcre, pcre_exec, [], [AC_MSG_ERROR(Cannot find PCRE)]) AC_CHECK_HEADERS([pcre.h], [], From c52252e733a38f881ce3a32cf5a77568903c142b Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Tue, 23 Sep 2025 12:00:30 -0500 Subject: [PATCH 8/8] Bump libntech to master --- libntech | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libntech b/libntech index 1d9ceb62cf..e2cfe202d4 160000 --- a/libntech +++ b/libntech @@ -1 +1 @@ -Subproject commit 1d9ceb62cf4cf64875199bd1454c74b8f124001f +Subproject commit e2cfe202d467ed53a4b297cba76eec87add83d9c