diff options
author | Yi Kong <yikong@google.com> | 2025-01-08 05:25:48 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-07 12:25:48 -0800 |
commit | cda43e1ba31346966830c01cd12120d884239128 (patch) | |
tree | e4ee22bad9fa009f25e2e1c5191833e0a59a0dde /libcxx/src/filesystem/operations.cpp | |
parent | ce33a48efdd61435e026733315f1ac960774c254 (diff) | |
download | llvm-cda43e1ba31346966830c01cd12120d884239128.zip llvm-cda43e1ba31346966830c01cd12120d884239128.tar.gz llvm-cda43e1ba31346966830c01cd12120d884239128.tar.bz2 |
[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.
Diffstat (limited to 'libcxx/src/filesystem/operations.cpp')
-rw-r--r-- | libcxx/src/filesystem/operations.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp index 208a557..3bb0c738 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>) |