diff mbox series

[v2,1/4] bluez5: Fix build with musl

Message ID 20240826174322.2938481-1-raj.khem@gmail.com
State Accepted, archived
Commit e5f9870757bf7ffd009ce4ba999d37e41274982c
Headers show
Series [v2,1/4] bluez5: Fix build with musl | expand

Commit Message

Khem Raj Aug. 26, 2024, 5:43 p.m. UTC
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
v2: Fix the upstream submission and latest patch submitted upstream

 meta/recipes-connectivity/bluez5/bluez5.inc   |   1 +
 ...U-basename-compatible-implementation.patch | 136 ++++++++++++++++++
 2 files changed, 137 insertions(+)
 create mode 100644 meta/recipes-connectivity/bluez5/bluez5/0001-Provide-GNU-basename-compatible-implementation.patch

Comments

patchtest@automation.yoctoproject.org Aug. 26, 2024, 5:53 p.m. UTC | #1
Thank you for your submission. Patchtest identified one
or more issues with the patch. Please see the log below for
more information:

---
Testing patch /home/patchtest/share/mboxes/v2-1-4-bluez5-Fix-build-with-musl.patch

FAIL: test commit message presence: Please include a commit message on your patch explaining the change (test_mbox.TestMbox.test_commit_message_presence)

PASS: test CVE tag format (test_patch.TestPatch.test_cve_tag_format)
PASS: test Signed-off-by presence (test_mbox.TestMbox.test_signed_off_by_presence)
PASS: test Signed-off-by presence (test_patch.TestPatch.test_signed_off_by_presence)
PASS: test Upstream-Status presence (test_patch.TestPatch.test_upstream_status_presence_format)
PASS: test author valid (test_mbox.TestMbox.test_author_valid)
PASS: test max line length (test_metadata.TestMetadata.test_max_line_length)
PASS: test mbox format (test_mbox.TestMbox.test_mbox_format)
PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade)
PASS: test shortlog format (test_mbox.TestMbox.test_shortlog_format)
PASS: test shortlog length (test_mbox.TestMbox.test_shortlog_length)

SKIP: pretest pylint: No python related patches, skipping test (test_python_pylint.PyLint.pretest_pylint)
SKIP: pretest src uri left files: No modified recipes, skipping pretest (test_metadata.TestMetadata.pretest_src_uri_left_files)
SKIP: test CVE check ignore: No modified recipes or older target branch, skipping test (test_metadata.TestMetadata.test_cve_check_ignore)
SKIP: test bugzilla entry format: No bug ID found (test_mbox.TestMbox.test_bugzilla_entry_format)
SKIP: test lic files chksum modified not mentioned: No modified recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_modified_not_mentioned)
SKIP: test lic files chksum presence: No added recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_presence)
SKIP: test license presence: No added recipes, skipping test (test_metadata.TestMetadata.test_license_presence)
SKIP: test pylint: No python related patches, skipping test (test_python_pylint.PyLint.test_pylint)
SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head)
SKIP: test src uri left files: No modified recipes, skipping pretest (test_metadata.TestMetadata.test_src_uri_left_files)
SKIP: test summary presence: No added recipes, skipping test (test_metadata.TestMetadata.test_summary_presence)
SKIP: test target mailing list: Series merged, no reason to check other mailing lists (test_mbox.TestMbox.test_target_mailing_list)

---

Please address the issues identified and
submit a new revision of the patch, or alternatively, reply to this
email with an explanation of why the patch should be accepted. If you
believe these results are due to an error in patchtest, please submit a
bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category
under 'Yocto Project Subprojects'). For more information on specific
failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank
you!
Richard Purdie Aug. 27, 2024, 7:31 a.m. UTC | #2
On Mon, 2024-08-26 at 10:43 -0700, Khem Raj via lists.openembedded.org wrote:
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
> v2: Fix the upstream submission and latest patch submitted upstream
> 
>  meta/recipes-connectivity/bluez5/bluez5.inc   |   1 +
>  ...U-basename-compatible-implementation.patch | 136 ++++++++++++++++++
>  2 files changed, 137 insertions(+)
>  create mode 100644 meta/recipes-connectivity/bluez5/bluez5/0001-Provide-GNU-basename-compatible-implementation.patch
> 
> diff --git a/meta/recipes-connectivity/bluez5/bluez5.inc b/meta/recipes-connectivity/bluez5/bluez5.inc
> index d8b9f817715..e0d3e651871 100644
> --- a/meta/recipes-connectivity/bluez5/bluez5.inc
> +++ b/meta/recipes-connectivity/bluez5/bluez5.inc
> @@ -70,6 +70,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/bluetooth/bluez-${PV}.tar.xz \
>             file://0001-tests-add-a-target-for-building-tests-without-runnin.patch \
>             file://0001-test-gatt-Fix-hung-issue.patch \
>             file://0004-src-shared-util.c-include-linux-limits.h.patch \
> +           file://0001-Provide-GNU-basename-compatible-implementation.patch \
>             "
>  S = "${WORKDIR}/bluez-${PV}"
>  
> diff --git a/meta/recipes-connectivity/bluez5/bluez5/0001-Provide-GNU-basename-compatible-implementation.patch b/meta/recipes-connectivity/bluez5/bluez5/0001-Provide-GNU-basename-compatible-implementation.patch
> new file mode 100644
> index 00000000000..293675ee0a2
> --- /dev/null
> +++ b/meta/recipes-connectivity/bluez5/bluez5/0001-Provide-GNU-basename-compatible-implementation.patch
> @@ -0,0 +1,136 @@
> +From 4ea6d5f344574b876bbf029501301131e623e992 Mon Sep 17 00:00:00 2001
> +From: Khem Raj <raj.khem@gmail.com>
> +Date: Mon, 26 Aug 2024 09:55:03 -0700
> +Subject: [PATCH BlueZ] Provide GNU basename compatible implementation
> +
> +Call to basename() relies on a GNU extension
> +to take a const char * vs a char *. Let's define
> +a trivial helper function to ensure compatibility
> +with musl.
> +
> +Fixes Issue: https://github.com/bluez/bluez/issues/843
> +
> +Upstream-Status: Submitted [https://lore.kernel.org/linux-bluetooth/20240826173844.2918630-1-raj.khem@gmail.com/T/#u]
> +Signed-off-by: Khem Raj <raj.khem@gmail.com>
> +---
> + Makefile.mesh           | 2 ++
> + Makefile.tools          | 3 ++-
> + mesh/mesh-config-json.c | 5 +++--
> + mesh/rpl.c              | 3 ++-
> + src/shared/util.h       | 6 ++++++
> + tools/hex2hcd.c         | 3 ++-
> + 6 files changed, 17 insertions(+), 5 deletions(-)
> +
> +diff --git a/Makefile.mesh b/Makefile.mesh
> +index e4c9fa6a3..bebedaf05 100644
> +--- a/Makefile.mesh
> ++++ b/Makefile.mesh
> +@@ -47,6 +47,8 @@ mesh/main.$(OBJEXT): src/builtin.h lib/bluetooth/bluetooth.h
> + mesh_bluetooth_meshd_SOURCES = $(mesh_sources) mesh/main.c
> + mesh_bluetooth_meshd_LDADD = src/libshared-ell.la $(ell_ldadd) -ljson-c
> + 
> ++mesh_bluetooth_meshd_CFLAGS = -I${top_srcdir}/src
> ++
> + if MANPAGES
> + man_MANS += mesh/bluetooth-meshd.8
> + endif
> +diff --git a/Makefile.tools b/Makefile.tools
> +index 5b9034078..6fc73b8a2 100644
> +--- a/Makefile.tools
> ++++ b/Makefile.tools
> +@@ -328,7 +328,8 @@ tools_l2ping_LDADD = lib/libbluetooth-internal.la
> + tools_bluemoon_SOURCES = tools/bluemoon.c monitor/bt.h
> + tools_bluemoon_LDADD = src/libshared-mainloop.la
> + 
> +-tools_hex2hcd_SOURCES = tools/hex2hcd.c
> ++tools_hex2hcd_SOURCES = tools/hex2hcd.c src/shared/util.h
> ++tools_hex2hcd_CFLAGS = -I${top_srcdir}/src
> + 
> + tools_mpris_proxy_SOURCES = tools/mpris-proxy.c
> + tools_mpris_proxy_LDADD = gdbus/libgdbus-internal.la $(GLIB_LIBS) $(DBUS_LIBS)
> +diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c
> +index c198627c6..8f89a1498 100644
> +--- a/mesh/mesh-config-json.c
> ++++ b/mesh/mesh-config-json.c
> +@@ -28,6 +28,7 @@
> + #include <ell/ell.h>
> + #include <json-c/json.h>
> + 
> ++#include "shared/util.h"
> + #include "mesh/mesh-defs.h"
> + #include "mesh/util.h"
> + #include "mesh/mesh-config.h"
> +@@ -2694,7 +2695,7 @@ bool mesh_config_load_nodes(const char *cfgdir_name, mesh_config_node_func_t cb,
> + 
> + void mesh_config_destroy_nvm(struct mesh_config *cfg)
> + {
> +-	char *node_dir, *node_name;
> ++	const char *node_dir, *node_name;
> + 	char uuid[33];
> + 
> + 	if (!cfg)
> +@@ -2706,7 +2707,7 @@ void mesh_config_destroy_nvm(struct mesh_config *cfg)
> + 	if (!hex2str(cfg->uuid, 16, uuid, sizeof(uuid)))
> + 		return;
> + 
> +-	node_name = basename(node_dir);
> ++	node_name = bluez_basename(node_dir);
> + 
> + 	/* Make sure path name of node follows expected guidelines */
> + 	if (strcmp(node_name, uuid))
> +diff --git a/mesh/rpl.c b/mesh/rpl.c
> +index fb225dddd..fb89f0afd 100644
> +--- a/mesh/rpl.c
> ++++ b/mesh/rpl.c
> +@@ -24,6 +24,7 @@
> + 
> + #include <ell/ell.h>
> + 
> ++#include "shared/util.h"
> + #include "mesh/mesh-defs.h"
> + 
> + #include "mesh/node.h"
> +@@ -146,7 +147,7 @@ static void get_entries(const char *iv_path, struct l_queue *rpl_list)
> + 	if (!dir)
> + 		return;
> + 
> +-	iv_txt = basename(iv_path);
> ++	iv_txt = bluez_basename(iv_path);
> + 	if (sscanf(iv_txt, "%08x", &iv_index) != 1) {
> + 		closedir(dir);
> + 		return;
> +diff --git a/src/shared/util.h b/src/shared/util.h
> +index f2ca4f29f..0f0f67718 100644
> +--- a/src/shared/util.h
> ++++ b/src/shared/util.h
> +@@ -296,3 +296,9 @@ static inline void put_be64(uint64_t val, void *dst)
> + {
> + 	put_unaligned(cpu_to_be64(val), (uint64_t *) dst);
> + }
> ++
> ++static inline const char *bluez_basename(const char *path)
> ++{
> ++	const char *base = strrchr(path, '/');
> ++	return base ? base + 1 : path;
> ++}
> +diff --git a/tools/hex2hcd.c b/tools/hex2hcd.c
> +index e6dca5a81..05fa69470 100644
> +--- a/tools/hex2hcd.c
> ++++ b/tools/hex2hcd.c
> +@@ -24,6 +24,7 @@
> + #include <stdlib.h>
> + #include <stdbool.h>
> + #include <sys/stat.h>
> ++#include "shared/util.h"
> + 
> + static ssize_t process_record(int fd, const char *line, uint16_t *upper_addr)
> + {
> +@@ -302,7 +303,7 @@ static void ver_parse_entry(const char *pathname)
> + 	}
> + 
> + 	if (S_ISREG(st.st_mode)) {
> +-		ver_parse_file(basename(pathname));
> ++		ver_parse_file(bluez_basename(pathname));
> + 		goto done;
> + 	}
> + 
> 

There were some autobuilder failures:

https://autobuilder.yoctoproject.org/typhoon/#/builders/47/builds/9377/steps/11/logs/stdio

| /home/pokybuild/yocto-worker/qemuarm-oecore/build/build/tmp-glibc/work/cortexa15t2hf-neon-oe-linux-gnueabi/bluez5/5.77/recipe-sysroot-native/usr/bin/arm-oe-linux-gnueabi/../../libexec/arm-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/14.2.0/ld: tools/hex2hcd-hex2hcd.o: relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
| /home/pokybuild/yocto-worker/qemuarm-oecore/build/build/tmp-glibc/work/cortexa15t2hf-neon-oe-linux-gnueabi/bluez5/5.77/recipe-sysroot-native/usr/bin/arm-oe-linux-gnueabi/../../libexec/arm-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/14.2.0/ld: tools/hex2hcd-hex2hcd.o(.text+0x7e): unresolvable R_ARM_THM_CALL relocation against symbol `__isoc23_sscanf@@GLIBC_2.38'
| /home/pokybuild/yocto-worker/qemuarm-oecore/build/build/tmp-glibc/work/cortexa15t2hf-neon-oe-linux-gnueabi/bluez5/5.77/recipe-sysroot-native/usr/bin/arm-oe-linux-gnueabi/../../libexec/arm-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/14.2.0/ld: final link failed
| collect2: error: ld returned 1 exit status
| make[1]: *** [Makefile:6681: tools/hex2hcd] Error 1



https://autobuilder.yoctoproject.org/typhoon/#/builders/107/builds/6495/steps/14/logs/stdio

ERROR: bluez5-5.77-r0 do_package_qa: QA Issue: bluez5: ELF binary /usr/bin/hex2hcd has relocations in .text [textrel]



https://autobuilder.yoctoproject.org/typhoon/#/builders/63/builds/9340/steps/13/logs/stdio


Cheers,

Richard
diff mbox series

Patch

diff --git a/meta/recipes-connectivity/bluez5/bluez5.inc b/meta/recipes-connectivity/bluez5/bluez5.inc
index d8b9f817715..e0d3e651871 100644
--- a/meta/recipes-connectivity/bluez5/bluez5.inc
+++ b/meta/recipes-connectivity/bluez5/bluez5.inc
@@ -70,6 +70,7 @@  SRC_URI = "${KERNELORG_MIRROR}/linux/bluetooth/bluez-${PV}.tar.xz \
            file://0001-tests-add-a-target-for-building-tests-without-runnin.patch \
            file://0001-test-gatt-Fix-hung-issue.patch \
            file://0004-src-shared-util.c-include-linux-limits.h.patch \
+           file://0001-Provide-GNU-basename-compatible-implementation.patch \
            "
 S = "${WORKDIR}/bluez-${PV}"
 
diff --git a/meta/recipes-connectivity/bluez5/bluez5/0001-Provide-GNU-basename-compatible-implementation.patch b/meta/recipes-connectivity/bluez5/bluez5/0001-Provide-GNU-basename-compatible-implementation.patch
new file mode 100644
index 00000000000..293675ee0a2
--- /dev/null
+++ b/meta/recipes-connectivity/bluez5/bluez5/0001-Provide-GNU-basename-compatible-implementation.patch
@@ -0,0 +1,136 @@ 
+From 4ea6d5f344574b876bbf029501301131e623e992 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Mon, 26 Aug 2024 09:55:03 -0700
+Subject: [PATCH BlueZ] Provide GNU basename compatible implementation
+
+Call to basename() relies on a GNU extension
+to take a const char * vs a char *. Let's define
+a trivial helper function to ensure compatibility
+with musl.
+
+Fixes Issue: https://github.com/bluez/bluez/issues/843
+
+Upstream-Status: Submitted [https://lore.kernel.org/linux-bluetooth/20240826173844.2918630-1-raj.khem@gmail.com/T/#u]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ Makefile.mesh           | 2 ++
+ Makefile.tools          | 3 ++-
+ mesh/mesh-config-json.c | 5 +++--
+ mesh/rpl.c              | 3 ++-
+ src/shared/util.h       | 6 ++++++
+ tools/hex2hcd.c         | 3 ++-
+ 6 files changed, 17 insertions(+), 5 deletions(-)
+
+diff --git a/Makefile.mesh b/Makefile.mesh
+index e4c9fa6a3..bebedaf05 100644
+--- a/Makefile.mesh
++++ b/Makefile.mesh
+@@ -47,6 +47,8 @@ mesh/main.$(OBJEXT): src/builtin.h lib/bluetooth/bluetooth.h
+ mesh_bluetooth_meshd_SOURCES = $(mesh_sources) mesh/main.c
+ mesh_bluetooth_meshd_LDADD = src/libshared-ell.la $(ell_ldadd) -ljson-c
+ 
++mesh_bluetooth_meshd_CFLAGS = -I${top_srcdir}/src
++
+ if MANPAGES
+ man_MANS += mesh/bluetooth-meshd.8
+ endif
+diff --git a/Makefile.tools b/Makefile.tools
+index 5b9034078..6fc73b8a2 100644
+--- a/Makefile.tools
++++ b/Makefile.tools
+@@ -328,7 +328,8 @@ tools_l2ping_LDADD = lib/libbluetooth-internal.la
+ tools_bluemoon_SOURCES = tools/bluemoon.c monitor/bt.h
+ tools_bluemoon_LDADD = src/libshared-mainloop.la
+ 
+-tools_hex2hcd_SOURCES = tools/hex2hcd.c
++tools_hex2hcd_SOURCES = tools/hex2hcd.c src/shared/util.h
++tools_hex2hcd_CFLAGS = -I${top_srcdir}/src
+ 
+ tools_mpris_proxy_SOURCES = tools/mpris-proxy.c
+ tools_mpris_proxy_LDADD = gdbus/libgdbus-internal.la $(GLIB_LIBS) $(DBUS_LIBS)
+diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c
+index c198627c6..8f89a1498 100644
+--- a/mesh/mesh-config-json.c
++++ b/mesh/mesh-config-json.c
+@@ -28,6 +28,7 @@
+ #include <ell/ell.h>
+ #include <json-c/json.h>
+ 
++#include "shared/util.h"
+ #include "mesh/mesh-defs.h"
+ #include "mesh/util.h"
+ #include "mesh/mesh-config.h"
+@@ -2694,7 +2695,7 @@ bool mesh_config_load_nodes(const char *cfgdir_name, mesh_config_node_func_t cb,
+ 
+ void mesh_config_destroy_nvm(struct mesh_config *cfg)
+ {
+-	char *node_dir, *node_name;
++	const char *node_dir, *node_name;
+ 	char uuid[33];
+ 
+ 	if (!cfg)
+@@ -2706,7 +2707,7 @@ void mesh_config_destroy_nvm(struct mesh_config *cfg)
+ 	if (!hex2str(cfg->uuid, 16, uuid, sizeof(uuid)))
+ 		return;
+ 
+-	node_name = basename(node_dir);
++	node_name = bluez_basename(node_dir);
+ 
+ 	/* Make sure path name of node follows expected guidelines */
+ 	if (strcmp(node_name, uuid))
+diff --git a/mesh/rpl.c b/mesh/rpl.c
+index fb225dddd..fb89f0afd 100644
+--- a/mesh/rpl.c
++++ b/mesh/rpl.c
+@@ -24,6 +24,7 @@
+ 
+ #include <ell/ell.h>
+ 
++#include "shared/util.h"
+ #include "mesh/mesh-defs.h"
+ 
+ #include "mesh/node.h"
+@@ -146,7 +147,7 @@ static void get_entries(const char *iv_path, struct l_queue *rpl_list)
+ 	if (!dir)
+ 		return;
+ 
+-	iv_txt = basename(iv_path);
++	iv_txt = bluez_basename(iv_path);
+ 	if (sscanf(iv_txt, "%08x", &iv_index) != 1) {
+ 		closedir(dir);
+ 		return;
+diff --git a/src/shared/util.h b/src/shared/util.h
+index f2ca4f29f..0f0f67718 100644
+--- a/src/shared/util.h
++++ b/src/shared/util.h
+@@ -296,3 +296,9 @@ static inline void put_be64(uint64_t val, void *dst)
+ {
+ 	put_unaligned(cpu_to_be64(val), (uint64_t *) dst);
+ }
++
++static inline const char *bluez_basename(const char *path)
++{
++	const char *base = strrchr(path, '/');
++	return base ? base + 1 : path;
++}
+diff --git a/tools/hex2hcd.c b/tools/hex2hcd.c
+index e6dca5a81..05fa69470 100644
+--- a/tools/hex2hcd.c
++++ b/tools/hex2hcd.c
+@@ -24,6 +24,7 @@
+ #include <stdlib.h>
+ #include <stdbool.h>
+ #include <sys/stat.h>
++#include "shared/util.h"
+ 
+ static ssize_t process_record(int fd, const char *line, uint16_t *upper_addr)
+ {
+@@ -302,7 +303,7 @@ static void ver_parse_entry(const char *pathname)
+ 	}
+ 
+ 	if (S_ISREG(st.st_mode)) {
+-		ver_parse_file(basename(pathname));
++		ver_parse_file(bluez_basename(pathname));
+ 		goto done;
+ 	}
+