From 85c77a80f1baa924535c3e1455fe4d9df7c13a6c Mon Sep 17 00:00:00 2001 From: David Faulkner Date: Thu, 6 Aug 2026 02:40:39 -0500 Subject: build(makefile): optimize for performance and security hardening - Enable -O3, -flto, -fomit-frame-pointer, and -march=native for performance - Add strict compiler warnings (-Werror, -Wconversion, -Wsign-conversion, -Wshadow, -Wformat=2) - Add security hardening flags (-fstack-protector-strong, -D_FORTIFY_SOURCE=2) - Pass -flto, -O3, and strip symbols (-Wl,-s) during linking --- Makefile | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 939f257..c2a75fd 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,20 @@ # Compiler and flags +# Compiler & Language Standard CC := gcc -CFLAGS := -Wall -Wextra -Wpedantic -O2 -std=c11 -D_POSIX_C_SOURCE=200809L +CFLAGS := -std=c11 -D_POSIX_C_SOURCE=200809L + +# --- PERFORMANCE FLAGS --- +CFLAGS += -O3 -flto -fomit-frame-pointer -march=native + +# --- SAFETY & STRICT WARNING FLAGS --- +CFLAGS += -Wall -Wextra -Wpedantic -Werror \ + -Wconversion -Wsign-conversion -Wshadow -Wformat=2 + +# --- HARDENING & RUNTIME PROTECTION FLAGS --- +CFLAGS += -fstack-protector-strong -D_FORTIFY_SOURCE=2 + +# --- LINKER FLAGS (LTO & Strip) --- +LDFLAGS := -flto -O3 -Wl,-s TARGET := ud SRC := main.c OBJ := $(SRC:.c=.o) -- cgit v1.2.3