From bb56ddc4e3487b63ee46ab0a67a59678b934b27e Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 20 Jan 2026 17:10:22 +0000 Subject: [PATCH] wasm: a potential workaround for cases such as [forum:1eec339854c935bd|forum post 1eec339854c935bd], where client-local needs require overriding Emscripten config defaults (which we very intentionally do not document or support for reasons explained in that thread). This is untested because it requires a special-needs setup, but it doesn't break anything for run-of-the-mill cases. FossilOrigin-Name: c8e6be9241e3e17898c451baad109b75dc8a97a91ff1e43c67a6c962b75af8f3 --- ext/wasm/api/extern-post-js.c-pp.js | 2 ++ ext/wasm/api/pre-js.c-pp.js | 12 ++++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/ext/wasm/api/extern-post-js.c-pp.js b/ext/wasm/api/extern-post-js.c-pp.js index 25b3f8ea97..cac6e4ab4f 100644 --- a/ext/wasm/api/extern-post-js.c-pp.js +++ b/ext/wasm/api/extern-post-js.c-pp.js @@ -73,6 +73,8 @@ const toExportForESM = const sIM = globalThis.sqlite3InitModule = function ff(...args){ //console.warn("Using replaced sqlite3InitModule()",globalThis.location); + sIMS.emscriptenLocateFile = args[0]?.locateFile /* see pre-js.c-pp.js [tag:locateFile] */; + sIMS.emscriptenInstantiateWasm = args[0]?.instantiateWasm /* see pre-js.c-pp.js [tag:locateFile] */; return originalInit(...args).then((EmscriptenModule)=>{ sIMS.debugModule("sqlite3InitModule() sIMS =",sIMS); sIMS.debugModule("sqlite3InitModule() EmscriptenModule =",EmscriptenModule); diff --git a/ext/wasm/api/pre-js.c-pp.js b/ext/wasm/api/pre-js.c-pp.js index 42acd7d0f3..59dc907d16 100644 --- a/ext/wasm/api/pre-js.c-pp.js +++ b/ext/wasm/api/pre-js.c-pp.js @@ -68,6 +68,14 @@ approach. */ Module['locateFile'] = function(path, prefix) { + if( this.emscriptenLocateFile instanceof Function ){ + /* [tag:locateFile] Client-overridden impl. We do not support + this but offer it as a back-door which will go away the + moment either Emscripten changes that interface or we manage + to get non-Emscripten builds working. + https://sqlite.org/forum/forumpost/1eec339854c935bd */ + return this.emscriptenLocateFile(path, prefix); + } //#if target:es6-module return new URL(path, import.meta.url).href; //#else @@ -107,6 +115,10 @@ node does not do fetch(). */ Module['instantiateWasm'] = function callee(imports,onSuccess){ + if( this.emscriptenInstantiateWasm instanceof Function ){ + /* See [tag:locateFile]. Same story here */ + return this.emscriptenInstantiateWasm(imports, onSuccess); + } const sims = this; const uri = Module.locateFile( sims.wasmFilename, ( diff --git a/manifest b/manifest index 134f28e22e..a8b12dcc3e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\sSQLITE_API_ARMOR\scheck\sto\ssqlite3_get_clientdata(),\sper\srequest\sin\s[forum:a011a001f4|forum\spost\sa011a001f4]. -D 2026-01-20T10:57:44.925 +C wasm:\sa\spotential\sworkaround\sfor\scases\ssuch\sas\s[forum:1eec339854c935bd|forum\spost\s1eec339854c935bd],\swhere\sclient-local\sneeds\srequire\soverriding\sEmscripten\sconfig\sdefaults\s(which\swe\svery\sintentionally\sdo\snot\sdocument\sor\ssupport\sfor\sreasons\sexplained\sin\sthat\sthread).\sThis\sis\suntested\sbecause\sit\srequires\sa\sspecial-needs\ssetup,\sbut\sit\sdoesn't\sbreak\sanything\sfor\srun-of-the-mill\scases. +D 2026-01-20T17:10:22.413 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -591,11 +591,11 @@ F ext/wasm/SQLTester/index.html 64f3435084c7d6139b08d1f2a713828a73f68de2ae6a3112 F ext/wasm/SQLTester/touint8array.c 2d5ece04ec1393a6a60c4bf96385bda5e1a10ad49f3038b96460fc5e5aa7e536 F ext/wasm/api/EXPORTED_FUNCTIONS.c-pp 7ba933e8f1290cc65459dd371c0c9a031d96bdf14d7a2244fa761d9775117b90 F ext/wasm/api/README.md a905d5c6bfc3e2df875bd391d6d6b7b48d41b43bdee02ad115b47244781a7e81 -F ext/wasm/api/extern-post-js.c-pp.js 4b310c9891886e7c1ea4e2419966ff45dfeda825b897fdaa4119332509f7e3d1 +F ext/wasm/api/extern-post-js.c-pp.js d9f42ecbedc784c0d086bc37800e52946a14f7a21600b291daa3f963c314f930 F ext/wasm/api/extern-pre-js.js cc61c09c7a24a07dbecb4c352453c3985170cec12b4e7e7e7a4d11d43c5c8f41 F ext/wasm/api/post-js-footer.js a50c1a2c4d008aede7b2aa1f18891a7ee71437c2f415b8aeb3db237ddce2935b F ext/wasm/api/post-js-header.js d24bd0d065f3489c8b78ddf3ead6321e5d047187a162cd503c41700e03dd1f06 -F ext/wasm/api/pre-js.c-pp.js a70c05cfc4aef68f0d264f3ae659ea367fe4367b196e54c15867a9689568a75e +F ext/wasm/api/pre-js.c-pp.js 4452b674f1ad74c02a787edcc5449c4d60937ecf4ed31edcba3c74f0ac1253d5 F ext/wasm/api/sqlite3-api-glue.c-pp.js 9b33e3ee467791dec4fd1b444b12a8545dfbb6c8b28ac651c7bdc7661a3b5a5c F ext/wasm/api/sqlite3-api-oo1.c-pp.js 45454631265d9ce82685f1a64e1650ee19c8e121c41db98a22b534c15e543cfa F ext/wasm/api/sqlite3-api-prologue.js 1fefd40ab21e3dbf46f43b6fafb07f13eb13cc157a884f7c1134caf631ddb3f2 @@ -2193,8 +2193,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c -P 81840bd4b2132c1c701bb6fd5a2ac48a4ed33d2b68a3f7a826fa32dc0fc16483 -R 333f8800db383a0d77a15f9b7b37171f +P 346ad366a8ebed1e7936c59f8a40e9c8e7e31d0153bc4f654a47b2ddc39b18ca +R 70e9be57b67a2088ac3d3ac3838ccb2f U stephan -Z 20800af8d71ad6093a502d20016c44a4 +Z 2bae166b43650196aaa0f91b2a88e5d9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index de318d0d66..5f5826cba2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -346ad366a8ebed1e7936c59f8a40e9c8e7e31d0153bc4f654a47b2ddc39b18ca +c8e6be9241e3e17898c451baad109b75dc8a97a91ff1e43c67a6c962b75af8f3 -- 2.47.3