[Buildroot] [git commit branch/2025.02.x] package/mbpfan: fix build on musl / uclibc-ng

Thomas Perale thomas.perale at mind.be
Thu Sep 11 15:03:37 UTC 2025


commit: https://git.buildroot.net/buildroot/commit/?id=3394bb0ff9ac4587bf38accfb7147a390825fd4a
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/2025.02.x

Fixes https://autobuild.buildroot.net/results/9526503fe8e756bd4444f1fb1e9cf1391c461901/

mbpfan uses vsyslog(), which is not in POSIX so only exposed by <syslog.h>
on musl and uclibc-ng if we define _DEFAULT_SOURCE:

https://git.musl-libc.org/cgit/musl/tree/include/syslog.h#n64
https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/include/sys/syslog.h#n200

Add a patch submitted upstream to do this.

[Peter: add patch rather than passing _DEFAULT_SOURCE in mbpfan.mk]
Signed-off-by: Peter Korsgaard <peter at korsgaard.com>
(cherry picked from commit 759a08633ea80e90cb91984b5f87d82304e711b9)
Signed-off-by: Thomas Perale <thomas.perale at mind.be>
---
 ...kefile-util.c-fix-build-on-musl-uClibc-ng.patch | 62 ++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/package/mbpfan/0001-Makefile-util.c-fix-build-on-musl-uClibc-ng.patch b/package/mbpfan/0001-Makefile-util.c-fix-build-on-musl-uClibc-ng.patch
new file mode 100644
index 0000000000..ac15143e2e
--- /dev/null
+++ b/package/mbpfan/0001-Makefile-util.c-fix-build-on-musl-uClibc-ng.patch
@@ -0,0 +1,62 @@
+From 924e38f159e4f5906f88cd8ddbe27f273c601cb0 Mon Sep 17 00:00:00 2001
+From: Peter Korsgaard <peter at korsgaard.com>
+Date: Mon, 1 Sep 2025 12:08:53 +0200
+Subject: [PATCH] {Makefile,util.c}: fix build on musl / uClibc-ng
+
+vsyslog() is not in POSIX, so only exposed by <syslog.h> on musl and
+uclibc-ng if we define _DEFAULT_SOURCE.
+
+https://git.musl-libc.org/cgit/musl/tree/include/syslog.h#n64
+https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/include/sys/syslog.h#n200
+
+While we are at it, drop the glibc-implementation-specific __USE_MISC define
+in src/util.c to get rid of a double definition:
+
+src/util.c:3: warning: "__USE_MISC" redefined
+    3 | #define __USE_MISC
+      |
+In file included from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
+                 from /usr/include/stdio.h:27,
+                 from src/util.c:2:
+/usr/include/features.h:395: note: this is the location of the previous definition
+  395 | # define __USE_MISC     1
+
+On glibc (and uClibc-ng) the internal __USE_MISC symbol gets defined if
+_DEFAULT_SOURCE is:
+
+https://github.com/bminor/glibc/blob/master/include/features.h#L417-L419
+
+Upstream: https://github.com/linux-on-mac/mbpfan/pull/271
+Signed-off-by: Peter Korsgaard <peter at korsgaard.com>
+---
+ Makefile   | 2 +-
+ src/util.c | 1 -
+ 2 files changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 94d72ee..ff1b7e6 100644
+--- a/Makefile
++++ b/Makefile
+@@ -19,7 +19,7 @@ BINFLAG = -o
+ INCLUDES =
+ LIBS = -lm
+ LIBPATH =
+-CFLAGS += $(COPT) -g $(INCLUDES) -Wall -Wextra -Wno-unused-function -Wno-unused-parameter -std=c99 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=500
++CFLAGS += $(COPT) -g $(INCLUDES) -Wall -Wextra -Wno-unused-function -Wno-unused-parameter -std=c99 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=500 -D_DEFAULT_SOURCE
+ LDFLAGS += $(LIBPATH) -g
+ 
+ OBJS := $(patsubst %.$(C),%.$(OBJ),$(wildcard $(SOURCE_PATH)*.$(C)))
+diff --git a/src/util.c b/src/util.c
+index df5b03f..25415b9 100644
+--- a/src/util.c
++++ b/src/util.c
+@@ -1,6 +1,5 @@
+ #include <stdarg.h>
+ #include <stdio.h>
+-#define __USE_MISC
+ #define _GNU_SOURCE
+ #include <syslog.h>
+ 
+-- 
+2.39.5
+


More information about the buildroot mailing list