RFR: 8336966: Alpine Linux x86_64 compilation error: sendfile64

Jan Kratochvil jkratochvil at openjdk.org
Fri Jul 26 10:59:30 UTC 2024


On Tue, 23 Jul 2024 09:22:05 GMT, Jan Kratochvil <jkratochvil at openjdk.org> wrote:

> Alpine Linux 3.20 x86_64 compilation error:
> 
> 
> .../src/java.base/linux/native/libnio/ch/FileDispatcherImpl.c: In function 'Java_sun_nio_ch_FileDispatcherImpl_transferTo0':
> .../src/java.base/linux/native/libnio/ch/FileDispatcherImpl.c:117:9: error: implicit declaration of function 'sendfile64'; did you mean 'sendfile'? [-Werror=implicit-function-declaration]
>   117 | n = sendfile64(dstFD, srcFD, &offset, (size_t)count);
>       | ^~~~~~~~~~
>       | sendfile
> cc1: all warnings being treated as errors
> * For target support_native_java.base_libnio_LinuxNativeDispatcher.o:
> In file included from .../src/java.base/share/native/libjava/jni_util.h:30,
>                  from .../src/java.base/linux/native/libnio/fs/LinuxNativeDispatcher.c:27:
> .../src/java.base/linux/native/libnio/fs/LinuxNativeDispatcher.c: In function 'Java_sun_nio_fs_LinuxNativeDispatcher_directCopy0':
> .../src/java.base/linux/native/libnio/fs/LinuxNativeDispatcher.c:214:21: error: implicit declaration of function 'sendfile64'; did you mean 'sendfile'? [-Werror=implicit-function-declaration]
>   214 | RESTARTABLE(sendfile64(dst, src, NULL, count), bytes_sent);
>       | ^~~~~~~~~~
> .../src/java.base/unix/native/libjava/jni_util_md.h:31:15: note: in definition of macro 'RESTARTABLE'
>    31 | _result = _cmd; \
>       | ^~~~
> cc1: all warnings being treated as errors
> 
> `make/autoconf/flags-cflags.m4`
> 
>   if test "x$OPENJDK_TARGET_OS" = xlinux; then
>     CFLAGS_OS_DEF_JVM="-DLINUX -D_FILE_OFFSET_BITS=64"
>     CFLAGS_OS_DEF_JDK="-D_GNU_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
> 
> `sendfile64` were introduced by: #10154 and inherited from https://github.com/openjdk/jdk/commit/a449cd08d7475215fe50218312a5d858068c694c

I have tested on x86 Debian trixies/sid that a file compiled with the same options works for `sendfile`. Is that sufficient?

(set -ex;rm -f in out;echo -n X|dd of=in bs=1 count=1 seek=$[5*1024*1024*1024];gcc -MMD -MF run.d.tmp -fvisibility=hidden -pipe -fstack-protector -DLIBC=gnu -D_GNU_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64 -DLINUX -DDEBUG -g -gdwarf-4 -std=c11 -fno-strict-aliasing -Wall -Wextra -Wformat=2 -Wpointer-arith -Wsign-compare -Wunused-function -Wundef -Wunused-value -Wreturn-type -Wtrampolines -m32 -D_LITTLE_ENDIAN '-DARCH="i586"' -Di586 -march=i586 -fno-omit-frame-pointer -fno-lifetime-dse -fPIC -I/home/azul/azul/openjdk-git/src/java.base/linux/native/libnio -I/home/azul/azul/openjdk-git/src/java.base/unix/native/libnio -I/home/azul/azul/openjdk-git/src/java.base/share/native/libnio -I/home/azul/azul/openjdk-git/build/linux-x86-server-fastdebug/support/headers/java.base -I/home/azul/azul/openjdk-git/src/java.base/linux/native/libnio/ch -I/home/azul/azul/openjdk-git/src/java.base/unix/native/libnio/ch -I/home/azul/azul/openjdk-git/src/java.base/share/native/libnio/ch -I/home/azul/azul/open
 jdk-git/src/java.base/linux/native/libnio/fs -I/home/azul/azul/openjdk-git/src/java.base/unix/native/libnio/fs -I/home/azul/azul/openjdk-git/src/hotspot/share/include -I/home/azul/azul/openjdk-git/src/hotspot/os/posix/include -I/home/azul/azul/openjdk-git/src/java.base/linux/native/libjava -I/home/azul/azul/openjdk-git/src/java.base/unix/native/libjava -I/home/azul/azul/openjdk-git/src/java.base/share/native/libjava -I/home/azul/azul/openjdk-git/src/java.base/unix/native/libnet -I/home/azul/azul/openjdk-git/src/java.base/share/native/libnet -I/home/azul/azul/openjdk-git/build/linux-x86-server-fastdebug/support/modules_include/java.base -I/home/azul/azul/openjdk-git/src/java.base/unix/native/include -I/home/azul/azul/openjdk-git/src/java.base/share/native/include -g -gdwarf-4 -Wno-unused-parameter -Wno-unused -Werror -O2 -D_FORTIFY_SOURCE=2 -c -o run.o run.c -frandom-seed=run.c;gcc -o run run.o -Wall;./run;echo done;ls -l out;cat out;echo) 

#include <sys/sendfile.h>
#include <fcntl.h>
#include <assert.h>
#include <unistd.h>
int main() {
  int in_fd=open("in",O_RDONLY);
  assert(in_fd!=-1);
  int out_fd=open("out",O_WRONLY|O_CREAT|O_TRUNC,0644);
  assert(out_fd!=-1);
  off_t offset = 5LL*1024*1024*1024;
  ssize_t got=sendfile(out_fd,in_fd,&offset,1/*count*/);
  assert(got==1);
  int err;
  err=close(in_fd);
  assert(!err);
  err=close(out_fd);
  assert(!err);
  return 0;
}

-------------

PR Comment: https://git.openjdk.org/jdk/pull/20295#issuecomment-2252511077


More information about the nio-dev mailing list