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

-use-ocamlfind and -tag thread doesn't work. #6127

Closed
vicuna opened this issue Aug 7, 2013 · 2 comments
Closed

-use-ocamlfind and -tag thread doesn't work. #6127

vicuna opened this issue Aug 7, 2013 · 2 comments

Comments

@vicuna
Copy link

vicuna commented Aug 7, 2013

Original bug ID: 6127
Reporter: @dbuenzli
Assigned to: @gasche
Status: closed (set by @xavierleroy on 2015-12-11T18:23:45Z)
Resolution: duplicate
Priority: normal
Severity: minor
Category: -for ocamlbuild use https://github.com/ocaml/ocamlbuild/issues
Duplicate of: #6058

Bug description

It seems that when -use-ocamlfind is used the thread tag no longer works.

ocamlbuild -classic-display -tag thread -use-ocamlfind tsdl.cma
/Users/dbuenzli/.opam/4.00.1/bin/ocamlfind ocamlc -a -cclib -L/usr/local/lib -cclib -lSDL2 -package ctypes -package ctypes.foreign src/tsdl_consts.cmo src/tsdl.cmo -o src/tsdl.cma

  • /Users/dbuenzli/.opam/4.00.1/bin/ocamlfind ocamlc -a -cclib -L/usr/local/lib -cclib -lSDL2 -package ctypes -package ctypes.foreign src/tsdl_consts.cmo src/tsdl.cmo -o src/tsdl.cma
    ocamlfind: Error from package `threads': Missing -thread or -vmthread switch
    Command exited with code 2.

Without -use-ocamlfind (fails because packages are used):

ocamlbuild -classic-display -tag thread tsdl.cma
Warning: tag "package" does not expect a parameter, but is used with parameter "ctypes"
Warning: tag "package" does not expect a parameter, but is used with parameter "ctypes.foreign"
/Users/dbuenzli/.opam/4.00.1/bin/ocamldep.opt -modules support/consts.ml > support/consts.ml.depends
/Users/dbuenzli/.opam/4.00.1/bin/ocamlc.opt -c -annot -thread -I support -I test -I src -o support/consts.cmo support/consts.ml
/Users/dbuenzli/.opam/4.00.1/bin/ocamlc.opt -ccopt -DHAS_SDL2 -ccopt -D_THREAD_SAFE -ccopt -I/usr/local/include/SDL2 -ccopt -I/usr/X11R6/include -c support/consts_stub.c
mv consts_stub.o support/consts_stub.o
/Users/dbuenzli/.opam/4.00.1/bin/ocamlc.opt -custom threads.cma -thread support/consts.cmo support/consts_stub.o -o support/consts.byte
support/consts.byte src/tsdl_consts.ml
/Users/dbuenzli/.opam/4.00.1/bin/ocamldep.opt -modules src/tsdl_consts.ml > src/tsdl_consts.ml.depends
/Users/dbuenzli/.opam/4.00.1/bin/ocamldep.opt -modules src/tsdl.mli > src/tsdl.mli.depends
/Users/dbuenzli/.opam/4.00.1/bin/ocamlc.opt -c -annot -thread -I src -I test -I support -o src/tsdl.cmi src/tsdl.mli
/Users/dbuenzli/.opam/4.00.1/bin/ocamldep.opt -modules src/tsdl.ml > src/tsdl.ml.depends
/Users/dbuenzli/.opam/4.00.1/bin/ocamlc.opt -c -annot -thread -I src -I test -I support -o src/tsdl_consts.cmo src/tsdl_consts.ml
/Users/dbuenzli/.opam/4.00.1/bin/ocamlc.opt -c -annot -thread -I src -I test -I support -o src/tsdl.cmo src/tsdl.ml

  • /Users/dbuenzli/.opam/4.00.1/bin/ocamlc.opt -c -annot -thread -I src -I test -I support -o src/tsdl.cmo src/tsdl.ml
    File "src/tsdl.ml", line 9, characters 0-11:
    Error: Unbound module Ctypes
    Command exited with code 2.
@vicuna
Copy link
Author

vicuna commented Aug 7, 2013

Comment author: @dbuenzli

Actually they are build correctly with the -thread. The problem seems more to be on ocamlfind (or a wrong invocation of ocamlfind):

ocamlbuild -classic-display -tag thread -use-ocamlfind tsdl.cma
/Users/dbuenzli/.opam/4.00.1/bin/ocamlfind ocamlopt -I /Users/dbuenzli/.opam/4.00.1/lib/ocaml/ocamlbuild unix.cmxa /Users/dbuenzli/.opam/4.00.1/lib/ocaml/ocamlbuild/ocamlbuildlib.cmxa myocamlbuild.ml /Users/dbuenzli/.opam/4.00.1/lib/ocaml/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
/Users/dbuenzli/.opam/4.00.1/bin/ocamlfind ocamldep -modules support/consts.ml > support/consts.ml.depends
/Users/dbuenzli/.opam/4.00.1/bin/ocamlfind ocamlc -c -annot -thread -I support -I test -I src -o support/consts.cmo support/consts.ml
/Users/dbuenzli/.opam/4.00.1/bin/ocamlfind ocamlc -ccopt -DHAS_SDL2 -ccopt -D_THREAD_SAFE -ccopt -I/usr/local/include/SDL2 -ccopt -I/usr/X11R6/include -c support/consts_stub.c
mv consts_stub.o support/consts_stub.o
/Users/dbuenzli/.opam/4.00.1/bin/ocamlfind ocamlc -linkpkg -custom -thread support/consts.cmo support/consts_stub.o -o support/consts.byte
support/consts.byte src/tsdl_consts.ml
/Users/dbuenzli/.opam/4.00.1/bin/ocamlfind ocamldep -modules src/tsdl_consts.ml > src/tsdl_consts.ml.depends
/Users/dbuenzli/.opam/4.00.1/bin/ocamlfind ocamldep -package ctypes -modules src/tsdl.mli > src/tsdl.mli.depends
/Users/dbuenzli/.opam/4.00.1/bin/ocamlfind ocamlc -c -annot -thread -package ctypes -I src -I test -I support -o src/tsdl.cmi src/tsdl.mli
/Users/dbuenzli/.opam/4.00.1/bin/ocamlfind ocamldep -package ctypes -modules src/tsdl.ml > src/tsdl.ml.depends
/Users/dbuenzli/.opam/4.00.1/bin/ocamlfind ocamlc -c -annot -thread -I src -I test -I support -o src/tsdl_consts.cmo src/tsdl_consts.ml
/Users/dbuenzli/.opam/4.00.1/bin/ocamlfind ocamlc -c -annot -thread -package ctypes -I src -I test -I support -o src/tsdl.cmo src/tsdl.ml
/Users/dbuenzli/.opam/4.00.1/bin/ocamlfind ocamlc -a -cclib -L/usr/local/lib -cclib -lSDL2 -package ctypes -package ctypes.foreign src/tsdl_consts.cmo src/tsdl.cmo -o src/tsdl.cma

  • /Users/dbuenzli/.opam/4.00.1/bin/ocamlfind ocamlc -a -cclib -L/usr/local/lib -cclib -lSDL2 -package ctypes -package ctypes.foreign src/tsdl_consts.cmo src/tsdl.cmo -o src/tsdl.cma
    ocamlfind: Error from package `threads': Missing -thread or -vmthread switch
    Command exited with code 2.

@vicuna
Copy link
Author

vicuna commented Aug 7, 2013

Comment author: @gasche

This should be fixed since #6058. Thanks for the feedback anyway!

PS: the problem indeed comes from the fact that ocamlfind's "error" mechanism is not flexible enough to express the difference between linking into a final program (where -thread is needed) and linking into an archive (when -thread is not needed), while OCamlbuild did this fine-grained distinction. The solution is to dumb down OCamlbuild and pass -thread each time.

In the other bugtracker item, william proposed a workaround that may interest you before the release: -lflags -thread.

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

No branches or pull requests

2 participants