Skip to contentSkip to conversation

package/uclibc: fix copy_file_range() declaration without off_t

PATCH In review Yegor Yefremov 2 participants 3 messages Nov 4 – Nov 5

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/uclibc: fix copy_file_range() declaration without off_t

uClibc-ng 1.0.59 declares copy_file_range() in unistd.h under "#ifdef _GNU_SOURCE", while off_t is only defined there for __USE_XOPEN or __USE_XOPEN2K, which <features.h> sets when it is first included. Sources that include a libc header before defining _GNU_SOURCE, typically through an autoconf config.h, therefore hit an undefined type. tpm2-tss does this in its FTDI SPI TCTI, which includes <stdlib.h>, then config.h and, through ftdi.h and usb.h, unistd.h:

  .../sysroot/usr/include/unistd.h:1166:30: error: unknown type name 'off_t'
   1166 | ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned);

Add a patch, submitted upstream, that declares copy_file_range() under __USE_GNU instead, as glibc does.

This issue has been present since commit b94d3eb72854 ("package/uclibc:
bump to 1.0.59"), as copy_file_range() was added in uClibc-ng 1.0.59. It therefore affects 2026.08 and later, 2026.05.x since 2026.05.2 and 2025.02.x since 2025.02.17, where the bump was backported.

Fixes:
https://autobuild.buildroot.org/results/1408ad5881aeff754b0493f1a0d0970d1afdaaf6

Fixes b94d3eb728546aeb196941472b98922843e36279 ("package/uclibc: bump to 1.0.59")
Assisted-by Claude:claude-opus-5-5
---
 ...lare-copy_file_range-under-__USE_GNU.patch | 45 +++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 package/uclibc/0008-unistd.h-declare-copy_file_range-under-__USE_GNU.patch
package/uclibc/0008-unistd.h-declare-copy_file_range-under-__USE_GNU.patch new file +45 -0
new file mode 100644
index 0000000000..6cf0a13eb6
@@ -0,0 +1,45 @@
+From 9cf18aedf41589b11ce5328a85726441d3b86282 Mon Sep 17 00:00:00 2001
+From: Yegor Yefremov <[email protected]>
+Date: Tue, 3 Nov 2026 23:54:41 +0100
+Subject: [PATCH] unistd.h: declare copy_file_range() under __USE_GNU
+
+copy_file_range() is declared under "#ifdef _GNU_SOURCE", but off_t is
+only defined in unistd.h for __USE_XOPEN or __USE_XOPEN2K, which are
+set by <features.h> when it is first included.
+
+When a source file includes another libc header before defining
+_GNU_SOURCE, for example through an autoconf config.h, _GNU_SOURCE is
+defined by the time unistd.h is read, but __USE_XOPEN* are not, so the
+declaration uses an undefined type. This breaks tpm2-tss, which
+includes <stdlib.h>, then config.h and, through ftdi.h and usb.h,
+unistd.h:
+
+  unistd.h:1166:30: error: unknown type name 'off_t'
+   1166 | ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned);
+
+Test __USE_GNU instead, as is done for the other GNU extensions and as
+glibc does.
+
+Assisted-by: Claude:claude-opus-5-5
+Upstream: sent to [email protected] on 2026-11-04, Message-Id <[email protected]>
+Signed-off-by: Yegor Yefremov <[email protected]>
+---
+ include/unistd.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/unistd.h b/include/unistd.h
+index 1956eee18..fb0ea0ff7 100644
+--- a/include/unistd.h
++++ b/include/unistd.h
+@@ -1263,7 +1263,7 @@ extern int getentropy(void *__buf, size_t __len) __nonnull ((1)) __wur;
+ extern __pid_t gettid(void);
+ #endif
+ 
+-#ifdef _GNU_SOURCE
++#ifdef __USE_GNU
+ ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned);
+ #endif
+ 
+-- 
+2.34.1
+
Signature · 6 lines
2.34.1

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

Hi Yegor,

Quoted 50 lines · Yegor Yefremov

uClibc-ng 1.0.59 declares copy_file_range() in unistd.h under "#ifdef _GNU_SOURCE", while off_t is only defined there for __USE_XOPEN or __USE_XOPEN2K, which <features.h> sets when it is first included. Sources that include a libc header before defining _GNU_SOURCE, typically through an autoconf config.h, therefore hit an undefined type. tpm2-tss does this in its FTDI SPI TCTI, which includes <stdlib.h>, then config.h and, through ftdi.h and usb.h, unistd.h:

  .../sysroot/usr/include/unistd.h:1166:30: error: unknown type name 'off_t'
   1166 | ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned);

Add a patch, submitted upstream, that declares copy_file_range() under __USE_GNU instead, as glibc does.

This issue has been present since commit b94d3eb72854 ("package/uclibc:
bump to 1.0.59"), as copy_file_range() was added in uClibc-ng 1.0.59. It therefore affects 2026.08 and later, 2026.05.x since 2026.05.2 and 2025.02.x since 2025.02.17, where the bump was backported.

Fixes:
https://autobuild.buildroot.org/results/1408ad5881aeff754b0493f1a0d0970d1afdaaf6

Fixes b94d3eb728546aeb196941472b98922843e36279 ("package/uclibc: bump to 1.0.59")
Assisted-by Claude:claude-opus-5-5
---
 ...lare-copy_file_range-under-__USE_GNU.patch | 45 +++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 package/uclibc/0008-unistd.h-declare-copy_file_range-under-__USE_GNU.patch
package/uclibc/0008-unistd.h-declare-copy_file_range-under-__USE_GNU.patch new file +14 -0
new file mode 100644
index 0000000000..6cf0a13eb6
@@ -0,0 +1,45 @@
+From 9cf18aedf41589b11ce5328a85726441d3b86282 Mon Sep 17 00:00:00 2001
+From: Yegor Yefremov <[email protected]>
+Date: Tue, 3 Nov 2026 23:54:41 +0100
+Subject: [PATCH] unistd.h: declare copy_file_range() under __USE_GNU
+
+copy_file_range() is declared under "#ifdef _GNU_SOURCE", but off_t is
+only defined in unistd.h for __USE_XOPEN or __USE_XOPEN2K, which are
+set by <features.h> when it is first included.
+
+When a source file includes another libc header before defining
+_GNU_SOURCE, for example through an autoconf config.h, _GNU_SOURCE is
+defined by the time unistd.h is read, but __USE_XOPEN* are not, so the
+declaration uses an undefined type. This breaks tpm2-tss, which
+includes <stdlib.h>, then config.h and, through ftdi.h and usb.h,

package/uclibc/0008-unistd.h-declare-copy_file_range-under-__USE_GNU.patch line 24

Quoted 10 lines
package/uclibc/0008-unistd.h-declare-copy_file_range-under-__USE_GNU.patch new file +10 -0
+unistd.h:
+
+  unistd.h:1166:30: error: unknown type name 'off_t'
+   1166 | ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned);
+
+Test __USE_GNU instead, as is done for the other GNU extensions and as
+glibc does.
+
+Assisted-by: Claude:claude-opus-5-5
+Upstream: sent to [email protected] on 2026-11-04, Message-Id <[email protected]>

Better link to your message in upstream mailing list archive:

https://mailman.openadk.org/mailman3/hyperkitty/list/[email protected]/thread/UXSNFB2SYQEX2ITN3Y7AEQH5PXVPRN5S/

baruch

Quoted 21 lines
package/uclibc/0008-unistd.h-declare-copy_file_range-under-__USE_GNU.patch new file +21 -0
+Signed-off-by: Yegor Yefremov <[email protected]>
+---
+ include/unistd.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/unistd.h b/include/unistd.h
+index 1956eee18..fb0ea0ff7 100644
+--- a/include/unistd.h
++++ b/include/unistd.h
+@@ -1263,7 +1263,7 @@ extern int getentropy(void *__buf, size_t __len) __nonnull ((1)) __wur;
+ extern __pid_t gettid(void);
+ #endif
+ 
+-#ifdef _GNU_SOURCE
++#ifdef __USE_GNU
+ ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned);
+ #endif
+ 
+-- 
+2.34.1
+
Signature · 7 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - [email protected] - tel: +972.52.368.4656, http://www.tkos.co.il -
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

PATCH v2 1/1 package/uclibc: fix copy_file_range() declaration without off_t

In reply to Yegor Yefremov

uClibc-ng 1.0.59 declares copy_file_range() in unistd.h under "#ifdef _GNU_SOURCE", while off_t is only defined there for __USE_XOPEN or __USE_XOPEN2K, which <features.h> sets when it is first included. Sources that include a libc header before defining _GNU_SOURCE, typically through an autoconf config.h, therefore hit an undefined type. tpm2-tss does this in its FTDI SPI TCTI, which includes <stdlib.h>, then config.h and, through ftdi.h and usb.h, unistd.h:

  .../sysroot/usr/include/unistd.h:1166:30: error: unknown type name 'off_t'
   1166 | ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned);

Add a patch, submitted upstream, that declares copy_file_range() under __USE_GNU instead, as glibc does.

This issue has been present since commit b94d3eb72854 ("package/uclibc:
bump to 1.0.59"), as copy_file_range() was added in uClibc-ng 1.0.59. It therefore affects 2026.08 and later, 2026.05.x since 2026.05.2 and 2025.02.x since 2025.02.17, where the bump was backported.

Fixes:
https://autobuild.buildroot.org/results/1408ad5881aeff754b0493f1a0d0970d1afdaaf6

Fixes b94d3eb728546aeb196941472b98922843e36279 ("package/uclibc: bump to 1.0.59")
Assisted-by Claude:claude-opus-5-5

---
Changes v1 -> v2:
- use the mailing list archive link in the Upstream: tag (suggested by Baruch Siach)

 ...lare-copy_file_range-under-__USE_GNU.patch | 45 +++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 package/uclibc/0008-unistd.h-declare-copy_file_range-under-__USE_GNU.patch
package/uclibc/0008-unistd.h-declare-copy_file_range-under-__USE_GNU.patch new file +45 -0
new file mode 100644
index 0000000000..dd821eedfb
@@ -0,0 +1,45 @@
+From 9cf18aedf41589b11ce5328a85726441d3b86282 Mon Sep 17 00:00:00 2001
+From: Yegor Yefremov <[email protected]>
+Date: Tue, 3 Nov 2026 23:54:41 +0100
+Subject: [PATCH] unistd.h: declare copy_file_range() under __USE_GNU
+
+copy_file_range() is declared under "#ifdef _GNU_SOURCE", but off_t is
+only defined in unistd.h for __USE_XOPEN or __USE_XOPEN2K, which are
+set by <features.h> when it is first included.
+
+When a source file includes another libc header before defining
+_GNU_SOURCE, for example through an autoconf config.h, _GNU_SOURCE is
+defined by the time unistd.h is read, but __USE_XOPEN* are not, so the
+declaration uses an undefined type. This breaks tpm2-tss, which
+includes <stdlib.h>, then config.h and, through ftdi.h and usb.h,
+unistd.h:
+
+  unistd.h:1166:30: error: unknown type name 'off_t'
+   1166 | ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned);
+
+Test __USE_GNU instead, as is done for the other GNU extensions and as
+glibc does.
+
+Assisted-by: Claude:claude-opus-5-5
+Upstream: https://mailman.openadk.org/mailman3/hyperkitty/list/[email protected]/thread/UXSNFB2SYQEX2ITN3Y7AEQH5PXVPRN5S/
+Signed-off-by: Yegor Yefremov <[email protected]>
+---
+ include/unistd.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/unistd.h b/include/unistd.h
+index 1956eee18..fb0ea0ff7 100644
+--- a/include/unistd.h
++++ b/include/unistd.h
+@@ -1263,7 +1263,7 @@ extern int getentropy(void *__buf, size_t __len) __nonnull ((1)) __wur;
+ extern __pid_t gettid(void);
+ #endif
+ 
+-#ifdef _GNU_SOURCE
++#ifdef __USE_GNU
+ ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned);
+ #endif
+ 
+-- 
+2.34.1
+
Signature · 6 lines
2.34.1

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