build.mk 936 B

12345678910111213141516171819202122232425262728
  1. SANITIZE := -fsanitize-address-use-after-scope \
  2. -fsanitize=leak -fsanitize=undefined \
  3. -fno-omit-frame-pointer -fno-optimize-sibling-calls \
  4. -fsanitize=address,undefined,pointer-subtract,pointer-compare
  5. DEBUG_CFLAGS := -ggdb -g3 -O0 ${SANITIZE}
  6. DEBUG_LDFLAGS := ${SANITIZE}
  7. RELEASE_CFLAGS := -march=native -O3 -flto -fPIC -fPIE \
  8. -freciprocal-math -fstack-protector-strong \
  9. -ftree-vectorize -funroll-loops -fno-math-errno \
  10. -fno-trapping-math -fno-math-errno -ffinite-math-only \
  11. -fno-rounding-math -fno-signed-zeros -fassociative-math
  12. RELEASE_LDFLAGS := -Wl,-O4 -Wl,--as-needed -Wl,-z,now -Wl,-z,relro
  13. RELEASE_CPPFLAGS := -D_FORTIFY_SOURCE=2
  14. .PHONY: debug
  15. debug: all
  16. debug: CFLAGS += ${DEBUG_CFLAGS}
  17. debug: LDFLAGS += ${DEBUG_LDFLAGS}
  18. .PHONY: release
  19. release: all
  20. release: CFLAGS += ${RELEASE_CFLAGS}
  21. release: LDFLAGS += ${RELEASE_LDFLAGS}
  22. release: CPPFLAGS += ${RELEASE_CPPFLAGS}