Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Further wasm build cleanups and tweaks. No functional changes. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | wasm-build-rework |
Files: | files | file ages | folders |
SHA3-256: |
3b72a143431537ec275aefae739e5633 |
User & Date: | stephan 2024-09-24 00:31:08.220 |
Context
2024-09-24
| ||
12:16 | Wasm build cleanups. Fix the wasm speedtest1 builds broken by yesterday's refactoring. (check-in: 5d4a090230 user: stephan tags: wasm-build-rework) | |
00:31 | Further wasm build cleanups and tweaks. No functional changes. (check-in: 3b72a14343 user: stephan tags: wasm-build-rework) | |
2024-09-23
| ||
22:56 | Typo fix in makefile comments. (check-in: a4a1287fe8 user: stephan tags: wasm-build-rework) | |
Changes
Changes to ext/wasm/GNUmakefile.
︙ | ︙ | |||
154 155 156 157 158 159 160 | # other parts of the build run, thus we use .NOTPARALLEL to disable # parallel build of that file and its dependants. .NOTPARALLEL: $(sqlite3.h) $(sqlite3.h): $(MAKE) -C $(dir.top) sqlite3.c $(sqlite3.c): $(sqlite3.h) | > | > | > > | > > > > > | | | | | | | | | | | > > > > | | < | > < > > > > | 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | # other parts of the build run, thus we use .NOTPARALLEL to disable # parallel build of that file and its dependants. .NOTPARALLEL: $(sqlite3.h) $(sqlite3.h): $(MAKE) -C $(dir.top) sqlite3.c $(sqlite3.c): $(sqlite3.h) ifneq (1,$(MAKING_CLEAN)) ifeq (,$(filter release snapshot,$(MAKECMDGOALS))) $(info ==============================================================) $(info == Development build. Use 'release' or 'snapshot' target) $(info == for a smaller release build.) $(info ==============================================================) endif endif ######################################################################## # Find emcc (Emscripten compiler)... ifeq (1,$(MAKING_CLEAN)) emcc.bin := echo emcc.version := unknown else emcc.bin := $(shell which emcc 2>/dev/null) ifeq (,$(emcc.bin)) ifneq (,$(EMSDK_HOME)) emcc.bin := $(wildcard $(EMSDK_HOME)/upstream/emscripten/emcc) endif ifeq (,$(emcc.bin)) $(error Cannot find emcc in path.) endif endif emcc.version := $(shell $(emcc.bin) --version | sed -n 1p | sed -e 's/^.* \([3-9][^ ]*\) .*$$/\1/;') $(info using emcc version [$(emcc.version)]) endif ######################################################################### # Find wasm-strip, which we need for release builds (see below for # why) but not strictly for non-release builds. ifeq (1,$(MAKING_CLEAN)) wasm-strip-bin := irrelevant else wasm-strip.bin ?= $(shell which wasm-strip 2>/dev/null) ifeq (,$(wasm-strip.bin)) $(info WARNING: *******************************************************************) $(info WARNING: Builds using -O2/-O3/-Os/-Oz will minify WASM-exported names,) $(info WARNING: breaking _All The Things_. The workaround for that is to build) $(info WARNING: with -g3 (which explodes the file size) and then strip the debug) $(info WARNING: info after compilation, using wasm-strip, to shrink the wasm file.) $(info WARNING: wasm-strip was not found in the PATH so we cannot strip those.) $(info WARNING: If this build uses any optimization level higher than -O1 then) $(info WARNING: the ***resulting JS code WILL NOT BE USABLE***.) $(info WARNING: wasm-strip is part of the wabt package:) $(info WARNING: https://github.com/WebAssembly/wabt) $(info WARNING: on Ubuntu-like systems it can be installed with:) $(info WARNING: sudo apt install wabt) $(info WARNING: *******************************************************************) wasm-strip.bin := echo "not wasm-stripping" endif ifneq (,$(filter release snapshot,$(MAKECMDGOALS))) $(error Cannot make release-quality binary because wasm-strip is not available.) endif endif maybe-wasm-strip := $(wasm-strip.bin) ######################################################################## # barebones=1 disables all "extraneous" stuff from sqlite3-wasm.c, the # goal being to create a WASM file with only the core APIs. ifeq (1,$(barebones)) wasm-bare-bones := 1 $(info ==============================================================) $(info == This is a bare-bones build. It trades away features for) $(info == a smaller .wasm file.) $(info ==============================================================) else wasm-bare-bones := 0 endif undefine barebones # Common options for building sqlite3-wasm.c and speedtest1.c. # Explicit ENABLEs... |
︙ | ︙ | |||
409 410 411 412 413 414 415 416 417 418 419 420 421 422 | # appended to $(C-PP.FILTER.global). bin.c-pp := ./c-pp $(bin.c-pp): c-pp.c $(sqlite3.c) $(MAKEFILE) $(CC) -O0 -o $@ c-pp.c $(sqlite3.c) '-DCMPP_DEFAULT_DELIM="//#"' -I$(dir.top) \ -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_UTF16 \ -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_WAL -DSQLITE_THREADSAFE=0 \ -DSQLITE_TEMP_STORE=3 C-PP.FILTER.global ?= ifeq (1,$(SQLITE_C_IS_SEE)) C-PP.FILTER.global += -Denable-see endif define C-PP.FILTER # Create $2 from $1 using $(bin.c-pp) # $1 = Input file: c-pp -f $(1).js | > | 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | # appended to $(C-PP.FILTER.global). bin.c-pp := ./c-pp $(bin.c-pp): c-pp.c $(sqlite3.c) $(MAKEFILE) $(CC) -O0 -o $@ c-pp.c $(sqlite3.c) '-DCMPP_DEFAULT_DELIM="//#"' -I$(dir.top) \ -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_UTF16 \ -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_WAL -DSQLITE_THREADSAFE=0 \ -DSQLITE_TEMP_STORE=3 DISTCLEAN_FILES += $(bin.c-pp) C-PP.FILTER.global ?= ifeq (1,$(SQLITE_C_IS_SEE)) C-PP.FILTER.global += -Denable-see endif define C-PP.FILTER # Create $2 from $1 using $(bin.c-pp) # $1 = Input file: c-pp -f $(1).js |
︙ | ︙ | |||
477 478 479 480 481 482 483 | EXPORTED_FUNCTIONS.api.core := $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-core EXPORTED_FUNCTIONS.api.in := $(EXPORTED_FUNCTIONS.api.core) ifeq (1,$(SQLITE_C_IS_SEE)) EXPORTED_FUNCTIONS.api.in += $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-see endif ifeq (0,$(wasm-bare-bones)) EXPORTED_FUNCTIONS.api.in += $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-extras | < < < < | 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | EXPORTED_FUNCTIONS.api.core := $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-core EXPORTED_FUNCTIONS.api.in := $(EXPORTED_FUNCTIONS.api.core) ifeq (1,$(SQLITE_C_IS_SEE)) EXPORTED_FUNCTIONS.api.in += $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-see endif ifeq (0,$(wasm-bare-bones)) EXPORTED_FUNCTIONS.api.in += $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-extras endif EXPORTED_FUNCTIONS.api := $(dir.tmp)/EXPORTED_FUNCTIONS.api $(EXPORTED_FUNCTIONS.api): $(EXPORTED_FUNCTIONS.api.in) $(sqlite3.c) $(MAKEFILE) cat $(EXPORTED_FUNCTIONS.api.in) > $@ ######################################################################## # sqlite3-license-version.js = generated JS file with the license |
︙ | ︙ | |||
849 850 851 852 853 854 855 856 857 858 859 860 | sqlite3.mjs := $(dir.dout)/sqlite3.mjs sqlite3-api-bundler-friendly.mjs := $(dir.dout)/sqlite3-api-bundler-friendly.mjs sqlite3-bundler-friendly.mjs := $(dir.dout)/sqlite3-bundler-friendly.mjs sqlite3-api-node.mjs := $(dir.dout)/sqlite3-api-node.mjs sqlite3-node.mjs := $(dir.dout)/sqlite3-node.mjs sqlite3-api-wasmfs.mjs := $(dir.tmp)/sqlite3-api-wasmfs.mjs sqlite3-wasmfs.mjs := $(dir.wasmfs)/sqlite3-wasmfs.mjs .wasmbuilds.make: $(bin.mkwb) @rm -f $@ $(bin.mkwb) > $@ @chmod -w $@ DISTCLEAN_FILES += .wasmbuilds.make | > > > | | 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 | sqlite3.mjs := $(dir.dout)/sqlite3.mjs sqlite3-api-bundler-friendly.mjs := $(dir.dout)/sqlite3-api-bundler-friendly.mjs sqlite3-bundler-friendly.mjs := $(dir.dout)/sqlite3-bundler-friendly.mjs sqlite3-api-node.mjs := $(dir.dout)/sqlite3-api-node.mjs sqlite3-node.mjs := $(dir.dout)/sqlite3-node.mjs sqlite3-api-wasmfs.mjs := $(dir.tmp)/sqlite3-api-wasmfs.mjs sqlite3-wasmfs.mjs := $(dir.wasmfs)/sqlite3-wasmfs.mjs ifneq (1,$(MAKING_CLEAN)) .wasmbuilds.make: $(bin.mkwb) @rm -f $@ $(bin.mkwb) > $@ @chmod -w $@ -include .wasmbuilds.make endif DISTCLEAN_FILES += .wasmbuilds.make # The various -D... values used by *.c-pp.js include: # # -Dtarget=es6-module: for all ESM module builds # # -Dtarget=node: for node.js builds # # -Dtarget=es6-module -Dtarget=es6-bundler-friendly: intended for |
︙ | ︙ |
Changes to ext/wasm/api/pre-js.c-pp.js.
︙ | ︙ | |||
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | "result =", theFile ); return theFile; //#endif target=es6-module }.bind(sqlite3InitModuleState); //#endif ifnot target=es6-bundler-friendly /** Bug warning: a custom Module.instantiateWasm() does not work in WASMFS builds: https://github.com/emscripten-core/emscripten/issues/17951 In such builds we must disable this. */ | > | > > > > > > > > > | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | "result =", theFile ); return theFile; //#endif target=es6-module }.bind(sqlite3InitModuleState); //#endif ifnot target=es6-bundler-friendly //#if custom-Module.instantiateModule /** Bug warning: a custom Module.instantiateWasm() does not work in WASMFS builds: https://github.com/emscripten-core/emscripten/issues/17951 In such builds we must disable this. */ const xNameOfInstantiateWasm = //#if wasmfs false //#else true /* This works, but it does not have the testing coverage in the wild which Emscripten's default impl does, so we'll save this option until we really need a custom Module.instantiateWasm() */ //#endif ? 'instantiateWasm' : 'emscripten-bug-17951'; Module[xNameOfInstantiateWasm] = function callee(imports,onSuccess){ imports.env.foo = function(){}; const uri = Module.locateFile( callee.uri, ( ('undefined'===typeof scriptDirectory/*var defined by Emscripten glue*/) ? "" : scriptDirectory) ); sqlite3InitModuleState.debugModule( "instantiateWasm() uri =", uri ); //console.warn("Custom instantiateModule",uri); const wfetch = ()=>fetch(uri, {credentials: 'same-origin'}); const loadWasm = WebAssembly.instantiateStreaming ? async ()=>{ return WebAssembly.instantiateStreaming(wfetch(), imports) .then((arg)=>onSuccess(arg.instance, arg.module)); } : async ()=>{ // Safari < v15 |
︙ | ︙ | |||
101 102 103 104 105 106 107 108 109 110 | X.js. Thus we need, at build-time, to redefine Module[xNameOfInstantiateWasm].uri by appending it to a build-specific copy of this file with the name of the wasm file. This is apparently why Emscripten hard-codes the name of the wasm file into their glue scripts. */ Module[xNameOfInstantiateWasm].uri = 'sqlite3.wasm'; /* END FILE: api/pre-js.js, noting that the build process may add a line after this one to change the above .uri to a build-specific one. */ | > | 111 112 113 114 115 116 117 118 119 120 121 | X.js. Thus we need, at build-time, to redefine Module[xNameOfInstantiateWasm].uri by appending it to a build-specific copy of this file with the name of the wasm file. This is apparently why Emscripten hard-codes the name of the wasm file into their glue scripts. */ Module[xNameOfInstantiateWasm].uri = 'sqlite3.wasm'; //#endif custom-Module.instantiateModule /* END FILE: api/pre-js.js, noting that the build process may add a line after this one to change the above .uri to a build-specific one. */ |
Changes to ext/wasm/c-pp.c.
︙ | ︙ | |||
1504 1505 1506 1507 1508 1509 1510 | ARGVAL; g.zDelim = zArg; g.nDelim = (unsigned short)strlen(zArg); if(!g.nDelim) fatal("Keyword delimiter may not be empty."); } ISFLAG("debug"){ ++g.doDebug; | | | 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 | ARGVAL; g.zDelim = zArg; g.nDelim = (unsigned short)strlen(zArg); if(!g.nDelim) fatal("Keyword delimiter may not be empty."); } ISFLAG("debug"){ ++g.doDebug; }else if(!zInfile && '-'!=argv[i][0]){ goto do_infile; }else{ fatal("Unhandled flag: %s", argv[i]); } } if(!zInfile) zInfile = "-"; if(!g.out.zName) g.out.zName = "-"; |
︙ | ︙ |
Changes to ext/wasm/mkwasmbuilds.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This app's single purpose is to emit parts of the Makefile code for ** building sqlite3's WASM build. The main motivation is to generate ** code which "can" be created via GNU Make's eval command but is | | | | | | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This app's single purpose is to emit parts of the Makefile code for ** building sqlite3's WASM build. The main motivation is to generate ** code which "can" be created via GNU Make's eval command but is ** highly illegible when constructed that way. Attempts to write this ** app in Bash and TCL have suffered from the problem that both ** require escaping $ symbols, making the resulting script code as ** illegible as the eval spaghetti we want to get away from. Writing ** it in C is, somewhat surprisingly, _slightly_ less illegible than ** writing it in bash, tcl, or native Make code. ** ** The emitted makefile code is not standalone - it depends on ** variables and $(call)able functions from the main makefile. ** */ #undef NDEBUG |
︙ | ︙ | |||
37 38 39 40 41 42 43 | #define zNM zName, zMode /* ** Valid names for the zName arguments. */ #define JS_BUILD_NAMES sqlite3 sqlite3-wasmfs /* | | > | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #define zNM zName, zMode /* ** Valid names for the zName arguments. */ #define JS_BUILD_NAMES sqlite3 sqlite3-wasmfs /* ** Valid names for the zMode arguments of the "sqlite3" build. For the ** "sqlite3-wasmfs" build, only "esm" (ES6 Module) is legal. */ #define JS_BUILD_MODES vanilla esm bundler-friendly node /* ** Emits common vars needed by the rest of the emitted code (but not ** needed by code outside of these generated pieces). */ |
︙ | ︙ | |||
68 69 70 71 72 73 74 | ** --post-js=FILE, and --extern-post-js=FILE emcc flags, as well as ** populating those files. */ static void mk_pre_post(const char *zName, const char *zMode){ pf("pre-post-%s-%s.flags ?=\n", zNM); /* --pre-js=... */ | | > > > > > > > | > > > > > > > > > > > < < < < < < < < < < < < | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | ** --post-js=FILE, and --extern-post-js=FILE emcc flags, as well as ** populating those files. */ static void mk_pre_post(const char *zName, const char *zMode){ pf("pre-post-%s-%s.flags ?=\n", zNM); /* --pre-js=... */ pf("pre-js.js.%s-%s := $(dir.tmp)/pre-js.%s-%s.js\n", zNM, zNM); pf("$(pre-js.js.%s-%s): $(MAKEFILE)\n", zNM); #if 1 pf("$(eval $(call C-PP.FILTER,$(pre-js.js.in),$(pre-js.js.%s-%s)," "$(c-pp.D.%s-%s)))\n", zNM, zNM); #else /* This part is needed if/when we re-enable the custom ** Module.instantiateModule() impl. */ pf("pre-js.js.%s-%s.intermediary := $(dir.tmp)/pre-js.%s-%s.intermediary.js\n", zNM, zNM); pf("$(eval $(call C-PP.FILTER,$(pre-js.js.in),$(pre-js.js.%s-%s.intermediary)," "$(c-pp.D.%s-%s)))\n", zNM, zNM); pf("$(pre-js.js.%s-%s): $(pre-js.js.%s-%s.intermediary)\n", zNM, zNM); pf("\tcp $(pre-js.js.%s-%s.intermediary) $@\n", zNM); /* Amend $(pre-js.js.zName-zMode) for all targets except the plain ** "sqlite3" build... */ if( 0!=strcmp("sqlite3-wasmfs", zName) && 0!=strcmp("sqlite3", zName) ){ pf("\t@echo 'Module[xNameOfInstantiateWasm].uri = " "\"%s.wasm\";' >> $@\n", zName); } #endif /* --post-js=... */ pf("post-js.js.%s-%s := $(dir.tmp)/post-js.%s-%s.js\n", zNM, zNM); pf("$(eval $(call C-PP.FILTER,$(post-js.js.in)," "$(post-js.js.%s-%s),$(c-pp.D.%s-%s)))\n", zNM, zNM); /* --extern-post-js=... */ pf("extern-post-js.js.%s-%s := $(dir.tmp)/extern-post-js.%s-%s.js\n", zNM, zNM); pf("$(eval $(call C-PP.FILTER,$(extern-post-js.js.in),$(extern-post-js.js.%s-%s)," "$(c-pp.D.%s-%s)))\n", zNM, zNM); /* Combine flags for use with emcc... */ pf("pre-post-common.flags.%s-%s := " "$(pre-post-common.flags) " "--post-js=$(post-js.js.%s-%s) " "--extern-post-js=$(extern-post-js.js.%s-%s)\n", zNM, zNM, zNM); pf("pre-post-%s-%s.flags += $(pre-post-common.flags.%s-%s) " "--pre-js=$(pre-js.js.%s-%s)\n", zNM, zNM, zNM); /* Set up deps... */ pf("pre-post-jses.%s-%s.deps := $(pre-post-jses.deps.common) " "$(post-js.js.%s-%s) $(extern-post-js.js.%s-%s)\n", zNM, zNM, zNM); pf("pre-post-%s-%s.deps := $(pre-post-jses.%s-%s.deps) $(dir.tmp)/pre-js.%s-%s.js\n", zNM, zNM, zNM); } |
︙ | ︙ | |||
134 135 136 137 138 139 140 141 142 143 144 145 146 147 | assert( zMode ); assert( zApiJsOut ); assert( zJsOut ); if( !zCmppD ) zCmppD = ""; if( !zEmcc ) zEmcc = ""; pf("#################### begin build [%s-%s]\n", zNM); pf("$(info Setting up build [%s-%s]: %s)\n", zNM, zJsOut); pf("c-pp.D.%s-%s := %s\n", zNM, zCmppD); mk_pre_post(zNM); pf("emcc.flags.%s.%s ?=\n", zNM); if( zEmcc[0] ){ pf("emcc.flags.%s.%s += %s\n", zNM, zEmcc); } | > | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | assert( zMode ); assert( zApiJsOut ); assert( zJsOut ); if( !zCmppD ) zCmppD = ""; if( !zEmcc ) zEmcc = ""; pf("#################### begin build [%s-%s]\n", zNM); pf("ifneq (1,$(MAKING_CLEAN))\n"); pf("$(info Setting up build [%s-%s]: %s)\n", zNM, zJsOut); pf("c-pp.D.%s-%s := %s\n", zNM, zCmppD); mk_pre_post(zNM); pf("emcc.flags.%s.%s ?=\n", zNM); if( zEmcc[0] ){ pf("emcc.flags.%s.%s += %s\n", zNM, zEmcc); } |
︙ | ︙ | |||
186 187 188 189 190 191 192 193 194 195 196 197 198 199 | } pf("\tls -la $$dotwasm $@\n"); if( 0!=strcmp("sqlite3-wasmfs", zName) ){ /* The sqlite3-wasmfs build is optional and needs to be invoked ** conditionally using info we don't have here. */ pf("all: %s\n", zJsOut); } pf("#################### end build [%s-%s]\n\n", zNM); } int main(void){ int rc = 0; pf("# What follows was GENERATED by %s. Edit at your own risk.\n", __FILE__); mk_prologue(); | > | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | } pf("\tls -la $$dotwasm $@\n"); if( 0!=strcmp("sqlite3-wasmfs", zName) ){ /* The sqlite3-wasmfs build is optional and needs to be invoked ** conditionally using info we don't have here. */ pf("all: %s\n", zJsOut); } ps("endif\n# ^^^ !$(MAKING_CLEAN)"); pf("#################### end build [%s-%s]\n\n", zNM); } int main(void){ int rc = 0; pf("# What follows was GENERATED by %s. Edit at your own risk.\n", __FILE__); mk_prologue(); |
︙ | ︙ |
Changes to ext/wasm/wasmfs.make.
1 2 3 4 5 6 7 8 | #!/usr/bin/make #^^^^ help emacs select makefile mode # # This is a sub-make for building a standalone wasmfs-based # sqlite3.wasm. It is intended to be "include"d from the main # GNUMakefile. ######################################################################## MAKEFILE.wasmfs := $(lastword $(MAKEFILE_LIST)) | > > > > | | > > > > | | | > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | #!/usr/bin/make #^^^^ help emacs select makefile mode # # This is a sub-make for building a standalone wasmfs-based # sqlite3.wasm. It is intended to be "include"d from the main # GNUMakefile. ######################################################################## MAKEFILE.wasmfs := $(lastword $(MAKEFILE_LIST)) # ensure that the following message starts on line 10 or higher for proper # alignment! ifneq (1,$(MAKING_CLEAN)) $(warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) $(warning !! The WASMFS build is not well-supported. WASMFS is a proverbial) $(warning !! moving target, sometimes changing in incompatible ways between) $(warning !! Emscripten versions. This build is provided for adventurous folks) $(warning !! and is not a supported deliverable of the SQLite project.) $(warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) endif sqlite3-wasmfs.js := $(dir.wasmfs)/sqlite3-wasmfs.js sqlite3-wasmfs.wasm := $(dir.wasmfs)/sqlite3-wasmfs.wasm ######################################################################## # emcc flags for .c/.o. cflags.sqlite3-wasmfs := cflags.sqlite3-wasmfs += -std=c99 -fPIC cflags.sqlite3-wasmfs += -pthread cflags.sqlite3-wasmfs += -DSQLITE_ENABLE_WASMFS ######################################################################## # emcc flags specific to building the final .js/.wasm file... emcc.flags.sqlite3-wasmfs := emcc.flags.sqlite3-wasmfs += \ -sEXPORTED_RUNTIME_METHODS=wasmMemory # wasmMemory ==> for -sIMPORTED_MEMORY # Some version of emcc between 3.1.60-ish(?) and 3.1.62 deprecated the # use of (allocateUTF8OnStack,stringToUTF8OnStack). Earlier emcc # versions will fail to build without those in the # EXPORTED_RUNTIME_METHODS list. emcc.flags.sqlite3-wasmfs += -sUSE_CLOSURE_COMPILER=0 emcc.flags.sqlite3-wasmfs += -Wno-limited-postlink-optimizations # ^^^^^ emcc likes to warn when we have "limited optimizations" via the -g3 flag. emcc.flags.sqlite3-wasmfs += -sMEMORY64=0 emcc.flags.sqlite3-wasmfs += -sINITIAL_MEMORY=$(emcc.INITIAL_MEMORY.128) # ^^^^ 64MB is not enough for WASMFS/OPFS test runs using batch-runner.js sqlite3-wasmfs.fsflags := -pthread -sWASMFS \ -sPTHREAD_POOL_SIZE=1 \ -sERROR_ON_UNDEFINED_SYMBOLS=0 -sLLD_REPORT_UNDEFINED # ^^^^^ why undefined symbols are necessary for the wasmfs build is anyone's guess. |
︙ | ︙ | |||
53 54 55 56 57 58 59 | # build infrastructure because the supplemental *.worker.js files get # generated with the name of the main module file # ($(sqlite3-wasmfs.{js,mjs})) hard-coded in them. Thus the last one # to get built gets the *.worker.js files mapped to it. In order to # build both modes they would need to have distinct base names or # output directories. "The problem" with giving them distinct base # names is that it means that the corresponding .wasm file is also | | | < | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | # build infrastructure because the supplemental *.worker.js files get # generated with the name of the main module file # ($(sqlite3-wasmfs.{js,mjs})) hard-coded in them. Thus the last one # to get built gets the *.worker.js files mapped to it. In order to # build both modes they would need to have distinct base names or # output directories. "The problem" with giving them distinct base # names is that it means that the corresponding .wasm file is also # built/saved multiple times. It is likely that anyone wanting to use # WASMFS will want an ES6 module, so that's what we build here. wasmfs.build.ext := mjs $(sqlite3-wasmfs.js) $(sqlite3-wasmfs.mjs): $(SOAP.js.bld) ifeq (js,$(wasmfs.build.ext)) $(sqlite3-wasmfs.wasm): $(sqlite3-wasmfs.js) wasmfs: $(sqlite3-wasmfs.js) else $(sqlite3-wasmfs.wasm): $(sqlite3-wasmfs.mjs) wasmfs: $(sqlite3-wasmfs.mjs) endif ######################################################################## # speedtest1 for wasmfs. speedtest1-wasmfs.mjs := $(dir.wasmfs)/speedtest1-wasmfs.mjs speedtest1-wasmfs.wasm := $(subst .mjs,.wasm,$(speedtest1-wasmfs.mjs)) emcc.flags.speedtest1-wasmfs := $(sqlite3-wasmfs.fsflags) emcc.flags.speedtest1-wasmfs += $(SQLITE_OPT) |
︙ | ︙ |