From 848eb19f505ef6ec638dddf9b73bd99aeee8c933 Mon Sep 17 00:00:00 2001 From: Gabriel Scherer Date: Fri, 26 Jul 2013 19:40:12 +0000 Subject: [PATCH] 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 --- ocamlbuild/ocaml_specific.ml | 11 +++++------ ocamlbuild/testsuite/level0.ml | 9 ++++++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ocamlbuild/ocaml_specific.ml b/ocamlbuild/ocaml_specific.ml index de0491603..dbf4bd671 100644 --- a/ocamlbuild/ocaml_specific.ml +++ b/ocamlbuild/ocaml_specific.ml @@ -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");; diff --git a/ocamlbuild/testsuite/level0.ml b/ocamlbuild/testsuite/level0.ml index de4dcf1a9..a47bf3cec 100644 --- a/ocamlbuild/testsuite/level0.ml +++ b/ocamlbuild/testsuite/level0.ml @@ -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"