Skip to content

Instantly share code, notes, and snippets.

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 angelorodem/73ea6893cab07e238fb324e11aa378c6 to your computer and use it in GitHub Desktop.
Save angelorodem/73ea6893cab07e238fb324e11aa378c6 to your computer and use it in GitHub Desktop.
For debugging
Linker:
-lgcov --coverage
Compiler:
-g -Og -dA -Wall -Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization -Wdiv-by-zero -Wendif-labels -Wformat-extra-args -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winline -Winvalid-pch -Wlogical-op -Wmissing-declarations -Wno-missing-format-attribute -Wmissing-include-dirs -Wmultichar -Wpacked -Wpointer-arith -Wreturn-type -Wsequence-point -Wsign-compare -Wstrict-aliasing -Wstrict-aliasing=2 -Wswitch -Wswitch-default -Werror=undef -Wno-unused -Wvariadic-macros -Wwrite-strings -Werror=declaration-after-statement -Werror=implicit-function-declaration -Werror=nested-externs -Werror=strict-prototypes -fno-strict-aliasing -static #-Werror=missing-braces
for release
(if you have problems with fwhole-program use -flto instead and use -flto in the linker too)
Compiler (fast but not safe):
-Ofast -fwhole-program -fomit-frame-pointer -fmodulo-sched -fmodulo-sched-allow-regmoves -fgcse-sm -fgcse-las -fgcse-after-reload -funsafe-loop-optimizations -flive-range-shrinkage -fsched-spec-load-dangerous -fsched2-use-superblocks -floop-nest-optimize -floop-parallelize-all -ftree-parallelize-loops=8 -fprefetch-loop-arrays -ffinite-math-only -march=native -mtune=native -mfpmath="387+sse" -std=c++1z -static
(for a bit more performance use profiling guided optimization aswell)
For a hardened release (slow but safe):
Linker:
-Wl,-z,now -Wl,-z,relro
Compiler:
-Os -fwhole-program -s -fPIE -fvisibility-inlines-hidden -flto -fomit-frame-pointer -fstack-protector-all -D_FORTIFY_SOURCE=2 -fcf-protection=full -fvisibility=hidden -fsanitize=address -fsanitize=kernel-address -fsanitize-address-use-after-scope -fsanitize-coverage=trace-cmp -mmpx -fcheck-pointer-bounds -static -fstack-check -fstack-clash-protection -fsplit-stack -fvtable-verify=preinit -fstack-reuse=none -fno-exceptions -freg-struct-return -fno-jump-tables -mfpmath="387+sse"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment