1

I've been using oasis to build my project using some external packages. Now I also want to use Jane Street's Core package. However, in order to compile with Core, you have to pass the -thread flag to ocamlfind, e.g. like this:

ocamlfind ocamlc -linkpkg -thread -package core foo.ml -o foo

How can I tell oasis to add the -thread flag? Right now, my _oasis file includes something like the following:

Executable "foo"
  BuildDepends: core,batteries,bar
  Path: src
  MainIs: foo.ml
  CompiledObject: best

Bar a collection of my own utilities from the same project. When I run oasis setup and make, I get this error:

ocamlfind: Error from package `threads': Missing -thread or -vmthread switch

I looked at the Oasis manual, and neither the common fields for all sections of the _oasis file, nor the fields that are specific to the Excutable section seem to be appropriate for adding a command line flag for ocamlfind.

I thought that this answer might be relevant, but when I tried adding the extra keys it suggested, with -thread as the value for XOCamlbuildExtraArgs, I got an error:

E: Field XOCamlbuildExtraArgs is not defined in schema Executable
Mars
  • 8,689
  • 2
  • 42
  • 70

1 Answers1

4

You need to add the following line to your _tags file:

<**/*>: thread

There will be a bunch of stuff between the OASIS_START and OASIS_STOP delimiters, don't add anything between them, but rather before or after.

ivg
  • 34,431
  • 2
  • 35
  • 63
  • Thanks ivg. That did the trick. (_tags is automatically generated by `oasis setup` but doesn't get overwritten once it's generated, it seems, so this solution should work in general.) – Mars Jun 19 '17 at 18:39
  • For anyone else coming along, what I wrote in that comment was wrong. _tags can be altered by `oasis setup`, but it leaves the additional line at the end as is. – Mars Jun 20 '17 at 01:43
  • 1
    I tried the above, with `BuildDepends: \n core`, in a very simple one-line “project”, but I'm getting: `Error: Files /usr/local/lib/ocaml/threads/threads.cmxa and /usr/local/lib/ocaml/threads/threads.cmxa both define a module named Thread` (yes, that's the same path twice … wtf?) – ELLIOTTCABLE Oct 02 '17 at 21:02