tweag / opam-nix

Turn opam-based OCaml projects into Nix derivations
MIT License
111 stars 33 forks source link

`eio-posix-1.1` fails to build on macOS ventura 13.6.7 #89

Open kentookura opened 5 months ago

kentookura commented 5 months ago
error: builder for '/nix/store/zpssmmd2cifm4xlsyksnx04vmskx0iwi-eio_posix-1.1.drv' failed with exit code 1;
       last 20 log lines:
       > Running phase: unpackPhase
       > unpacking source archive /nix/store/2giwhf2h39bchbz2h8gmyydk0xzyqivh-eio-1.1.tbz
       > source root is eio-1.1
       > setting SOURCE_DATE_EPOCH to timestamp 1716894397 of file eio-1.1/tests/trace.md
       > Running phase: patchPhase
       > Running phase: configurePhase
       > patching script interpreter paths in .
       > Running phase: buildPhase
       > File "lib_eio_posix/dune", line 9, characters 9-24:
       > 9 |   (names eio_posix_stubs))
       >              ^^^^^^^^^^^^^^^
       > (cd _build/default/lib_eio_posix && /nix/store/iyk4jyp5aqmrp6mq5mlvirjdijhrdbna-clang-wrapper-16.0.6/bin/cc -O2 -fno-strict-aliasing -fwrapv -pthread -D_FILE_OFFSET_BITS=64 -fdiagnostics-color=always -D_LARGEFILE64_SOURCE -g -I /nix/store/6sc7asvwvwqicyczhsiyhhaqgkwd81a3-ocaml-base-compiler-5.1.1/lib/ocaml -I /nix/store/6sc7asvwvwqicyczhsiyhhaqgkwd81a3-ocaml-base-compiler-5.1.1/lib/ocaml/runtime_events -I /nix/store/6sc7asvwvwqicyczhsiyhhaqgkwd81a3-ocaml-base-compiler-5.1.1/lib/ocaml/threads -I /nix/store/6sc7asvwvwqicyczhsiyhhaqgkwd81a3-ocaml-base-compiler-5.1.1/lib/ocaml/unix -I /nix/store/6z4nynxml3hm47rjlrivncpbyp75rwcc-bigstringaf-0.9.1/lib/ocaml/5.1.1/site-lib/bigstringaf -I /nix/store/77pxgjv7ndrhm11wij2pwmnw1l37cl68-iomux-0.3/lib/ocaml/5.1.1/site-lib/iomux -I /nix/store/9nhfnqlcx5wc4749whcpjjfgh9ljip07-optint-0.3.0/lib/ocaml/5.1.1/site-lib/optint -I /nix/store/f9y9cimmydclqbvh5nsym0n329nn9cmv-lwt-dllist-1.0.1/lib/ocaml/5.1.1/site-lib/lwt-dllist -I /nix/store/fbd6i566p0s915i4c4p16sa2pdnpfkk3-seq-base/lib/ocaml/5.1.1/site-lib/seq -I /nix/store/h7rl940vdrv7ghz5f7iq2mv5b7g3ypkg-eio-1.1/lib/ocaml/5.1.1/site-lib/eio -I /nix/store/h7rl940vdrv7ghz5f7iq2mv5b7g3ypkg-eio-1.1/lib/ocaml/5.1.1/site-lib/eio/core -I /nix/store/h7rl940vdrv7ghz5f7iq2mv5b7g3ypkg-eio-1.1/lib/ocaml/5.1.1/site-lib/eio/runtime_events -I /nix/store/h7rl940vdrv7ghz5f7iq2mv5b7g3ypkg-eio-1.1/lib/ocaml/5.1.1/site-lib/eio/unix -I /nix/store/h7rl940vdrv7ghz5f7iq2mv5b7g3ypkg-eio-1.1/lib/ocaml/5.1.1/site-lib/eio/utils -I /nix/store/hylnp4rnal9mfk80lgyyk24hgi7a861v-thread-table-1.0.0/lib/ocaml/5.1.1/site-lib/thread-table -I /nix/store/jh6j1kg1vk1w4pxm18ljgkfc1zjfpp5x-mtime-2.0.0/lib/ocaml/5.1.1/site-lib/mtime -I /nix/store/jh6j1kg1vk1w4pxm18ljgkfc1zjfpp5x-mtime-2.0.0/lib/ocaml/5.1.1/site-lib/mtime/clock/os -I /nix/store/l8g8g5mxgvwbn7rxcgw0l1qv26rv464a-cstruct-6.2.0/lib/ocaml/5.1.1/site-lib/cstruct -I /nix/store/mj0ri949k37ar70192vzghhdfyf3r520-psq-0.2.1/lib/ocaml/5.1.1/site-lib/psq -I /nix/store/qikgfx8jqhhnyih7k3qhka1hn3vm9scp-fmt-0.9.0/lib/ocaml/5.1.1/site-lib/fmt -I /nix/store/rwnkfah6ckvg65sizrvks7m7v8azy5jj-hmap-0.8.1/lib/ocaml/5.1.1/site-lib/hmap -I /nix/store/ynq5inhfj63d1ds9ifhdsi1297ndllzz-domain-local-await-1.0.1/lib/ocaml/5.1.1/site-lib/domain-local-await -I ../lib_eio/unix/include -o eio_posix_stubs.o -c eio_posix_stubs.c)
       > eio_posix_stubs.c:133:7: error: call to undeclared function 'preadv'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
       >   r = preadv(Int_val(v_fd), iov, n_bufs, offset);
       >       ^
       > eio_posix_stubs.c:150:7: error: call to undeclared function 'pwritev'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
       >   r = pwritev(Int_val(v_fd), iov, n_bufs, offset);
       >       ^
       > 2 errors generated.
       >
       For full logs, run 'nix-store -l /nix/store/zpssmmd2cifm4xlsyksnx04vmskx0iwi-eio_posix-1.1.drv'.
error: 1 dependencies of derivation '/nix/store/36z756dqwgjgk4nsbrlfdzxnpbnz94yg-eio_main-1.1.drv' failed to build
error: 1 dependencies of derivation '/nix/store/sfyqcshn69716iaij95zlmi92h41yfb2-forester-4.1.0.drv' failed to build

To Reproduce Run nix build on https://git.sr.ht/~jonsterling/ocaml-forester/commit/e9bd3a5a784e8fe1a34928d85ef0188e3ea41947

Expected behavior Build succeeds

Environment



Build *does* succeed on at least macOS Sonoma 14.5 
balsoft commented 5 months ago

Hey! I don't have a macOS machine with this OS version, so can't reproduce. Can you check if this builds locally with just opam, without opam-nix? I feel like it could just be broken there.

kentookura commented 4 months ago

I managed to build it fine with native opam/dune

balsoft commented 4 months ago

Ok, thanks! I've got a VM with the right macOS version now, will fix

balsoft commented 4 months ago

Hey! I can't seem to repro :(

$ git clone https://git.sr.ht/~jonsterling/ocaml-forester
$ cd ocaml-forester
$ git checkout e9bd3a5a784e8fe1a34928d85ef0188e3ea41947
HEAD is now at e9bd3a5 upgrade menhir
$ nix build
trace: warning: `overrideScope'` (from `lib.makeScope`) has been renamed to `overrideScope`.
trace: warning: `overrideScope'` (from `lib.makeScope`) has been renamed to `overrideScope`.
trace: warning: `overrideScope'` (from `lib.makeScope`) has been renamed to `overrideScope`.
$ ./result/bin/forester --version
4.1.0
$ sw_vers
ProductName:        macOS
ProductVersion:     13.6
BuildVersion:       22G120

All I got during the build is some warnings about unused variables.

$ nix build github:tweag/opam-nix#eio_posix.latest

Succeeds too.

kentookura commented 4 months ago

Strange, running

$ nix build github:tweag/opam-nix#eio_posix.latest

succeeds, but even after running nix flake update (checked out at the latest commit), the build of ocaml-forester fails with the same error.

balsoft commented 4 months ago

Oh, are you running on Apple silicon (aarch64) or Intel (x86_64)?

kentookura commented 4 months ago

It's an intel machine. This issue is not particularly pressing. I'm the only one who has reported this breakage and I don't regularly use apple, and none of our users have complained yet.

suspenss commented 1 month ago

Similar issue?

       > /nix/store/j645h2bcqjww615dfkka4v4q1nyyy5m1-cctools-port-973.0.1/libexec/as/x86_64/as: this system assembler is deprecated. Please migrate to the clang integrated assembler (`as -q').
       > Undefined symbols for architecture x86_64:
       >   "_preadv", referenced from:
       >       _caml_eio_posix_preadv in libeio_posix_stubs.a(eio_posix_stubs.o)
       >      (maybe you meant: _caml_eio_posix_preadv)
       >   "_pwritev", referenced from:
       >       _caml_eio_posix_pwritev in libeio_posix_stubs.a(eio_posix_stubs.o)
       >      (maybe you meant: _caml_eio_posix_pwritev)
       > ld: symbol(s) not found for architecture x86_64
       > clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
       > File "caml_startup", line 1:
       > Error: Error during linking (exit code 1)
       >
       For full logs, run 'nix log /nix/store/xdgsaz5j39zl7n74w53by20r3h2zmyld-forester-4.3.1.drv'.

in

~/learn/forest> sw_vers
ProductName:        macOS
ProductVersion:     14.7
BuildVersion:       23H124
suspenss commented 1 month ago

Oh, I think is the problem with Apple command line tools, I can't just complie a hello world which using stdc++ library, sorry for this issue. I will try degrade the version and check this problem.