1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-10-25 20:58:26 +03:00

Experimenting with a custom wasm loader, but don't enable it without an explicit build flag. The goal here is to make the WebAssembly.Module object available internally (the default loader hides it from us).

FossilOrigin-Name: e5f0256feab95c30a8e3e1e69963fb3e25ed2da296aff5bc6646fe96a76c0b81
This commit is contained in:
stephan
2025-09-22 02:40:06 +00:00
parent 1d49644650
commit 5a2e3c4af2
9 changed files with 132 additions and 111 deletions

View File

@@ -381,6 +381,15 @@ $(bin.stripccomments): $(bin.stripccomments).c $(MAKEFILE)
$(CC) -o $@ $< $(CC) -o $@ $<
DISTCLEAN_FILES += $(bin.stripccomments) DISTCLEAN_FILES += $(bin.stripccomments)
#
# If $(WASM_CUSTOM_INSTANTIATE) is 1 then mkwasmbuilds will add
# -Dcustom-Module.instantiateWasm to some of the builds. This is
# experimental.
#
# Changing this may require a clean rebuild.
#
WASM_CUSTOM_INSTANTIATE = 0
######################################################################## ########################################################################
# SQLITE.CALL.C-PP.FILTER: a $(call)able to transform $(1) to $(2) via: # SQLITE.CALL.C-PP.FILTER: a $(call)able to transform $(1) to $(2) via:
# #
@@ -928,7 +937,6 @@ $(dir.dout)/sqlite3-bundler-friendly.mjs: $(sqlite3.mjs)
$(dir.dout)/sqlite3-node.mjs: $(sqlite3.mjs) $(dir.dout)/sqlite3-node.mjs: $(sqlite3.mjs)
#CLEAN_FILES += $(sqlite3.wasm) #CLEAN_FILES += $(sqlite3.wasm)
ifneq (1,$(MAKING_CLEAN))
# This block MUST come between the above definitions of # This block MUST come between the above definitions of
# sqlite3-...js/mjs and the $(eval) calls below this block which use # sqlite3-...js/mjs and the $(eval) calls below this block which use
# SQLITE.CALL.C-PP.FILTER. # SQLITE.CALL.C-PP.FILTER.
@@ -944,16 +952,17 @@ ifneq (1,$(MAKING_CLEAN))
# Maintenance note: the various $(c-pp.D.XYZ) vars are defined via # Maintenance note: the various $(c-pp.D.XYZ) vars are defined via
# $(bin.mkwb). # $(bin.mkwb).
bin.mkwb = ./mkwasmbuilds bin.mkwb = ./mkwasmbuilds
ifneq (1,$(MAKING_CLEAN))
$(bin.mkwb): $(bin.mkwb).c $(MAKEFILE) $(bin.mkwb): $(bin.mkwb).c $(MAKEFILE)
$(CC) -o $@ $< $(CC) -o $@ $< -DWASM_CUSTOM_INSTANTIATE=$(WASM_CUSTOM_INSTANTIATE)
DISTCLEAN_FILES += $(bin.mkwb)
.wasmbuilds.make: $(bin.mkwb) .wasmbuilds.make: $(bin.mkwb)
@rm -f $@ @rm -f $@
$(bin.mkwb) > $@ $(bin.mkwb) > $@
@chmod -w $@ @chmod -w $@
-include .wasmbuilds.make -include .wasmbuilds.make
endif endif
DISTCLEAN_FILES += .wasmbuilds.make CLEAN_FILES += .wasmbuilds.make $(bin.mkwb)
######################################################################## ########################################################################
# We need separate copies of certain supplementary JS files for the # We need separate copies of certain supplementary JS files for the

View File

@@ -38,7 +38,7 @@ const toExportForESM =
into the global scope and delete it when sqlite3InitModule() into the global scope and delete it when sqlite3InitModule()
is called. is called.
*/ */
const initModuleState = globalThis.sqlite3InitModuleState = Object.assign(Object.create(null),{ const sIMS = globalThis.sqlite3InitModuleState = Object.assign(Object.create(null),{
moduleScript: globalThis?.document?.currentScript, moduleScript: globalThis?.document?.currentScript,
isWorker: ('undefined' !== typeof WorkerGlobalScope), isWorker: ('undefined' !== typeof WorkerGlobalScope),
location: globalThis.location, location: globalThis.location,
@@ -46,27 +46,27 @@ const toExportForESM =
? new URL(globalThis.location.href).searchParams ? new URL(globalThis.location.href).searchParams
: new URLSearchParams() : new URLSearchParams()
}); });
initModuleState.debugModule = sIMS.debugModule =
initModuleState.urlParams.has('sqlite3.debugModule') sIMS.urlParams.has('sqlite3.debugModule')
? (...args)=>console.warn('sqlite3.debugModule:',...args) ? (...args)=>console.warn('sqlite3.debugModule:',...args)
: ()=>{}; : ()=>{};
if(initModuleState.urlParams.has('sqlite3.dir')){ if(sIMS.urlParams.has('sqlite3.dir')){
initModuleState.sqlite3Dir = initModuleState.urlParams.get('sqlite3.dir') +'/'; sIMS.sqlite3Dir = sIMS.urlParams.get('sqlite3.dir') +'/';
}else if(initModuleState.moduleScript){ }else if(sIMS.moduleScript){
const li = initModuleState.moduleScript.src.split('/'); const li = sIMS.moduleScript.src.split('/');
li.pop(); li.pop();
initModuleState.sqlite3Dir = li.join('/') + '/'; sIMS.sqlite3Dir = li.join('/') + '/';
} }
globalThis.sqlite3InitModule = function ff(...args){ globalThis.sqlite3InitModule = function ff(...args){
//console.warn("Using replaced sqlite3InitModule()",globalThis.location); //console.warn("Using replaced sqlite3InitModule()",globalThis.location);
return originalInit(...args).then((EmscriptenModule)=>{ return originalInit(...args).then((EmscriptenModule)=>{
//console.warn("originalInit() then() arg =",EmscriptenModule); //console.warn("originalInit() then() arg =",EmscriptenModule);
//console.warn("initModuleState =",initModuleState); //console.warn("sqlite3InitModule(): sIMS =",sIMS);
EmscriptenModule.runSQLite3PostLoadInit(EmscriptenModule); EmscriptenModule.runSQLite3PostLoadInit(EmscriptenModule);
const s = EmscriptenModule.sqlite3; const s = EmscriptenModule.sqlite3;
s.scriptInfo = initModuleState; s.scriptInfo = sIMS;
//console.warn("sqlite3.scriptInfo =",s.scriptInfo); //console.warn("sqlite3.scriptInfo =",s.scriptInfo);
if(ff.__isUnderTest){ if(ff.__isUnderTest){
s.__isUnderTest = true; s.__isUnderTest = true;
@@ -95,13 +95,12 @@ const toExportForESM =
}; };
globalThis.sqlite3InitModule.ready = originalInit.ready; globalThis.sqlite3InitModule.ready = originalInit.ready;
if(globalThis.sqlite3InitModuleState.moduleScript){ if(sIMS.moduleScript){
const sim = globalThis.sqlite3InitModuleState; let src = sIMS.moduleScript.src.split('/');
let src = sim.moduleScript.src.split('/');
src.pop(); src.pop();
sim.scriptDir = src.join('/') + '/'; sIMS.scriptDir = src.join('/') + '/';
} }
initModuleState.debugModule('sqlite3InitModuleState =',initModuleState); sIMS.debugModule('extern-post-js.c-pp.js sqlite3InitModuleState =',sIMS);
if(0){ if(0){
console.warn("Replaced sqlite3InitModule()"); console.warn("Replaced sqlite3InitModule()");
console.warn("globalThis.location.href =",globalThis.location.href); console.warn("globalThis.location.href =",globalThis.location.href);

View File

@@ -1,6 +1,3 @@
/* The current function scope was opened via post-js-header.js, which
gets prepended to this at build-time. This file closes that
scope. */
//console.warn("This is the end of the Module.runSQLite3PostLoadInit handler."); //console.warn("This is the end of the Module.runSQLite3PostLoadInit handler.");
}/*Module.runSQLite3PostLoadInit()*/; }/*Module.runSQLite3PostLoadInit(EmscriptenModule)*/;
//console.warn("This is the end of the setup of the (pending) Module.runSQLite3PostLoadInit"); //console.warn("This is the end of the setup of the (pending) Module.runSQLite3PostLoadInit");

View File

@@ -17,6 +17,7 @@ Module.runSQLite3PostLoadInit = function(EmscriptenModule/*the Emscripten-style
//console.warn("This is the start of Module.runSQLite3PostLoadInit()"); //console.warn("This is the start of Module.runSQLite3PostLoadInit()");
/* This function will contain at least the following: /* This function will contain at least the following:
- extern-pre-js.js => out-of-Emscripten prologue
- post-js-header.js => this file - post-js-header.js => this file
- sqlite3-api-prologue.js => Bootstrapping bits to attach the rest to - sqlite3-api-prologue.js => Bootstrapping bits to attach the rest to
- common/whwasmutil.js => Replacements for much of Emscripten's glue - common/whwasmutil.js => Replacements for much of Emscripten's glue
@@ -29,5 +30,6 @@ Module.runSQLite3PostLoadInit = function(EmscriptenModule/*the Emscripten-style
- sqlite3-vfs-opfs.c-pp.js => OPFS VFS - sqlite3-vfs-opfs.c-pp.js => OPFS VFS
- sqlite3-vfs-opfs-sahpool.c-pp.js => OPFS SAHPool VFS - sqlite3-vfs-opfs-sahpool.c-pp.js => OPFS SAHPool VFS
- sqlite3-api-cleanup.js => final API cleanup - sqlite3-api-cleanup.js => final API cleanup
- post-js-footer.js => closes this function - post-js-footer.js => this file's epilogue
- extern-post-js.js => out-of-Emscripten epilogue
*/ */

View File

@@ -4,14 +4,14 @@
This file is intended to be prepended to the sqlite3.js build using This file is intended to be prepended to the sqlite3.js build using
Emscripten's --pre-js=THIS_FILE flag (or equivalent). Emscripten's --pre-js=THIS_FILE flag (or equivalent).
*/ */
// See notes in extern-post-js.js // See notes in extern-post-js.js
const sqlite3InitModuleState = globalThis.sqlite3InitModuleState const sIMS =
globalThis.sqlite3InitModuleState/*from extern-post-js.c-pp.js*/
|| Object.assign(Object.create(null),{ || Object.assign(Object.create(null),{
debugModule: ()=>{} debugModule: ()=>{}
}); });
delete globalThis.sqlite3InitModuleState; delete globalThis.sqlite3InitModuleState;
sqlite3InitModuleState.debugModule('globalThis.location =',globalThis.location); sIMS.debugModule('pre-js.js sqlite3InitModuleState =',sIMS);
//#ifnot target=es6-bundler-friendly //#ifnot target=es6-bundler-friendly
/** /**
@@ -23,14 +23,16 @@ sqlite3InitModuleState.debugModule('globalThis.location =',globalThis.location);
1) If URL param named the same as `path` is set, it is returned. 1) If URL param named the same as `path` is set, it is returned.
2) If sqlite3InitModuleState.sqlite3Dir is set, then (thatName + path) 2) If sqlite3InitModuleState.sqlite3Dir is set, then (thatName + path)
is returned (it's assumed to end with '/'). is returned (it's assumed to end with '/').
3) If this code is running in the main UI thread AND it was loaded 3) If this code is running in the main UI thread AND it was loaded
from a SCRIPT tag, the directory part of that URL is used from a SCRIPT tag, the directory part of that URL is used
as the prefix. (This form of resolution unfortunately does not as the prefix. (This form of resolution unfortunately does not
function for scripts loaded via importScripts().) function for scripts loaded via importScripts().)
4) If none of the above apply, (prefix+path) is returned. 4) If none of the above apply, (prefix+path) is returned.
None of the above apply in ES6 builds.
*/ */
Module['locateFile'] = function(path, prefix) { Module['locateFile'] = function(path, prefix) {
//#if target=es6-module //#if target=es6-module
@@ -56,10 +58,10 @@ Module['locateFile'] = function(path, prefix) {
); );
return theFile; return theFile;
//#endif target=es6-module //#endif target=es6-module
}.bind(sqlite3InitModuleState); }.bind(sIMS);
//#endif ifnot target=es6-bundler-friendly //#endif ifnot target=es6-bundler-friendly
//#if custom-Module.instantiateModule //#if custom-Module.instantiateWasm
/** /**
Bug warning: a custom Module.instantiateWasm() does not work Bug warning: a custom Module.instantiateWasm() does not work
in WASMFS builds: in WASMFS builds:
@@ -70,52 +72,59 @@ Module['locateFile'] = function(path, prefix) {
*/ */
const xNameOfInstantiateWasm = const xNameOfInstantiateWasm =
//#if wasmfs //#if wasmfs
false false
//#else //#else
true /* This works, but it does not have the testing coverage in the true /* This works, but it does not have the testing coverage in
wild which Emscripten's default impl does, so we'll save the wild which Emscripten's default impl does, so we'll
this option until we really need a custom save this option until we really need a custom
Module.instantiateWasm() */ Module.instantiateWasm(). */
//#endif //#endif
? 'instantiateWasm' ? 'instantiateWasm'
: 'emscripten-bug-17951'; : 'emscripten-bug-17951';
Module[xNameOfInstantiateWasm] = function callee(imports,onSuccess){ Module[xNameOfInstantiateWasm] = function callee(imports,onSuccess){
imports.env.foo = function(){}; const sims = this;
const uri = Module.locateFile( const uri = Module.locateFile(
callee.uri, ( sims.wasmFilename, (
('undefined'===typeof scriptDirectory/*var defined by Emscripten glue*/) ('undefined'===typeof scriptDirectory/*var defined by Emscripten glue*/)
? "" : scriptDirectory) ? "" : scriptDirectory)
); );
sqlite3InitModuleState.debugModule( sims.debugModule("instantiateWasm() uri =", uri, "sIMS =",this);
"instantiateWasm() uri =", uri
);
//console.warn("Custom instantiateModule",uri);
const wfetch = ()=>fetch(uri, {credentials: 'same-origin'}); const wfetch = ()=>fetch(uri, {credentials: 'same-origin'});
const loadWasm = WebAssembly.instantiateStreaming const loadWasm = WebAssembly.instantiateStreaming
? async ()=>{ ? async ()=>
return WebAssembly.instantiateStreaming(wfetch(), imports) WebAssembly
.then((arg)=>onSuccess(arg.instance, arg.module)); .instantiateStreaming(wfetch(), imports)
} .then((arg)=>{
: async ()=>{ // Safari < v15 arg.imports = imports;
return wfetch() sims.intantiateWasm = arg;
.then(response => response.arrayBuffer()) onSuccess(arg.instance, arg.module);
.then(bytes => WebAssembly.instantiate(bytes, imports)) })
.then((arg)=>onSuccess(arg.instance, arg.module)); : async ()=>// Safari < v15
}; wfetch()
loadWasm(); .then(response => response.arrayBuffer())
return {}; .then(bytes => WebAssembly.instantiate(bytes, imports))
}; .then((arg)=>{
arg.imports = imports;
sims.intantiateWasm = arg;
onSuccess(arg.instance, arg.module);
})
;
return loadWasm();
//return {};
}.bind(sIMS);
/* /*
It is literally impossible to reliably get the name of _this_ script It is literally impossible to reliably get the name of _this_
at runtime, so impossible to derive X.wasm from script name script at runtime, so impossible to derive X.wasm from script name
X.js. Thus we need, at build-time, to redefine X.js. Thus we need, at build-time, to redefine
Module[xNameOfInstantiateWasm].uri by appending it to a build-specific sIMS.uri by appending it to a build-specific
copy of this file with the name of the wasm file. This is apparently copy of this file with the name of the wasm file. This is
why Emscripten hard-codes the name of the wasm file into their glue apparently why Emscripten hard-codes the name of the wasm file
scripts. into their glue scripts.
*/ */
Module[xNameOfInstantiateWasm].uri = 'sqlite3.wasm'; sIMS.wasmFilename = 'sqlite3.wasm';
//#endif custom-Module.instantiateModule //#endif custom-Module.instantiateWasm
/* END FILE: api/pre-js.js, noting that the build process may add a /* Automation may append ".x = y" to this file, for some value of x and y.
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 line after this one to change the above .uri to a build-specific
one. */ one. */

View File

@@ -2505,15 +2505,13 @@ globalThis.WhWasmUtilInstaller.yawl = function(config){
yetAnotherWasmLoader()'s return value */; yetAnotherWasmLoader()'s return value */;
}; };
const loadWasm = WebAssembly.instantiateStreaming const loadWasm = WebAssembly.instantiateStreaming
? function loadWasmStreaming(){ ? ()=>WebAssembly
return WebAssembly.instantiateStreaming(wfetch(), config.imports||{}) .instantiateStreaming(wfetch(), config.imports||{})
.then(finalThen); .then(finalThen)
} : ()=> wfetch()// Safari < v15
: function loadWasmOldSchool(){ // Safari < v15 .then(response => response.arrayBuffer())
return wfetch() .then(bytes => WebAssembly.instantiate(bytes, config.imports||{}))
.then(response => response.arrayBuffer()) .then(finalThen)
.then(bytes => WebAssembly.instantiate(bytes, config.imports||{})) ;
.then(finalThen);
};
return loadWasm; return loadWasm;
}.bind(globalThis.WhWasmUtilInstaller)/*yawl()*/; }.bind(globalThis.WhWasmUtilInstaller)/*yawl()*/;

View File

@@ -86,11 +86,18 @@ struct BuildDef {
const char *zJsOut; /* Name of generated sqlite3.js/.mjs */ const char *zJsOut; /* Name of generated sqlite3.js/.mjs */
/* TODO: dynamically determine zJsOut based on zName, zMode, and /* TODO: dynamically determine zJsOut based on zName, zMode, and
flags. */ flags. */
const char *zWasmOut; /* zJsOut w/ .wasm extension if it needs to be renamed */
const char *zCmppD; /* Extra -D... flags for c-pp */ const char *zCmppD; /* Extra -D... flags for c-pp */
const char *zEmcc; /* Extra flags for emcc */ const char *zEmcc; /* Extra flags for emcc */
}; };
typedef struct BuildDef BuildDef; typedef struct BuildDef BuildDef;
#if !defined(WASM_CUSTOM_INSTANTIATE)
# define WASM_CUSTOM_INSTANTIATE 0
#elif (WASM_CUSTOM_INSTANTIATE+0)==0
# undef WASM_CUSTOM_INSTANTIATE
# define WASM_CUSTOM_INSTANTIATE 0
#endif
/* /*
** The set of WASM builds for the library (as opposed to the apps ** The set of WASM builds for the library (as opposed to the apps
** (fiddle, speedtest1)). This array must end with an empty sentinel ** (fiddle, speedtest1)). This array must end with an empty sentinel
@@ -101,11 +108,11 @@ typedef struct BuildDef BuildDef;
*/ */
const BuildDef aBuildDefs[] = { const BuildDef aBuildDefs[] = {
{/* Core build */ {/* Core build */
"sqlite3", "vanilla", 0, "$(sqlite3.js)", 0, 0}, "sqlite3", "vanilla", 0, "$(sqlite3.js)", 0, 0, 0},
{/* Core ESM */ {/* Core ESM */
"sqlite3", "esm", LIBMODE_ESM, "$(sqlite3.mjs)", "sqlite3", "esm", LIBMODE_ESM, "$(sqlite3.mjs)", 0,
"-Dtarget=es6-module", 0}, "-Dtarget=es6-module", 0},
{/* Core bundler-friendly build. Untested and "not really" {/* Core bundler-friendly build. Untested and "not really"
** supported, but required by the downstream npm subproject. ** supported, but required by the downstream npm subproject.
@@ -114,22 +121,21 @@ const BuildDef aBuildDefs[] = {
** subproject and they spot failures pretty quickly ;). */ ** subproject and they spot failures pretty quickly ;). */
"sqlite3", "bundler-friendly", "sqlite3", "bundler-friendly",
LIBMODE_BUNDLER_FRIENDLY | LIBMODE_ESM, LIBMODE_BUNDLER_FRIENDLY | LIBMODE_ESM,
"$(dir.dout)/sqlite3-bundler-friendly.mjs", "$(dir.dout)/sqlite3-bundler-friendly.mjs", 0,
"$(c-pp.D.sqlite3-esm) -Dtarget=es6-bundler-friendly", 0}, "$(c-pp.D.sqlite3-esm) -Dtarget=es6-bundler-friendly", 0},
{/* node.js mode. Untested and unsupported. */ {/* node.js mode. Untested and unsupported. */
"sqlite3", "node", LIBMODE_UNSUPPORTED | LIBMODE_NODEJS, "sqlite3", "node", LIBMODE_UNSUPPORTED | LIBMODE_NODEJS,
"$(dir.dout)/sqlite3-node.mjs", "$(dir.dout)/sqlite3-node.mjs", "sqlite3-node.wasm",
"$(c-pp.D.sqlite3-bundler-friendly) -Dtarget=node", 0}, "$(c-pp.D.sqlite3-bundler-friendly) -Dtarget=node", 0},
{/* Wasmfs build. Fully unsupported and largely untested. */ {/* Wasmfs build. Fully unsupported and largely untested. */
"sqlite3-wasmfs", "esm" , "sqlite3-wasmfs", "esm" ,
LIBMODE_UNSUPPORTED | LIBMODE_WASMFS | LIBMODE_ESM, LIBMODE_UNSUPPORTED | LIBMODE_WASMFS | LIBMODE_ESM,
"$(dir.wasmfs)/sqlite3-wasmfs.mjs", "$(dir.wasmfs)/sqlite3-wasmfs.mjs", "sqlite3-wasmfs.wasm",
"$(c-pp.D.sqlite3-bundler-friendly) -Dwasmfs", "$(c-pp.D.sqlite3-bundler-friendly) -Dwasmfs",
"-sEXPORT_ES6 -sUSE_ES6_IMPORT_META"}, "-sEXPORT_ES6 -sUSE_ES6_IMPORT_META"},
{/*End-of-list sentinel*/0,0,0,0,0,0,0}
{/*End-of-list sentinel*/0,0,0,0,0,0}
}; };
/* /*
@@ -250,7 +256,8 @@ static void mk_prologue(void){
static void mk_pre_post(const char *zName /* build name */, static void mk_pre_post(const char *zName /* build name */,
const char *zMode /* build mode */, const char *zMode /* build mode */,
const char *zCmppD /* optional -D flags for c-pp for the const char *zCmppD /* optional -D flags for c-pp for the
** --pre/--post-js files. */){ ** --pre/--post-js files. */,
const char *zWasmOut){
/* Very common printf() args combo. */ /* Very common printf() args combo. */
#define zNM zName, zMode #define zNM zName, zMode
@@ -262,7 +269,8 @@ static void mk_pre_post(const char *zName /* build name */,
pf("pre-js.js.%s-%s = $(dir.tmp)/pre-js.%s-%s.js\n", pf("pre-js.js.%s-%s = $(dir.tmp)/pre-js.%s-%s.js\n",
zNM, zNM); zNM, zNM);
pf("$(pre-js.js.%s-%s): $(MAKEFILE_LIST) $(sqlite3-license-version.js)\n", zNM); pf("$(pre-js.js.%s-%s): $(MAKEFILE_LIST) $(sqlite3-license-version.js)\n", zNM);
#if 1 #if !WASM_CUSTOM_INSTANTIATE
(void)zWasmOut;
pf("$(eval $(call SQLITE.CALL.C-PP.FILTER,$(pre-js.js.in),$(pre-js.js.%s-%s)," pf("$(eval $(call SQLITE.CALL.C-PP.FILTER,$(pre-js.js.in),$(pre-js.js.%s-%s),"
"$(c-pp.D.%s-%s)))\n", zNM, zNM); "$(c-pp.D.%s-%s)))\n", zNM, zNM);
#else #else
@@ -271,17 +279,14 @@ static void mk_pre_post(const char *zName /* build name */,
pf("pre-js.js.%s-%s.intermediary = $(dir.tmp)/pre-js.%s-%s.intermediary.js\n", pf("pre-js.js.%s-%s.intermediary = $(dir.tmp)/pre-js.%s-%s.intermediary.js\n",
zNM, zNM); zNM, zNM);
pf("$(eval $(call SQLITE.CALL.C-PP.FILTER,$(pre-js.js.in),$(pre-js.js.%s-%s.intermediary)," pf("$(eval $(call SQLITE.CALL.C-PP.FILTER,$(pre-js.js.in),$(pre-js.js.%s-%s.intermediary),"
"$(c-pp.D.%s-%s) -Dcustom-Module.instantiateModule))\n", zNM, zNM); "$(c-pp.D.%s-%s) -Dcustom-Module.instantiateWasm))\n", zNM, zNM);
pf("$(pre-js.js.%s-%s): $(pre-js.js.%s-%s.intermediary)\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); pf("\tcp $(pre-js.js.%s-%s.intermediary) $@\n", zNM);
/* Amend $(pre-js.js.zName-zMode) for all targets except the plain /* Amend $(pre-js.js.zName-zMode) for all targets except the plain
** "sqlite3" and the "sqlite3-wasmfs" builds... */ ** "sqlite3" and the "sqlite3-wasmfs" builds... */
if( 0!=strcmp("sqlite3-wasmfs", zName) if( zWasmOut ){
&& 0!=strcmp("sqlite3", zName) ){ pf("\t@echo 'sIMS.wasmFilename = \"%s\";' >> $@\n", zWasmOut);
#error "This part ^^^ is needs adapting for use with the LIBMODE_... flags"
pf("\t@echo 'Module[xNameOfInstantiateWasm].uri = "
"\"%s.wasm\";' >> $@\n", zName);
} }
#endif #endif
@@ -320,7 +325,7 @@ static void mk_pre_post(const char *zName /* build name */,
static void mk_fiddle(void){ static void mk_fiddle(void){
int i = 0; int i = 0;
mk_pre_post("fiddle-module","vanilla", 0); mk_pre_post("fiddle-module","vanilla", 0, "fiddle-module.wasm");
for( ; i < 2; ++i ){ for( ; i < 2; ++i ){
/* 0==normal, 1==debug */ /* 0==normal, 1==debug */
const char *zTail = i ? ".debug" : ""; const char *zTail = i ? ".debug" : "";
@@ -389,7 +394,7 @@ static void mk_lib_mode(const BuildDef * pB){
pf("# zJsOut=%s\n# zCmppD=%s\n", pB->zJsOut, pf("# zJsOut=%s\n# zCmppD=%s\n", pB->zJsOut,
pB->zCmppD ? pB->zCmppD : "<none>"); pB->zCmppD ? pB->zCmppD : "<none>");
pf("$(info Setting up build [%s-%s]: %s)\n", zNM, pB->zJsOut); pf("$(info Setting up build [%s-%s]: %s)\n", zNM, pB->zJsOut);
mk_pre_post(zNM, pB->zCmppD); mk_pre_post(zNM, pB->zCmppD, pB->zWasmOut);
pf("\nemcc.flags.%s.%s ?=\n", zNM); pf("\nemcc.flags.%s.%s ?=\n", zNM);
if( pB->zEmcc && pB->zEmcc[0] ){ if( pB->zEmcc && pB->zEmcc[0] ){
pf("emcc.flags.%s.%s += %s\n", zNM, pB->zEmcc); pf("emcc.flags.%s.%s += %s\n", zNM, pB->zEmcc);
@@ -397,6 +402,7 @@ static void mk_lib_mode(const BuildDef * pB){
/* target pB->zJsOut */ /* target pB->zJsOut */
pf("%s: $(MAKEFILE_LIST) $(sqlite3-wasm.cfiles) $(EXPORTED_FUNCTIONS.api) " pf("%s: $(MAKEFILE_LIST) $(sqlite3-wasm.cfiles) $(EXPORTED_FUNCTIONS.api) "
"$(bin.mkwb) "
"$(pre-post-%s-%s.deps) " "$(pre-post-%s-%s.deps) "
"$(sqlite3-api.ext.jses)" "$(sqlite3-api.ext.jses)"
/* ^^^ maintenance reminder: we set these as deps so that they /* ^^^ maintenance reminder: we set these as deps so that they
@@ -476,8 +482,9 @@ int main(void){
mk_lib_mode( pB ); mk_lib_mode( pB );
} }
mk_fiddle(); mk_fiddle();
mk_pre_post("speedtest1","vanilla", 0); mk_pre_post("speedtest1","vanilla", 0, "speedtest1.wasm");
mk_pre_post("speedtest1-wasmfs","esm", mk_pre_post("speedtest1-wasmfs","esm",
"$(c-pp.D.sqlite3-bundler-friendly) -Dwasmfs"); "$(c-pp.D.sqlite3-bundler-friendly) -Dwasmfs",
"speetest1-wasmfs.wasm");
return rc; return rc;
} }

View File

@@ -1,5 +1,5 @@
C Minor\sinternal\soptimizations\sin\sthe\swasm\sglue. C Experimenting\swith\sa\scustom\swasm\sloader,\sbut\sdon't\senable\sit\swithout\san\sexplicit\sbuild\sflag.\sThe\sgoal\shere\sis\sto\smake\sthe\sWebAssembly.Module\sobject\savailable\sinternally\s(the\sdefault\sloader\shides\sit\sfrom\sus).
D 2025-09-21T23:15:12.210 D 2025-09-22T02:40:06.033
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -578,7 +578,7 @@ F ext/session/sqlite3session.c 9cd47bfefb23c114b7a5d9ee5822d941398902f30516bf0dd
F ext/session/sqlite3session.h 7404723606074fcb2afdc6b72c206072cdb2b7d8ba097ca1559174a80bc26f7a F ext/session/sqlite3session.h 7404723606074fcb2afdc6b72c206072cdb2b7d8ba097ca1559174a80bc26f7a
F ext/session/test_session.c 8766b5973a6323934cb51248f621c3dc87ad2a98f023c3cc280d79e7d78d36fb F ext/session/test_session.c 8766b5973a6323934cb51248f621c3dc87ad2a98f023c3cc280d79e7d78d36fb
F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c
F ext/wasm/GNUmakefile 0d44bd3fb861f062b27ec86c43e62230b43d7f0125c1dc6e48b71082385e97cd F ext/wasm/GNUmakefile 772aabff47c96450209af61aa7b6a9894313d6523afb857b58b611f10fa9b766
F ext/wasm/README-dist.txt f01081a850ce38a56706af6b481e3a7878e24e42b314cfcd4b129f0f8427066a F ext/wasm/README-dist.txt f01081a850ce38a56706af6b481e3a7878e24e42b314cfcd4b129f0f8427066a
F ext/wasm/README.md 66ace67ae98a45e4116f2ca5425b716887bcee4d64febee804ff6398e1ae9ec7 F ext/wasm/README.md 66ace67ae98a45e4116f2ca5425b716887bcee4d64febee804ff6398e1ae9ec7
F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff
@@ -591,11 +591,11 @@ F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras cb4fa8842c875b6ee99381523792975
F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b
F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287 F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287
F ext/wasm/api/README.md 7f029c5fe83b3493931d2fb915e2febd3536267d538a56408a6fef284ea38d29 F ext/wasm/api/README.md 7f029c5fe83b3493931d2fb915e2febd3536267d538a56408a6fef284ea38d29
F ext/wasm/api/extern-post-js.c-pp.js c4801f87c18c9c738295eef199efbb9fe4e42ff25ae6927953dd3a27bac74bce F ext/wasm/api/extern-post-js.c-pp.js 6d058dd44164f3d3055299979db92f8a5821ac79cfd89635ef44363cfd82c64d
F ext/wasm/api/extern-pre-js.js cc61c09c7a24a07dbecb4c352453c3985170cec12b4e7e7e7a4d11d43c5c8f41 F ext/wasm/api/extern-pre-js.js cc61c09c7a24a07dbecb4c352453c3985170cec12b4e7e7e7a4d11d43c5c8f41
F ext/wasm/api/post-js-footer.js 365405929f41ca0e6d389ed8a8da3f3c93e11d3ef43a90ae151e37fa9f75bf41 F ext/wasm/api/post-js-footer.js e617e5f81a907362de152576323155f02d24642e625fc05fb801b86b6a269444
F ext/wasm/api/post-js-header.js 53740d824e5d9027eb1e6fd59e216abbd2136740ce260ea5f0699ff2acb0a701 F ext/wasm/api/post-js-header.js 935c4ff097dd2579217918ccbaaffa445e83f82f91cdd7ad68c8363080fa6913
F ext/wasm/api/pre-js.c-pp.js 58f823de197e2c10d76179aa05410a593b7ae03e1ece983bb42ffd818e8857e1 F ext/wasm/api/pre-js.c-pp.js d52f4a8e900927ac6f5f3608f322b2ad42cad181ec405b2ac8619d2cbf143bd2
F ext/wasm/api/sqlite3-api-cleanup.js d4f1a5e665afaf84015f6ef0ddd766f638cb28501c4569b1d4b527c4b5a2b9a4 F ext/wasm/api/sqlite3-api-cleanup.js d4f1a5e665afaf84015f6ef0ddd766f638cb28501c4569b1d4b527c4b5a2b9a4
F ext/wasm/api/sqlite3-api-glue.c-pp.js 12f5b36775fab1e7bf5385689fded2b2a9f77360562515e9849acb5e66602e2d F ext/wasm/api/sqlite3-api-glue.c-pp.js 12f5b36775fab1e7bf5385689fded2b2a9f77360562515e9849acb5e66602e2d
F ext/wasm/api/sqlite3-api-oo1.c-pp.js db4c8ebb03bac60db32ce03f8c615b00f4e4ad53e7d5de5e63d2780cba052caa F ext/wasm/api/sqlite3-api-oo1.c-pp.js db4c8ebb03bac60db32ce03f8c615b00f4e4ad53e7d5de5e63d2780cba052caa
@@ -618,7 +618,7 @@ F ext/wasm/c-pp.c cca55c5b55ebd8d29916adbedb0e40baa12caa9a2e8429f812683c308f9b0e
F ext/wasm/common/SqliteTestUtil.js 7adaeffef757d8708418dc9190f72df22367b531831775804b31598b44f6aa51 F ext/wasm/common/SqliteTestUtil.js 7adaeffef757d8708418dc9190f72df22367b531831775804b31598b44f6aa51
F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15 F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15
F ext/wasm/common/testing.css e97549bab24126c24e0daabfe2de9bb478fb0a69fdb2ddd0a73a992c091aad6f F ext/wasm/common/testing.css e97549bab24126c24e0daabfe2de9bb478fb0a69fdb2ddd0a73a992c091aad6f
F ext/wasm/common/whwasmutil.js fb2a10747234ad720fbe713d7fecbad54abed30ac41355872e7c431f62c23e72 F ext/wasm/common/whwasmutil.js a4d0736b7e3abfbbe5342743d11c4663a9a1411def3a25cf6a3f5982baa73f95
F ext/wasm/config.make.in c424ae1cc3c89274520ad312509d36c4daa34a3fce5d0c688e5f8f4365e1049a F ext/wasm/config.make.in c424ae1cc3c89274520ad312509d36c4daa34a3fce5d0c688e5f8f4365e1049a
F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed
F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508 F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508
@@ -639,7 +639,7 @@ F ext/wasm/index-dist.html 56132399702b15d70c474c3f1952541e25cb0922942868f70daf1
F ext/wasm/index.html bcaa00eca521b372a6a62c7e7b17a870b0fcdf3e418a5921df1fd61e5344080d F ext/wasm/index.html bcaa00eca521b372a6a62c7e7b17a870b0fcdf3e418a5921df1fd61e5344080d
F ext/wasm/jaccwabyt/jaccwabyt.js bbac67bc7a79dca34afe6215fd16b27768d84e22273507206f888c117e2ede7d F ext/wasm/jaccwabyt/jaccwabyt.js bbac67bc7a79dca34afe6215fd16b27768d84e22273507206f888c117e2ede7d
F ext/wasm/jaccwabyt/jaccwabyt.md 167fc0b624c9bc2c477846e336de9403842d81b1a24fc4d3b24317cb9eba734f F ext/wasm/jaccwabyt/jaccwabyt.md 167fc0b624c9bc2c477846e336de9403842d81b1a24fc4d3b24317cb9eba734f
F ext/wasm/mkwasmbuilds.c b722a3a44edc1498575d935939dfcbe23172f98b0f40d068998e0950707e749d F ext/wasm/mkwasmbuilds.c 17e1ed7825fbadce15ab2955c003ab61d0efb73167af9028ebd863cfc4a2fd00
F ext/wasm/module-symbols.html dc476b403369b26a1a23773e13b80f41b9a49f0825e81435fe3600a7cfbbe337 F ext/wasm/module-symbols.html dc476b403369b26a1a23773e13b80f41b9a49f0825e81435fe3600a7cfbbe337
F ext/wasm/scratchpad-wasmfs.html a3d7388f3c4b263676b58b526846e9d02dfcb4014ff29d3a5040935286af5b96 F ext/wasm/scratchpad-wasmfs.html a3d7388f3c4b263676b58b526846e9d02dfcb4014ff29d3a5040935286af5b96
F ext/wasm/scratchpad-wasmfs.mjs 66034b9256b218de59248aad796760a1584c1dd842231505895eff00dbd57c63 F ext/wasm/scratchpad-wasmfs.mjs 66034b9256b218de59248aad796760a1584c1dd842231505895eff00dbd57c63
@@ -2175,8 +2175,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 6a070f450ac9ee3d4d6a3e05ef8fa2071a684181ea160805e236c3bba226510a P fb053a27d94f9caedfddf28680e13836343745376e84c8008641df6bb517cd8b
R 4abaa719c3f0b3c283ef0653194b4d07 R 100960854ade0f263f89ddfe27508ecf
U stephan U stephan
Z 0755752744575b5a7a7fc02264f08ee2 Z ad7ae87bed8b1ac707c9f8f92f28fda3
# Remove this line to create a well-formed Fossil manifest. # Remove this line to create a well-formed Fossil manifest.

View File

@@ -1 +1 @@
fb053a27d94f9caedfddf28680e13836343745376e84c8008641df6bb517cd8b e5f0256feab95c30a8e3e1e69963fb3e25ed2da296aff5bc6646fe96a76c0b81