Index: llvm/lib/Support/Unix/Path.inc =================================================================== --- llvm/lib/Support/Unix/Path.inc +++ llvm/lib/Support/Unix/Path.inc @@ -1075,14 +1075,19 @@ Expected readNativeFileSlice(file_t FD, MutableArrayRef Buf, uint64_t Offset) { +#if defined(__APPLE__) + size_t Size = Buf.size() < INT32_MAX ? Buf.size() : INT32_MAX; +#else + size_t Size = Buf.size(); +#endif #ifdef HAVE_PREAD ssize_t NumRead = - sys::RetryAfterSignal(-1, ::pread, FD, Buf.data(), Buf.size(), Offset); + sys::RetryAfterSignal(-1, ::pread, FD, Buf.data(), Size, Offset); #else if (lseek(FD, Offset, SEEK_SET) == -1) return errorCodeToError(std::error_code(errno, std::generic_category())); ssize_t NumRead = - sys::RetryAfterSignal(-1, ::read, FD, Buf.data(), Buf.size()); + sys::RetryAfterSignal(-1, ::read, FD, Buf.data(), Size); #endif if (NumRead == -1) return errorCodeToError(std::error_code(errno, std::generic_category()));