Skip to content

Commit 5402e12

Browse files
committed
emscripten: improve makefile and build flags.
1 parent 46e86b5 commit 5402e12

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

Makefile.emscripten

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ ifeq ($(DEBUG),1)
77
ASSERTIONS := 2
88
DEBUG_EMFLAGS := -s SAFE_HEAP=1
99
else
10-
OPTFLAGS := -O3 -flto
10+
OPTFLAGS := -Oz -flto
1111
ASSERTIONS := 0
1212
DEBUG_EMFLAGS :=
1313
endif
1414

1515
# Emscripten stuff
1616
EMFLAGS := --bind -s WASM=1 -s MODULARIZE=1 -s EXPORT_ES6=1 -s EXPORT_NAME="'TIVarsLib'" -s NO_EXIT_RUNTIME=1 -s ASSERTIONS=$(ASSERTIONS) -s DISABLE_EXCEPTION_CATCHING=0 -s EXPORTED_RUNTIME_METHODS="['FS','getExceptionMessage','decrementExceptionRefcount']" $(DEBUG_EMFLAGS)
1717

18-
CXXFLAGS := $(OPTFLAGS) -std=c++2a -DTH_GDB_SUPPORT=1 -Ivendor/pugixml -W -Wall -Wextra -fexceptions
18+
CPPFLAGS := -DTH_GDB_SUPPORT=1 -Ivendor/pugixml
19+
CXXFLAGS := $(OPTFLAGS) -std=c++2a -W -Wall -Wextra -fexceptions
1920
CFLAGS := $(OPTFLAGS) -std=c2x -W -Wall -Wextra
2021
LFLAGS := $(OPTFLAGS) $(EMFLAGS)
2122

@@ -34,22 +35,22 @@ wasm-tests: $(TEST_OUTPUT).js
3435
node --no-warnings scripts/run_wasm_tests.mjs
3536

3637
%.bc: %.cpp
37-
$(CXX) $(CXXFLAGS) -c $< -o $@
38+
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
3839

3940
%.bc: %.c
4041
$(CC) $(CFLAGS) -c $< -o $@
4142

4243
$(OUTPUT).js: $(OBJS)
43-
$(CXX) $(CXXFLAGS) $(LFLAGS) $^ -o $@
44+
$(CXX) $(LFLAGS) $^ -o $@
4445

4546
tests_wasm.bc: tests.cpp
46-
$(CXX) $(CXXFLAGS) -Dmain=tivars_tests_main -c $< -o $@
47+
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -Dmain=tivars_tests_main -c $< -o $@
4748

4849
scripts/wasm_tests_main.bc: scripts/wasm_tests_main.cpp
49-
$(CXX) $(CXXFLAGS) -c $< -o $@
50+
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
5051

5152
$(TEST_OUTPUT).js: $(filter-out src/main_emscripten.bc,$(OBJS)) tests_wasm.bc scripts/wasm_tests_main.bc
52-
$(CXX) $(CXXFLAGS) $(OPTFLAGS) --bind -s WASM=1 -s MODULARIZE=1 -s EXPORT_ES6=1 -s EXPORT_NAME="'TIVarsTests'" -s NODERAWFS=1 -s EXIT_RUNTIME=1 -s ASSERTIONS=$(ASSERTIONS) -s DISABLE_EXCEPTION_CATCHING=0 -s ALLOW_MEMORY_GROWTH=1 -s EXPORTED_RUNTIME_METHODS="['callMain','getExceptionMessage','decrementExceptionRefcount']" $^ -o $@
53+
$(CXX) $(OPTFLAGS) --bind -s WASM=1 -s MODULARIZE=1 -s EXPORT_ES6=1 -s EXPORT_NAME="'TIVarsTests'" -s NODERAWFS=1 -s EXIT_RUNTIME=1 -s ASSERTIONS=$(ASSERTIONS) -s DISABLE_EXCEPTION_CATCHING=0 -s ALLOW_MEMORY_GROWTH=1 -s EXPORTED_RUNTIME_METHODS="['callMain','getExceptionMessage','decrementExceptionRefcount']" $^ -o $@
5354

5455
clean:
5556
$(RM) -f $(OBJS) tests_wasm.bc scripts/wasm_tests_main.bc $(OUTPUT).js* $(OUTPUT).was* $(TEST_OUTPUT).js* $(TEST_OUTPUT).was*

TIVarsLib.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TIVarsLib.wasm

-6.02 KB
Binary file not shown.

0 commit comments

Comments
 (0)