Commit eb90d7d
committed
Add copy_file_range syscall stub
llvm/llvm-project#169405 has this:
```diff
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -41,17 +41,10 @@
#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 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__)
+#if _LIBCPP_GLIBC_PREREQ(2, 27) || _LIBCPP_HAS_MUSL_LIBC || defined(__FreeBSD__)
# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
#endif
+
#if __has_include(<sys/sendfile.h>)
# include <sys/sendfile.h>
# define _LIBCPP_FILESYSTEM_USE_SENDFILE
```
Before the PR, because we didn't define `__linux__`,
`_LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE` was not defined. But after it
`#if defined(__linux__)` check was gone, and because we defined
`_LIBCPP_HAS_MUSL_LIBC`, `_LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE` was
defined as well.
After this PR, we started to have
`error: undefined symbol: copy_file_range` error on
`core*.test_dylink_exceptions_try_catch_6_*` tests.
---
This commit fixes the linker error by wiring up `SYS_copy_file_range`
and provides a stub implementation returning `-ENOSYS` for both legacy
JS syscalls and WASMFS. This allows `copy_file_range.c` from musl to be
compiled into the system library. The libcxx implementation falls back
to other mechanisms when receiving `ENOSYS`.1 parent b119c87 commit eb90d7d
6 files changed
Lines changed: 15 additions & 1 deletion
File tree
- src/lib
- system
- include/emscripten
- lib
- libc/musl/arch/emscripten/bits
- wasmfs
- tools
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
708 | 708 | | |
709 | 709 | | |
710 | 710 | | |
| 711 | + | |
| 712 | + | |
711 | 713 | | |
712 | 714 | | |
713 | 715 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
125 | 126 | | |
126 | 127 | | |
127 | 128 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1887 | 1887 | | |
1888 | 1888 | | |
1889 | 1889 | | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
1890 | 1899 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1344 | 1344 | | |
1345 | 1345 | | |
1346 | 1346 | | |
1347 | | - | |
| 1347 | + | |
1348 | 1348 | | |
1349 | 1349 | | |
1350 | 1350 | | |
| |||
0 commit comments