Commit 4ce9f66a

4ce9f66a7290Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 4 files · +2 added · ~2 modified

Description

build: move string->number parsers into libspinel_rt.a (sp_core.c)

First step of slimming sp_runtime.h, which is re-parsed in every generated translation unit (600+ times across make test). The cold, self-contained sp_str_to_i_* / sp_str_to_f_strict parsers now live in lib/sp_core.c (compiled once into libspinel_rt.a) and are declared via lib/sp_core.h, mirroring the sp_time.c split. sp_raise_cls / sp_sprintf become external so the archived code can call them at link time.

The bootstrap binaries previously linked without libspinel_rt.a; they now link it (it was already a prerequisite), since the compiler itself uses these parsers. This unblocks moving further cold, non-inline helpers out of the header in follow-ups. install now ships sp_core.h and sp_time.h (the latter was a pre-existing gap).

Bootstrap converges; 640 tests pass; optcarrot checksum 59662.

Details

Commit
4ce9f66a7290
Parent
7ed159b52c93

MakefilemodifiedView file

@@ -284,9 +284,13 @@
284284 @mkdir -p build
285285 $(CC) -c -O2 -Wno-all $(SEC_FLAGS) -Ilib lib/sp_time.c -o build/sp_time.o
286286
287+build/sp_core.o: lib/sp_core.c lib/sp_core.h
288+ @mkdir -p build
289+ $(CC) -c -O2 -Wno-all $(SEC_FLAGS) -Ilib lib/sp_core.c -o build/sp_core.o
290+
287291 SP_RT_LIB = lib/libspinel_rt.a
288292
289-$(SP_RT_LIB): $(RE_OBJ) build/sp_bigint.o build/sp_crypto.o build/sp_pack.o build/sp_strscan.o build/sp_time.o
293+$(SP_RT_LIB): $(RE_OBJ) build/sp_bigint.o build/sp_crypto.o build/sp_pack.o build/sp_strscan.o build/sp_time.o build/sp_core.o
290294 ar rcs $@ $^
291295
292296 regexp: $(SP_RT_LIB)
@@ -327,10 +331,10 @@
327331 ruby spinel_codegen.rb build/codegen.ast build/codegen.ir build/codegen1.c
328332
329333 spinel_analyze$(EXE): build/analyze1.c $(SP_RT_LIB)
330- $(CC) $(BOOTSTRAP_CFLAGS) -Ilib build/analyze1.c $(LDFLAGS) -lm -o spinel_analyze$(EXE)
334+ $(CC) $(BOOTSTRAP_CFLAGS) -Ilib build/analyze1.c $(SP_RT_LIB) $(LDFLAGS) -lm -o spinel_analyze$(EXE)
331335
332336 spinel_codegen$(EXE): build/codegen1.c $(SP_RT_LIB)
333- $(CC) $(BOOTSTRAP_CFLAGS) -Ilib build/codegen1.c $(LDFLAGS) -lm -o spinel_codegen$(EXE)
337+ $(CC) $(BOOTSTRAP_CFLAGS) -Ilib build/codegen1.c $(SP_RT_LIB) $(LDFLAGS) -lm -o spinel_codegen$(EXE)
334338
335339 # ---- Self-hosting verification ----
336340 # After CRuby builds spinel_{analyze,codegen}, run them on each
@@ -353,7 +357,7 @@
353357 ./spinel_codegen$(EXE) build/analyze.ast build/analyze2.ir build/analyze2.c
354358
355359 build/bin2_analyze$(EXE): build/analyze2.c $(SP_RT_LIB)
356- $(CC) $(BOOTSTRAP_CFLAGS) -Ilib build/analyze2.c $(LDFLAGS) -lm -o build/bin2_analyze$(EXE)
360+ $(CC) $(BOOTSTRAP_CFLAGS) -Ilib build/analyze2.c $(SP_RT_LIB) $(LDFLAGS) -lm -o build/bin2_analyze$(EXE)
357361
358362 build/codegen2.ir: build/codegen.ast spinel_analyze$(EXE)
359363 ./spinel_analyze$(EXE) build/codegen.ast build/codegen2.ir
@@ -362,7 +366,7 @@
362366 ./spinel_codegen$(EXE) build/codegen.ast build/codegen2.ir build/codegen2.c
363367
364368 build/bin2_codegen$(EXE): build/codegen2.c $(SP_RT_LIB)
365- $(CC) $(BOOTSTRAP_CFLAGS) -Ilib build/codegen2.c $(LDFLAGS) -lm -o build/bin2_codegen$(EXE)
369+ $(CC) $(BOOTSTRAP_CFLAGS) -Ilib build/codegen2.c $(SP_RT_LIB) $(LDFLAGS) -lm -o build/bin2_codegen$(EXE)
366370
367371 build/analyze3.ir: build/analyze.ast build/bin2_analyze$(EXE)
368372 ./build/bin2_analyze$(EXE) build/analyze.ast build/analyze3.ir
@@ -588,6 +592,8 @@
588592 install -m 644 spinel_codegen.rb $(SPNLDIR)/
589593 install -m 644 lib/libspinel_rt.a $(SPNLDIR)/lib/
590594 install -m 644 lib/sp_runtime.h $(SPNLDIR)/lib/
595+ install -m 644 lib/sp_core.h $(SPNLDIR)/lib/
596+ install -m 644 lib/sp_time.h $(SPNLDIR)/lib/
591597 install -m 644 lib/*.rb $(SPNLDIR)/lib/
592598 install -d $(PREFIX)/bin
593599 ln -sf $(SPNLDIR)/spinel $(PREFIX)/bin/spinel