Skip to content

Instantly share code, notes, and snippets.

@Jacajack
Created March 12, 2019 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jacajack/ee0f73f2652fcdb13d4016a659453185 to your computer and use it in GitHub Desktop.
Save Jacajack/ee0f73f2652fcdb13d4016a659453185 to your computer and use it in GitHub Desktop.
My list of useful compilation flags

Warnings:

  • -Weverything - even more than -Wpedantic in Clang

Debugging:

  • -g - Preserve debugging symbols
  • -fno-omit-frame-pointer - if some symbols remain broken
  • -fno-builtin - Do not perform some printf, scanf, malloc, etc. optimizations (debugging is easier)
  • -fsanitize=address - Use address sanitizer
  • -fsanitize=thread - Use thread sanitizer
  • -fsanitize=undefined - Use UB sanitizer
  • -fsanitize=memory - Use memory sanitizer
  • -masm=intel - Use Intel asm syntax
  • -fverbose-asm - Add some comments to assembly output

Performance:

  • -ffast-math - Allow FP operations to break strict IEEE compilance
  • -ftree-vectorize - Allow loops vectorization
  • -march=native/skylake - Optimize for Skylake architecture (I don't think Coffe Lake is here yet)

Shared libraries:

  • -shared - Compile as a shared library
  • -fPIC - Generate position independent code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment