aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-29 00:49:47 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-29 00:49:47 +0200
commit302897c5e8d61db9107505ba929f9abfc197896d (patch)
tree55c1504dcb03727b22a9af6b0c420fc65c039298 /Makefile
parent46e482552c35456ddc836720df0a44ba25f60544 (diff)
downloadclectio-302897c5e8d61db9107505ba929f9abfc197896d.tar.gz
clectio-302897c5e8d61db9107505ba929f9abfc197896d.zip
perf: DEFLATE (puff) + -no-pie -> OF binary 879 KB -> 662 KB (-25%)
Two size wins: - Replace the home-grown LZSS (2.0x) with DEFLATE: mktext gzips the text and strips the gzip container to a raw DEFLATE stream; clectio decompresses it with puff, Mark Adler's public-domain reference inflate (~200 lines, verified byte-identical to gunzip on the OF/EF text, repetitive, random and empty inputs). Text blob 671 KB -> 492 KB (OF), 164 KB -> 132 KB (EF), 2.7x. - Build with -no-pie: clectio is a local CLI reading static embedded data with no attack surface, so it needs no PIE/ASLR. The linker then bakes the string- table pointers in at link time instead of emitting ~57 KB of runtime relocations. Net: OF 879 -> 662 KB, EF 266 -> 214 KB. Verified byte-identical to lectio. The default build still needs only a compiler + libc; a CORPUS= rebuild now also needs gzip. lz.h removed. Claude-Session: https://claude.ai/code/session_01S1CD1u3tgSS4xNu6WHfp5a
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile12
1 files changed, 8 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index aa3896e..ae74a05 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,11 @@
CC ?= cc
CFLAGS = -std=c99 -Os -Wall -Wextra
-LDFLAGS = -s
+# -no-pie: this is a local CLI reading static embedded data with no attack
+# surface, so it does not need PIE/ASLR. Dropping it lets the linker bake the
+# string-table pointers in at link time instead of emitting ~57 KB of runtime
+# relocations -- a ~6% smaller binary for free.
+LDFLAGS = -s -no-pie
PREFIX = /usr/local
# The form to build is read from config.h so there is one source of truth.
@@ -19,7 +23,7 @@ all: clectio
config.h:
cp config.def.h config.h
-mktext: mktext.c lz.h
+mktext: mktext.c
$(CC) $(CFLAGS) -o $@ mktext.c
bin2h: bin2h.c
@@ -38,8 +42,8 @@ endif
text.lz.h: bin2h text_$(FORM).lz
./bin2h text_$(FORM).lz > $@
-clectio: clectio.c config.h text.lz.h gen/liturgy_$(FORM).h lz.h
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ clectio.c
+clectio: clectio.c puff.c puff.h config.h text.lz.h gen/liturgy_$(FORM).h
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ clectio.c puff.c
size: clectio
@ls -l clectio | awk '{printf "clectio (%s): %d bytes = %.0f KB\n","$(FORM)",$$5,$$5/1024}'