diff options
| author | David Faulkner <[email protected]> | 2026-08-06 02:40:39 -0500 |
|---|---|---|
| committer | David Faulkner <[email protected]> | 2026-08-06 02:40:39 -0500 |
| commit | 85c77a80f1baa924535c3e1455fe4d9df7c13a6c (patch) | |
| tree | 1a125ec3f49bf2764c8b81c48d48e376f4da5bd1 | |
| parent | 407017e02f32f471d17800f7d52b556a80cf9a0e (diff) | |
build(makefile): optimize for performance and security hardeningv1.0.1
- 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
| -rw-r--r-- | Makefile | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -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) |
