Skip to content

Commit 7a69b7f

Browse files
Enable LTO, reduce asset count
Enable -flto, -sEVAL_CTORS=1, reduce output file size by doing link-time optimizations and pre-evaluating code. --memory-init-file=0 allows for lesser split output files. Disable AUTO_NATIVE_LIBRARIES Use --embed-file instead of --preload-file
1 parent 952afbd commit 7a69b7f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Makefile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
BASE_DIR:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
55
DIST_DIR:=$(BASE_DIR)dist/libraries
66

7-
export LDFLAGS = -O3 -s ENVIRONMENT=web,webview,worker -s NO_EXIT_RUNTIME=1
8-
export CFLAGS = -O3 -s USE_PTHREADS=0
7+
export LDFLAGS = -O3 -s EVAL_CTORS=1 -flto -s ENVIRONMENT=web,webview,worker -s NO_EXIT_RUNTIME=1
8+
export CFLAGS = -O3 -flto -s USE_PTHREADS=0
99
export CXXFLAGS = $(CFLAGS)
1010
export PKG_CONFIG_PATH = $(DIST_DIR)/lib/pkgconfig
1111
export EM_PKG_CONFIG_PATH = $(PKG_CONFIG_PATH)
@@ -155,12 +155,14 @@ all-src:
155155
EMCC_COMMON_ARGS = \
156156
$(LDFLAGS) \
157157
-s EXPORTED_FUNCTIONS="['_main', '_malloc']" \
158+
-s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE="['\$$Browser']" \
158159
-s EXPORTED_RUNTIME_METHODS="['ccall', 'cwrap', 'getValue', 'FS_createPreloadedFile', 'FS_createPath']" \
159-
--use-preload-plugins \
160-
--preload-file assets/default.woff2 \
161-
--preload-file assets/fonts.conf \
160+
--embed-file assets/default.woff2 \
161+
--embed-file assets/fonts.conf \
162+
-s AUTO_NATIVE_LIBRARIES=0 \
162163
-s ALLOW_MEMORY_GROWTH=1 \
163164
-s NO_FILESYSTEM=0 \
165+
--memory-init-file=0 \
164166
--no-heap-copy \
165167
-o $@
166168

0 commit comments

Comments
 (0)