* [Buildroot] [PATCH] package/git: fix wchar-less uclibc build
@ 2024-10-20 9:25 Bagas Sanjaya
2024-10-28 22:13 ` Thomas Petazzoni via buildroot
0 siblings, 1 reply; 4+ messages in thread
From: Bagas Sanjaya @ 2024-10-20 9:25 UTC (permalink / raw)
To: Buildroot Development
Cc: Bagas Sanjaya, Edgar Bonet, Brandon Maier, Thomas Petazzoni,
Dario Binacchi, Ben Wolsieffer
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.
Fixes: https://autobuild.buildroot.org/results/45a1bd9a34c4b0945a07c22338b201908cf45d8c/
Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
---
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/ZxHrIBCdnwdRdXAv@pks.im/
...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
diff --git a/package/git/0001-t-unit-tests-fix-clar-build-for-wchar-less-uclibc.patch b/package/git/0001-t-unit-tests-fix-clar-build-for-wchar-less-uclibc.patch
new file mode 100644
index 0000000000..50e844f5d4
--- /dev/null
+++ b/package/git/0001-t-unit-tests-fix-clar-build-for-wchar-less-uclibc.patch
@@ -0,0 +1,97 @@
+From 3d24a1610bf5a84486c84526ded567a53e10b96f Mon Sep 17 00:00:00 2001
+From: Edgar Bonet <bonet@grenoble.cnrs.fr>
+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/ZxJnfYtuxnAEBc1E@archie.me/
+Signed-off-by: Edgar Bonet <bonet@grenoble.cnrs.fr>
+Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
+---
+ 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
--
An old man doll... just what I always wanted! - Clara
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Buildroot] [PATCH] package/git: fix wchar-less uclibc build
2024-10-20 9:25 [Buildroot] [PATCH] package/git: fix wchar-less uclibc build Bagas Sanjaya
@ 2024-10-28 22:13 ` Thomas Petazzoni via buildroot
2024-10-28 22:39 ` Edgar Bonet
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Petazzoni via buildroot @ 2024-10-28 22:13 UTC (permalink / raw)
To: Bagas Sanjaya
Cc: Buildroot Development, Edgar Bonet, Brandon Maier, Dario Binacchi,
Ben Wolsieffer
Hello,
On Sun, 20 Oct 2024 16:25:29 +0700
Bagas Sanjaya <bagasdotme@gmail.com> wrote:
> diff --git a/package/git/0001-t-unit-tests-fix-clar-build-for-wchar-less-uclibc.patch b/package/git/0001-t-unit-tests-fix-clar-build-for-wchar-less-uclibc.patch
> new file mode 100644
> index 0000000000..50e844f5d4
> --- /dev/null
> +++ b/package/git/0001-t-unit-tests-fix-clar-build-for-wchar-less-uclibc.patch
> @@ -0,0 +1,97 @@
> +From 3d24a1610bf5a84486c84526ded567a53e10b96f Mon Sep 17 00:00:00 2001
> +From: Edgar Bonet <bonet@grenoble.cnrs.fr>
> +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.
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.h
endif
> +
> +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
--
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] 4+ messages in thread
* Re: [Buildroot] [PATCH] package/git: fix wchar-less uclibc build
2024-10-28 22:13 ` Thomas Petazzoni via buildroot
@ 2024-10-28 22:39 ` Edgar Bonet
2024-10-30 9:55 ` Bagas Sanjaya
0 siblings, 1 reply; 4+ messages in thread
From: Edgar Bonet @ 2024-10-28 22:39 UTC (permalink / raw)
To: Thomas Petazzoni, Bagas Sanjaya
Cc: Buildroot Development, Brandon Maier, Dario Binacchi,
Ben Wolsieffer
Hello!
Bagas Sanjaya wrote:
> +Fix the build failure by only using wchar_t when __UCLIBC_HAS_WCHAR__
> +is actually defined.
Thomas Petazzoni replied:
> 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/cover.1729506329.git.ps@pks.im/T/#u
(long thread, search for “uClibc” to see the relevant bits).
Regards,
Edgar Bonet.
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Buildroot] [PATCH] package/git: fix wchar-less uclibc build
2024-10-28 22:39 ` Edgar Bonet
@ 2024-10-30 9:55 ` Bagas Sanjaya
0 siblings, 0 replies; 4+ messages in thread
From: Bagas Sanjaya @ 2024-10-30 9:55 UTC (permalink / raw)
To: Edgar Bonet, Thomas Petazzoni
Cc: Buildroot Development, Brandon Maier, Dario Binacchi,
Ben Wolsieffer
[-- Attachment #1.1: Type: text/plain, Size: 657 bytes --]
On Mon, Oct 28, 2024 at 11:39:49PM +0100, Edgar Bonet wrote:
> Hello!
>
> Bagas Sanjaya wrote:
> > +Fix the build failure by only using wchar_t when __UCLIBC_HAS_WCHAR__
> > +is actually defined.
>
> Thomas Petazzoni replied:
> > 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/cover.1729506329.git.ps@pks.im/T/#u
>
> (long thread, search for “uClibc” to see the relevant bits).
OK, I will pull from upstream instead.
Thanks.
--
An old man doll... just what I always wanted! - Clara
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
[-- Attachment #2: Type: text/plain, Size: 150 bytes --]
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-30 9:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-20 9:25 [Buildroot] [PATCH] package/git: fix wchar-less uclibc build Bagas Sanjaya
2024-10-28 22:13 ` Thomas Petazzoni via buildroot
2024-10-28 22:39 ` Edgar Bonet
2024-10-30 9:55 ` Bagas Sanjaya
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox