If I give clang -O2 -O3
in the same command line, in that order, is the -O3
going to override the -O2
? Does the later argument always override?
A build script which I can't change by default adds -O2
and I can only add things after it. Is that an acceptable thing to do?
Operation of the Clang driver is described in the manual page Driver Design & Internals § Driver stages. Note how you can use the -###
option to get it to dump the result of each stage. This is not something you can exercise with your borken build system since the option must be listed first. But you can verify that the driver does in fact do what you hope it does:
clang -### foo.cpp -O2 -O3 # dumps yayayada "-O3" yadamore
clang -### foo.cpp -O3 -O2 # dumps yayayada "-O2" yadamore
Where “yada” is spew that I omitted since there’s too much of it. So, indeed, the last -O
option you specify is the one that is effective. Which is the expected behavior for any compiler driver.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With