Hi Philippe and Richard, thank you for the feedback. > Actually what about checking the symbol presence in meson? > Something like (untested): > > -- >8 -- > diff --git a/meson.build b/meson.build > index b18c46d16a2..33185fdf315 100644 > --- a/meson.build > +++ b/meson.build > @@ -2654,3 +2654,2 @@ config_host_data.set('CONFIG_TIMERFD', > cc.has_function('timerfd_create')) > config_host_data.set('CONFIG_GETLOADAVG', cc.has_function('getloadavg')) > -config_host_data.set('HAVE_COPY_FILE_RANGE', > cc.has_function('copy_file_range')) > config_host_data.set('HAVE_GETIFADDRS', cc.has_function('getifaddrs')) > @@ -2756,2 +2755,6 @@ config_host_data.set('HAVE_UTMPX', > > +config_host_data.set('HAVE_COPY_FILE_RANGE', cc.links(gnu_source_prefix > + ''' > + #include <unistd.h> > + int main(void) { return copy_file_range(-1, NULL, -1, NULL, 0, 0); }''')) > config_host_data.set('CONFIG_EVENTFD', cc.links(''' > ---
Emscripten doesn't provide copy_file_range implementation but it declares this function in its headers. Meson correctly detects the missing implementation and unsets HAVE_COPY_FILE_RANGE. However, the stub defined in file-posix.c causes a type conflict with the declaration from Emscripten during compilation: > ../qemu/block/file-posix.c:2019:14: error: static declaration of 'copy_file_range' follows non-static declaration > 2019 | static off_t copy_file_range(int in_fd, off_t *in_off, int out_fd, > | ^ > /emsdk/upstream/emscripten/cache/sysroot/include/unistd.h:207:9: note: previous declaration is here > 207 | ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned); > | ^ > 1 error generated. If introducing a new stub isn't preferable, we could update the existing stub in file-posix.c to match the declaration used by Emscripten. The manpage[1] also aligns with this signature. [1] https://man7.org/linux/man-pages/man2/copy_file_range.2.html