Skip to content

Instantly share code, notes, and snippets.

@jepio
Last active October 14, 2015 11:07
Show Gist options
  • Select an option

  • Save jepio/d34a2a7778f951729030 to your computer and use it in GitHub Desktop.

Select an option

Save jepio/d34a2a7778f951729030 to your computer and use it in GitHub Desktop.
Common compiler flags that are supported by both gcc and clang.
-O3 # enable various code gen optimizations incl. vectorization
-march=native # enable all instructions sets supp. on curr. machine
-mtune=native # tune for the caches of the curr. machine
-flto # enable link time optimization - cross translation unit - AWESOME!
-fprofile-generate # enable code instrumentation to generate profile of program exec.
-fprofile-use # use profile of program exec. to tune branches and stuff
-ffunction-sections # place functions in separate sections that can be discarded by linker
-fdata-sections # ^^same but for data
-Wl,--gc-sections # garbage collect unused sections during linking
-Wl,-O1 # perform linker optimizations (not very significant)
-Wl,--as-needed # don't link in libs that aren't used - breaks bad programs (yay) and
# improves startup of good ones
-fuse-ld=gold # use gold linker, useful when using clang with lto when system linker is bfd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment