PR#6058: have ocamlbuild add -thread for all "link" tags

The -thread option is only needed when creating a compilation unit
("compile" tag handled separated), or linking libraries into a final
program ("link";"program"). However, ocamlfind will fail with an error
if neither of -thread or -vmthread is passed into the command-line of
any linking step, such as when creating a cm(x)a archive. The present
fix enables the -thread option for all linking steps, which should fix
any -use-ocamlfind issue and be harmless in other cases.


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13934 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Gabriel Scherer 2013-07-26 19:40:12 +00:00
parent 10a88a4c01
commit 848eb19f50
2 changed files with 13 additions and 7 deletions

View File

@ -569,14 +569,13 @@ flag ["ocaml"; "compile"; "profile"; "native"] (A "-p");;
(* threads, with or without findlib *)
flag ["ocaml"; "compile"; "thread"] (A "-thread");;
flag ["ocaml"; "link"; "thread"] (A "-thread");;
if not !Options.use_ocamlfind then begin
flag ["ocaml"; "doc"; "thread"] (S[A"-I"; A"+threads"]);
flag ["ocaml"; "link"; "thread"; "native"; "program"] (S[A "threads.cmxa"; A "-thread"]);
flag ["ocaml"; "link"; "thread"; "byte"; "program"] (S[A "threads.cma"; A "-thread"]);
flag ["ocaml"; "link"; "thread"; "native"; "toplevel"] (S[A "threads.cmxa"; A "-thread"]);
flag ["ocaml"; "link"; "thread"; "byte"; "toplevel"] (S[A "threads.cma"; A "-thread"])
end else begin
flag ["ocaml"; "link"; "thread"; "program"] (A "-thread")
flag ["ocaml"; "link"; "thread"; "native"; "program"] (A "threads.cmxa");
flag ["ocaml"; "link"; "thread"; "byte"; "program"] (A "threads.cma");
flag ["ocaml"; "link"; "thread"; "native"; "toplevel"] (A "threads.cmxa");
flag ["ocaml"; "link"; "thread"; "byte"; "toplevel"] (A "threads.cma");
end;;
flag ["ocaml"; "compile"; "nopervasives"] (A"-nopervasives");;

View File

@ -64,6 +64,13 @@ test "camlp4.opt"
~matching:[M.x "dummy.native" ~output:"Hello"]
~targets:("dummy.native",[]) ();;
test "ThreadAndArchive"
~description:"Fixes PR#6058"
~options:[`use_ocamlfind; `package "threads"; `tag "thread"]
~tree:[T.f "t.ml" ~content:""]
~matching:[M.f "_build/t.cma"]
~targets:("t.cma",[]) ();;
let tag_pat_msgs =
["*:a", "File \"_tags\", line 1, column 0: Lexing error: Invalid globbing pattern \"*\".";
"\n<*{>:a", "File \"_tags\", line 2, column 0: Lexing error: Invalid globbing pattern \"<*{>\".";
@ -136,7 +143,7 @@ test "NativeMliCmi"
(part of PR#4613)"
~tree:[T.f "foo.mli" ~content:"val bar : int"]
~options:[`ocamlc "toto";(*using ocamlc would fail*) `tags["native"]]
~matching:[M.f "_build/foo.cmi"]
~matching:[_build [M.f "foo.cmi"]]
~targets:("foo.cmi",[]) ();;
test "NoIncludeNoHygiene1"