Skip to content

Commit

Permalink
Use -Oz instead of -O2 to reduce compiled asset sizes significantly (#…
Browse files Browse the repository at this point in the history
…479)

* Run `npm ci` automatically after the devcontainer is created.
This reduces the chance that another dev will forget to do this.

* Upgrade to Emscripten 2.0.29
Changes required:
* Defined EM_NODE_JS environment variable to get rid of
a warning that appears if the NODE environment variable
is set, but EM_NODE_JS is not.
* EXTRA_EXPORTED_RUNTIME_METHODS is now EXPORTED_RUNTIME_METHODS
* No longer pass the `-s LINKABLE=1` option to emcc when compiling. (This is a linktime setting and emcc
warns about not using a linktime setting when compiling now).

* Upgrade to Sqlite 3.36.0
Sqlite now publishes the hash as a SHA3 instead of SHA1,
necessitating the installation of the sha3sum command.

* Use -Oz optimizations instead of -O2
This reduces most compilation output by around 50%
  • Loading branch information
Taytay committed Jun 1, 2022
1 parent 3f054c2 commit adb788c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ EXTENSION_FUNCTIONS_SHA1 = c68fa706d6d9ff98608044c00212473f9c14892f

EMCC=emcc

CFLAGS = \
-O2 \
SQLITE_COMPILATION_FLAGS = \
-Oz \
-DSQLITE_OMIT_LOAD_EXTENSION \
-DSQLITE_DISABLE_LFS \
-DSQLITE_ENABLE_FTS3 \
Expand Down Expand Up @@ -53,7 +53,7 @@ EMFLAGS_WASM = \

EMFLAGS_OPTIMIZED= \
-s INLINING_LIMIT=50 \
-O3 \
-Oz \
-flto \
--closure 1

Expand Down Expand Up @@ -148,13 +148,13 @@ dist/worker.sql-wasm-debug.js: dist/sql-wasm-debug.js src/worker.js
out/sqlite3.bc: sqlite-src/$(SQLITE_AMALGAMATION)
mkdir -p out
# Generate llvm bitcode
$(EMCC) $(CFLAGS) -c sqlite-src/$(SQLITE_AMALGAMATION)/sqlite3.c -o $@
$(EMCC) $(SQLITE_COMPILATION_FLAGS) -c sqlite-src/$(SQLITE_AMALGAMATION)/sqlite3.c -o $@

# Since the extension-functions.c includes other headers in the sqlite_amalgamation, we declare that this depends on more than just extension-functions.c
out/extension-functions.bc: sqlite-src/$(SQLITE_AMALGAMATION)
mkdir -p out
# Generate llvm bitcode
$(EMCC) $(CFLAGS) -c sqlite-src/$(SQLITE_AMALGAMATION)/extension-functions.c -o $@
$(EMCC) $(SQLITE_COMPILATION_FLAGS) -c sqlite-src/$(SQLITE_AMALGAMATION)/extension-functions.c -o $@

# TODO: This target appears to be unused. If we re-instatate it, we'll need to add more files inside of the JS folder
# module.tar.gz: test package.json AUTHORS README.md dist/sql-asm.js
Expand Down

0 comments on commit adb788c

Please sign in to comment.