* [Buildroot] [PATCH] package/libmicrohttpd: fix build without thread support
@ 2026-09-26 13:36 Yegor Yefremov via buildroot
2026-09-28 8:55 ` Thomas Petazzoni via buildroot
0 siblings, 1 reply; 5+ messages in thread
From: Yegor Yefremov via buildroot @ 2026-09-26 13:36 UTC (permalink / raw)
To: buildroot; +Cc: Bernd Kuhls, Will Newton
Add an upstream-submitted patch that moves connection_get_wait() out
of the threads-only region, as MHD_get_timeout64() calls it
unconditionally. Without it the build fails with
--with-threads=none:
daemon.c:4524:18: error: implicit declaration of function 'connection_get_wait' [-Wimplicit-function-declaration]
Fixes:
https://autobuild.buildroot.org/results/10f33829552059264104623353a9ec1584b08e4f
Assisted-by: Claude:claude-opus-5
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
---
...t-thread-support-connection_get_wait.patch | 145 ++++++++++++++++++
1 file changed, 145 insertions(+)
create mode 100644 package/libmicrohttpd/0001-fix-build-without-thread-support-connection_get_wait.patch
diff --git a/package/libmicrohttpd/0001-fix-build-without-thread-support-connection_get_wait.patch b/package/libmicrohttpd/0001-fix-build-without-thread-support-connection_get_wait.patch
new file mode 100644
index 0000000000..d7f93f57f3
--- /dev/null
+++ b/package/libmicrohttpd/0001-fix-build-without-thread-support-connection_get_wait.patch
@@ -0,0 +1,145 @@
+From b9da2097d719dbd125849f2e344d0a7d80b56da6 Mon Sep 17 00:00:00 2001
+From: Yegor Yefremov <yegorslists@googlemail.com>
+Date: Sat, 26 Sep 2026 12:08:52 +0200
+Subject: [PATCH] fix build without thread support: connection_get_wait() must
+ be unconditional
+
+connection_get_wait() was defined inside the
+"#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)"
+region, but MHD_get_timeout64(), which is compiled unconditionally,
+calls it. When MHD is configured with --with-threads=none the
+definition is not compiled and the build fails:
+
+ daemon.c: In function 'MHD_get_timeout64':
+ daemon.c:4524:18: error: implicit declaration of function
+ 'connection_get_wait' [-Wimplicit-function-declaration]
+
+Move the function above the threads-only region. Pure code motion,
+no functional change; the two thread-only call sites in
+thread_main_handle_connection() still follow the definition.
+
+Found while cross-compiling for a Buildroot mips64el/uClibc toolchain
+without thread support (--with-threads=none).
+
+Upstream: https://lists.gnu.org/archive/html/libmicrohttpd/2026-08/msg00002.html
+Assisted-by: Claude:claude-opus-5
+Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
+---
+ src/microhttpd/daemon.c | 97 +++++++++++++++++++++--------------------
+ 1 file changed, 49 insertions(+), 48 deletions(-)
+
+diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
+index b42d4ee..081d9a6 100644
+--- a/src/microhttpd/daemon.c
++++ b/src/microhttpd/daemon.c
+@@ -1847,6 +1847,55 @@ process_urh (struct MHD_UpgradeResponseHandle *urh)
+
+ #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */
+
++
++/**
++ * Get maximum wait period for the connection (the amount of time left before
++ * connection time out)
++ * @param c the connection to check
++ * @return the maximum number of millisecond before the connection must be
++ * processed again.
++ */
++static uint64_t
++connection_get_wait (struct MHD_Connection *c)
++{
++ const uint64_t now = MHD_monotonic_msec_counter ();
++ const uint64_t since_actv = now - c->last_activity;
++ const uint64_t timeout = c->connection_timeout_ms;
++ uint64_t mseconds_left;
++
++ mhd_assert (0 != timeout);
++ /* Keep the next lines in sync with #connection_check_timedout() to avoid
++ * undesired side-effects like busy-waiting. */
++ if (timeout < since_actv)
++ {
++ if (UINT64_MAX / 2 < since_actv)
++ {
++ const uint64_t jump_back = c->last_activity - now;
++ /* Very unlikely that it is more than quarter-million years pause.
++ * More likely that system clock jumps back. */
++ if (5000 >= jump_back)
++ { /* Jump back is less than 5 seconds, try to recover. */
++ return 100; /* Set wait time to 0.1 seconds */
++ }
++ /* Too large jump back */
++ }
++ return 0; /* Connection has timed out */
++ }
++ else if (since_actv == timeout)
++ {
++ /* Exact match for timeout and time from last activity.
++ * Maybe this is just a precise match or this happens because the timer
++ * resolution is too low.
++ * Set wait time to 0.1 seconds to avoid busy-waiting with low
++ * timer resolution as connection is not timed-out yet. */
++ return 100;
++ }
++ mseconds_left = timeout - since_actv;
++
++ return mseconds_left;
++}
++
++
+ #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
+ #ifdef UPGRADE_SUPPORT
+ /**
+@@ -2009,54 +2058,6 @@ thread_main_connection_upgrade (struct MHD_Connection *con)
+ #endif /* UPGRADE_SUPPORT */
+
+
+-/**
+- * Get maximum wait period for the connection (the amount of time left before
+- * connection time out)
+- * @param c the connection to check
+- * @return the maximum number of millisecond before the connection must be
+- * processed again.
+- */
+-static uint64_t
+-connection_get_wait (struct MHD_Connection *c)
+-{
+- const uint64_t now = MHD_monotonic_msec_counter ();
+- const uint64_t since_actv = now - c->last_activity;
+- const uint64_t timeout = c->connection_timeout_ms;
+- uint64_t mseconds_left;
+-
+- mhd_assert (0 != timeout);
+- /* Keep the next lines in sync with #connection_check_timedout() to avoid
+- * undesired side-effects like busy-waiting. */
+- if (timeout < since_actv)
+- {
+- if (UINT64_MAX / 2 < since_actv)
+- {
+- const uint64_t jump_back = c->last_activity - now;
+- /* Very unlikely that it is more than quarter-million years pause.
+- * More likely that system clock jumps back. */
+- if (5000 >= jump_back)
+- { /* Jump back is less than 5 seconds, try to recover. */
+- return 100; /* Set wait time to 0.1 seconds */
+- }
+- /* Too large jump back */
+- }
+- return 0; /* Connection has timed out */
+- }
+- else if (since_actv == timeout)
+- {
+- /* Exact match for timeout and time from last activity.
+- * Maybe this is just a precise match or this happens because the timer
+- * resolution is too low.
+- * Set wait time to 0.1 seconds to avoid busy-waiting with low
+- * timer resolution as connection is not timed-out yet. */
+- return 100;
+- }
+- mseconds_left = timeout - since_actv;
+-
+- return mseconds_left;
+-}
+-
+-
+ /**
+ * Complete the resume of a connection that has its own thread.
+ *
--
2.34.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Buildroot] [PATCH] package/libmicrohttpd: fix build without thread support
2026-09-26 13:36 [Buildroot] [PATCH] package/libmicrohttpd: fix build without thread support Yegor Yefremov via buildroot
@ 2026-09-28 8:55 ` Thomas Petazzoni via buildroot
2026-09-28 9:08 ` Yegor Yefremov via buildroot
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-09-28 8:55 UTC (permalink / raw)
To: Yegor Yefremov; +Cc: buildroot, Bernd Kuhls, Will Newton
Hello,
On Sat, Sep 26, 2026 at 03:36:54PM +0200, Yegor Yefremov via buildroot wrote:
> Add an upstream-submitted patch that moves connection_get_wait() out
> of the threads-only region, as MHD_get_timeout64() calls it
> unconditionally. Without it the build fails with
> --with-threads=none:
>
> daemon.c:4524:18: error: implicit declaration of function 'connection_get_wait' [-Wimplicit-function-declaration]
>
> Fixes:
> https://autobuild.buildroot.org/results/10f33829552059264104623353a9ec1584b08e4f
>
> Assisted-by: Claude:claude-opus-5
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Thanks a lot for the patch. However could you identify which commit
introduced this regression so that we know whether this fix should be
backported or not?
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Buildroot] [PATCH] package/libmicrohttpd: fix build without thread support
2026-09-28 8:55 ` Thomas Petazzoni via buildroot
@ 2026-09-28 9:08 ` Yegor Yefremov via buildroot
2026-09-28 10:05 ` Thomas Petazzoni via buildroot
0 siblings, 1 reply; 5+ messages in thread
From: Yegor Yefremov via buildroot @ 2026-09-28 9:08 UTC (permalink / raw)
To: Thomas Petazzoni; +Cc: buildroot, Bernd Kuhls, Will Newton
Hi Thomas,
On Mon, Sep 28, 2026 at 10:55 AM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
>
> Hello,
>
> On Sat, Sep 26, 2026 at 03:36:54PM +0200, Yegor Yefremov via buildroot wrote:
> > Add an upstream-submitted patch that moves connection_get_wait() out
> > of the threads-only region, as MHD_get_timeout64() calls it
> > unconditionally. Without it the build fails with
> > --with-threads=none:
> >
> > daemon.c:4524:18: error: implicit declaration of function 'connection_get_wait' [-Wimplicit-function-declaration]
> >
> > Fixes:
> > https://autobuild.buildroot.org/results/10f33829552059264104623353a9ec1584b08e4f
> >
> > Assisted-by: Claude:claude-opus-5
> > Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
>
> Thanks a lot for the patch. However could you identify which commit
> introduced this regression so that we know whether this fix should be
> backported or not?
The issue was introduced upstream by commit 73c43a7ef7bd ("Added
workaround for system clock jumps back"), which is part of v0.9.75.
That commit added connection_get_wait() inside the
"#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)"
block and at the same time called it from MHD_get_timeout(), which is
built unconditionally.
In Buildroot it was pulled in by commit 8ec001b467
("package/libmicrohttpd: bump version to 0.9.75"), so all maintained
branches are affected (2025.02.x, 2026.02.x, 2026.05.x and 2026.08.x
have 1.0.5, 1.0.9 or 1.0.10, which all have the same code).
It went unnoticed for a long time because GCC < 14 only warns about
implicit function declarations. GCC 14 made it an error by default,
and the failing autobuilder configuration uses GCC 16.
Yegor
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Buildroot] [PATCH] package/libmicrohttpd: fix build without thread support
2026-09-28 9:08 ` Yegor Yefremov via buildroot
@ 2026-09-28 10:05 ` Thomas Petazzoni via buildroot
2026-09-28 10:14 ` Yegor Yefremov via buildroot
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-09-28 10:05 UTC (permalink / raw)
To: Yegor Yefremov; +Cc: buildroot, Bernd Kuhls, Will Newton
Hello,
On Mon, Sep 28, 2026 at 11:08:54AM +0200, Yegor Yefremov via buildroot wrote:
> The issue was introduced upstream by commit 73c43a7ef7bd ("Added
> workaround for system clock jumps back"), which is part of v0.9.75.
> That commit added connection_get_wait() inside the
> "#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)"
> block and at the same time called it from MHD_get_timeout(), which is
> built unconditionally.
>
> In Buildroot it was pulled in by commit 8ec001b467
> ("package/libmicrohttpd: bump version to 0.9.75"), so all maintained
> branches are affected (2025.02.x, 2026.02.x, 2026.05.x and 2026.08.x
> have 1.0.5, 1.0.9 or 1.0.10, which all have the same code).
>
> It went unnoticed for a long time because GCC < 14 only warns about
> implicit function declarations. GCC 14 made it an error by default,
> and the failing autobuilder configuration uses GCC 16.
Thanks for the feedback. Then, which GCC version started considering
this as an error? GCC 14, 15 or 16?
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Buildroot] [PATCH] package/libmicrohttpd: fix build without thread support
2026-09-28 10:05 ` Thomas Petazzoni via buildroot
@ 2026-09-28 10:14 ` Yegor Yefremov via buildroot
0 siblings, 0 replies; 5+ messages in thread
From: Yegor Yefremov via buildroot @ 2026-09-28 10:14 UTC (permalink / raw)
To: Thomas Petazzoni; +Cc: buildroot, Bernd Kuhls, Will Newton
Hello,
On Mon, Sep 28, 2026 at 12:05 PM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
>
> Hello,
>
> On Mon, Sep 28, 2026 at 11:08:54AM +0200, Yegor Yefremov via buildroot wrote:
>
> > The issue was introduced upstream by commit 73c43a7ef7bd ("Added
> > workaround for system clock jumps back"), which is part of v0.9.75.
> > That commit added connection_get_wait() inside the
> > "#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)"
> > block and at the same time called it from MHD_get_timeout(), which is
> > built unconditionally.
> >
> > In Buildroot it was pulled in by commit 8ec001b467
> > ("package/libmicrohttpd: bump version to 0.9.75"), so all maintained
> > branches are affected (2025.02.x, 2026.02.x, 2026.05.x and 2026.08.x
> > have 1.0.5, 1.0.9 or 1.0.10, which all have the same code).
> >
> > It went unnoticed for a long time because GCC < 14 only warns about
> > implicit function declarations. GCC 14 made it an error by default,
> > and the failing autobuilder configuration uses GCC 16.
>
> Thanks for the feedback. Then, which GCC version started considering
> this as an error? GCC 14, 15 or 16?
It went unnoticed for a long time because until GCC 13 implicit
function declarations only triggered a warning. Since GCC 14 they
are errors by default (see "Implicit function declarations" in
https://gcc.gnu.org/gcc-14/porting_to.html).
So, GCC 14 is the earliest version to trigger this error.
Yegor
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-28 10:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-26 13:36 [Buildroot] [PATCH] package/libmicrohttpd: fix build without thread support Yegor Yefremov via buildroot
2026-09-28 8:55 ` Thomas Petazzoni via buildroot
2026-09-28 9:08 ` Yegor Yefremov via buildroot
2026-09-28 10:05 ` Thomas Petazzoni via buildroot
2026-09-28 10:14 ` Yegor Yefremov via buildroot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.