Skip to contentSkip to conversation

package/libsolv: add upstream patch to fix musl build

PATCH Applied Bernd Kuhls 2 participants 4 messages Oct 26, 2025 – Oct 30, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 package/libsolv: add upstream patch to fix musl build

From: Gong Zhile <[email protected]>

After the introduction of qsort_r in musl, building libsolv with musl fails with unmatched qsort_r function signature. The commit adds the recently upstreamed patch to fix it.

Original PR: https://github.com/openSUSE/libsolv/pull/600

---
v2: added Upstream: tag in patch file

 ..._r-preprocessor-for-musl-and-FreeBSD.patch | 83 +++++++++++++++++++
 1 file changed, 83 insertions(+)
 create mode 100644 package/libsolv/0001-Fix-qsort_r-preprocessor-for-musl-and-FreeBSD.patch
package/libsolv/0001-Fix-qsort_r-preprocessor-for-musl-and-FreeBSD.patch new file +83 -0
new file mode 100644
index 0000000000..04a4312db4
@@ -0,0 +1,83 @@
+From 2d0718a4f2001c857d9af24398c68d676a98a3ca Mon Sep 17 00:00:00 2001
+From: Gong Zhile <[email protected]>
+Date: Wed, 22 Oct 2025 18:14:30 +0800
+Subject: [PATCH] Fix qsort_r preprocessor for musl and FreeBSD
+
+The original mentioned qsort_r signature difference now only exists in DragonFly
+BSD & MacOS. However, the preprocessor also broke the compliation on musl+linux
+and FreeBSD, leading the compilation error on buildroot.
+
+musl: https://git.musl-libc.org/cgit/musl/commit/?id=b76f37fd5625d038141b52184956fb4b7838e9a5
+freebsd, dragonfly, macos: QSORT(3)
+
+FreeBSD and musl use the same GNU-like signature.
+
+Upstream: https://github.com/openSUSE/libsolv/commit/2d0718a4f2001c857d9af24398c68d676a98a3ca
+
+Signed-off-by: Gong Zhile <[email protected]>
+[Bernd: added Upstream: tag]
+Signed-off-by: Bernd Kuhls <[email protected]>
+---
+ src/util.c | 35 +++++++++++++++++++----------------
+ 1 file changed, 19 insertions(+), 16 deletions(-)
+
+diff --git a/src/util.c b/src/util.c
+index 72426e09..a60ed3da 100644
+--- a/src/util.c
++++ b/src/util.c
+@@ -154,26 +154,14 @@ solv_setcloexec(int fd, int state)
+   #endif
+ }
+ 
+-/* bsd's qsort_r has different arguments, so we define our
++#if defined(HAVE_QSORT_R) || defined(HAVE___QSORT_R)
++#if (defined(__APPLE__) || defined(__DragonFly__)) && defined(HAVE_QSORT_R)
++
++/* MacOS and DragonFly have qsort_r with different arguments, so we define our
+    own version in case we need to do some clever mapping
+ 
+    see also: http://sources.redhat.com/ml/libc-alpha/2008-12/msg00003.html
+  */
+-#if (defined(__GLIBC__) || defined(__NEWLIB__)) && (defined(HAVE_QSORT_R) || defined(HAVE___QSORT_R))
+-
+-void
+-solv_sort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *compard)
+-{
+-# if defined(HAVE_QSORT_R)
+-  qsort_r(base, nmemb, size, compar, compard);
+-# else
+-  /* backported for SLE10-SP2 */
+-  __qsort_r(base, nmemb, size, compar, compard);
+-# endif
+-
+-}
+-
+-#elif defined(HAVE_QSORT_R) /* not glibc, but has qsort_r() */
+ 
+ struct solv_sort_data {
+   int (*compar)(const void *, const void *, void *);
+@@ -196,6 +184,21 @@ solv_sort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, con
+   qsort_r(base, nmemb, size, &d, solv_sort_helper);
+ }
+ 
++#else
++
++void
++solv_sort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *compard)
++{
++# if defined(HAVE_QSORT_R)
++  qsort_r(base, nmemb, size, compar, compard);
++# else
++  /* backported for SLE10-SP2 */
++  __qsort_r(base, nmemb, size, compar, compard);
++# endif
++
++}
++
++#endif
+ #else /* not glibc and no qsort_r() */
+ /* use own version of qsort if none available */
+ #include "qsort_r.c"
+-- 
+2.47.3
+
Signature · 6 lines
2.47.3

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH 2/2 package/libsolv: bump version to 0.7.35

Release notes: https://github.com/openSUSE/libsolv/blob/0.7.35/NEWS

---
 package/libsolv/libsolv.hash | 2 +-
 package/libsolv/libsolv.mk   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
package/libsolv/libsolv.hash +1 -1
index 97259ae93f..14726168a3 100644
@@ -1,3 +1,3 @@
 # Locally calculated
-sha256  ce4aa2f0e3c5c9ab99dced6a1810af3f670f1b98892394edc68ccabe7b272133  libsolv-0.7.30.tar.gz
+sha256  e6ef552846f908beb3bbf6ca718b6dd431bd8a281086d82af9a6d2a3ba919be5  libsolv-0.7.35.tar.gz
 sha256  57f15acfb29fbef7749779e096a5885c60b716633e34484a21bb717554c0198f  LICENSE.BSD
package/libsolv/libsolv.mk +1 -1
index 2317d3e663..2217ef499b 100644
@@ -4,7 +4,7 @@
 #
 ################################################################################
 
-LIBSOLV_VERSION = 0.7.30
+LIBSOLV_VERSION = 0.7.35
 LIBSOLV_SITE = $(call github,openSUSE,libsolv,$(LIBSOLV_VERSION))
 LIBSOLV_LICENSE = BSD-3-Clause
 LIBSOLV_LICENSE_FILES = LICENSE.BSD
Signature · 6 lines
2.47.3

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw
In reply to Bernd Kuhls
Quoted 6 lines · Bernd Kuhls

From: Gong Zhile <[email protected]>

After the introduction of qsort_r in musl, building libsolv with musl fails with unmatched qsort_r function signature. The commit adds the recently upstreamed patch to fix it.

Quoted 6 lines

Original PR: https://github.com/openSUSE/libsolv/pull/600

Series applied to master, thanks.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw
In reply to Bernd Kuhls

In reply of:

Quoted 10 lines

After the introduction of qsort_r in musl, building libsolv with musl fails with unmatched qsort_r function signature. The commit adds the recently upstreamed patch to fix it.

Original PR: https://github.com/openSUSE/libsolv/pull/600

Applied to 2025.02.x & 2025.08.x. Thanks

Quoted 103 lines

---
v2: added Upstream: tag in patch file

 ..._r-preprocessor-for-musl-and-FreeBSD.patch | 83 +++++++++++++++++++
 1 file changed, 83 insertions(+)
 create mode 100644 package/libsolv/0001-Fix-qsort_r-preprocessor-for-musl-and-FreeBSD.patch
package/libsolv/0001-Fix-qsort_r-preprocessor-for-musl-and-FreeBSD.patch new file +83 -0
new file mode 100644
index 0000000000..04a4312db4
@@ -0,0 +1,83 @@
+From 2d0718a4f2001c857d9af24398c68d676a98a3ca Mon Sep 17 00:00:00 2001
+From: Gong Zhile <[email protected]>
+Date: Wed, 22 Oct 2025 18:14:30 +0800
+Subject: [PATCH] Fix qsort_r preprocessor for musl and FreeBSD
+
+The original mentioned qsort_r signature difference now only exists in DragonFly
+BSD & MacOS. However, the preprocessor also broke the compliation on musl+linux
+and FreeBSD, leading the compilation error on buildroot.
+
+musl: https://git.musl-libc.org/cgit/musl/commit/?id=b76f37fd5625d038141b52184956fb4b7838e9a5
+freebsd, dragonfly, macos: QSORT(3)
+
+FreeBSD and musl use the same GNU-like signature.
+
+Upstream: https://github.com/openSUSE/libsolv/commit/2d0718a4f2001c857d9af24398c68d676a98a3ca
+
+Signed-off-by: Gong Zhile <[email protected]>
+[Bernd: added Upstream: tag]
+Signed-off-by: Bernd Kuhls <[email protected]>
+---
+ src/util.c | 35 +++++++++++++++++++----------------
+ 1 file changed, 19 insertions(+), 16 deletions(-)
+
+diff --git a/src/util.c b/src/util.c
+index 72426e09..a60ed3da 100644
+--- a/src/util.c
++++ b/src/util.c
+@@ -154,26 +154,14 @@ solv_setcloexec(int fd, int state)
+   #endif
+ }
+ 
+-/* bsd's qsort_r has different arguments, so we define our
++#if defined(HAVE_QSORT_R) || defined(HAVE___QSORT_R)
++#if (defined(__APPLE__) || defined(__DragonFly__)) && defined(HAVE_QSORT_R)
++
++/* MacOS and DragonFly have qsort_r with different arguments, so we define our
+    own version in case we need to do some clever mapping
+ 
+    see also: http://sources.redhat.com/ml/libc-alpha/2008-12/msg00003.html
+  */
+-#if (defined(__GLIBC__) || defined(__NEWLIB__)) && (defined(HAVE_QSORT_R) || defined(HAVE___QSORT_R))
+-
+-void
+-solv_sort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *compard)
+-{
+-# if defined(HAVE_QSORT_R)
+-  qsort_r(base, nmemb, size, compar, compard);
+-# else
+-  /* backported for SLE10-SP2 */
+-  __qsort_r(base, nmemb, size, compar, compard);
+-# endif
+-
+-}
+-
+-#elif defined(HAVE_QSORT_R) /* not glibc, but has qsort_r() */
+ 
+ struct solv_sort_data {
+   int (*compar)(const void *, const void *, void *);
+@@ -196,6 +184,21 @@ solv_sort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, con
+   qsort_r(base, nmemb, size, &d, solv_sort_helper);
+ }
+ 
++#else
++
++void
++solv_sort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *compard)
++{
++# if defined(HAVE_QSORT_R)
++  qsort_r(base, nmemb, size, compar, compard);
++# else
++  /* backported for SLE10-SP2 */
++  __qsort_r(base, nmemb, size, compar, compard);
++# endif
++
++}
++
++#endif
+ #else /* not glibc and no qsort_r() */
+ /* use own version of qsort if none available */
+ #include "qsort_r.c"
+-- 
+2.47.3
+
Signature · 6 lines
2.47.3

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot