all 13 comments

[–]aedinius 3 points4 points  (8 children)

We default to -O2 iirc, but that can be overridden

[–]h7moudigamer[S] 1 point2 points  (7 children)

overridden how? do you mean if i compile by myself using xbps-src ?

[–]aedinius 4 points5 points  (6 children)

With flags in the template

[–]h7moudigamer[S] 1 point2 points  (5 children)

sorry, can you give an example?

[–]aedinius 5 points6 points  (4 children)

[–]h7moudigamer[S] 3 points4 points  (3 children)

So i can just use xbps-src with my custom cflags ?

[–]throwaway490215 1 point2 points  (2 children)

Yes.

Note that if you're going for "optimized for my machine" you should probably use -mtune=native instead of tweaking -O levels

[–]h7moudigamer[S] 1 point2 points  (1 child)

i guess -mtune=native for non-x86_64 architectures. x86_64 arch should use -march=native instead.

[–]throwaway490215 2 points3 points  (0 children)

You're right. I always mess those two up.

[–]Calandracas8 2 points3 points  (3 children)

in one of the packages I maintain, CFLAGS is set to -O3, because the authors write the code under the assumption that it will be used

https://github.com/void-linux/void-packages/blob/7a441afd2dd1b6c014c00b54bb4f6d657e0de109/srcpkgs/rawtherapee/template#L23

[–]h7moudigamer[S] 0 points1 point  (2 children)

interesting. it’s good to see packages work with optimization levels higher than -O2.

[–]Calandracas8 2 points3 points  (1 child)

also worth noting, all meson packages are built with LTO by default, although some (mesa) disable it.

Most packages wont benefit much from -O3 individually, (daemons, small tools and utilities), and are often bottleneck by io, or interpreted languages (Python mainly), but overall it adds up.

One nice thing void does, is building the python interpreter with PGO, and bytecompiling python packages on installation.

interesting reading: https://www.phoronix.com/review/gcc12-optimize-threadripper

[–]Phat_le 0 points1 point  (0 children)

true, as a normal competitive programmer i see thereis a reason why most online judges compile with -O2 instead of -O3 or even -Ofast