[libcxx-commits] [libcxx] [libcxx] Fix build for glibc < 2.27 (PR #121893)
Yi Kong via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jan 7 09:02:58 PST 2025
https://github.com/kongy updated https://github.com/llvm/llvm-project/pull/121893
>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 1/3] [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>)
>From 77205e5355d2d21696980b45d3436c6dd8871038 Mon Sep 17 00:00:00 2001
From: Yi Kong <yikong at google.com>
Date: Wed, 8 Jan 2025 00:54:18 +0800
Subject: [PATCH 2/3] _LIBCPP_GLIBC_PREREQ might not be defined
---
libcxx/src/filesystem/operations.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp
index e68f89ab1e6114..ef8d58e5c63a5c 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -40,7 +40,7 @@
#include <time.h>
// 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__)
+#if (defined(__linux__) && ((defined(_LIBCPP_GLIBC_PREREQ) && _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>)
>From 628bcb082e19f6a8fac75a0384b3c6199ab4a642 Mon Sep 17 00:00:00 2001
From: Yi Kong <yikong at google.com>
Date: Wed, 8 Jan 2025 01:02:28 +0800
Subject: [PATCH 3/3] Apply clang-format
---
libcxx/src/filesystem/operations.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp
index ef8d58e5c63a5c..d954dc6c4c6d6e 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -40,7 +40,9 @@
#include <time.h>
// since Linux 4.5 and FreeBSD 13, but the Linux libc wrapper is only provided by glibc >= 2.27 and musl
-#if (defined(__linux__) && ((defined(_LIBCPP_GLIBC_PREREQ) && _LIBCPP_GLIBC_PREREQ(2, 27)) || _LIBCPP_HAS_MUSL_LIBC)) || defined(__FreeBSD__)
+#if (defined(__linux__) && \
+ ((defined(_LIBCPP_GLIBC_PREREQ) && _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