janestreet/core

ERROR while compiling core.v0.15~preview.125.13+424

denis631 opened this issue · 9 comments

I am experiencing issues installing the latest core.
Console output:

# context     2.1.0 | macos/x86_64 | ocaml-base-compiler.4.11.1 | https://ocaml.janestreet.com/opam-repository
# path        ~/Documents/abc/_opam/.opam-switch/build/core.v0.15~preview.125.13+424
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p core -j 11
# exit-code   1
# env-file    ~/.opam/log/core-46669-d090ee.env
# output-file ~/.opam/log/core-46669-d090ee.out
### output ###
# 1 error generated.
# [...]
# (cd _build/default && /Users/denis.grebennicov/Documents/abc/_opam/bin/ocamlc.opt -w -40 -g -bin-annot -I linux_ext/src/.linux_ext.objs/byte -I /Users/denis.grebennicov/Documents/abc/_opam/lib/base -I /Users/denis.grebennicov/Documents/abc/_opam/lib/base/base_internalhash_types -I /Users/denis.grebennicov/Documents/abc/_opam/lib/base/caml -I /Users/denis.greben[...]
# File "linux_ext/src/linux_ext.ml", line 615, characters 17-29:
# 615 | module Timerfd = Null.Timerfd
#                        ^^^^^^^^^^^^
# Error: Unbound module Null
#     ocamlopt linux_ext/src/.linux_ext.objs/native/linux_ext.{cmx,o} (exit 2)
# (cd _build/default && /Users/denis.grebennicov/Documents/abc/_opam/bin/ocamlopt.opt -w -40 -g -I linux_ext/src/.linux_ext.objs/byte -I linux_ext/src/.linux_ext.objs/native -I /Users/denis.grebennicov/Documents/abc/_opam/lib/base -I /Users/denis.grebennicov/Documents/abc/_opam/lib/base/base_internalhash_types -I /Users/denis.grebennicov/Documents/abc/_opam/lib/b[...]
# File "linux_ext/src/linux_ext.ml", line 615, characters 17-29:
# 615 | module Timerfd = Null.Timerfd
#                        ^^^^^^^^^^^^
# Error: Unbound module Null
bcc32 commented

Hi @denis631, thanks for reporting this. Looks like there was some code that was erroneously considered "unused" because it was conditionally not-compiled in our build environment. We are working on a fix, it should make its way to GitHub soon.

@bcc32 Could osx be added to the automated test runner in order to catch these kinds of bugs?

bcc32 commented

Possibly, if you mean GitHub Actions CI or something like that. @aalekseyev does the public release, so he'd be a good person to ask what we have available.

I've submitted a prototype PR here janestreet/bonsai#17 that adds a linux and osx GitHub-actions runner for Bonsai (though the workflow.yml is generic enough to be used in other repos as well).

In my fork, you can see that it fails to build on OSX due to the issue described in this issue.

Oh actually, there's another error that it found:

# core_unix_time_stubs.c:57:13: error: implicit declaration of function 'clock_getcpuclockid' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
#   int ret = clock_getcpuclockid(pid, &clock);
#             ^
# core_unix_time_stubs.c:57:13: note: did you mean 'caml_clock_getcpuclockid'?
# core_unix_time_stubs.c:52:16: note: 'caml_clock_getcpuclockid' declared here
# CAMLprim value caml_clock_getcpuclockid(value v_pid) {
#                ^
# 1 error generated.
#       ocamlc linux_ext/src/.linux_ext.objs/byte/linux_ext.{cmo,cmt} (exit 2)

Maybe this is a silly question, but would it help if we removed linux_ext from the core_unix opam package?

This library is useless on OSX, and I think that the only reason it's even being built is because when you ask for core_unix it builds all the libraries in that directory.

@TyOverby, we have some potentially-bit-rotted tooling to test public-release on Darwin. I think I'll need to revive that soon before we can do a stable public-release.

GitHub-actions runner

That's cool, maybe it's worth using that instead of some custom AWS box that we're using (or have been using a year+ ago).

if we removed linux_ext from the core_unix opam package?

I don't know the reason you're using core_unix, but for example async_unix uses Linux_ext, so at least there it wouldn't be helpful.

Oh I see, I assumed that Linux_ext was only for linux, but it looks like it tries to provide fallbacks for other operating systems (indeed, those fallback appear to be what is currently broken).

@aalekseyev I think that Github Actions is a nice workflow for making sure that tip-of-tree always builds, but I'm unsure how well it would work for the kind of pushes that we typically do where every repo is updated more-or-less simultaneously.

Oh actually, there's another error that it found:

# core_unix_time_stubs.c:57:13: error: implicit declaration of function 'clock_getcpuclockid' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
#   int ret = clock_getcpuclockid(pid, &clock);
#             ^
# core_unix_time_stubs.c:57:13: note: did you mean 'caml_clock_getcpuclockid'?
# core_unix_time_stubs.c:52:16: note: 'caml_clock_getcpuclockid' declared here
# CAMLprim value caml_clock_getcpuclockid(value v_pid) {
#                ^
# 1 error generated.
#       ocamlc linux_ext/src/.linux_ext.objs/byte/linux_ext.{cmo,cmt} (exit 2)

I also ran into this error while trying to compile postgres_async. I proposed a workaround at janestreet/jst-config#4 as it seems like jet-config should be checking if clock_getcpuclockid is available (in addition to clock_gettime, clock_settime and clock_getres) on the host before considering JSC_POSIX_TIMERS as available.