| Message ID | 20260514164448.92054-1-chakrabortyshubham66@gmail.com |
|---|---|
| State | Changes Requested |
| Headers | show |
| Series | package/git: Fix build on older glibc | expand |
Hi Shubham, Thank you for this patch! On 14/05/2026 18:44, Shubham Chakraborty wrote: > The build of the 'git' package fails on older Linux toolchains (like > bootlin-aarch64-glibc-old which uses glibc 2.24) with the following > error: > compat/posix.h:159:24: fatal error: sys/random.h: No such file or directory > #include <sys/random.h> > > This happens because Git recently made 'getrandom' the default > CSPRNG_METHOD on Linux, which unconditionally includes <sys/random.h>. > However, this header was only introduced in glibc 2.25. > Fix this by using __has_include to check for the header's existence. > If it's missing, undefine HAVE_GETRANDOM so Git falls back to its > /dev/urandom implementation. > > Command to reproduce: > - ./utils/test-pkg -p git -c git-subtree.config -T bootlin-aarch64-glibc-old > > Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com> > --- > .../git/0001-fix-build-on-older-glibc.patch | 45 +++++++++++++++++++ > 1 file changed, 45 insertions(+) > create mode 100644 package/git/0001-fix-build-on-older-glibc.patch > > diff --git a/package/git/0001-fix-build-on-older-glibc.patch b/package/git/0001-fix-build-on-older-glibc.patch > new file mode 100644 > index 0000000000..b95ca94c23 > --- /dev/null > +++ b/package/git/0001-fix-build-on-older-glibc.patch > @@ -0,0 +1,45 @@ > +From c53f54a87503ae729640a6f12302778a980f84d9 Mon Sep 17 00:00:00 2001 > +From: Shubham Chakraborty <chakrabortyshubham66@gmail.com> > +Date: Thu, 14 May 2026 21:09:07 +0530 > +Subject: [PATCH] compat/posix.h: fix build on older glibc (missing sys/random.h) > + > +The build of the 'git' package fails on older Linux toolchains (like > +bootlin-aarch64-glibc-old which uses glibc 2.24) with the following > +error: > + > +compat/posix.h:159:24: fatal error: sys/random.h: No such file or directory > + > +This happens because Git recently made 'getrandom' the default > +CSPRNG_METHOD on Linux, which unconditionally includes <sys/random.h>. > +However, this header was only introduced in glibc 2.25. > + > +Fix this by using __has_include to check for the header's existence. > +If it's missing, undefine HAVE_GETRANDOM so Git falls back to its > +/dev/urandom implementation. > + > +Upstream: N/A (Buildroot specific fallback) I don't think this should be configured Buildroot specific. Nobody says that git shouldn't work on older platforms. Except of course that we're still on autotools and upstream is moving to meson. And in fact, meson.build already has: elif csprng_backend in ['auto', 'getrandom'] and compiler.has_header_symbol('sys/random.h', 'getrandom', required: csprng_backend == 'getrandom') so I think the proper fix is not to patch anything, but rather to switch to meson as the build system. Regards, Arnout > +Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com> > +--- > + compat/posix.h | 7 +++++++ > + 1 file changed, 7 insertions(+) > + > +diff --git a/compat/posix.h b/compat/posix.h > +index faaae1b..1632221 100644 > +--- a/compat/posix.h > ++++ b/compat/posix.h > +@@ -155,6 +155,13 @@ > + #ifdef HAVE_ARC4RANDOM_LIBBSD > + #include <bsd/stdlib.h> > + #endif > ++#if defined(HAVE_GETRANDOM) && defined(__linux__) > ++# if defined(__has_include) > ++# if !__has_include(<sys/random.h>) > ++# undef HAVE_GETRANDOM > ++# endif > ++# endif > ++#endif > + #ifdef HAVE_GETRANDOM > + #include <sys/random.h> > + #endif > +-- > +2.54.0
diff --git a/package/git/0001-fix-build-on-older-glibc.patch b/package/git/0001-fix-build-on-older-glibc.patch new file mode 100644 index 0000000000..b95ca94c23 --- /dev/null +++ b/package/git/0001-fix-build-on-older-glibc.patch @@ -0,0 +1,45 @@ +From c53f54a87503ae729640a6f12302778a980f84d9 Mon Sep 17 00:00:00 2001 +From: Shubham Chakraborty <chakrabortyshubham66@gmail.com> +Date: Thu, 14 May 2026 21:09:07 +0530 +Subject: [PATCH] compat/posix.h: fix build on older glibc (missing sys/random.h) + +The build of the 'git' package fails on older Linux toolchains (like +bootlin-aarch64-glibc-old which uses glibc 2.24) with the following +error: + +compat/posix.h:159:24: fatal error: sys/random.h: No such file or directory + +This happens because Git recently made 'getrandom' the default +CSPRNG_METHOD on Linux, which unconditionally includes <sys/random.h>. +However, this header was only introduced in glibc 2.25. + +Fix this by using __has_include to check for the header's existence. +If it's missing, undefine HAVE_GETRANDOM so Git falls back to its +/dev/urandom implementation. + +Upstream: N/A (Buildroot specific fallback) +Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com> +--- + compat/posix.h | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/compat/posix.h b/compat/posix.h +index faaae1b..1632221 100644 +--- a/compat/posix.h ++++ b/compat/posix.h +@@ -155,6 +155,13 @@ + #ifdef HAVE_ARC4RANDOM_LIBBSD + #include <bsd/stdlib.h> + #endif ++#if defined(HAVE_GETRANDOM) && defined(__linux__) ++# if defined(__has_include) ++# if !__has_include(<sys/random.h>) ++# undef HAVE_GETRANDOM ++# endif ++# endif ++#endif + #ifdef HAVE_GETRANDOM + #include <sys/random.h> + #endif +-- +2.54.0
The build of the 'git' package fails on older Linux toolchains (like bootlin-aarch64-glibc-old which uses glibc 2.24) with the following error: compat/posix.h:159:24: fatal error: sys/random.h: No such file or directory #include <sys/random.h> This happens because Git recently made 'getrandom' the default CSPRNG_METHOD on Linux, which unconditionally includes <sys/random.h>. However, this header was only introduced in glibc 2.25. Fix this by using __has_include to check for the header's existence. If it's missing, undefine HAVE_GETRANDOM so Git falls back to its /dev/urandom implementation. Command to reproduce: - ./utils/test-pkg -p git -c git-subtree.config -T bootlin-aarch64-glibc-old Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com> --- .../git/0001-fix-build-on-older-glibc.patch | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 package/git/0001-fix-build-on-older-glibc.patch