Skip to content

Commit 51f4d26

Browse files
committed
ref(make): explicit opt flags
1 parent 8aad222 commit 51f4d26

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

Makefile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
CC = clang
22

3-
CFLAGS = --target=wasm32 -nostdlib -O2 \
4-
-ffunction-sections -fdata-sections \
5-
-mbulk-memory \
6-
-DCLAY_IMPLEMENTATION -DCLAY_WASM \
7-
-Isrc -I.
3+
CFLAGS_BASE = --target=wasm32 -nostdlib \
4+
-ffunction-sections -fdata-sections \
5+
-mbulk-memory \
6+
-Isrc -I.
7+
8+
INPUT_OPT ?= -Oz
9+
LAYOUT_OPT ?= -O2
10+
11+
LAYOUT_CFLAGS = $(CFLAGS_BASE) $(LAYOUT_OPT) -DCLAY_IMPLEMENTATION -DCLAY_WASM
12+
INPUT_CFLAGS = $(CFLAGS_BASE) $(INPUT_OPT)
813

914
LDFLAGS_COMMON = -Wl,--no-entry \
1015
-Wl,--import-memory \
@@ -54,10 +59,10 @@ all: layout.wasm input.wasm layout.wasm.ts input.wasm.ts
5459
@echo "Built input.wasm ($$(wc -c < input.wasm) bytes raw, $$(gzip -c input.wasm | wc -c) bytes gzip)"
5560

5661
layout.wasm: $(DEPS)
57-
$(CC) $(CFLAGS) $(LAYOUT_LDFLAGS) -o $@ src/module-layout.c
62+
$(CC) $(LAYOUT_CFLAGS) $(LAYOUT_LDFLAGS) -o $@ src/module-layout.c
5863

5964
input.wasm: $(DEPS)
60-
$(CC) $(filter-out -DCLAY_IMPLEMENTATION -DCLAY_WASM, $(CFLAGS)) $(INPUT_LDFLAGS) -o $@ src/module-input.c
65+
$(CC) $(INPUT_CFLAGS) $(INPUT_LDFLAGS) -o $@ src/module-input.c
6166

6267
layout.wasm.ts: layout.wasm
6368
deno run --allow-read --allow-write tasks/bundle-wasm.ts layout.wasm layout.wasm.ts

0 commit comments

Comments
 (0)