Skip to contentSkip to conversation

package/git: require wchar support

PATCH In review Bagas Sanjaya 3 participants 4 messages Oct 18, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/git: require wchar support

Git version 2.47.0 fails to build on systems without wide characters support (e.g. uClibc-ng 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 git now imports clar unit testing framework since upstream commit 9b7caa2809cb (t: import the clar unit testing framework, 2024-09-04).

From upstream discussion [1], git requires toolchains with full ISO C99 support (including wchar). As such, depend the package on toolchain's wchar support (BR2_USE_WCHAR).

[1]: https://lore.kernel.org/git/[email protected]/t/#u

---
 package/git/Config.in | 5 +++++
 1 file changed, 5 insertions(+)
package/git/Config.in +5 -0
index d53921d7d5..a8ae5f59bf 100644
@@ -1,6 +1,7 @@
 config BR2_PACKAGE_GIT
 	bool "git"
 	depends on BR2_USE_MMU # uses fork()
+	depends on BR2_USE_WCHAR # clar unit test
 	select BR2_PACKAGE_ZLIB
 	select BR2_PACKAGE_LIBICONV if !BR2_ENABLE_LOCALE
 	help
@@ -9,3 +10,7 @@ config BR2_PACKAGE_GIT
 	  projects.
 
 	  http://git-scm.com
+
+comment "git needs a toolchain w/ wchar"
+	depends on BR2_USE_MMU
+	depends on !BR2_USE_WCHAR

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
#1 lore raw

Hi Bagas,

Quoted 44 lines · Bagas Sanjaya

Git version 2.47.0 fails to build on systems without wide characters support (e.g. uClibc-ng 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 git now imports clar unit testing framework since upstream commit 9b7caa2809cb (t: import the clar unit testing framework, 2024-09-04).

Quoted 5 lines

From upstream discussion [1], git requires toolchains with full ISO C99 support (including wchar). As such, depend the package on toolchain's wchar support (BR2_USE_WCHAR).

[1]: https://lore.kernel.org/git/[email protected]/t/#u

I sent a patch last week that did this same change! Thomas Petazzoni reviewed it and had some comments I haven't had time to address. If you want to address those in your patch, I'd be happy to drop mine.

Thomas comments were:

You need to look at reverse dependencies that "select BR2_PACKAGE_GIT" and propagate this wchar dependency. For example package/git-crypt/ will need it. And also the reverse dependencies of the reverse dependencies, if any;

Did you look at a way of disabling building the test suite? I very quickly glanced through the git Makefile, and it didn't seem like there was such a possibility. But if there was such a possibility, it would be an alternative solution to the addition of the wchar dependency.

My patch: https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

Thanks!
Brandon Maier

Quoted 27 lines
---
 package/git/Config.in | 5 +++++
 1 file changed, 5 insertions(+)
package/git/Config.in +5 -0
index d53921d7d5..a8ae5f59bf 100644
@@ -1,6 +1,7 @@
 config BR2_PACKAGE_GIT
 	bool "git"
 	depends on BR2_USE_MMU # uses fork()
+	depends on BR2_USE_WCHAR # clar unit test
 	select BR2_PACKAGE_ZLIB
 	select BR2_PACKAGE_LIBICONV if !BR2_ENABLE_LOCALE
 	help
@@ -9,3 +10,7 @@ config BR2_PACKAGE_GIT
 	  projects.
 
 	  http://git-scm.com
+
+comment "git needs a toolchain w/ wchar"
+	depends on BR2_USE_MMU
+	depends on !BR2_USE_WCHAR
Quoted 1 line

base-commit: 0ad7035fce67cbe91db9dea7d81e6a4bc0691ad1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw

Hello!

Quoted 7 lines · Bagas Sanjaya

Git version 2.47.0 fails to build on systems without wide characters support (e.g. uClibc-ng without BR2_TOOLCHAIN_BUILDROOT_WCHAR selected): [...] From upstream discussion [1], git requires toolchains with full ISO C99 support (including wchar). As such, depend the package on toolchain's wchar support (BR2_USE_WCHAR).

[1] https://lore.kernel.org/git/[email protected]/t/#u

Brandon Maier replied:

Quoted 2 lines

I sent a patch last week that did this same change! Thomas Petazzoni reviewed it and had some comments I haven't had time to address. [...]

I took a look at the issue, and here is what I found:

1. There is no obvious way to disable building the git test suite.

2. uClibc always installs wchar.h in sysroot, although this file is a stub if wchar support is disabled.

3. Patrick Steinhardt proposed a patch in the git mailing list[1] that would make git compatible with wchar-less uClibc. This patch, however, won't work for us for a couple of reasons:

* It doesn't apply on 2.47.0.

* It assumes that, when using uClibc, __UCLIBC__ should be defined *before* the first #include, which is not the case.

Below is a version of Patrick Steinhardt's patch that seems to work on Buildroot/master.

Regards,

Edgar.

[1] https://lore.kernel.org/git/[email protected]/

------------------------------------------------------------------ >8 --

t/unit-tests/clar/clar.c +9 -0
index cef0f023c2..6de0b415b1 100644
@@ -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);

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw
In reply to Brandon Maier via buildroot
Quoted 11 lines · Brandon Maier

I sent a patch last week that did this same change! Thomas Petazzoni reviewed it and had some comments I haven't had time to address. If you want to address those in your patch, I'd be happy to drop mine.

Thomas comments were:

You need to look at reverse dependencies that "select BR2_PACKAGE_GIT" and propagate this wchar dependency. For example package/git-crypt/ will need it. And also the reverse dependencies of the reverse dependencies, if any;

Quoted 7 lines

Did you look at a way of disabling building the test suite? I very quickly glanced through the git Makefile, and it didn't seem like there was such a possibility. But if there was such a possibility, it would be an alternative solution to the addition of the wchar dependency.

My patch: https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

Oops! I didn't see that.

Thanks anyway.

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