aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2025-11-16 13:52:14 +0800
committerMistivia <i@mistivia.com>2025-11-16 13:52:14 +0800
commitf547737c46fdb09f47072348b0725074a7352db2 (patch)
treed9005ad7599f45e4aaf35642797ece5223183cf3 /Makefile
parentf19a0f0dd0a36a7a9129eacf9362f1168561c9c2 (diff)
update compile flags
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile17
1 files changed, 15 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index de7591d..3dfe832 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,23 @@
mode ?= debug
+# https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.html
+common_cflags = -Wall -Wno-sign-conversion -Wno-conversion -Wformat -Wformat=2 \
+ -Werror=format-security \
+ -D_GLIBCXX_ASSERTIONS \
+ -fstrict-flex-arrays=3 \
+ -fstack-clash-protection -fstack-protector-strong \
+ -Wtrampolines -fzero-init-padding-bits=all \
+ -Wbidi-chars=any \
+ -Werror=implicit -Werror=incompatible-pointer-types -Werror=int-conversion \
+ -fexceptions
+
cc = gcc
ifeq ($(mode), debug)
- cflags = -g
+ cflags = $(common_cflags) -g -Werror
else
- cflags = -O2
+ cflags = $(common_cflags) -O2 \
+ -fno-delete-null-pointer-checks -fno-strict-overflow -fno-strict-aliasing -ftrivial-auto-var-init=zero \
+ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3
endif
src = $(shell ls *.c)