package/git: fix wchar-less uclibc build
PATCH 1/1 package/git: fix wchar-less uclibc build
The package fails to build on wchar-less uClibc-ng configuration (i.e. without BR2_TOOLCHAIN_BUILDROOT_WCHAR selected):
```
CC t/unit-tests/unit-test.o
t/unit-tests/clar/clar.c: In function 'clar__assert_equal':
t/unit-tests/clar/clar.c:767:23: error: unknown type name 'wchar_t'
767 | const wchar_t *wcs1 = va_arg(args, const wchar_t *);
| ^~~~~~~
In file included from t/unit-tests/clar/clar.c:13:
t/unit-tests/clar/clar.c:767:58: error: unknown type name 'wchar_t'
767 | const wchar_t *wcs1 = va_arg(args, const wchar_t *);
| ^~~~~~~
t/unit-tests/clar/clar.c:768:23: error: unknown type name 'wchar_t'
768 | const wchar_t *wcs2 = va_arg(args, const wchar_t *);
| ^~~~~~~
t/unit-tests/clar/clar.c:768:58: error: unknown type name 'wchar_t'
768 | const wchar_t *wcs2 = va_arg(args, const wchar_t *);
| ^~~~~~~
t/unit-tests/clar/clar.c:769:65: warning: implicit declaration of function 'wcscmp' [-Wimplicit-function-declaration]
769 | is_equal = (!wcs1 || !wcs2) ? (wcs1 == wcs2) : !wcscmp(wcs1, wcs2);
| ^~~~~~
t/unit-tests/clar/clar.c:784:23: error: unknown type name 'wchar_t'
784 | const wchar_t *wcs1 = va_arg(args, const wchar_t *);
| ^~~~~~~
t/unit-tests/clar/clar.c:784:58: error: unknown type name 'wchar_t'
784 | const wchar_t *wcs1 = va_arg(args, const wchar_t *);
| ^~~~~~~
t/unit-tests/clar/clar.c:785:23: error: unknown type name 'wchar_t'
785 | const wchar_t *wcs2 = va_arg(args, const wchar_t *);
| ^~~~~~~
t/unit-tests/clar/clar.c:785:58: error: unknown type name 'wchar_t'
785 | const wchar_t *wcs2 = va_arg(args, const wchar_t *);
| ^~~~~~~
t/unit-tests/clar/clar.c:787:65: warning: implicit declaration of function 'wcsncmp' [-Wimplicit-function-declaration]
787 | is_equal = (!wcs1 || !wcs2) ? (wcs1 == wcs2) : !wcsncmp(wcs1, wcs2, len);
| ^~~~~~~
make[1]: *** [Makefile:2795: t/unit-tests/clar/clar.o] Error 1
```This is because since version 2.47.0, Git imports clar unit testing framework, which uses wchar_t. On wchar-less uClibc-ng configuration, however, the installed <wchar.h> header is a stub (that is, wchar_t is undefined).
Fix the build failure by only using wchar_t when __UCLIBC_HAS_WCHAR__ is actually defined.
---
From upstream discussion [1], it seems like wchar-less uclibc config is broken and needs to be fixed in uclibc-ng proper. Cc'ing Waldemar.
[1]: https://lore.kernel.org/git/[email protected]/
...fix-clar-build-for-wchar-less-uclibc.patch | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 package/git/0001-t-unit-tests-fix-clar-build-for-wchar-less-uclibc.patch
package/git/0001-t-unit-tests-fix-clar-build-for-wchar-less-uclibc.patch new file +97 -0
@@ -0,0 +1,97 @@ +From 3d24a1610bf5a84486c84526ded567a53e10b96f Mon Sep 17 00:00:00 2001 +From: Edgar Bonet <[email protected]> +Date: Fri, 18 Oct 2024 14:59:48 +0200 +Subject: [PATCH] t/unit-tests: fix clar build for wchar-less uclibc + +Git fails to build on uclibc systems without wchar support: + +``` + CC t/unit-tests/unit-test.o +t/unit-tests/clar/clar.c: In function 'clar__assert_equal': +t/unit-tests/clar/clar.c:767:23: error: unknown type name 'wchar_t' + 767 | const wchar_t *wcs1 = va_arg(args, const wchar_t *); + | ^~~~~~~ +In file included from t/unit-tests/clar/clar.c:13: +t/unit-tests/clar/clar.c:767:58: error: unknown type name 'wchar_t' + 767 | const wchar_t *wcs1 = va_arg(args, const wchar_t *); + | ^~~~~~~ +t/unit-tests/clar/clar.c:768:23: error: unknown type name 'wchar_t' + 768 | const wchar_t *wcs2 = va_arg(args, const wchar_t *); + | ^~~~~~~ +t/unit-tests/clar/clar.c:768:58: error: unknown type name 'wchar_t' + 768 | const wchar_t *wcs2 = va_arg(args, const wchar_t *); + | ^~~~~~~ +t/unit-tests/clar/clar.c:769:65: warning: implicit declaration of function 'wcscmp' [-Wimplicit-function-declaration] + 769 | is_equal = (!wcs1 || !wcs2) ? (wcs1 == wcs2) : !wcscmp(wcs1, wcs2); + | ^~~~~~ +t/unit-tests/clar/clar.c:784:23: error: unknown type name 'wchar_t' + 784 | const wchar_t *wcs1 = va_arg(args, const wchar_t *); + | ^~~~~~~ +t/unit-tests/clar/clar.c:784:58: error: unknown type name 'wchar_t' + 784 | const wchar_t *wcs1 = va_arg(args, const wchar_t *); + | ^~~~~~~ +t/unit-tests/clar/clar.c:785:23: error: unknown type name 'wchar_t' + 785 | const wchar_t *wcs2 = va_arg(args, const wchar_t *); + | ^~~~~~~ +t/unit-tests/clar/clar.c:785:58: error: unknown type name 'wchar_t' + 785 | const wchar_t *wcs2 = va_arg(args, const wchar_t *); + | ^~~~~~~ +t/unit-tests/clar/clar.c:787:65: warning: implicit declaration of function 'wcsncmp' [-Wimplicit-function-declaration] + 787 | is_equal = (!wcs1 || !wcs2) ? (wcs1 == wcs2) : !wcsncmp(wcs1, wcs2, len); + | ^~~~~~~ +make[1]: *** [Makefile:2795: t/unit-tests/clar/clar.o] Error 1 +``` + +This is because on these systems, although there is #error macro +in uclibc source when __UCLIBC_HAS_WCHAR__ is not defined, somehow +the #error doesn't get triggered when wchar_t is used in clar. + +Fix the build failure by only using wchar_t when __UCLIBC_HAS_WCHAR__ +is actually defined. + +Upstream: https://lore.kernel.org/git/[email protected]/ +Signed-off-by: Edgar Bonet <[email protected]> +Signed-off-by: Bagas Sanjaya <[email protected]> +--- + t/unit-tests/clar/clar.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/t/unit-tests/clar/clar.c b/t/unit-tests/clar/clar.c +index cef0f023c2..6de0b415b1 100644 +--- a/t/unit-tests/clar/clar.c ++++ b/t/unit-tests/clar/clar.c +@@ -18,6 +18,13 @@ + #include <sys/types.h> + #include <sys/stat.h> + ++#if defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_WCHAR__) ++ /* uClibc can be built without wchar support, in which case the ++ installed <wchar.h> is a stub that does not define wchar_t. */ ++#else ++# define HAVE_WCHAR ++#endif ++ + #ifdef _WIN32 + # define WIN32_LEAN_AND_MEAN + # include <windows.h> +@@ -763,6 +770,7 @@ void clar__assert_equal( + } + } + } ++#ifdef HAVE_WCHAR + else if (!strcmp("%ls", fmt)) { + const wchar_t *wcs1 = va_arg(args, const wchar_t *); + const wchar_t *wcs2 = va_arg(args, const wchar_t *); +@@ -798,6 +806,7 @@ void clar__assert_equal( + } + } + } ++#endif // HAVE_WCHAR + else if (!strcmp("%"PRIuZ, fmt) || !strcmp("%"PRIxZ, fmt)) { + size_t sz1 = va_arg(args, size_t), sz2 = va_arg(args, size_t); + is_equal = (sz1 == sz2); + +base-commit: 777489f9e09c8d0dd6b12f9d90de6376330577a2 +-- +An old man doll... just what I always wanted! - Clara +
base-commit: 0ad7035fce67cbe91db9dea7d81e6a4bc0691ad1
Signature · 6 lines
An old man doll... just what I always wanted! - Clara _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hello,
Quoted 43 lines · On Sun, 20 Oct 2024 16:25:29 +0700 Bagas Sanjaya <[email protected]> wrote:
package/git/0001-t-unit-tests-fix-clar-build-for-wchar-less-uclibc.patch new file +37
-0@@ -0,0 +1,97 @@ +From 3d24a1610bf5a84486c84526ded567a53e10b96f Mon Sep 17 00:00:00 2001 +From: Edgar Bonet <[email protected]> +Date: Fri, 18 Oct 2024 14:59:48 +0200 +Subject: [PATCH] t/unit-tests: fix clar build for wchar-less uclibc + +Git fails to build on uclibc systems without wchar support: + +``` + CC t/unit-tests/unit-test.o +t/unit-tests/clar/clar.c: In function 'clar__assert_equal': +t/unit-tests/clar/clar.c:767:23: error: unknown type name 'wchar_t' + 767 | const wchar_t *wcs1 = va_arg(args, const wchar_t *); + | ^~~~~~~ +In file included from t/unit-tests/clar/clar.c:13: +t/unit-tests/clar/clar.c:767:58: error: unknown type name 'wchar_t' + 767 | const wchar_t *wcs1 = va_arg(args, const wchar_t *); + | ^~~~~~~ +t/unit-tests/clar/clar.c:768:23: error: unknown type name 'wchar_t' + 768 | const wchar_t *wcs2 = va_arg(args, const wchar_t *); + | ^~~~~~~ +t/unit-tests/clar/clar.c:768:58: error: unknown type name 'wchar_t' + 768 | const wchar_t *wcs2 = va_arg(args, const wchar_t *); + | ^~~~~~~ +t/unit-tests/clar/clar.c:769:65: warning: implicit declaration of function 'wcscmp' [-Wimplicit-function-declaration] + 769 | is_equal = (!wcs1 || !wcs2) ? (wcs1 == wcs2) : !wcscmp(wcs1, wcs2); + | ^~~~~~ +t/unit-tests/clar/clar.c:784:23: error: unknown type name 'wchar_t' + 784 | const wchar_t *wcs1 = va_arg(args, const wchar_t *); + | ^~~~~~~ +t/unit-tests/clar/clar.c:784:58: error: unknown type name 'wchar_t' + 784 | const wchar_t *wcs1 = va_arg(args, const wchar_t *); + | ^~~~~~~ +t/unit-tests/clar/clar.c:785:23: error: unknown type name 'wchar_t' + 785 | const wchar_t *wcs2 = va_arg(args, const wchar_t *); + | ^~~~~~~ +t/unit-tests/clar/clar.c:785:58: error: unknown type name 'wchar_t' + 785 | const wchar_t *wcs2 = va_arg(args, const wchar_t *);
package/git/0001-t-unit-tests-fix-clar-build-for-wchar-less-uclibc.patch line 47
Quoted 10 lines
package/git/0001-t-unit-tests-fix-clar-build-for-wchar-less-uclibc.patch new file +10
-0+ | ^~~~~~~ +t/unit-tests/clar/clar.c:787:65: warning: implicit declaration of function 'wcsncmp' [-Wimplicit-function-declaration] + 787 | is_equal = (!wcs1 || !wcs2) ? (wcs1 == wcs2) : !wcsncmp(wcs1, wcs2, len); + | ^~~~~~~ +make[1]: *** [Makefile:2795: t/unit-tests/clar/clar.o] Error 1 +``` + +This is because on these systems, although there is #error macro +in uclibc source when __UCLIBC_HAS_WCHAR__ is not defined, somehow +the #error doesn't get triggered when wchar_t is used in clar.
When wchar support is disabled in uClibc, the wchar.h file that gets installed is ./include/wchar-stub.h, and it doesn't have any #error. See in the uClibc Makefile:
ifeq ($(UCLIBC_HAS_WCHAR),)
$(Q)cd $(PREFIX)$(DEVEL_PREFIX)include && mv -f wchar-stub.h wchar.h
else
$(Q)cd $(PREFIX)$(DEVEL_PREFIX)include && $(RM) -f wchar-stub.hendif
package/git/0001-t-unit-tests-fix-clar-build-for-wchar-less-uclibc.patch line 50
Quoted 3 lines
package/git/0001-t-unit-tests-fix-clar-build-for-wchar-less-uclibc.patch new file +3
-0+ +Fix the build failure by only using wchar_t when __UCLIBC_HAS_WCHAR__ +is actually defined.
The solution isn't really nice, because it adds some uClibc specific logic. Isn't there some configure.ac logic that runs to properly detect the availability of wchar?
Otherwise, we could also make git depend on wchar, and be done with it.
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
Hello!
package/git/0001-t-unit-tests-fix-clar-build-for-wchar-less-uclibc.patch line 50
Quoted 2 lines · Bagas Sanjaya
package/git/0001-t-unit-tests-fix-clar-build-for-wchar-less-uclibc.patch new file +2
-0+Fix the build failure by only using wchar_t when __UCLIBC_HAS_WCHAR__ +is actually defined.
Thomas Petazzoni replied:
Quoted 2 lines
The solution isn't really nice, because it adds some uClibc specific logic.
Indeed. Note, however, that the patch is making its way upstream:
https://lore.kernel.org/git/[email protected]/T/#u
(long thread, search for “uClibc” to see the relevant bits).
Regards,
Edgar Bonet.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 7 lines · Edgar Bonet
Hello!
package/git/0001-t-unit-tests-fix-clar-build-for-wchar-less-uclibc.patch line 50
Quoted 2 lines · Bagas Sanjaya
package/git/0001-t-unit-tests-fix-clar-build-for-wchar-less-uclibc.patch new file +2
-0+Fix the build failure by only using wchar_t when __UCLIBC_HAS_WCHAR__ +is actually defined.Thomas Petazzoni replied:
Quoted 8 lines
Quoted 2 lines
The solution isn't really nice, because it adds some uClibc specific logic.
Indeed. Note, however, that the patch is making its way upstream:
https://lore.kernel.org/git/[email protected]/T/#u(long thread, search for “uClibc” to see the relevant bits).
OK, I will pull from upstream instead.
Thanks.
Signature · 1 line
An old man doll... just what I always wanted! - Clara
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot