mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-08-08 08:30:47 -09:00
Version 2.1.x has introduced a cmake-based build, and upstream strongly
recomends using it over the legacy Makefiles, which will ultimately be
retired.
So we do the switch, which cause quite some noise in the .mk file, but
at the same time allows for a bit of cleanup in the build process, as we
can now use the cmake-package infra.
Mosquitto now wants to peek into the malloc() internals for memory
tracking, and that only works on systems with an MMU (uClibc-ng does not
expose it for noMMU builds, as it's part of its malloc-standard
implementation).
Static-only builds are broken, even when only building the library. This
seems beyond a simple repair, so just require shared libs now (since
we're requiring an MMU as well, requiring shared libs is not too much of
an additional burden).
cJSON is now a required dependency, used in common parts of the code
(not just for the plugins).
There are a few options that we forcibly disable; they'll get addressed
in followup patches.
There are still a few build failures that are difficult to account for
(except):
$ printf 'BR2_PACKAGE_MOSQUITTO=y\n' >mosq.cfg
$ ./utils/docker-run ./utils/test-pkg -d $(pwd)/run-tests -c mosq.cfg -p mosquitto
br-arm-full-static [5/6]: FAILED
=> old uClibc-ng, would need __GNU_SOURCE (with dunder) to define
getrandom(); no longer needed since uClibc-ng 1.0.50; would need
openssl otherwise
bootlin-aarch64-glibc-old [6/6]: FAILED
=> really old glibc, missing getrandom(); would need openssl
Drop our existing patches, they've either been applied upstream, or are
no longer needed. Add new patches to fix various build issues
(submission upstream pending the signature of the CLA..,).
Thanks a lot to Titouan for providing his initial work on the update!
Some of his findings ended up in this patch. 👍
Note: by lack of a trusted path back to the PGP key that signed the
archive, the comment was dropped, as checking a signature without a
trust-chain does not make much sense...
Co-developped-by: Titouan Christophe <titouan.christophe@mind.be>
Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
Cc: Peter Korsgaard <peter@korsgaard.com>
Cc: Titouan Christophe <titouan.christophe@mind.be>
[Romain: remove "mosquitto broker" comment for static builds]
Signed-off-by: Romain Naour <romain.naour@smile.fr>
91 lines
2.8 KiB
Diff
91 lines
2.8 KiB
Diff
From a1d0c56984f8a65d5ffb7fbde7f200b36b5ddae5 Mon Sep 17 00:00:00 2001
|
|
From: "Yann E. MORIN" <yann.morin@orange.com>
|
|
Date: Tue, 10 Feb 2026 12:01:32 +0100
|
|
Subject: [PATCH] libcommon: check for getrandom()
|
|
|
|
Not all C libraries are glibc, or impersonating it; for example, musl
|
|
does not pretend to be any version of glibc. Thus, building on musl
|
|
fails when openssl is disabled, because no random-providing function is
|
|
detected, although musl does provide getrandom().
|
|
|
|
uClibc-ng on the other hand, can impersonate glibc, but availability of
|
|
getrandom() is not guatranteed there: getrandom() can be compiled out of
|
|
uClinbc-ng, or uClibc-ng can be too old to have it.
|
|
|
|
Add a configure-time check that getrandom() is available, as a fallback
|
|
when TLS is not enabled (and thus openssl is not used), and when not on
|
|
Win32 (where getting random numbers is always possible, at least from a
|
|
build perspective).
|
|
|
|
However, building with the plain Makefiles should keep working, so
|
|
slightly rework the defines checks in the code to account for the fact
|
|
that HAVE_GETRANDOM may already be defined at configure time.
|
|
|
|
Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
|
|
Upstream: https://github.com/eclipse-mosquitto/mosquitto/commit/a487cd4f8f56a9352eec1b6e05592a73794b162b)
|
|
---
|
|
libcommon/CMakeLists.txt | 8 ++++++++
|
|
libcommon/random_common.c | 14 +++++++-------
|
|
2 files changed, 15 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/libcommon/CMakeLists.txt b/libcommon/CMakeLists.txt
|
|
index 8f3474a0..7b9118bc 100644
|
|
--- a/libcommon/CMakeLists.txt
|
|
+++ b/libcommon/CMakeLists.txt
|
|
@@ -57,6 +57,14 @@ if (WITH_TLS)
|
|
PUBLIC
|
|
OpenSSL::SSL
|
|
)
|
|
+elseif(NOT WIN32)
|
|
+ include(CheckSymbolExists)
|
|
+ check_symbol_exists(getrandom "sys/random.h" GETRANDOM_FOUND)
|
|
+ if(GETRANDOM_FOUND)
|
|
+ add_definitions("-DHAVE_GETRANDOM")
|
|
+ else()
|
|
+ message(FATAL_ERROR "C library does not provide getrandom(); enable WITH_TLS instead")
|
|
+ endif()
|
|
endif()
|
|
|
|
if(INC_MEMTRACK)
|
|
diff --git a/libcommon/random_common.c b/libcommon/random_common.c
|
|
index 555bd801..e2c8d23a 100644
|
|
--- a/libcommon/random_common.c
|
|
+++ b/libcommon/random_common.c
|
|
@@ -26,18 +26,18 @@ Contributors:
|
|
# include <lmcons.h>
|
|
#endif
|
|
|
|
-#if !defined(WITH_TLS) && defined(__linux__) && defined(__GLIBC__)
|
|
+#ifdef WITH_TLS
|
|
+# include <openssl/bn.h>
|
|
+# include <openssl/rand.h>
|
|
+#elif defined(HAVE_GETRANDOM) /* From CMakeLists.txt */
|
|
+# include <sys/random.h>
|
|
+#elif defined(__linux__) && defined(__GLIBC__) /* For legacy Makefiles */
|
|
# if __GLIBC_PREREQ(2, 25)
|
|
# include <sys/random.h>
|
|
# define HAVE_GETRANDOM 1
|
|
# endif
|
|
#endif
|
|
|
|
-#ifdef WITH_TLS
|
|
-# include <openssl/bn.h>
|
|
-# include <openssl/rand.h>
|
|
-#endif
|
|
-
|
|
#include "mosquitto.h"
|
|
|
|
|
|
@@ -65,7 +65,7 @@ int mosquitto_getrandom(void *bytes, int count)
|
|
}
|
|
|
|
CryptReleaseContext(provider, 0);
|
|
-#else
|
|
+#else /* For legacy Makefiles */
|
|
# error "No suitable random function found."
|
|
#endif
|
|
return rc;
|
|
--
|
|
2.34.1
|
|
|