git: 55e2bfab4485 - stable/14 - tools/build: Support building with glibc 2.38
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 19 Feb 2024 16:45:07 UTC
The branch stable/14 has been updated by andrew:
URL: https://cgit.FreeBSD.org/src/commit/?id=55e2bfab448589d29cbd09bd97643a46a9735064
commit 55e2bfab448589d29cbd09bd97643a46a9735064
Author: Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2023-10-20 15:45:06 +0000
Commit: Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2024-02-19 13:11:00 +0000
tools/build: Support building with glibc 2.38
Ubuntu 23.10 uses glibc 2.38. This adds strlcpy and strlcmp so we need
to remove them from the cross build environment.
Reviewed by: jrtc27 (earlier version), arichardson
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D42303
(cherry picked from commit ceefd491c7f0490515fadca2f3740cb24e3f449e)
---
tools/build/Makefile | 10 ++++++++--
tools/build/cross-build/include/linux/string.h | 3 +++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/tools/build/Makefile b/tools/build/Makefile
index 92f7d396825c..aff664f2a68b 100644
--- a/tools/build/Makefile
+++ b/tools/build/Makefile
@@ -194,9 +194,15 @@ SRCS+= strtonum.c merge.c heapsort.c reallocf.c
SRCS+= rpmatch.c
.if ${.MAKE.OS} == "Linux"
-# On Linux, glibc does not provide strlcpy,strlcat or strmode.
+# On Linux, glibc does not provide strmode. It only provides strlcpy
+# and strlcat from glibc 2.38.
.PATH: ${LIBC_SRCTOP}/string
-SRCS+= strlcpy.c strlcat.c strmode.c
+SRCS+= strmode.c
+# Assume if strlcpy exists so does strlcat
+_WITH_EXPLICIT_STRLCPY!= cat ${HOST_INCLUDE_ROOT}/strings.h ${HOST_INCLUDE_ROOT}/string.h | grep -c strlcpy || true
+.if ${_WITH_EXPLICIT_STRLCPY} == 0
+SRCS+= strlcpy.c strlcat.c
+.endif
# On Linux, glibc provides ffs* but not fls*
SRCS+= fls.c flsl.c flsll.c
# Compile the fgetln/fgetwln/closefrom fallback code from libbsd:
diff --git a/tools/build/cross-build/include/linux/string.h b/tools/build/cross-build/include/linux/string.h
index 87347df1e9bf..8fac9e0fe083 100644
--- a/tools/build/cross-build/include/linux/string.h
+++ b/tools/build/cross-build/include/linux/string.h
@@ -47,8 +47,11 @@
#include <sys/cdefs.h>
__BEGIN_DECLS
+#if !defined(__GLIBC__) || \
+ (defined(__GLIBC__) && (!__GLIBC_PREREQ(2, 38) || !defined(_GNU_SOURCE)))
size_t strlcpy(char *dst, const char *src, size_t siz);
size_t strlcat(char *dst, const char *src, size_t siz);
+#endif
char *strnstr(const char *str, const char *find, size_t str_len);
void strmode(mode_t mode, char *str);