Skip to contentSkip to conversation

util-linux: Fix lscpu on musl

PATCH Superseded Khem Raj 1 participant 3 messages Sep 15, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/3 util-linux: Fix lscpu on musl

---
 meta/recipes-core/util-linux/util-linux.inc   |  1 +
 ...-buffer-size-for-cpuinfo_parse_cache.patch | 36 +++++++++++++++++++
 2 files changed, 37 insertions(+)
 create mode 100644 meta/recipes-core/util-linux/util-linux/0001-lscpu-Use-larger-buffer-size-for-cpuinfo_parse_cache.patch
meta/recipes-core/util-linux/util-linux.inc +1 -0
index 99ce2a24b0a..214fcb03908 100644
@@ -35,6 +35,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/util-linux/v${MAJOR_VERSION}/util-lin
            file://run-ptest \
            file://display_testname_for_subtest.patch \
            file://avoid_parallel_tests.patch \
+           file://0001-lscpu-Use-larger-buffer-size-for-cpuinfo_parse_cache.patch \
            "
 
 SRC_URI[sha256sum] = "890ae8ff810247bd19e274df76e8371d202cda01ad277681b0ea88eeaa00286b"
meta/recipes-core/util-linux/util-linux/0001-lscpu-Use-larger-buffer-size-for-cpuinfo_parse_cache.patch new file +36 -0
new file mode 100644
index 00000000000..6182e4b6fbf
@@ -0,0 +1,36 @@
+From 4697f1555fae2d24518ed00ac22387a258d0ca33 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Fri, 15 Sep 2023 00:18:18 -0700
+Subject: [PATCH] lscpu: Use larger buffer size for cpuinfo_parse_cache
+
+BUFSIZ can vary quite a bit  e.g. glibc/linux systems its 8192
+but on musl/linux and OSX its 1024, on mingW it is 256, some tests e.g.
+x86_64-64cpu-linux6.2.tar.gz has added really long line for cpu flags
+line which is greater than 1024 characters and hence this test fails
+on musl because lscpu -s reports truncated string
+
+Upstream-Status: Submitted [https://github.com/util-linux/util-linux/pull/2492]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ sys-utils/lscpu-cputype.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/sys-utils/lscpu-cputype.c b/sys-utils/lscpu-cputype.c
+index 3fd5f7a3c..863f63152 100644
+--- a/sys-utils/lscpu-cputype.c
++++ b/sys-utils/lscpu-cputype.c
+@@ -462,7 +462,11 @@ static int cpuinfo_parse_cache(struct lscpu_cxt *cxt, int keynum, char *data)
+ int lscpu_read_cpuinfo(struct lscpu_cxt *cxt)
+ {
+ 	FILE *fp;
++#if BUFSIZ <= 1024
++	char buf[BUFSIZ * 8];
++#else
+ 	char buf[BUFSIZ];
++#endif
+ 	size_t i;
+ 	struct lscpu_cputype *ct;
+ 	struct cpuinfo_parser _pr = { .cxt = cxt }, *pr = &_pr;
+-- 
+2.42.0
+
Signature · 1 line
2.42.0
author
#1 lore raw

PATCH 2/3 util-linux: Disable failing tests on musl

These tests need strptime with %s which is glibc specific extention

---
 meta/recipes-core/util-linux/util-linux_2.39.1.bb | 9 +++++++++
 1 file changed, 9 insertions(+)
meta/recipes-core/util-linux/util-linux_2.39.1.bb +9 -0
index c81405533c4..821a44a1453 100644
@@ -322,3 +322,12 @@ do_install_ptest() {
         rm -rf ${D}${PTEST_PATH}/tests/ts/chfn
     fi
 }
+
+# Delete tests not working on musl
+do_install_ptest:append:libc-musl() {
+    for t in tests/ts/col/multibyte \
+            tests/ts/lib/timeutils \
+            tests/ts/dmesg/limit; do
+        rm -rf ${D}${PTEST_PATH}/$t
+    done
+}
Signature · 1 line
2.42.0
author
#2 lore raw

PATCH 3/3 Revert "util-linux: scanf_cv_alloc_modifier changed from 'as' -> 'ms'"

In reply to Khem Raj

This was needed for uclibc, which is long gone in OE

This reverts commit d3ffa39e2edcf68583fa85c191f59a54c4722abd.

---
 meta/recipes-core/util-linux/util-linux_2.39.1.bb | 1 -
 1 file changed, 1 deletion(-)
meta/recipes-core/util-linux/util-linux_2.39.1.bb +0 -1
index 821a44a1453..927037a3429 100644
@@ -62,7 +62,6 @@ PACKAGESPLITFUNCS =+ "util_linux_libpackages"
 
 PACKAGES_DYNAMIC = "^${PN}-.*"
 
-CACHED_CONFIGUREVARS += "scanf_cv_alloc_modifier=ms"
 UTIL_LINUX_LIBDIR = "${libdir}"
 UTIL_LINUX_LIBDIR:class-target = "${base_libdir}"
 EXTRA_OECONF = "\
Signature · 1 line
2.42.0