package/uclibc: declare wcsdup() for POSIX.1-2008
PATCH 1/1 package/uclibc: declare wcsdup() for POSIX.1-2008
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
--- ...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
package/uclibc/0007-wchar.h-declare-wcsdup-for-POSIX.1-2008.patch new file +41 -0
@@ -0,0 +1,41 @@ +From 936a08b682e761afba98ef3800265add951201fc Mon Sep 17 00:00:00 2001 +From: Yegor Yefremov <[email protected]> +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 <[email protected]> +--- + 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
Signature · 6 lines
2.34.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hello,
package/uclibc/0007-wchar.h-declare-wcsdup-for-POSIX.1-2008.patch line 22
Quoted 2 lines · Yegor Yefremov via buildroot
package/uclibc/0007-wchar.h-declare-wcsdup-for-POSIX.1-2008.patch new file +2
-0+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
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Raphaël Mélotte via buildroot
AppliedIn reply of:
Quoted 25 lines
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, sowcsdup()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 hiddenwcsdup()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).
Quoted 6 lines
Fixes:
https://autobuild.buildroot.org/results/eba842f15d96e483e0d16b12028da2ce10dcdeb0Fixes 5eb0203cb05c0a65bdb7f89a2644eef7cff2dd27 ("package/gcc: add version 14.x")Assisted-by Claude:claude-opus-5-5Signed-off-by Yegor Yefremov <[email protected]>
Applied to 2025.02.x, 2026.08.x. Thanks
Quoted 42 lines
--- ...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.patchpackage/uclibc/0007-wchar.h-declare-wcsdup-for-POSIX.1-2008.patch new file +31
-0@@ -0,0 +1,41 @@ +From 936a08b682e761afba98ef3800265add951201fc Mon Sep 17 00:00:00 2001 +From: Yegor Yefremov <[email protected]> +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 <[email protected]> +--- + 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
package/uclibc/0007-wchar.h-declare-wcsdup-for-POSIX.1-2008.patch line 41
Quoted 10 lines
package/uclibc/0007-wchar.h-declare-wcsdup-for-POSIX.1-2008.patch new file +10
-0+@@ -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
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot