From 3b56f296e94a9f8bcf735dc3a086d6b81a582198 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 24 Sep 2025 03:05:31 +0000 Subject: [PATCH] Generic build simplifications. FossilOrigin-Name: 61648610c3e454fce77b78e6f6be1b71e27bb9587af03ae5c0e083eac7158a64 --- ext/wasm/GNUmakefile | 52 ------------------------ ext/wasm/mkwasmbuilds.c | 90 ++++++++++++++++------------------------- manifest | 14 +++---- manifest.uuid | 2 +- 4 files changed, 43 insertions(+), 115 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 0122e8d986..fbf0e5dd6e 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -559,45 +559,6 @@ sqlite3-api.ext.jses = $(SOAP.js.out) $(SOAP.js.out): $(SOAP.js) cp $< $@ -######################################################################## -# $(sqlite3-api*.*js) contain the core library code but not the -# Emscripten-related glue which deals with loading sqlite3.wasm. In -# theory they can be used by arbitrary build environments and WASM -# loaders, but in practice that breaks down because the WASM loader -# has to be able to provide all of the necessary "imports" to -# sqlite3.wasm, and that list of imports is unknown until sqlite3.wasm -# is compiled, at which point Emscripten sets up the imports -# appropriately. Abstractly speaking, it's impossible for other build -# environments to know exactly which imports are needed and provide -# them. Tools like wasm-objdump can be used to find the list of -# imports but it's questionable whether a non-Emscripten tool could -# realistically use that info to provide proper implementations. -# -# Sidebar: some of the imports are used soley by the Emscripten glue, -# which the sqlite3 JS code does not rely on. -# -# 2025-09-04: the most significant WASM imports sqlite3.wasm relies on -# are (A) sqlite3_malloc/sqlite3_free() (the memory-management APIs -# used by the whole library) and (B) the libc proxies for POSIX I/O -# emulation (arguably one of Emscripten's most convenient features -# when building C code for WASM). If we eliminate the POSIX I/O -# emulation then we could hypothetically eliminate all, or maybe all -# but one, Emscripten import dependency. We would either need to add -# our own POSIX emulation layer (not a trivial effort) or restrict the -# library to use of only in-memory VFSes and the JS-side VFSes. -# -# sqlite3-api.js.in = the amalgamated sqlite3-api.js before it gets -# preprocessed. It contains all of $(sqlite3-api.jses) but none of the -# Emscripten-specific headers and footers. -sqlite3-api.js.in = $(dir.tmp)/sqlite3-api.c-pp.js -$(sqlite3-api.js.in): $(MKDIR.bld) $(sqlite3-api.jses) $(MAKEFILE) - @echo "Making $@ ..." - @for i in $(sqlite3-api.jses); do \ - echo "/* BEGIN FILE: $$i */"; \ - cat $$i; \ - echo "/* END FILE: $$i */"; \ - done > $@ - ######################################################################## # emcc flags for .c/.o/.wasm/.js. emcc.flags = @@ -740,19 +701,6 @@ emcc.jsflags += -sLLD_REPORT_UNDEFINED # -g3 debugging info, _huge_. ######################################################################## -######################################################################## -# $(sqlite3-api-build-version.js) injects the build version info into -# the bundle in JSON form. -$(sqlite3-api-build-version.js): $(MKDIR.bld) $(bin.version-info) $(MAKEFILE) - @echo "Making $@..." - @{ \ - echo 'globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){'; \ - echo -n ' sqlite3.version = '; \ - $(bin.version-info) --json; \ - echo ';'; \ - echo '});'; \ - } > $@ - # Undocumented Emscripten feature: if the target file extension is # "mjs", it defaults to ES6 module builds: diff --git a/ext/wasm/mkwasmbuilds.c b/ext/wasm/mkwasmbuilds.c index 5c1012a80c..7ceb8ad91d 100644 --- a/ext/wasm/mkwasmbuilds.c +++ b/ext/wasm/mkwasmbuilds.c @@ -349,43 +349,27 @@ static void mk_prologue(void){ ); ps(zBanner - "# Inputs for the sqlite3-api.js family.\n" + "# Inputs/outputs for the sqlite3-api.js family.\n" "#\n" - "# sqlite3-license-version.js = generated JS file with the license\n" - "# header and version info.\n" "sqlite3-license-version.js = $(dir.tmp)/sqlite3-license-version.js\n" - "# $(sqlite3-api-build-version.js) = generated JS file which populates the\n" - "# sqlite3.version object using $(bin.version-info).\n" "sqlite3-api-build-version.js = $(dir.tmp)/sqlite3-api-build-version.js\n" "# sqlite3-api.jses = the list of JS files which make up\n" "# $(sqlite3-api.js.in), in the order they need to be assembled.\n" + "sqlite3-api.js.in = $(dir.tmp)/sqlite3-api.c-pp.js\n" "sqlite3-api.jses = $(sqlite3-license-version.js)\n" - "# sqlite3-api-prologue.js: initial bootstrapping bits:\n" "sqlite3-api.jses += $(dir.api)/sqlite3-api-prologue.js\n" - "# whwhasm.js and jaccwabyt.js: Low-level utils, mostly replacing\n" - "# Emscripten glue:\n" "sqlite3-api.jses += $(dir.common)/whwasmutil.js\n" "sqlite3-api.jses += $(dir.jacc)/jaccwabyt.js\n" - "# sqlite3-api-glue Glues the previous part together with sqlite:\n" "sqlite3-api.jses += $(dir.api)/sqlite3-api-glue.c-pp.js\n" "sqlite3-api.jses += $(sqlite3-api-build-version.js)\n" - "# sqlite3-api-oo1 = the oo1 API:\n" "sqlite3-api.jses += $(dir.api)/sqlite3-api-oo1.c-pp.js\n" - "# sqlite3-api-worker = the Worker1 API:\n" "sqlite3-api.jses += $(dir.api)/sqlite3-api-worker1.c-pp.js\n" - "# sqlite3-vfs-helper = helper APIs for VFSes:\n" "sqlite3-api.jses += $(dir.api)/sqlite3-vfs-helper.c-pp.js\n" "ifeq (0,$(wasm-bare-bones))\n" - " # sqlite3-vtab-helper = helper APIs for VTABLEs:\n" " sqlite3-api.jses += $(dir.api)/sqlite3-vtab-helper.c-pp.js\n" "endif\n" - "# sqlite3-vfs-opfs = the first OPFS VFS:\n" "sqlite3-api.jses += $(dir.api)/sqlite3-vfs-opfs.c-pp.js\n" - "# sqlite3-vfs-opfs-sahpool = the second OPFS VFS:\n" "sqlite3-api.jses += $(dir.api)/sqlite3-vfs-opfs-sahpool.c-pp.js\n" - "# sqlite3-api-cleanup.js = \"finalizes\" the build and cleans up\n" - "# any extraneous global symbols which are needed temporarily\n" - "# by the previous files.\n" "sqlite3-api.jses += $(dir.api)/sqlite3-api-cleanup.js" ); @@ -398,7 +382,7 @@ static void mk_prologue(void){ "$(sqlite3-license-version.js): $(MKDIR.bld) $(sqlite3.h) " "$(dir.api)/sqlite3-license-version-header.js $(MAKEFILE)\n" "\t@echo '$(logtag.@) $(emo.disk)'; { \\\n" - "\t\tcat $(dir.api)/sqlite3-license-version-header.js; \\\n" + "\t\tcat $(dir.api)/sqlite3-license-version-header.js || exit $$?; \\\n" "\t\techo '/*'; \\\n" "\t\techo '** This code was built from sqlite3 version...'; \\\n" "\t\techo '**'; \\\n" @@ -423,6 +407,16 @@ static void mk_prologue(void){ "\t} > $@" ); + ps(zBanner + "$(sqlite3-api.js.in): $(MKDIR.bld) $(sqlite3-api.jses) $(MAKEFILE)\n" + "\t@echo 'Making $@ ...'\n" + "\t@for i in $(sqlite3-api.jses); do \\\n" + "\t\techo \"/* BEGIN FILE: $$i */\"; \\\n" + "\t\tcat $$i; \\\n" + "echo \"/* END FILE: $$i */\"; \\\n" + "\tdone > $@\n" + ); + ps(zBanner "# extern-post-js* and extern-pre-js* are files for use with\n" "# Emscripten's --extern-pre-js and --extern-post-js flags.\n" @@ -459,12 +453,15 @@ static void mk_prologue(void){ "# Emscripten-specific post-bootstrapping code.\n" "pre-js.in.js = $(dir.api)/pre-js.c-pp.js\n" "post-js.in.js = $(dir.tmp)/post-js.c-pp.js\n" - "post-jses.js = $(dir.api)/post-js-header.js $(sqlite3-api.js.in) $(dir.api)/post-js-footer.js\n" + "post-jses.js =" + " $(dir.api)/post-js-header.js" + " $(sqlite3-api.js.in)" + " $(dir.api)/post-js-footer.js\n" "$(post-js.in.js): $(MKDIR.bld) $(post-jses.js) $(MAKEFILE)\n" " @echo '$(logtag.@) $(emo.disk)'\n" " @for i in $(post-jses.js); do \\n" " echo \"/* BEGIN FILE: $$i */\"; \\n" - " cat $$i; \\n" + " cat $$i || exit $$?; \\n" " echo \"/* END FILE: $$i */\"; \\n" " done > $@\n" ); @@ -576,14 +573,14 @@ static void mk_pre_post(char const *zBuildName){ pf("pre-js.%s.js = $(dir.tmp)/pre-js.%s.js\n" "CLEAN_FILES += $(pre-js.%s.js)\n" "$(pre-js.%s.js): " - "$(MAKEFILE_LIST) $(sqlite3-license-version.js)\n", + "$(MAKEFILE_LIST) $(pre-js.in.js)\n", zBuildName, zBuildName, zBuildName, zBuildName); if( 0==WASM_CUSTOM_INSTANTIATE ){ pf("\t@echo '$(logtag.%s) $(emo.disk) $(c-pp.D.%s)'; " - "cat $(pre-js.in.js) | $(bin.c-pp) -o $@ $(c-pp.D.%s)\n", + "cat $(pre-js.in.js) | $(bin.c-pp) -o $@ $(c-pp.D.%s) || exit $$?\n", zBuildName, zBuildName, zBuildName); }else{ #if 0 @@ -609,14 +606,14 @@ static void mk_pre_post(char const *zBuildName){ ps("\n# --post-js=..."); pf("post-js.%s.js = $(dir.tmp)/post-js.%s.js\n", zBuildName, zBuildName); - pf("post-jses.%s = " - "$(dir.api)/post-js-header.js " - "$(sqlite3-api.%s.js) " - "$(dir.api)/post-js-footer.js\n", + pf("post-js.%s.in =" + " $(dir.api)/post-js-header.js" + " $(sqlite3-api.%s.js)" + " $(dir.api)/post-js-footer.js\n", zBuildName, zBuildName); pf("$(eval $(call b.do.c-pp," "%s," - "$(post-jses.%s)," + "$(post-js.%s.in)," "$(post-js.%s.js)," "$(c-pp.D.%s)" "))\n", @@ -667,34 +664,17 @@ static void emit_target_start(char const *zBuildName){ static void emit_api_js(char const *zBuildName, char const *zCmppD){ - pf("sqlite3-api.%s.c-pp.js = $(dir.tmp)/sqlite3-api.%s.c-pp.js\n", + pf("c-pp.D.%s ?= %s\n" + "sqlite3-api.%s.js = $(dir.tmp)/sqlite3-api.%s.js\n", + zBuildName, zCmppD ? zCmppD: "", zBuildName, zBuildName); - - pf("sqlite3-api.%s.js = $(dir.tmp)/sqlite3-api.%s.js\n", - zBuildName, zBuildName); - pf("c-pp.D.%s = %s\n", zBuildName, zCmppD ? zCmppD: "" ); - - pf("$(sqlite3-api.%s.c-pp.js): $(sqlite3-api.jses)\n" - "\t@$(call b.do.mkdir@); \\\n" - "\techo '$(logtag.%s) $(emo.disk)'; \\\n" - "\tfor i in $(sqlite3-api.jses); do \\\n" - "\t\techo \"/* BEGIN FILE: $$i */\"; \\\n" - "\t\tcat $$i; \\\n" - "\t\techo \"/* END FILE: $$i */\"; \\\n" - "\tdone > $@\n", - zBuildName, zBuildName); - - pf("$(sqlite3-api.%s.js): $(sqlite3-api.%s.c-pp.js)\n" - "$(eval $(call b.do.c-pp," + pf("$(eval $(call b.do.c-pp," "%s," - "$(sqlite3-api.%s.c-pp.js)," + "$(sqlite3-api.js.in)," "$(sqlite3-api.%s.js)," - "$(c-pp.D.%s)" + "$(c-pp.D.%s) %s" "))\n", - zBuildName, zBuildName, - zBuildName, zBuildName, - zBuildName, zBuildName); - + zBuildName, zBuildName, zBuildName, zCmppD ? zCmppD : ""); pf("$(out.%s.js): $(sqlite3-api.%s.js)\n", zBuildName, zBuildName); } @@ -800,8 +780,8 @@ void mk_lib_mode(const char *zBuildName, const BuildDef * pB){ ); } if( CP_WASM & pB->flags ){ - pf("\t@$(call b.do.cp,@,$(out.%s.wasm),$(dir.dout)/.)\n", - zBuildName + pf("\t@$(call b.do.cp,%s,$(out.%s.wasm),$(dir.dout)/.)\n", + zBuildName, zBuildName //"\techo '[%s $(out.%s.wasm)] $(emo.disk) $(dir.dout)/$(notdir $(out.%s.wasm))' //pB->zEmo, zBuildName ); @@ -915,7 +895,7 @@ static void mk_fiddle(void){ "$(SOAP.js)\n", zBuildName, zBuildName); emit_target_start(zBuildName); - pf("\t$(bin.emcc) -o $@" + pf("\t$(cmd.loud)$(bin.emcc) -o $@" " $(emcc.flags.%s)" /* set in fiddle.make */ " $(pre-post.%s.flags)" " $(fiddle.cses)" diff --git a/manifest b/manifest index fe77a343e3..d35561097d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Get\sfiddle\sbuilding\sproperly\sagain\sand\sfiddle/fiddle.debug\sbuilding\sin\sparallel. -D 2025-09-24T01:50:08.077 +C Generic\sbuild\ssimplifications. +D 2025-09-24T03:05:31.667 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 9cd47bfefb23c114b7a5d9ee5822d941398902f30516bf0dd 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 d3c31bcd9436a2b7e2ab3fda0ce788c7ebef623d9d276dd346878368d7917aa3 +F ext/wasm/GNUmakefile 87fac98d2dbca42c8361aa7951b951f9e5b6084ce78f8e56b81bd9a594c74c73 F ext/wasm/README-dist.txt f01081a850ce38a56706af6b481e3a7878e24e42b314cfcd4b129f0f8427066a F ext/wasm/README.md 66ace67ae98a45e4116f2ca5425b716887bcee4d64febee804ff6398e1ae9ec7 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -639,7 +639,7 @@ F ext/wasm/index-dist.html 56132399702b15d70c474c3f1952541e25cb0922942868f70daf1 F ext/wasm/index.html bcaa00eca521b372a6a62c7e7b17a870b0fcdf3e418a5921df1fd61e5344080d F ext/wasm/jaccwabyt/jaccwabyt.js bbac67bc7a79dca34afe6215fd16b27768d84e22273507206f888c117e2ede7d F ext/wasm/jaccwabyt/jaccwabyt.md 167fc0b624c9bc2c477846e336de9403842d81b1a24fc4d3b24317cb9eba734f -F ext/wasm/mkwasmbuilds.c 2c2cfd7edbeb02ed728ca0d600ea901b875c7644bc6f230b4060c2ed1fb8bf78 +F ext/wasm/mkwasmbuilds.c 87ee81ce0f78d31ca1e8ce58a1bc74ac6a0cecf6494612f093951197bab80462 F ext/wasm/module-symbols.html dc476b403369b26a1a23773e13b80f41b9a49f0825e81435fe3600a7cfbbe337 F ext/wasm/scratchpad-wasmfs.html a3d7388f3c4b263676b58b526846e9d02dfcb4014ff29d3a5040935286af5b96 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.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d725a075bc3303c5a26c4014f57162235cebc6491425083b4d80936de8f07fb0 -R cf0819fecf9c57d781fdf43886df17f2 +P 85fe9c6155f72583cea46d38bf5e040623d71fb5317ff9373421dbfdb179b2b0 +R 98bc100816e0f8dda14ba297aca98894 U stephan -Z b75ff23e1fde07fb82f0c0c838191732 +Z 7161ecf91dac252ddb71b18b364e931a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 001acce0ec..a802384b39 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -85fe9c6155f72583cea46d38bf5e040623d71fb5317ff9373421dbfdb179b2b0 +61648610c3e454fce77b78e6f6be1b71e27bb9587af03ae5c0e083eac7158a64 -- 2.47.3