Commit 32885d0a
32885d0ab5ccMerged
Yasuhiro Matsumoto <[email protected]> · 7 months ago · 1 file · ~1 modified
Description
build: thread .exe suffix through Makefile for MinGW builds
MinGW gcc rewrites -o foo to foo.exe, so targets named without the
suffix never matched the file on disk — Make would rebuild parse/bootstrap
on every invocation, cp build/bin2 spinel_codegen would fail, make install would look for non-existent files, and make clean would leave
the binaries behind. Introduce an EXE variable (.exe on Windows,
empty elsewhere) and apply it to every executable target, build output,
invocation, and install/clean path.
Details
- Commit
- 32885d0ab5cc
- Parent
- f252c5868029
MakefilemodifiedView file
@@ -20,9 +20,12 @@
2020
GC_FLAGS = -Wl,--gc-sections2121
endif2222
23-
# Windows (MinGW) default stack is 1MB — far too small for the deeply24-
# recursive bootstrap compile (~75k frames of AST traversal). Reserve 64MB.23+
# MinGW gcc appends .exe to its output filename; reflect that in target24+
# names so Make's dependency tracking and install/clean match reality.25+
# Windows (MinGW) default stack is also only 1MB — far too small for the26+
# deeply recursive bootstrap compile (~75k frames of AST traversal).2527
ifeq ($(OS),Windows_NT)28+
EXE = .exe2629
LDFLAGS += -Wl,--stack,671088642730
endif2831
@@ -88,9 +91,9 @@
8891
8992
# ---- C Parser ----9093
91-
parse: spinel_parse94+
parse: spinel_parse$(EXE)9295
93-
spinel_parse: spinel_parse.c $(PRISM_LIB)96+
spinel_parse$(EXE): spinel_parse.c $(PRISM_LIB)9497
$(CC) $(CFLAGS) -I$(PRISM_INC) $< $(PRISM_LIB) -lm -o $@9598
9699
# ---- Runtime library (regexp + bigint) ----@@ -115,35 +118,35 @@
115118
116119
# ---- Bootstrap ----117120
118-
bootstrap: spinel_codegen121+
bootstrap: spinel_codegen$(EXE)119122
120-
spinel_codegen: spinel_codegen.rb spinel_parse123+
spinel_codegen$(EXE): spinel_codegen.rb spinel_parse$(EXE)121124
@echo "=== Bootstrap Step 1: parse ==="122-
./spinel_parse spinel_codegen.rb build/codegen.ast125+
./spinel_parse$(EXE) spinel_codegen.rb build/codegen.ast123126
@echo "=== Bootstrap Step 2: gen1 (CRuby) ==="124127
ruby spinel_codegen.rb build/codegen.ast build/gen1.c125-
$(CC) $(CFLAGS) -Ilib build/gen1.c $(LDFLAGS) -lm -o build/bin1128+
$(CC) $(CFLAGS) -Ilib build/gen1.c $(LDFLAGS) -lm -o build/bin1$(EXE)126129
@echo "=== Bootstrap Step 3: gen2 (bin1) ==="127-
./build/bin1 build/codegen.ast build/gen2.c128-
$(CC) $(CFLAGS) -Ilib build/gen2.c $(LDFLAGS) -lm -o build/bin2130+
./build/bin1$(EXE) build/codegen.ast build/gen2.c131+
$(CC) $(CFLAGS) -Ilib build/gen2.c $(LDFLAGS) -lm -o build/bin2$(EXE)129132
@echo "=== Bootstrap Step 4: gen3 (bin2) - verify ==="130-
./build/bin2 build/codegen.ast build/gen3.c133+
./build/bin2$(EXE) build/codegen.ast build/gen3.c131134
@diff build/gen2.c build/gen3.c > /dev/null && echo "gen2.c == gen3.c (bootstrap OK)" || (echo "BOOTSTRAP FAILED: gen2.c != gen3.c" && exit 1)132-
cp build/bin2 spinel_codegen135+
cp build/bin2$(EXE) spinel_codegen$(EXE)133136
134137
# ---- Test ----135138
136-
test: spinel_parse $(SP_RT_LIB)137-
@if [ ! -f spinel_codegen ]; then echo "Run 'make bootstrap' first"; exit 1; fi139+
test: spinel_parse$(EXE) $(SP_RT_LIB)140+
@if [ ! -f spinel_codegen$(EXE) ]; then echo "Run 'make bootstrap' first"; exit 1; fi138141
@pass=0; fail=0; err=0; \139142
for f in test/*.rb; do \140143
bn=$$(basename "$$f" .rb); \141-
./spinel_parse "$$f" /tmp/_sp_t.ast 2>/dev/null && \142-
./spinel_codegen /tmp/_sp_t.ast /tmp/_sp_t.c 2>/dev/null && \143-
$(CC) $(CFLAGS) -Werror $(SEC_FLAGS) -Ilib /tmp/_sp_t.c $(SP_RT_LIB) $(LDFLAGS) -lm $(GC_FLAGS) -o /tmp/_sp_t_bin 2>/dev/null; \144+
./spinel_parse$(EXE) "$$f" /tmp/_sp_t.ast 2>/dev/null && \145+
./spinel_codegen$(EXE) /tmp/_sp_t.ast /tmp/_sp_t.c 2>/dev/null && \146+
$(CC) $(CFLAGS) -Werror $(SEC_FLAGS) -Ilib /tmp/_sp_t.c $(SP_RT_LIB) $(LDFLAGS) -lm $(GC_FLAGS) -o /tmp/_sp_t_bin$(EXE) 2>/dev/null; \144147
if [ $$? -eq 0 ]; then \145148
expected=$$(timeout 10 ruby "$$f" 2>/dev/null); \146-
actual=$$(timeout 10 /tmp/_sp_t_bin 2>/dev/null); \149+
actual=$$(timeout 10 /tmp/_sp_t_bin$(EXE) 2>/dev/null); \147150
if [ "$$expected" = "$$actual" ]; then \148151
pass=$$((pass+1)); \149152
else \@@ -153,24 +156,24 @@
153156
echo "ERR: $$bn"; err=$$((err+1)); \154157
fi; \155158
done; \156-
rm -f /tmp/_sp_t.ast /tmp/_sp_t.c /tmp/_sp_t_bin; \159+
rm -f /tmp/_sp_t.ast /tmp/_sp_t.c /tmp/_sp_t_bin$(EXE); \157160
echo "Tests: $$pass pass, $$fail fail, $$err error"158161
159-
bench: spinel_parse $(SP_RT_LIB)160-
@if [ ! -f spinel_codegen ]; then echo "Run 'make bootstrap' first"; exit 1; fi162+
bench: spinel_parse$(EXE) $(SP_RT_LIB)163+
@if [ ! -f spinel_codegen$(EXE) ]; then echo "Run 'make bootstrap' first"; exit 1; fi161164
@pass=0; fail=0; skip=0; \162165
for f in benchmark/*.rb; do \163166
bn=$$(basename "$$f" .rb); \164-
timeout 10 ./spinel_parse "$$f" /tmp/_sp_b.ast 2>/dev/null && \165-
timeout 10 ./spinel_codegen /tmp/_sp_b.ast /tmp/_sp_b.c 2>/dev/null && \166-
$(CC) $(CFLAGS) -Werror $(SEC_FLAGS) -Ilib /tmp/_sp_b.c $(SP_RT_LIB) $(LDFLAGS) -lm $(GC_FLAGS) -o /tmp/_sp_b_bin 2>/dev/null; \167+
timeout 10 ./spinel_parse$(EXE) "$$f" /tmp/_sp_b.ast 2>/dev/null && \168+
timeout 10 ./spinel_codegen$(EXE) /tmp/_sp_b.ast /tmp/_sp_b.c 2>/dev/null && \169+
$(CC) $(CFLAGS) -Werror $(SEC_FLAGS) -Ilib /tmp/_sp_b.c $(SP_RT_LIB) $(LDFLAGS) -lm $(GC_FLAGS) -o /tmp/_sp_b_bin$(EXE) 2>/dev/null; \167170
if [ $$? -eq 0 ]; then \168171
expected=$$(timeout 60 ruby "$$f" 2>/dev/null); \169172
ruby_rc=$$?; \170173
if [ $$ruby_rc -eq 124 ]; then \171174
echo "SKIP: $$bn (ruby timeout)"; skip=$$((skip+1)); \172175
else \173-
actual=$$(timeout 60 /tmp/_sp_b_bin 2>/dev/null); \176+
actual=$$(timeout 60 /tmp/_sp_b_bin$(EXE) 2>/dev/null); \174177
if [ "$$expected" = "$$actual" ]; then \175178
pass=$$((pass+1)); \176179
else \@@ -181,7 +184,7 @@
181184
echo "ERR: $$bn"; \182185
fi; \183186
done; \184-
rm -f /tmp/_sp_b.ast /tmp/_sp_b.c /tmp/_sp_b_bin; \187+
rm -f /tmp/_sp_b.ast /tmp/_sp_b.c /tmp/_sp_b_bin$(EXE); \185188
echo "Benchmarks: $$pass pass, $$fail fail, $$skip skip"186189
187190
# ---- Install ----@@ -191,14 +194,14 @@
191194
192195
install: all193196
install -d $(SPNLDIR)/lib194-
install -m 755 spinel $(SPNLDIR)/195-
install -m 755 spinel_parse $(SPNLDIR)/196-
install -m 755 spinel_codegen $(SPNLDIR)/197-
install -m 644 spinel_parse.rb $(SPNLDIR)/198-
install -m 644 spinel_codegen.rb $(SPNLDIR)/199-
install -m 644 lib/libspinel_rt.a $(SPNLDIR)/lib/200-
install -m 644 lib/sp_runtime.h $(SPNLDIR)/lib/201-
install -m 644 lib/*.rb $(SPNLDIR)/lib/197+
install -m 755 spinel $(SPNLDIR)/198+
install -m 755 spinel_parse$(EXE) $(SPNLDIR)/199+
install -m 755 spinel_codegen$(EXE) $(SPNLDIR)/200+
install -m 644 spinel_parse.rb $(SPNLDIR)/201+
install -m 644 spinel_codegen.rb $(SPNLDIR)/202+
install -m 644 lib/libspinel_rt.a $(SPNLDIR)/lib/203+
install -m 644 lib/sp_runtime.h $(SPNLDIR)/lib/204+
install -m 644 lib/*.rb $(SPNLDIR)/lib/202205
install -d $(PREFIX)/bin203206
ln -sf $(SPNLDIR)/spinel $(PREFIX)/bin/spinel204207
@@ -210,4 +213,4 @@
210213
211214
clean:212215
rm -rf build/213-
rm -f spinel_parse spinel_codegen216+
rm -f spinel_parse$(EXE) spinel_codegen$(EXE)