Generate C++ and compile with different compiler options

69 views
Skip to first unread message

York

unread,
Jul 19, 2017, 10:24:17 AM7/19/17
to Haxe
Hi all,

I would like to generate C++ code from a sample program written in Haxe, and then I would apply different compiler optimizations options such as -O1 -O2 -O3, etc.  when compiling the the generated CPP sources  to binaries. 

Is it please possible? 

Thank you in advance 

Hugh

unread,
Jul 20, 2017, 12:56:37 AM7/20/17
to Haxe
The optimize flags are a bit tricky because they can be set per-file and they can be different on different targets.

The easiest way to start would be to just change the "toolchain" files in hxcpp.
These contain lines like:

<flag value="-O2" tag="release" />

You can just change the "O2" and see if you get the desired result.

If you want to take it a bit further, you could do:
 <flag value="${MY_OPTIM_FLAG}" tag="release" /> 

and then set MY_OPTIM_FLAG via something like "haxe -main .... -D MY_OPTIM_FLAG=-O1"

This should get you started.

Hugh
Reply all
Reply to author
Forward
0 new messages