Disable all optimization options in GCC

Stricto sensu, the GCC compiler middle-end is made of a sequence (actually a nested tree, dynamically changing during compilation) of optimization passes, so if GCC did no optimization, it won’t be able to emit any code.

Think of it another way: the input language to GCC is quite rich (even for plain C, where you have while, for, ….) but the intermediate Gimple language is much more poor (in particular Gimple/SSA) so you need to apply some transformations to go from source AST to Gimple. These transformations are optimization passes, almost by definition.

See also the pictures from that answer and this one (an SVG image) and read the references mentioned here.

You should understand -O0 as disabling any additional optimizations (e.g. provided by -O1 etc…) not needed to produce some executable.

Leave a Comment