问题
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 ?
回答1:
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.
回答2:
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.
回答3:
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
.
来源:https://stackoverflow.com/questions/28561971/how-to-configure-oasis-for-ocaml-to-set-profile-flag