Skip to content

Commit 55fe8ca

Browse files
committed
fix bionic and no-locale config
Signed-off-by: Jannik Glückert <[email protected]>
1 parent 79185fd commit 55fe8ca

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

libcxx/src/filesystem/operations.cpp

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

41-
// since Linux 4.5 and FreeBSD 13
42-
#if defined(__linux__) || defined(__FreeBSD__)
41+
// since Linux 4.5 and FreeBSD 13, but the Linux libc wrapper is only provided by glibc and musl
42+
#if (defined(__linux__) && (defined(__GLIBC__) || _LIBCPP_HAS_MUSL_LIBC)) || defined(__FreeBSD__)
4343
# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
4444
#endif
4545
#if __has_include(<sys/sendfile.h>)
@@ -54,8 +54,9 @@
5454

5555
// sendfile and copy_file_range need to fall back
5656
// to the fstream implementation for special files
57-
#if defined(_LIBCPP_FILESYSTEM_USE_SENDFILE) || defined(_LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE) || \
58-
defined(_LIBCPP_FILESYSTEM_USE_FSTREAM)
57+
#if (defined(_LIBCPP_FILESYSTEM_USE_SENDFILE) || defined(_LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE) || \
58+
defined(_LIBCPP_FILESYSTEM_USE_FSTREAM)) && \
59+
_LIBCPP_HAS_LOCALIZATION
5960
# include <fstream>
6061
# define _LIBCPP_FILESYSTEM_NEED_FSTREAM
6162
#endif
@@ -316,7 +317,12 @@ bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_cod
316317
ec.clear();
317318
# endif
318319

320+
# if defined(_LIBCPP_FILESYSTEM_NEED_FSTREAM)
319321
return copy_file_impl_fstream(read_fd, write_fd, ec);
322+
# else
323+
// since iostreams are unavailable in the no-locale build, just fail after a failed sendfile
324+
return false;
325+
# endif
320326
}
321327
#elif defined(_LIBCPP_FILESYSTEM_USE_COPYFILE)
322328
bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {

0 commit comments

Comments
 (0)