Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to read from compiled code what CCFLAGS (particularly the optimizations) were set at compile time?

share|improve this question
I think your question is a duplicate of stackoverflow.com/questions/2387040/… but given it's on a different SE site I can't report it through the "flag" button. – Shadok Feb 21 '13 at 13:49
@Shadok almost what he wants: your link refers to reading the GCC version, the asker wants to know if he can find the CFLAGS used for building the binary. – Renan Feb 21 '13 at 13:57
Sorry I think I swapped two links, here the one I wanted to link: stackoverflow.com/questions/189350/… – Shadok Feb 21 '13 at 14:16
Thanks Shadok - if you add this as an answer I'll accept it. In my case the code was compiled with gcc 4.5 :) but the binary in question has been stripped :( – symcbean Feb 21 '13 at 22:56
up vote 0 down vote accepted

Apparently there is but only with gcc >= 4.3,the switch -frecord-gcc-switches causes the whole command line to be put into ASCII commentaries.

See here for an answer to this question on SO.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.