Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Threads library explicitely required to build with netsys #1024

Closed
Khady opened this issue Jul 17, 2018 · 5 comments
Closed

Threads library explicitely required to build with netsys #1024

Khady opened this issue Jul 17, 2018 · 5 comments

Comments

@Khady
Copy link
Contributor

Khady commented Jul 17, 2018

When using the netsys library (from ocamlnet), it is necessary to add the threads library to the libraries field BEFORE the netsys library. This is confusing because usually I think the order of the libraries doesn't matter. And when using ocamlbuild, there is no need to specify the dependency on threads.

The threads might be necessary because there is no requires(mt) += "threads" in the META file of netsys. But I didn't read in dune's documentation that the order in libraries is important.

$ dune build main.exe
    ocamlopt main.exe (exit 2)
(cd _build/default && /home/louis/.opam/frontend/bin/ocamlopt.opt -w @a-4-29-40-41-42-44-45-48-58-59-60-40 -strict-sequence -strict-formats -short-paths -keep-locs -g -o main.exe -I /home/louis/.opam/frontend/lib/bytes -I /home/louis/.opam/frontend/lib/netsys /home/louis/.opam/frontend/lib/ocaml/unix.cmxa /home/louis/.opam/frontend/lib/ocaml/bigarray.cmxa /home/louis/.opam/frontend/lib/netsys/netsys_oothr_mt.cmxa /home/louis/.opam/frontend/lib/netsys/netsys_oothr_mt_init.cmx /home/louis/.opam/frontend/lib/netsys/netsys.cmxa .main.eobjs/main.cmx)
File "_none_", line 1:
Error: No implementations provided for the following modules:
         Thread referenced from /home/louis/.opam/frontend/lib/netsys/netsys_oothr_mt.cmxa(Netsys_oothr_mt)
         Mutex referenced from /home/louis/.opam/frontend/lib/netsys/netsys_oothr_mt.cmxa(Netsys_oothr_mt)
         Condition referenced from /home/louis/.opam/frontend/lib/netsys/netsys_oothr_mt.cmxa(Netsys_oothr_mt)

Files to reproduce:

main.ml:

module N = Netsys

dune file I expected to work:

(executable (name main) (libraries netsys))

dune file with threads not working:

(executable (name main) (libraries netsys threads))

dune file working:

(executable (name main) (libraries threads netsys))

To compile with ocamlbuild:

touch _tags
ocamlbuild -use-ocamlfind -package netsys main.native

Netsys META file:

description = "Ocamlnet - OS-specific functions"
requires = "bytes,unix,bigarray"
version = "4.1.6"
archive(byte) = "netsys_oothr.cma netsys.cma"
archive(native) = "netsys_oothr.cmxa netsys.cmxa"
archive(native,gprof) = "netsys_oothr.p.cmxa netsys.p.cmxa netsys_c_gprof.o netsys_gprof_init.p.cmx"
archive(byte,mt) = "netsys_oothr_mt.cma netsys_oothr_mt_init.cmo netsys.cma"
archive(native,mt) = "netsys_oothr_mt.cmxa netsys_oothr_mt_init.cmx netsys.cmxa"
archive(native,gprof,mt) = "netsys_oothr_mt.p.cmxa netsys_oothr_mt_init.p.cmx netsys.p.cmxa"
archive(byte,toploop) = "netsys_oothr.cma netsys.cma"
archive(byte,mt,toploop) = "netsys_oothr_mt.cma netsys_oothr_mt_init.cmo netsys.cma"

plugin(byte) = "netsys_oothr.cma netsys.cma"
plugin(byte,mt) = "netsys_oothr_mt.cma netsys_oothr_mt_init.cmo netsys.cma"
plugin(native) = "netsys_oothr.cmxs netsys.cmxs"
plugin(native,mt) = "netsys_oothr_mt.cmxs netsys_oothr_mt_init.cmxs netsys.cmxs"
plugin(native,gprof,mt) = "netsys_oothr_mt.p.cmxs netsys_oothr_mt_init.p.cmxs netsys.p.cmxs"

package "outofheap" (
        version = "4.1.6"
        description = "Ocamlnet - override caml_modify and caml_initialize"
        requires = ""
	exists_if = "netsys_c_outofheap.o"
        archive(byte) = "netsys_c_outofheap.o"
        archive(native) = "netsys_c_outofheap.o"
        linkopts(byte) = "-custom"
)
@ghost
Copy link

ghost commented Jul 17, 2018

I'm not sure why it works with ocamlfind, maybe ocamlfind does some magic to automatically add threads in some cases? In any case, this looks like an issue with the meta file of netsys

@Khady
Copy link
Contributor Author

Khady commented Jul 17, 2018

Might be related to #96?

@ghost
Copy link

ghost commented Jul 17, 2018

Not really, the META file of netsys still looks wrong to me and it should declare a dependency on threads when mt is set. There is not much we can do in dune.

@ghost
Copy link

ghost commented Jul 17, 2018

Ah, looking at #96 I see that ocamlfind indeed has some magic. I'm not really keen on adding this to dune though. Could you try sending a patch to netsys instead?

@Khady
Copy link
Contributor Author

Khady commented Jul 17, 2018

It is already reported at https://gitlab.camlcity.org/gerd/lib-ocamlnet3/issues/14

Closing this issue then. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant