[libcxx] Only use copy_file_range on Linux or FreeBSD targets#184373
[libcxx] Only use copy_file_range on Linux or FreeBSD targets#184373TartanLlama wants to merge 3 commits intollvm:mainfrom
copy_file_range on Linux or FreeBSD targets#184373Conversation
|
@llvm/pr-subscribers-libcxx Author: Sy Brand (TartanLlama) ChangesPrior to #169405, The WASI libc implementation is based on musl libc, we just don't have support for This PR guards the GLIBC and musl libc checks against the Full diff: https://github.com/llvm/llvm-project/pull/184373.diff 1 Files Affected:
diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp
index 745db87ce3736..c1834a61b55de 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -41,7 +41,7 @@
#include <time.h>
// since Linux 4.5 and FreeBSD 13, but the Linux libc wrapper is only provided by glibc >= 2.27 and musl
-#if _LIBCPP_GLIBC_PREREQ(2, 27) || _LIBCPP_HAS_MUSL_LIBC || defined(__FreeBSD__)
+#if (defined(__linux__) && (_LIBCPP_GLIBC_PREREQ(2, 27) || _LIBCPP_HAS_MUSL_LIBC)) || defined(__FreeBSD__)
# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
#endif
|
Prior to #169405,
copy_file_rangewas used only on Linux targets with specific libc constraints, or any FreeBSD target. The PR simplified theifdefs, resulting in the Linux requirement being dropped. This broke libc++ builds forwasm32-wasitargets. See LLVM issue #181543.The WASI libc implementation is based on musl libc, we just don't have support for
copy_file_range, so this is not declared inwasi-libc. Prior to the PR that changed the libc++ behaviour, we suppliedHAS_MUSL_LIBCwhen building libc++. We have temporarily disabled this (WebAssembly/wasi-sdk#585), but it would be great if we could re-enable it to benefit from any other MUSL-targeted specializations.This PR guards the GLIBC and musl libc checks against the
__linux__define, which will suffice to disable it forwasm32-wasitargets.