]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
systemd-bootchart: Fix build on musl
authorKhem Raj <raj.khem@gmail.com>
Thu, 23 May 2024 14:59:18 +0000 (07:59 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 28 May 2024 08:38:20 +0000 (09:38 +0100)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-devtools/systemd-bootchart/systemd-bootchart/0001-Define-portable-basename-function.patch [new file with mode: 0644]
meta/recipes-devtools/systemd-bootchart/systemd-bootchart_235.bb

diff --git a/meta/recipes-devtools/systemd-bootchart/systemd-bootchart/0001-Define-portable-basename-function.patch b/meta/recipes-devtools/systemd-bootchart/systemd-bootchart/0001-Define-portable-basename-function.patch
new file mode 100644 (file)
index 0000000..dc4c44c
--- /dev/null
@@ -0,0 +1,59 @@
+From 4b19c32791fb8a8663b3335f8a3675a2bbabe688 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Mon, 20 May 2024 18:40:36 -0700
+Subject: [PATCH] Define portable basename function
+
+Newer version of musl have removed prototype for basename in string.h [1]
+which now makes it fail to compile with GCC14+ compiler therefore
+define local basename utility function.
+
+[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7
+
+Upstream-Status: Submitted [https://github.com/systemd/systemd-bootchart/pull/53]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ src/conf-files.c | 14 ++++++++++++--
+ 1 file changed, 12 insertions(+), 2 deletions(-)
+
+diff --git a/src/conf-files.c b/src/conf-files.c
+index 5dd2d7d..b932bb2 100644
+--- a/src/conf-files.c
++++ b/src/conf-files.c
+@@ -35,6 +35,16 @@
+ #include "strv.h"
+ #include "util.h"
++/***
++ * basename is implemented differently across different C libraries. This
++ * implementation matches the one provided by the GNU libc, and does not
++ * modify its input parameter.
++***/
++static const char *sbc_basename(const char *path) {
++        const char *base = strrchr(path, '/');
++        return base ? base + 1 : path;
++}
++
+ static int files_add(Hashmap *h, const char *root, const char *path, const char *suffix) {
+         _cleanup_closedir_ DIR *dir = NULL;
+         const char *dirpath;
+@@ -63,7 +73,7 @@ static int files_add(Hashmap *h, const char *root, const char *path, const char
+                 if (!p)
+                         return -ENOMEM;
+-                r = hashmap_put(h, basename(p), p);
++                r = hashmap_put(h, sbc_basename(p), p);
+                 if (r == -EEXIST) {
+                         log_debug("Skipping overridden file: %s.", p);
+                         free(p);
+@@ -84,7 +94,7 @@ static int base_cmp(const void *a, const void *b) {
+         s1 = *(char * const *)a;
+         s2 = *(char * const *)b;
+-        return strcmp(basename(s1), basename(s2));
++        return strcmp(sbc_basename(s1), sbc_basename(s2));
+ }
+ static int conf_files_list_strv_internal(char ***strv, const char *suffix, const char *root, char **dirs) {
+-- 
+2.45.1
+
index 25544029d5c1ded30b32a7b9aa60511d8b7a35a5..3c3c84ff4a4a84ae3985229bb8d32f91eaaa4da5 100644 (file)
@@ -17,6 +17,7 @@ SRC_URI:append:libc-musl = " \
     file://0001-comparison_fn_t-is-glibc-specific-use-raw-signature-.patch \
     file://0002-musl-does-not-provide-printf-h.patch \
     file://0003-musl-does-not-provide-canonicalize_file_name.patch \
+    file://0001-Define-portable-basename-function.patch \
     "