All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Bagas Sanjaya <bagasdotme@gmail.com>
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: Thu, 17 Oct 2024 15:54:28 +0200	[thread overview]
Message-ID: <ZxEXFI80i4Q_4NJT@pks.im> (raw)
In-Reply-To: <ZxESP0xHV4cK64i0@pks.im>

On Thu, Oct 17, 2024 at 03:33:51PM +0200, Patrick Steinhardt wrote:
> On Thu, Oct 17, 2024 at 10:51:05AM +0700, Bagas Sanjaya wrote:
> > Hi,
> > 
> > Since clar unit testing framework was imported by commit 9b7caa2809cb (t:
> > import the clar unit testing framework, 2024-09-04), Git FTBFS on uclibc
> > systems built by Buildroot:
> 
> Wait a second, that doesn't sound right to me. `wchar_t` is part of ISO
> C90, so any system not supporting it would basically be unsupported by
> us from my point of view. And indeed, uclibc _does_ support that type
> alright. I guess the issue is rather that we're relying on some kind of
> platform-specific behaviour and thus don't include the correct header.
> 
> I'll have a look, thanks for the report!

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);


  reply	other threads:[~2024-10-17 13:54 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 [this message]
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
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=ZxEXFI80i4Q_4NJT@pks.im \
    --to=ps@pks.im \
    --cc=bagasdotme@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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.