chasep255
chasep255

Reputation: 12185

DCRaw says I should compile with -O4 in gcc. Does -O4 exist?

I was looking at building DCRaw from the source. On its web page it recommends that I build with one of the following lines.

Compile with "gcc -o dcraw -O4 dcraw.c -lm -ljasper -ljpeg -llcms2" or "gcc -o dcraw -O4 dcraw.c -lm -DNODEPS".

I have never heard of -O4 in gcc. How is that different from -O3?

https://www.cybercom.net/~dcoffin/dcraw/

Upvotes: 0

Views: 294

Answers (2)

Andy Brown
Andy Brown

Reputation: 13009

Currently -O3 is the highest numbered option that actually adds flags. gcc's numbered optimization levels are cumulative. That is, -O3 includes all the -O2 flags and -O2 includes all of the -O1 flags. This leaves the door open for a future -O4 that would include all of -O3 plus more.

The actual flags are in the documentation but I think you get a better insight from the code itself.

Upvotes: 0

ouah
ouah

Reputation: 145899

The maximum level of optimizations with gcc is -O3. Using -O4 (or -O5, -O6, ..., -O9) actually reverts to -O3. There is no guarantee theses options are supported or will behave differently in the future, so just use -O3 for portability.

 gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
 gcc -c -Q -O4 --help=optimizers > /tmp/O4-opts
 diff -u /tmp/O3-opts /tmp/O4-opts

Upvotes: 1

Related Questions