[libcxx-commits] [libcxx] cda43e1 - [libcxx] Fix build for glibc < 2.27 (#121893)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jan 7 12:25:52 PST 2025
Author: Yi Kong
Date: 2025-01-07T12:25:48-08:00
New Revision: cda43e1ba31346966830c01cd12120d884239128
URL: https://github.com/llvm/llvm-project/commit/cda43e1ba31346966830c01cd12120d884239128
DIFF: https://github.com/llvm/llvm-project/commit/cda43e1ba31346966830c01cd12120d884239128.diff
LOG: [libcxx] Fix build for glibc < 2.27 (#121893)
PR #109211 introduced a build break on systems with glibc < 2.27, since
copy_file_range was only introduced after that version. A version check
is added to prevent this breakage.
Added:
Modified:
libcxx/src/filesystem/operations.cpp
Removed:
################################################################################
diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp
index 208a55723d8838..3bb0c7388d9320 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -39,8 +39,16 @@
#include <fcntl.h> /* values for fchmodat */
#include <time.h>
-// since Linux 4.5 and FreeBSD 13, but the Linux libc wrapper is only provided by glibc and musl
-#if (defined(__linux__) && (defined(__GLIBC__) || _LIBCPP_HAS_MUSL_LIBC)) || defined(__FreeBSD__)
+// since Linux 4.5 and FreeBSD 13, but the Linux libc wrapper is only provided by glibc >= 2.27 and musl
+#if defined(__linux__)
+# if defined(_LIBCPP_GLIBC_PREREQ)
+# if _LIBCPP_GLIBC_PREREQ(2, 27)
+# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
+# endif
+# elif _LIBCPP_HAS_MUSL_LIBC
+# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
+# endif
+#elif defined(__FreeBSD__)
# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
#endif
#if __has_include(<sys/sendfile.h>)
More information about the libcxx-commits
mailing list