Open jirutka opened 6 years ago
If nothing else, this may be useful for debugging code generation problems.
In the sync call, @kulibali mentioned that the actual place for setting optimization level for LLVM codegen is here: https://github.com/ponylang/ponyc/blob/master/src/libponyc/codegen/genopt.cc#L1366
The line shown above is only for the linker.
@mfelsche is going to read about whether it would be a good idea to allow lowering the linker optimization level.
To avoid confusion, and to chime into what @jemc wrote, this is only a linker optimization flag.
The -O
flag here is only setting a linker optimization level, and as far as i understand both the ld and gold linker docs and sources (my understanding might be very shallow), this is only used for optimizing the output file size, not actually doing optimizations as a C compiler would do (inlining and stuff). And this is also unrelated to what is known as link-time-optimization afaik. But i am happy to stand corrected.
Regardless of this being true or not, it might be interesting to set the linker optimization level from the ponyc command line.
I would rather consider this an enhancement, then a bug.
The
-O
flag here is only setting a linker optimization level … this is only used for optimizing the output file size …
That’s actually what I’m currently interested in, to optimize size of the output binary (i.e. compile with -Os
).
Why is optimization level hard-coded to
-O3
? https://github.com/ponylang/ponyc/blob/c76e5900a3453c6f922d68a3e78bb6e0dafeb971/src/libponyc/codegen/genexe.c#L361I’d expect to be able to specify optimization level using CLI argument for
ponyc
.