Skip to content

Commit cda43e1

Browse files
authored
[libcxx] Fix build for glibc < 2.27 (llvm#121893)
PR llvm#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.
1 parent ce33a48 commit cda43e1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

libcxx/src/filesystem/operations.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,16 @@
3939
#include <fcntl.h> /* values for fchmodat */
4040
#include <time.h>
4141

42-
// since Linux 4.5 and FreeBSD 13, but the Linux libc wrapper is only provided by glibc and musl
43-
#if (defined(__linux__) && (defined(__GLIBC__) || _LIBCPP_HAS_MUSL_LIBC)) || defined(__FreeBSD__)
42+
// since Linux 4.5 and FreeBSD 13, but the Linux libc wrapper is only provided by glibc >= 2.27 and musl
43+
#if defined(__linux__)
44+
# if defined(_LIBCPP_GLIBC_PREREQ)
45+
# if _LIBCPP_GLIBC_PREREQ(2, 27)
46+
# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
47+
# endif
48+
# elif _LIBCPP_HAS_MUSL_LIBC
49+
# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
50+
# endif
51+
#elif defined(__FreeBSD__)
4452
# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
4553
#endif
4654
#if __has_include(<sys/sendfile.h>)

0 commit comments

Comments
 (0)