How do I enable/disable individual optimizations in Apple's Clang?

I work on a very large project based on Mozilla Firefox, I am getting a crash at -O2 and -O3. It is stable at -O0 and -O1, so I did some research and found a number of optimizations that supposedly get enabled at -O2. The information I found tells me that I should use -mllvm and the optimization flag that gets passed to the LLVM "opt" command in the normal LLVM toolchain. However Apple's command line tools do not have the "opt" command and -mllvm does not seem to accept the "opt" flags.

What is the Apple way of seeing what optimizations are enabled in -O2 and how do I enable or disable them individually?

  • So there seems to be no way to do it, however it turns out the issue was caused by some stack corruption that was identified with the address sanitizer. The stack corruption only caused a crash when some optimizations were enabled. It still would be interesting to know which optimizations were triggering it... so leaving this open in case at some point it becomes possible to enable or disable individual optimizations.

Add a Comment

Replies

I'm facing a similar issue. I'm trying to narrow down the optimization flags used to determine what is causing my issues.

I have yet to find other flags than the ones accepted for GCC_OPTIMIZATION_LEVEL.