]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Get wasmfs build working in the new setup. Disable the custom wasm loader because...
authorstephan <stephan@noemail.net>
Fri, 26 Sep 2025 12:49:41 +0000 (12:49 +0000)
committerstephan <stephan@noemail.net>
Fri, 26 Sep 2025 12:49:41 +0000 (12:49 +0000)
FossilOrigin-Name: 36bc2514f70af5608aa20903d9c38b316603e2f78f2cbf4a20c7c79b60c5b8d5

ext/wasm/GNUmakefile
ext/wasm/mkwasmbuilds.c
ext/wasm/wasmfs.make [deleted file]
manifest
manifest.uuid

index 348aab87ebacb656ca3e413885bd9caca39df805..778328d5719d491445658376a4310b603309250d 100644 (file)
@@ -466,9 +466,9 @@ endif
 # -Dcustom-Module.instantiateWasm to some of the builds. This is
 # experimental.
 #
-# Changing this may require a clean rebuild.
+# Changing this may require a clean rebuild. It also might not work.
 #
-WASM_CUSTOM_INSTANTIATE = 1
+WASM_CUSTOM_INSTANTIATE = 0
 
 ########################################################################
 # $(bin.c-pp): a minimal text file preprocessor. Like C's but much
@@ -514,7 +514,7 @@ ifeq (1,$(SQLITE_C_IS_SEE))
 endif
 
 # cflags.common = C compiler flags for all builds
-cflags.common =  -I. -I$(dir $(sqlite3.c))
+cflags.common =  -I. -I$(dir $(sqlite3.c)) -std=c99 -fPIC
 # emcc.WASM_BIGINT = 1 for BigInt (C int64) support, else 0.  The API
 # disables certain features if BigInt is not enabled and such builds
 # _are not tested_ on any regular basis.
@@ -821,40 +821,6 @@ endef
 #
 ########################################################################
 
-#
-# Only add wasmfs if wasmfs.enable=1 or we're running (dist)clean
-#
-ifneq (,$(filter wasmfs,$(MAKECMDGOALS)))
-wasmfs.enable ?= 1
-else
-# Unconditionally enable wasmfs for [dist]clean so that the wasmfs
-# sub-make can clean up.
-wasmfs.enable ?= $(MAKING_CLEAN)
-endif
-ifeq (1,$(wasmfs.enable))
-# wasmfs build disabled 2022-10-19 per /chat discussion.
-# OPFS-over-wasmfs was initially a stopgap measure and a convenient
-# point of comparison for the OPFS sqlite3_vfs's performance, but it
-# currently doubles our deliverables and build maintenance burden for
-# little benefit.
-#
-########################################################################
-# Some platforms do not support the WASMFS build. Raspberry Pi OS is
-# one of them (or was when that comment was initially written). As
-# such platforms are discovered, add their (uname -m) name to
-# PLATFORMS_WITH_NO_WASMFS to exclude the wasmfs build parts.
-PLATFORMS_WITH_NO_WASMFS = aarch64 # add any others here
-THIS_ARCH = $(shell /usr/bin/uname -m)
-ifneq (,$(filter $(THIS_ARCH),$(PLATFORMS_WITH_NO_WASMFS)))
-$(info This platform does not support the WASMFS build.)
-HAVE_WASMFS = 0
-else
-HAVE_WASMFS = 1
-endif
-endif
-# /wasmfs
-########################################################################
-
 #
 # Inputs/outputs for the sqlite3-api.js family.
 #
@@ -1041,6 +1007,25 @@ fiddle.EXPORTED_FUNCTIONS.in = \
 
 fiddle.c.in = $(dir.top)/shell.c $(sqlite3-wasm.c)
 
+#
+# Only add wasmfs if wasmfs.enable=1 or we're running (dist)clean
+#
+ifneq (,$(filter wasmfs b-wasmfs,$(MAKECMDGOALS)))
+wasmfs.enable ?= 1
+else
+# Unconditionally enable wasmfs for [dist]clean so that the wasmfs
+# sub-make can clean up.
+wasmfs.enable ?= $(MAKING_CLEAN)
+endif
+#
+# WASMFS build - unsupported and untested. We used WASMFS
+# to jumpstart development early on, but it has always been
+# a moving target, in that Emscripten updates have broken
+# our build often enough that we no longer actively support it.
+# It's interesting to keep around, though.
+#
+cflags.wasmfs = -DSQLITE_ENABLE_WASMFS
+
 #
 # bin.mkwb is used for generating much of the makefile code for the
 # various wasm builds. It used to be generated in this makefile via a
index e8442d6db5d803a669cf478077bf86eac08a473b..6f9bd5d69274d70a1712e8ac6f33e9589c3a6e2e 100644 (file)
@@ -112,10 +112,13 @@ enum BuildDefFlags {
 ** within the body of sqlite3InitModule().
 **
 ** --extern-pre-js = gets injected before sqlite3InitModule(), in the
-** global scope.
+** global scope. We inject the license and version info here.
 **
-** --extern-pre-js = gets injected immediately after
-** sqlite3InitModule(), in the global scope.
+** --extern-post-js = gets injected immediately after
+** sqlite3InitModule(), in the global scope. In this step we replace
+** sqlite3InitModule() with a slightly customized, the main purpose of
+** which is to (A) give us (not Emscripten) control over the arguments
+** it accepts and (B) to run the library bootstrap step.
 **
 ** Then there's sqlite3-api.BuildName.js, which is the entire SQLite3
 ** JS API (generated from the list defined in $(sqlite3-api.jses)). It
@@ -402,11 +405,16 @@ const BuildDefs oBuildDefs = {
     .zDotWasm    = 0,
     .zCmppD      = "$(c-pp.D.bundler)",
     .zEmcc       = 0,
-    .zEmccExtra  = "-sEXPORT_ES6 -sUSE_ES6_IMPORT_META",
+    .zEmccExtra  =
+    "-sEXPORT_ES6 -sUSE_ES6_IMPORT_META"
+    " -sUSE_CLOSURE_COMPILER=0"
+    " -pthread -sWASMFS -sPTHREAD_POOL_SIZE=1"
+    " -sERROR_ON_UNDEFINED_SYMBOLS=0 -sLLD_REPORT_UNDEFINED"
+    ,
     .zEnv        = 0,
     .zDeps       = 0,
-    .zIfCond     = "ifeq (1,$(HAVE_WASMFS))",
-    .flags       = CP_ALL | F_UNSUPPORTED | F_WASMFS
+    .zIfCond     = 0,
+    .flags       = CP_ALL | F_UNSUPPORTED | F_WASMFS | F_ESM
   }
 };
 
diff --git a/ext/wasm/wasmfs.make b/ext/wasm/wasmfs.make
deleted file mode 100644 (file)
index b694b8e..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-#!/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
-# $(warning) alignment!
-ifneq (1,$(MAKING_CLEAN))
-  $(warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!)
-  $(warning !! The WASMFS build is unsupported. Use at your own risk.
-  $(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.
-emcc.flags.sqlite3-wasmfs += $(sqlite3-wasmfs.fsflags)
-emcc.flags.sqlite3-wasmfs += -sALLOW_MEMORY_GROWTH=0
-#^^^ using ALLOW_MEMORY_GROWTH produces a warning from emcc:
-#   USE_PTHREADS + ALLOW_MEMORY_GROWTH may run non-wasm code slowly,
-#   see https://github.com/WebAssembly/design/issues/1271 [-Wpthreads-mem-growth]
-# And, indeed, it runs slowly if memory is permitted to grow.
-#emcc.flags.sqlite3-wasmfs.vanilla =
-#emcc.flags.sqlite3-wasmfs.esm = -sEXPORT_ES6 -sUSE_ES6_IMPORT_META
-$(sqlite3-wasmfs.js) $(dir.wasmfs)/sqlite3-wasmfs.mjs: $(MAKEFILE.wasmfs)
-########################################################################
-# Build quirk: we cannot build BOTH .js and .mjs with our current
-# 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) $(dir.wasmfs)/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): $(dir.wasmfs)/sqlite3-wasmfs.mjs
-  wasmfs: $(dir.wasmfs)/sqlite3-wasmfs.mjs
-endif
-all: wasmfs
-
-########################################################################
-# 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)
-emcc.flags.speedtest1-wasmfs += -sALLOW_MEMORY_GROWTH=0
-emcc.flags.speedtest1-wasmfs += -sINITIAL_MEMORY=$(emcc.INITIAL_MEMORY.128)
-#$(info speedtest DEPS=pre-post-sqlite3-wasmfs-esm.deps=$(pre-post-sqlite3-wasmfs-esm.deps))
-$(speedtest1-wasmfs.mjs): $(speedtest1.cfiles) $(sqlite3-wasmfs.js) \
-  $(MAKEFILE) $(MAKEFILE.wasmfs) $(pre-post-sqlite3-wasmfs-esm.deps) \
-  $(EXPORTED_FUNCTIONS.speedtest1)
-       @echo "Building $@ ..."
-       $(bin.emcc) \
-        $(pre-post-sqlite3-wasmfs-esm.flags) \
-        $(cflags.common) \
-        $(cflags.sqlite3-wasmfs) \
-        $(emcc.speedtest1.common) \
-        $(emcc.flags.speedtest1-vanilla) \
-        $(emcc.flags.sqlite3-wasmfs) \
-        $(emcc.flags.speedtest1-wasmfs) \
-        -o $@ $(speedtest1.cfiles) -lm
-       @$(call SQLITE.CALL.xJS.ESM-EXPORT-DEFAULT,1,1,$(logtag.wasmfs))
-       $(maybe-wasm-strip) $(speedtest1-wasmfs.wasm)
-       chmod -x $(speedtest1-wasmfs.wasm)
-       ls -la $@ $(speedtest1-wasmfs.wasm)
-
-wasmfs: $(speedtest1-wasmfs.mjs)
-# end speedtest1.js
-########################################################################
index 9823a03bc9a23decffde1646c54e24968da71de8..d49423a3fddb6ba1e8abfe66c66be562c3c072cd 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sharmless\sinteger\soverflows\scaused\sby\sover-sized\sinteger\sconstants\sin\nthe\s"{m,n}"\ssyntax\sof\sthe\sregexp\sextension.
-D 2025-09-26T11:53:54.114
+C Get\swasmfs\sbuild\sworking\sin\sthe\snew\ssetup.\sDisable\sthe\scustom\swasm\sloader\sbecause\sits\sgenerated\smakefile\scode\sis\scurrently\sbroken.
+D 2025-09-26T12:49:41.370
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -578,7 +578,7 @@ F ext/session/sqlite3session.c b3de195ce668cace9b324599bf6255a70290cbfb5451e826e
 F ext/session/sqlite3session.h 7404723606074fcb2afdc6b72c206072cdb2b7d8ba097ca1559174a80bc26f7a
 F ext/session/test_session.c 8766b5973a6323934cb51248f621c3dc87ad2a98f023c3cc280d79e7d78d36fb
 F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c
-F ext/wasm/GNUmakefile c6cd306a0b078daf7da2af2decd2f60d84aacc3cd6775b5481285628291c877b
+F ext/wasm/GNUmakefile 3c9bab1b8bf5c816fbfe226927e27e72812a8bade09e96cced474e94741051ce
 F ext/wasm/README-dist.txt f01081a850ce38a56706af6b481e3a7878e24e42b314cfcd4b129f0f8427066a
 F ext/wasm/README.md 66ace67ae98a45e4116f2ca5425b716887bcee4d64febee804ff6398e1ae9ec7
 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff
@@ -634,7 +634,7 @@ F ext/wasm/index.html 1b329fb63e057c02a17ce178308d6b06aac62d92af7dd6d821fb0e183e
 F ext/wasm/jaccwabyt/jaccwabyt.js bbac67bc7a79dca34afe6215fd16b27768d84e22273507206f888c117e2ede7d
 F ext/wasm/jaccwabyt/jaccwabyt.md 167fc0b624c9bc2c477846e336de9403842d81b1a24fc4d3b24317cb9eba734f
 F ext/wasm/mkdist.sh 29f8a37a7aba41fa5df8e89b1fab02b83b35c43473c5cf808584872e022514b8 x
-F ext/wasm/mkwasmbuilds.c 91624cea0a0e7b9b0c96bfb682f5a89c46d4f804a116b209dcbc808001a2c97f
+F ext/wasm/mkwasmbuilds.c d8b5e332b53a9ccbad937a3dbb59d850cbef91d67efa9c326feac0430ee90fbb
 F ext/wasm/module-symbols.html dc476b403369b26a1a23773e13b80f41b9a49f0825e81435fe3600a7cfbbe337
 F ext/wasm/scratchpad-wasmfs.html a3d7388f3c4b263676b58b526846e9d02dfcb4014ff29d3a5040935286af5b96
 F ext/wasm/scratchpad-wasmfs.mjs 66034b9256b218de59248aad796760a1584c1dd842231505895eff00dbd57c63
@@ -659,7 +659,6 @@ F ext/wasm/tests/opfs/sahpool/digest.html 206d08a34dc8bd570b2581d3d9ab3ecad3201b
 F ext/wasm/tests/opfs/sahpool/index.html be736567fd92d3ecb9754c145755037cbbd2bca01385e2732294b53f4c842328
 F ext/wasm/tests/opfs/sahpool/sahpool-pausing.js f264925cfc82155de38cecb3d204c36e0f6991460fff0cb7c15079454679a4e2
 F ext/wasm/tests/opfs/sahpool/sahpool-worker.js bd25a43fc2ab2d1bafd8f2854ad3943ef673f7c3be03e95ecf1612ff6e8e2a61
-F ext/wasm/wasmfs.make 5de02751b3e9e79b81a52ab4fe0ed6aa6a23311a90db58fea98c1c4e2845e562
 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0
 F main.mk fd45a3578989f38bbeb2564a63883f6f6c077105c9f1361c3eac411d31f3afbd
 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
@@ -2170,8 +2169,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
 F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P d022ee167b90a7c32049a93d476e869270018017f60551185024409730d77640
-R b5ba3b2e9358725e1c77fc6398b42b2c
-U drh
-Z 70b5e36db724d08f297bb83c1614bd83
+P 8f17e1d869685b51f3368feed03dc06543ec16bc8fd81b8daad2ac2dbf99c5d6
+R 5e672d86934b8320ca0a7d5b18bc23c5
+U stephan
+Z 1a1ba5bad861e833b8982957ff27b00f
 # Remove this line to create a well-formed Fossil manifest.
index 22e1faa9569387d4c8beee43a3c3bc98e608a0d8..d27b9a429f98020319e36728d7b2d50321607e5f 100644 (file)
@@ -1 +1 @@
-8f17e1d869685b51f3368feed03dc06543ec16bc8fd81b8daad2ac2dbf99c5d6
+36bc2514f70af5608aa20903d9c38b316603e2f78f2cbf4a20c7c79b60c5b8d5