From: Bagas Sanjaya <bagasdotme@gmail.com>
To: Patrick Steinhardt <ps@pks.im>, Edgar Bonet <bonet@grenoble.cnrs.fr>
Cc: Git Mailing List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: clar unit testing framework FTBFS on uclibc systems (wchar_t unsupported)
Date: Fri, 18 Oct 2024 20:49:49 +0700 [thread overview]
Message-ID: <ZxJnfYtuxnAEBc1E@archie.me> (raw)
In-Reply-To: <ZxEXFI80i4Q_4NJT@pks.im>
[-- Attachment #1: Type: text/plain, Size: 3245 bytes --]
On Thu, Oct 17, 2024 at 03:54:28PM +0200, Patrick Steinhardt wrote:
> Okay, uclibc indeed has _optional_ support for `wchar_t`. But what
> really throws me off: "include/wchar.h" from uclibc has the following
> snippet right at the top:
>
> #ifndef __UCLIBC_HAS_WCHAR__
> #error Attempted to include wchar.h when uClibc built without wide char support.
> #endif
>
> We unconditionally include <wchar.h>, and your system does not seem to
> have support for it built in. So why doesn't the `#error` trigger? It's
> also not like this is a recent error, it has been added with 581deed72
> (The obligatory forgotten files..., 2002-05-06).
>
> We can do something like the below patch in clar, but I'd first like to
> understand why your platform seems to be broken in such a way.
>
> Patrick
>
> diff --git a/clar.c b/clar.c
> index 64879cf..06fe3d1 100644
> --- a/clar.c
> +++ b/clar.c
> @@ -9,6 +9,11 @@
> #define _DARWIN_C_SOURCE
> #define _DEFAULT_SOURCE
>
> +#if defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_WCHAR__)
> +#else
> +# define HAVE_WCHAR
> +#endif
> +
> #include <errno.h>
> #include <setjmp.h>
> #include <stdlib.h>
> @@ -16,7 +21,9 @@
> #include <string.h>
> #include <math.h>
> #include <stdarg.h>
> +#ifdef HAVE_WCHAR
> #include <wchar.h>
> +#endif
> #include <time.h>
> #include <inttypes.h>
>
> @@ -766,6 +773,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 *);
> @@ -801,6 +809,7 @@ void clar__assert_equal(
> }
> }
> }
> +#endif // HAVE_WCHAR
> else if (!strcmp("%"PRIuMAX, fmt) || !strcmp("%"PRIxMAX, fmt)) {
> uintmax_t sz1 = va_arg(args, uintmax_t), sz2 = va_arg(args, uintmax_t);
> is_equal = (sz1 == sz2);
>
Hi,
On Buildroot site, Edgar Bonet (Cc:'ed) suggests to improve your patch by
wrapping strcmps [1]:
---- >8 ----
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);
Thanks.
[1]: https://lore.kernel.org/buildroot/f517190c-6fcd-4101-afa6-f6ea521feb9e@grenoble.cnrs.fr/
--
An old man doll... just what I always wanted! - Clara
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2024-10-18 13:49 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-17 3:51 clar unit testing framework FTBFS on uclibc systems (wchar_t unsupported) Bagas Sanjaya
2024-10-17 13:33 ` Patrick Steinhardt
2024-10-17 13:54 ` Patrick Steinhardt
2024-10-17 20:08 ` Taylor Blau
2024-10-17 22:21 ` brian m. carlson
2024-10-18 4:51 ` Jeff King
2024-10-18 4:59 ` Patrick Steinhardt
2024-10-18 5:24 ` Jeff King
2024-10-18 5:31 ` Patrick Steinhardt
2024-10-18 20:50 ` Taylor Blau
2024-10-21 6:44 ` Patrick Steinhardt
2024-10-21 19:30 ` Jeff King
2024-10-21 19:41 ` Taylor Blau
2024-10-18 20:07 ` brian m. carlson
2024-10-21 19:19 ` Jeff King
2024-10-21 19:31 ` Jeff King
2024-10-18 13:49 ` Bagas Sanjaya [this message]
2024-10-21 6:44 ` Patrick Steinhardt
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=ZxJnfYtuxnAEBc1E@archie.me \
--to=bagasdotme@gmail.com \
--cc=bonet@grenoble.cnrs.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ps@pks.im \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).