From: stephan Date: Sat, 15 Nov 2025 13:30:13 +0000 (+0000) Subject: Random JS build cleanups and parallel build mkdir race fixes. Reinstate the recently... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e83ffd5c873854c16922e04ba45997b9db5d2a5d;p=thirdparty%2Fsqlite.git Random JS build cleanups and parallel build mkdir race fixes. Reinstate the recently-removed [a65bd978cbc646ec] after finding a reformulation which works on Emscripten 4.0.19 (and saves about 85kb on the JS deliverables). FossilOrigin-Name: acb1525a49463de67716638626406ccde9a282907d0de218ab88bf474ba830ee --- diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index be0d96773f..7bc843a552 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -219,9 +219,8 @@ b.cp = $(call b.mkdir@); \ # $4 = optional $(bin.c-pp) flags define b.c-pp.shcmd $(call b.mkdir@); \ -$(call b.echo,$(1),$(emo.disk)$(emo.lock) $(bin.c-pp) $(4) $(if $(loud.if),$(2))); \ -rm -f $(3); \ -$(bin.c-pp) -o $(3) $(4) $(2) || exit; \ +$(call b.echo,$(1),$(emo.disk)$(emo.lock)[$(3)] $(4)); \ +rm -f $(3); $(bin.c-pp) -o $(3) $(4) $(2) || exit; \ chmod -w $(3) endef @@ -233,7 +232,8 @@ endef # Args: as for $(b.c-pp.shcmd). define b.c-pp.target $(3): $$(MAKEFILE_LIST) $$(bin.c-pp) $(2) - @$$(call b.c-pp.shcmd,$(1),$(2),$(3),$(4) $(b.c-pp.target.flags)) + @$$(call b.mkdir@) + @$$(call b.c-pp.shcmd,$(1),$(2),$(3),$(4) $$(b.c-pp.target.flags)) CLEAN_FILES += $(3) endef @@ -260,7 +260,7 @@ endef # # To repeat: all node.js builds are 100% untested and unsupported. # -# Most c-pp.D.X are set via $(bin.mkwasmbuilds) and X is a build name. +# Most c-pp.D.X are set via $(bin.mkwb) and X is a build name. # Those make rules reference c-pp.D.64bit, so it should be defined in # advance. # @@ -282,9 +282,20 @@ c-pp.D.64bit = -Dbits64 # This is intended to be used in makefile targets which generate an # Emscripten module and where $@ is the module's .js/.mjs file. # +# This is inherently fragile and has been broken by Emscripten updates +# before. +# +ifeq (1,1) +define b.strip-js-emcc-bindings +echo "$(1) $(emo.garbage) Stripping export wrappers."; \ +sed -i -e '/var _sqlite3.*makeInvalidEarly.*;/d' \ +-e '/assert.*sqlite3.*missing.*;/d' \ +-e '/_sqlite.*createExportWrapper.*;/d' $@ +endef +else b.strip-js-emcc-bindings = \ echo '$(1) $(emo.bug) (disabled because it breaks emsdk 4.0.16+)' - +endif # # Set up sqlite3.c and sqlite3.h... @@ -850,9 +861,8 @@ endef # sqlite3-license-version.js = $(dir.tmp)/sqlite3-license-version.js $(sqlite3-license-version.js): $(bin.version-info) \ - $(dir.api)/sqlite3-license-version-header.js - @echo '$(logtag.@) $(emo.disk)'; \ - $(call b.mkdir@); { \ + $(dir.api)/sqlite3-license-version-header.js $(MAKEFILE) + @$(call b.mkdir@); echo '$(logtag.@) $(emo.disk)'; { \ cat $(dir.api)/sqlite3-license-version-header.js || exit $$?; \ echo '/*'; \ echo '** This code was built from sqlite3 version...'; \ @@ -860,7 +870,7 @@ $(sqlite3-license-version.js): $(bin.version-info) \ awk '/define SQLITE_VERSION/{$$1=""; print "**" $$0}' $(sqlite3.h); \ awk '/define SQLITE_SOURCE_ID/{$$1=""; print "**" $$0}' $(sqlite3.h); \ echo '**'; echo '** Emscripten SDK: $(emcc.version)'; \ - echo '**'; \ + echo '**'; echo '** Preprocessed by:'; echo '** @c-pp::ARGV@'; \ echo '*/'; \ } > $@ @@ -886,10 +896,10 @@ $(sqlite3-api-build-version.js): $(bin.version-info) $(MAKEFILE) # sqlite3-api.js, in the order they need to be assembled. sqlite3-api.jses = $(sqlite3-license-version.js) sqlite3-api.jses += $(dir.api)/sqlite3-api-prologue.js +sqlite3-api.jses += $(sqlite3-api-build-version.js) sqlite3-api.jses += $(dir.common)/whwasmutil.js sqlite3-api.jses += $(dir.jacc)/jaccwabyt.js sqlite3-api.jses += $(dir.api)/sqlite3-api-glue.c-pp.js -sqlite3-api.jses += $(sqlite3-api-build-version.js) sqlite3-api.jses += $(dir.api)/sqlite3-api-oo1.c-pp.js sqlite3-api.jses += $(dir.api)/sqlite3-api-worker1.c-pp.js sqlite3-api.jses += $(dir.api)/sqlite3-vfs-helper.c-pp.js @@ -899,6 +909,13 @@ endif sqlite3-api.jses += $(dir.api)/sqlite3-vfs-opfs.c-pp.js sqlite3-api.jses += $(dir.api)/sqlite3-vfs-opfs-sahpool.c-pp.js +# Parallel builds can fail if $(sqlite3-license-version.js) is not +# created early enough, so make all files in $(sqlite-api.jses) except +# for $(sqlite3-license-version.js) depend on +# $(sqlite3-license-version.js). +deps.jses = $(filter-out $(sqlite3-license-version.js),$(sqlite3-api.jses)) +$(deps.jses): $(sqlite3-license-version.js) + # # extern-post-js* and extern-pre-js* are files for use with # Emscripten's --extern-pre-js and --extern-post-js flags. @@ -936,7 +953,7 @@ $(post-js.in.js): $(MKDIR.bld) $(post-jses.js) $(MAKEFILE) done > $@ # -# speedtest1 decls needed before the $(bin.mkws)-generated makefile +# speedtest1 decls needed before the $(bin.mkwb)-generated makefile # is included. # bin.speedtest1 = ../../speedtest1 @@ -977,7 +994,7 @@ endif EXPORTED_FUNCTIONS.fiddle = $(dir.tmp)/EXPORTED_FUNCTIONS.fiddle $(EXPORTED_FUNCTIONS.fiddle): $(EXPORTED_FUNCTIONS.api.in) $(MAKEFILE_LIST) - @$(b.mkdir@) + @$(call b.mkdir@) @$(call b.c-pp.shcmd,filter,$(EXPORTED_FUNCTIONS.api.in),\ $@,$(EXPORTED_FUNCTIONS.c-pp.flags) -Dfiddle) @echo $(logtag.@) $(emo.disk) @@ -1105,10 +1122,10 @@ sqlite3.ext.js = define gen-worker1 # $1 = X.ext part of sqlite3-worker1X.ext # $2 = $(c-pp.D.NAME) -$(call b.c-pp.target,filter,$(dir.api)/sqlite3-worker1.c-pp.js,\ - $(dir.dout)/sqlite3-worker1$(1),$(2)) -sqlite3.ext.js += $(dir.dout)/sqlite3-worker1$(1) -all: $(dir.dout)/sqlite3-worker1$(1) +$(call b.c-pp.target,filter,$$(dir.api)/sqlite3-worker1.c-pp.js,\ + $$(dir.dout)/sqlite3-worker1$(1),$(2)) +sqlite3.ext.js += $$(dir.dout)/sqlite3-worker1$(1) +all: $$(dir.dout)/sqlite3-worker1$(1) endef $(eval $(call gen-worker1,.js,$(c-pp.D.vanilla))) @@ -1122,10 +1139,10 @@ $(eval $(call gen-worker1,-bundler-friendly.mjs,$(c-pp.D.bundler))) define gen-promiser # $1 = X.ext part of sqlite3-worker1-promiserX.ext # $2 = $(c-pp.D.NAME) -$(call b.c-pp.target,filter,$(dir.api)/sqlite3-worker1-promiser.c-pp.js,\ - $(dir.dout)/sqlite3-worker1-promiser$(1),$(2)) -sqlite3.ext.js += $(dir.dout)/sqlite3-worker1-promiser$(1) -all: $(dir.dout)/sqlite3-worker1-promiser$(1) +$(call b.c-pp.target,filter,$$(dir.api)/sqlite3-worker1-promiser.c-pp.js,\ + $$(dir.dout)/sqlite3-worker1-promiser$(1),$(2)) +sqlite3.ext.js += $$(dir.dout)/sqlite3-worker1-promiser$(1) +all: $$(dir.dout)/sqlite3-worker1-promiser$(1) endef $(eval $(call gen-promiser,.js,$(c-pp.D.vanilla))) @@ -1167,14 +1184,19 @@ $(dir.dout)/sqlite3-opfs-async-proxy.js: $(dir.api)/sqlite3-opfs-async-proxy.js # we don't otherwise have a great place to attach them such that # they're always copied when we need them. # -# The var $(out.$(B).js) comes from $(bin.mkwasmbuilds). +# The var $(out.$(B).js) comes from $(bin.mkwb) and $(B) is the name +# of a build set up by that tool, e.g. b-vanilla or b-esm64. # $(foreach B,$(b.names),$(eval $(out.$(B).js): $(sqlite3.ext.js))) + # # b-all: builds all available js/wasm builds. # $(foreach B,$(b.names),$(eval b-all: $(out.$(B).js))) +#$(foreach B,$(b.names),$(eval pre: $(pre-js.$(B).js))) +$(foreach B,$(b.names),$(eval post: $(post-js.$(B).js))) + # # speedtest1 is our primary benchmarking tool. # @@ -1224,8 +1246,7 @@ speedtest1.exit-runtime1 = -sEXIT_RUNTIME=1 # which runs speedtest1 multiple times. $(EXPORTED_FUNCTIONS.speedtest1): $(EXPORTED_FUNCTIONS.api) - @$(call b.echo,@,$(emo.disk)); \ - $(call b.mkdir@); \ + @$(call b.mkdir@); $(call b.echo,@,$(emo.disk)); \ { echo _wasm_main; cat $(EXPORTED_FUNCTIONS.api); } > $@ || exit speedtest1: b-speedtest1 diff --git a/ext/wasm/mkwasmbuilds.c b/ext/wasm/mkwasmbuilds.c index 9ecd524432..e3e9329035 100644 --- a/ext/wasm/mkwasmbuilds.c +++ b/ext/wasm/mkwasmbuilds.c @@ -280,7 +280,7 @@ const BuildDefs oBuildDefs = { " -DSQLITE_SPEEDTEST1_WASM" " $(SQLITE_OPT)" " -USQLITE_WASM_BARE_BONES" - " -USQLITE_C -DSQLITE_C=$(sqlite3.canonical.c)" + " -USQLITE_C -DSQLITE_C=$(sqlite3.c)" " $(speedtest1.exit-runtime0)" " $(speedtest1.c.in)" " -lm", @@ -308,7 +308,7 @@ const BuildDefs oBuildDefs = { " -DSQLITE_SPEEDTEST1_WASM" " $(SQLITE_OPT)" " -USQLITE_WASM_BARE_BONES" - " -USQLITE_C -DSQLITE_C=$(sqlite3.canonical.c)" + " -USQLITE_C -DSQLITE_C=$(sqlite3.c)" " $(speedtest1.exit-runtime0)" " $(speedtest1.c.in)" " -lm", @@ -633,7 +633,7 @@ static void mk_pre_post(char const *zBuildName, BuildDef const * pB){ pB->zDotWasm); } ps(""); - pf("\t@$(call b.c-pp.shcmd," + pf("\t@$(call b.mkdir@); $(call b.c-pp.shcmd," "%s," "$(pre-js.in.js)," "$(pre-js.%s.js)," diff --git a/manifest b/manifest index d361cba4e6..fefb7859b2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Reorder\sinitialization\sof\ssqlite3ApiBootstrap()'s\sbownstrapped\sconfig\sobject\sso\sthat\sit's\spossible\sto\sinject\sthe\swasm\smemory\sand\sexports\svia\sthat,\sto\ssimplify\splugging-in\sof\ssqlite3-api.js\sin\sother\sbuilds.\sPreviously\sthe\sbuild-provided\swasm\sexports/memory\soverrode\sany\swhich\sa\sclient\smight\swant\sto\suse. -D 2025-11-15T11:53:30.331 +C Random\sJS\sbuild\scleanups\sand\sparallel\sbuild\smkdir\srace\sfixes.\sReinstate\sthe\srecently-removed\s[a65bd978cbc646ec]\safter\sfinding\sa\sreformulation\swhich\sworks\son\sEmscripten\s4.0.19\s(and\ssaves\sabout\s85kb\son\sthe\sJS\sdeliverables). +D 2025-11-15T13:30:13.350 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -575,7 +575,7 @@ F ext/session/sessionwor.test 6fd9a2256442cebde5b2284936ae9e0d54bde692d0f5fd009e F ext/session/sqlite3session.c b3de195ce668cace9b324599bf6255a70290cbfb5451e826e946f3aee6e64c54 F ext/session/sqlite3session.h 7404723606074fcb2afdc6b72c206072cdb2b7d8ba097ca1559174a80bc26f7a F ext/session/test_session.c 8766b5973a6323934cb51248f621c3dc87ad2a98f023c3cc280d79e7d78d36fb -F ext/wasm/GNUmakefile d32546590afc62c7adb71781b929b9fed6b35520e9a17542f576194ab8c9f50c +F ext/wasm/GNUmakefile aef238930e96197fed6fa1b4d9e5443b519dd6c24e0139e124c26bc51270f39a F ext/wasm/README-dist.txt f01081a850ce38a56706af6b481e3a7878e24e42b314cfcd4b129f0f8427066a F ext/wasm/README.md 2e87804e12c98f1d194b7a06162a88441d33bb443efcfe00dc6565a780d2f259 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -627,7 +627,7 @@ F ext/wasm/index.html 54e27db740695ab2cb296e02d42c4c66b3f11b65797340d19fa6590f5b F ext/wasm/jaccwabyt/jaccwabyt.js 1e734c624205cdf621f322972dfb0fc8013d573a5882f57492a6830e5ec23e17 F ext/wasm/jaccwabyt/jaccwabyt.md 167fc0b624c9bc2c477846e336de9403842d81b1a24fc4d3b24317cb9eba734f F ext/wasm/mkdist.sh 64d53f469c823ed311f6696f69cec9093f745e467334b34f5ceabdf9de3c5b28 x -F ext/wasm/mkwasmbuilds.c 9b02298593276962a6136575630498d452de5055f4a4737a3c254c1b04e7cc04 +F ext/wasm/mkwasmbuilds.c ef42e404236dd98cedb6ecea47b6d2474e3c593633ce6d992d316289dfc442b6 F ext/wasm/module-symbols.html e54f42112e0aac2a31f850ab33e7f2630a2ea4f63496f484a12469a2501e07e2 F ext/wasm/scratchpad-wasmfs.html a3d7388f3c4b263676b58b526846e9d02dfcb4014ff29d3a5040935286af5b96 F ext/wasm/scratchpad-wasmfs.mjs 66034b9256b218de59248aad796760a1584c1dd842231505895eff00dbd57c63 @@ -2166,8 +2166,8 @@ F tool/version-info.c 33d0390ef484b3b1cb685d59362be891ea162123cea181cb8e6d2cf6dd F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 5bc37e5c2fcd83fd0bc40234144072363f1cbf7d811a15b74a0991e397a35eb8 -R 01161c70faa9fb89e01dc6a6fa0c8e0f +P 2bd0addb6068cd2b34f6151a824c578e2253f541a8c55b578219b09c42afd82b +R cb76483e55da810a9fb38d6425ffedc4 U stephan -Z 029e333fd7ad6a6e77e1741105d38c02 +Z 3f713550333ee0705fe41873843f5246 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a859f678be..edcf03503e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2bd0addb6068cd2b34f6151a824c578e2253f541a8c55b578219b09c42afd82b +acb1525a49463de67716638626406ccde9a282907d0de218ab88bf474ba830ee