From b58bd50e64183dc79eec9f0b3cbaef9aa4ec5b9a Mon Sep 17 00:00:00 2001 From: javalsai Date: Wed, 27 Aug 2025 19:54:24 +0200 Subject: [PATCH] perf: some compiler flag optimizations https://stackoverflow.com/questions/6687630/how-to-remove-unused-c-c-symbols-with-gcc-and-ld --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9556882..e689da1 100644 --- a/Makefile +++ b/Makefile @@ -9,10 +9,11 @@ ODIR=dist PREFIX=/usr CC?=gcc -CFLAGS?=-O3 -Wall +CFLAGS?=-O3 -Wall -fdata-sections -ffunction-sections # C PreProcessor flags, not C Plus Plus CPPFLAGS?= ALLFLAGS=$(CFLAGS) $(CPPFLAGS) -I$(IDIR) +LDFLAGS?=-Wl,--gc-sections LIBS=-lpam @@ -41,7 +42,7 @@ $(ODIR)/%.o: $(CDIR)/%.c $(DEPS) $(CC) -c -o $@ $< $(ALLFLAGS) lidm: $(OBJ) - $(CC) -o $@ $^ $(ALLFLAGS) $(LIBS) + $(CC) -o $@ $^ $(ALLFLAGS) $(LIBS) $(LDFLAGS) clean: rm -f $(ODIR)/*.o lidm