* [Buildroot] [PATCH] package/uclibc: declare wcsdup() for POSIX.1-2008
@ 2026-10-24 8:24 Yegor Yefremov via buildroot
2026-10-25 17:38 ` Thomas Petazzoni via buildroot
0 siblings, 1 reply; 2+ messages in thread
From: Yegor Yefremov via buildroot @ 2026-10-24 8:24 UTC (permalink / raw)
To: buildroot
hidapi fails to build with uClibc-ng and GCC >= 14:
hid.c: In function 'utf8_to_wchar_t':
hid.c:116:32: error: implicit declaration of function 'wcsdup'; did you mean 'wcscmp'? [-Wimplicit-function-declaration]
116 | return wcsdup(L"");
hid.c:116:32: error: returning 'int' from a function with return type 'wchar_t *' {aka 'long int *'} makes pointer from integer without a cast [-Wint-conversion]
wcsdup() is part of POSIX.1-2008 and glibc declares it under
__USE_XOPEN2K8, but uClibc-ng only declares it under __USE_GNU. hidapi's
Linux hidraw backend doesn't define _GNU_SOURCE, so wcsdup() is
implicitly declared, which GCC 14 turned into an error. With older
compilers, the returned pointer was silently truncated to int on 64-bit
targets.
Backport the upstream commit moving the wcsdup() declaration under
__USE_XOPEN2K8, which is enabled by default (_DEFAULT_SOURCE) and by
_GNU_SOURCE. This fixes the issue for any package relying on the POSIX
declaration, not only hidapi.
This issue has been present since commit 5eb0203cb05c ("package/gcc: add
version 14.x"), as GCC 14 made implicit function declarations an error
while uClibc-ng has always hidden wcsdup() behind _GNU_SOURCE. It
therefore affects 2024.05 and later, including all maintained branches
(2025.02.x, 2025.11.x, 2026.02.x, 2026.05.x and 2026.08.x).
Fixes:
https://autobuild.buildroot.org/results/eba842f15d96e483e0d16b12028da2ce10dcdeb0
Fixes: 5eb0203cb05c0a65bdb7f89a2644eef7cff2dd27 ("package/gcc: add version 14.x")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
---
...ar.h-declare-wcsdup-for-POSIX.1-2008.patch | 41 +++++++++++++++++++
1 file changed, 41 insertions(+)
create mode 100644 package/uclibc/0007-wchar.h-declare-wcsdup-for-POSIX.1-2008.patch
diff --git a/package/uclibc/0007-wchar.h-declare-wcsdup-for-POSIX.1-2008.patch b/package/uclibc/0007-wchar.h-declare-wcsdup-for-POSIX.1-2008.patch
new file mode 100644
index 0000000000..76c3039a4f
--- /dev/null
+++ b/package/uclibc/0007-wchar.h-declare-wcsdup-for-POSIX.1-2008.patch
@@ -0,0 +1,41 @@
+From 936a08b682e761afba98ef3800265add951201fc Mon Sep 17 00:00:00 2001
+From: Yegor Yefremov <yegorslists@googlemail.com>
+Date: Thu, 22 Oct 2026 13:55:32 +0200
+Subject: [PATCH] wchar.h: declare wcsdup() for POSIX.1-2008
+
+wcsdup() is part of POSIX.1-2008, and glibc declares it under
+__USE_XOPEN2K8, but uClibc-ng only declares it under __USE_GNU.
+
+As a consequence, code that doesn't define _GNU_SOURCE (for example
+hidapi's Linux hidraw backend) gets an implicit declaration of wcsdup().
+With GCC >= 14 this is an error:
+
+ hid.c:116:32: error: implicit declaration of function 'wcsdup'; did you mean 'wcscmp'? [-Wimplicit-function-declaration]
+
+and with older compilers the returned pointer is silently truncated to
+int on 64-bit targets.
+
+Move the declaration under __USE_XOPEN2K8, which is also enabled by
+default (_DEFAULT_SOURCE) and by _GNU_SOURCE.
+
+Assisted-by: Claude:claude-opus-5-5
+Upstream: https://gogs.waldemar-brodkorb.de/oss/uclibc-ng/commit/936a08b682e761afba98ef3800265add951201fc
+Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
+---
+ include/wchar.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/include/wchar.h b/include/wchar.h
+index 2e6ff77c0..0056f93da 100644
+--- a/include/wchar.h
++++ b/include/wchar.h
+@@ -210,7 +210,9 @@ extern size_t wcsxfrm_l (wchar_t *__s1, const wchar_t *__s2,
+ libc_hidden_proto(wcsxfrm_l)
+
+ #endif /* __UCLIBC_HAS_XLOCALE__ */
++#endif
+
++#ifdef __USE_XOPEN2K8
+ /* Duplicate S, returning an identical malloc'd string. */
+ extern wchar_t *wcsdup (const wchar_t *__s) __THROW __attribute_malloc__;
+ #endif
--
2.34.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Buildroot] [PATCH] package/uclibc: declare wcsdup() for POSIX.1-2008
2026-10-24 8:24 [Buildroot] [PATCH] package/uclibc: declare wcsdup() for POSIX.1-2008 Yegor Yefremov via buildroot
@ 2026-10-25 17:38 ` Thomas Petazzoni via buildroot
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-10-25 17:38 UTC (permalink / raw)
To: Yegor Yefremov; +Cc: buildroot
Hello,
On Sat, Oct 24, 2026 at 10:24:24AM +0200, Yegor Yefremov via buildroot wrote:
> +Assisted-by: Claude:claude-opus-5-5
> +Upstream: https://gogs.waldemar-brodkorb.de/oss/uclibc-ng/commit/936a08b682e761afba98ef3800265add951201fc
This link does not work for me, it requires authentication. So I've
replaced it by a link to the github mirror.
Applied with this change. Thanks a lot!
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-25 17:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-24 8:24 [Buildroot] [PATCH] package/uclibc: declare wcsdup() for POSIX.1-2008 Yegor Yefremov via buildroot
2026-10-25 17:38 ` Thomas Petazzoni via buildroot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox