[libcxx-commits] [libcxx] [libcxx] Fix build for glibc < 2.27 (PR #121893)
Yi Kong via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jan 6 23:18:05 PST 2025
https://github.com/kongy created https://github.com/llvm/llvm-project/pull/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.
>From dbaa5feb1269d6be869d2e4ca274a265b6666d6c Mon Sep 17 00:00:00 2001
From: Yi Kong <yikong at google.com>
Date: Tue, 7 Jan 2025 15:13:42 +0800
Subject: [PATCH] [libcxx] Fix build for glibc < 2.27
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.
---
libcxx/src/filesystem/operations.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp
index bd37c5af86f6c3..e68f89ab1e6114 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -39,8 +39,8 @@
#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__) && (_LIBCPP_GLIBC_PREREQ(2, 27) || _LIBCPP_HAS_MUSL_LIBC)) || defined(__FreeBSD__)
# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
#endif
#if __has_include(<sys/sendfile.h>)
More information about the libcxx-commits
mailing list