All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bagas Sanjaya <bagasdotme@gmail.com>
To: Buildroot Development <buildroot@buildroot.org>
Cc: Bagas Sanjaya <bagasdotme@gmail.com>,
	Edgar Bonet <bonet@grenoble.cnrs.fr>,
	Brandon Maier <brandon.maier@collins.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Dario Binacchi <dario.binacchi@amarulasolutions.com>,
	Ben Wolsieffer <Ben.Wolsieffer@hefring.com>
Subject: [Buildroot] [PATCH] package/git: fix wchar-less uclibc build
Date: Sun, 20 Oct 2024 16:25:29 +0700	[thread overview]
Message-ID: <20241020092527.734923-3-bagasdotme@gmail.com> (raw)

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

             reply	other threads:[~2024-10-20  9:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-20  9:25 Bagas Sanjaya [this message]
2024-10-28 22:13 ` [Buildroot] [PATCH] package/git: fix wchar-less uclibc build Thomas Petazzoni via buildroot
2024-10-28 22:39   ` Edgar Bonet
2024-10-30  9:55     ` Bagas Sanjaya

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241020092527.734923-3-bagasdotme@gmail.com \
    --to=bagasdotme@gmail.com \
    --cc=Ben.Wolsieffer@hefring.com \
    --cc=bonet@grenoble.cnrs.fr \
    --cc=brandon.maier@collins.com \
    --cc=buildroot@buildroot.org \
    --cc=dario.binacchi@amarulasolutions.com \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.