Skip to content

Commit

Permalink
[libcxx] Fix build for glibc < 2.27 (llvm#121893)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kongy authored Jan 7, 2025
1 parent ce33a48 commit cda43e1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions libcxx/src/filesystem/operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>)
Expand Down

0 comments on commit cda43e1

Please sign in to comment.