Hi Philippe,

> If meson fails to link, it won't define HAVE_COPY_FILE_RANGE,

Yes, meson correctly detects the link failure when checking for
copy_file_range, as shown in meson-log.txt:

> wasm-ld: error: /tmp/emscripten_temp_oqvz296m/testfile_0.o: undefined
symbol: copy_file_range

and reflects this in the configure output:

> Checking for function "copy_file_range" : NO

> so you
> shouldn't get "static declaration of 'copy_file_range' follows
> non-static declaration" right?

To fix this error, I needed to update the stub implementation in
file-posix.c to exactly match the declaration in Emscripten's
headers. Specifically, I changed the return type from off_t to ssize_t and
removed the "static" qualifier. With this change, file-posix.c builds
correctly under Emscripten, and there is no need to add a new stub in
stubs/emscripten.c

The following is the patch updates file-posix.c to solve this error:

 #ifndef HAVE_COPY_FILE_RANGE
-static off_t copy_file_range(int in_fd, off_t *in_off, int out_fd,
-                             off_t *out_off, size_t len, unsigned int
flags)
+ssize_t copy_file_range(int in_fd, off_t *in_off, int out_fd,
+                               off_t *out_off, size_t len, unsigned int
flags)
 {
 #ifdef __NR_copy_file_range
     return syscall(__NR_copy_file_range, in_fd, in_off, out_fd,

Reply via email to