4

I have an existing project in OCaml and one _oasis file. I don't know where to enable the profiling flag for ocamlbuild.

I looked up Oasis manual and the code, and found there was a variable profile available in setup.data. I assume this was what Oasis auto generated.

Where and what should I include in _oasis to set profile to true ?

perror
  • 7,071
  • 16
  • 58
  • 85
Txin
  • 43
  • 4

3 Answers3

3

You can activate the ocamlbuild_more_args feature.

On top of your _oasis file:

AlphaFeatures: ocamlbuild_more_args

Then, in your Package:

XOCamlbuildExtraArgs: your_ocamlbuild_option

I can't find any -profile option in ocamlbuild though, so I'm not sure of what this is about. Also, this option is still quite unstable.

A better way to handle that would be to modify your _tags file accordingly. It is generated by oasis but you can modify it.

EDIT:

setup.data informs you of environment variables. As for profile, it shows if the -p option will be passed to ocamlopt. You can pass it using the NativeOpt field.

PatJ
  • 5,996
  • 1
  • 31
  • 37
  • `ocamlbuild` allows us to specify `ocamlc` options via `cflags`, but profile is an `ocamlopt` flag, not the `ocamlc` one, so we can't pass it through ocamlbuild. We can only rely on the set intersections of the `ocamlc` and `ocamlopt` options. – ivg Feb 17 '15 at 15:54
1

You can enable the oasis profile flag by adding the --enable-profile argument to the ./configure flag. But so far, I have only noticed any effect when I enabled native code compilation (CompiledObject: native in _oasis). Even then, the profiling generation is only done for gprof.

lambda.xy.x
  • 4,918
  • 24
  • 35
0

I suggest you to use _tags file as it is the easiest way. Just add the following to your _tags:

<true> : profile

You run this command:

echo "<true> : profile" >> _tags

in the folder where your _tags file is located.

If you still want to use _oasis file, then you can use NativeOpt field, to add options that will be passed to native compiler, i.e., ocamlopt.

ivg
  • 34,431
  • 2
  • 35
  • 63