ocaml-multicore / eio

Effects-based direct-style IO for multicore OCaml
Other
559 stars 72 forks source link

Fails to build with musl-gcc w/ linux-lts headers (no `struct clone_args`) #737

Closed copy closed 5 months ago

copy commented 5 months ago

I install musl-gcc and kernel-headers-musl on Arch Linux, then create a switch with CC=musl-gcc opam switch create .... Installing eio_linux fails as follows:

File "lib_eio_linux/dune", line 13, characters 9-18:
13 |   (names eio_stubs))
              ^^^^^^^^^
(cd _build/default/lib_eio_linux && /usr/bin/musl-gcc -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC -pthread -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -g -I /home/fabian/.opam/5.2.0+musl/lib/ocaml -I /home/fabian/.opam/5.2.0+musl/lib/bigstringaf -I /home/fabian/.opam/5.2.0+musl/lib/cstruct -I /home/fabian/.opam/5.2.0+musl/lib/domain-local-await -I /home/fabian/.opam/5.2.0+musl/lib/eio -I /home/fabian/.opam/5.2.0+musl/lib/eio/core -I /home/fabian/.opam/5.2.0+musl/lib/eio/unix -I /home/fabian/.opam/5.2.0+musl/lib/eio/utils -I /home/fabian/.opam/5.2.0+musl/lib/fmt -I /home/fabian/.opam/5.2.0+musl/lib/hmap -I /home/fabian/.opam/5.2.0+musl/lib/logs -I /home/fabian/.opam/5.2.0+musl/lib/lwt-dllist -I /home/fabian/.opam/5.2.0+musl/lib/mtime -I /home/fabian/.opam/5.2.0+musl/lib/mtime/clock/os -I /home/fabian/.opam/5.2.0+musl/lib/ocaml/threads -I /home/fabian/.opam/5.2.0+musl/lib/ocaml/unix -I /home/fabian/.opam/5.2.0+musl/lib/optint -I /home/fabian/.opam/5.2.0+musl/lib/psq -I /home/fabian/.opam/5.2.0+musl/lib/seq -I /home/fabian/.opam/5.2.0+musl/lib/thread-table -I /home/fabian/.opam/5.2.0+musl/lib/uring -I ../lib_eio/unix/include -o eio_stubs.o -c eio_stubs.c)
eio_stubs.c:161:42: warning: ‘struct clone_args’ declared inside parameter list will not be visible outside of this definition or declaration
  161 | static pid_t clone3_with_fallback(struct clone_args *cl_args) {
      |                                          ^~~~~~~~~~
eio_stubs.c: In function ‘clone3_with_fallback’:
eio_stubs.c:162:42: error: invalid use of undefined type ‘struct clone_args’
  162 |   int *pidfd = (int *)(uintptr_t) cl_args->pidfd;
      |                                          ^~
...

Note that the kernel-headers-musl package uses 4.19.88 (LTS) headers, which don't have struct clone_args: https://github.com/sabotage-linux/kernel-headers

talex5 commented 5 months ago

eio_stubs.c provides its own struct clone_args for older kernels: https://github.com/ocaml-multicore/eio/blob/77d881014d0abb3246dda6f7af8178e86f05061a/lib_eio_linux/eio_stubs.c#L39-L55

If you can figure out the right ifdef, it should be an easy fix!