From: stephan Date: Tue, 23 Sep 2025 02:04:07 +0000 (+0000) Subject: Add makefile target '64bit' to ext/wasm/GNUmakefile to build the 64-bit bundles.... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=12f17d41f92e98630c10589e123bc4f667b66431;p=thirdparty%2Fsqlite.git Add makefile target '64bit' to ext/wasm/GNUmakefile to build the 64-bit bundles. It does not yet generate copies of the test apps to load/test them, pending other reworking of the build. FossilOrigin-Name: 3e2ea990ad76f9e68d514568f53eaa692a1eb11695fceb1bcc58cea00605fff9 --- diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 2d02974af4..a9b4af209a 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -693,8 +693,10 @@ emcc.jsflags += -sSTRICT_JS=0 # emcc -sENVIRONMENT values for the various build modes: emcc.environment.vanilla = web,worker +emcc.environment.vanilla64 = $(emcc.environment.vanilla) emcc.environment.bundler-friendly = $(emcc.environment.vanilla) emcc.environment.esm = $(emcc.environment.vanilla) +emcc.environment.esm64 = $(emcc.environment.vanilla) emcc.environment.node = node # Adding ",node" to the list for the other builds causes Emscripten to # generate code which confuses node: it cannot reliably determine @@ -731,7 +733,7 @@ endif emcc.jsflags += -sINITIAL_MEMORY=$(emcc.INITIAL_MEMORY.$(emcc.INITIAL_MEMORY)) # /INITIAL_MEMORY ######################################################################## -emcc.jsflags += -sMEMORY64=$(emcc.MEMORY64) +#emcc.jsflags += -sMEMORY64=$(emcc.MEMORY64) emcc.jsflags += $(emcc.environment) emcc.jsflags += -sSTACK_SIZE=512KB @@ -898,8 +900,16 @@ if [ x1 = x$(1) ]; then \ fi endef +# +# We define these to assist in deps handling to avoid concurrent +# builds (more notes on that below). +# sqlite3.js = $(dir.dout)/sqlite3.js sqlite3.mjs = $(dir.dout)/sqlite3.mjs +sqlite3.wasm = $(dir.dout)/sqlite3.wasm +sqlite3-64bit.js = $(dir.dout)/sqlite3-64bit.js +sqlite3-64bit.mjs = $(dir.dout)/sqlite3-64bit.mjs +sqlite3-64bit.wasm = $(dir.dout)/sqlite3-64bit.wasm EXPORTED_FUNCTIONS.fiddle = $(dir.tmp)/EXPORTED_FUNCTIONS.fiddle # The various -D... values used by *.c-pp.js include: @@ -925,6 +935,7 @@ EXPORTED_FUNCTIONS.fiddle = $(dir.tmp)/EXPORTED_FUNCTIONS.fiddle # We repeat: all node.js builds are 100% untested and unsupported. # ######################################################################## + ######################################################################## # We have to ensure that we do not build $(sqlite3*.*js) in parallel # for any builds which result in the creation of $(sqlite3.wasm). We @@ -936,6 +947,8 @@ EXPORTED_FUNCTIONS.fiddle = $(dir.tmp)/EXPORTED_FUNCTIONS.fiddle # build time). $(sqlite3.wasm): $(sqlite3.js) $(sqlite3.mjs): $(sqlite3.js) +$(sqlite3-64bit.wasm): $(sqlite3-64bit.js) +$(sqlite3-64bit.mjs): $(sqlite3-64bit.js) $(dir.dout)/sqlite3-bundler-friendly.mjs: $(sqlite3.mjs) $(dir.dout)/sqlite3-node.mjs: $(sqlite3.mjs) #CLEAN_FILES += $(sqlite3.wasm) @@ -944,7 +957,7 @@ $(dir.dout)/sqlite3-node.mjs: $(sqlite3.mjs) # sqlite3-...js/mjs and the $(eval) calls below this block which use # SQLITE.CALL.C-PP.FILTER. ######################################################################## -# bin.mkwb is used for generating some of the makefile code for the +# 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 # difficult-to-read/maintain block of $(eval)'d code. Attempts were # made to generate it from tcl and bash (shell) but having to escape @@ -957,7 +970,7 @@ $(dir.dout)/sqlite3-node.mjs: $(sqlite3.mjs) bin.mkwb = ./mkwasmbuilds ifneq (1,$(MAKING_CLEAN)) $(bin.mkwb): $(bin.mkwb).c $(MAKEFILE) - $(CC) -o $@ $< -DWASM_CUSTOM_INSTANTIATE=$(WASM_CUSTOM_INSTANTIATE) + $(CC) -g -std=c99 -o $@ $< -DWASM_CUSTOM_INSTANTIATE=$(WASM_CUSTOM_INSTANTIATE) .wasmbuilds.make: $(bin.mkwb) @rm -f $@ @@ -1012,6 +1025,7 @@ sqlite3-api.ext.jses += \ $(dir.dout)/sqlite3-worker1.js all quick: $(sqlite3-api.ext.jses) q: quick +64bit: # populated by $(bin.mkwb) ######################################################################## # batch-runner.js is part of one of the test apps which reads in SQL diff --git a/ext/wasm/mkwasmbuilds.c b/ext/wasm/mkwasmbuilds.c index 1e1ff53f26..6d1786094d 100644 --- a/ext/wasm/mkwasmbuilds.c +++ b/ext/wasm/mkwasmbuilds.c @@ -44,7 +44,8 @@ ** Valid build modes. For the "sqlite3-wasmfs" build, only "esm" (ES6 ** Module) is legal. */ -#define JS_BUILD_MODES vanilla esm bundler-friendly node +#define JS_BUILD_MODES \ + vanilla vanilla64 esm esm64 bundler-friendly bundler-friendly64 node /* Separator to help eyeballs find the different output sections */ static const char * zBanner = @@ -67,11 +68,14 @@ enum LibModeFlags { ** added to the 'all' target. The unsupported builds exist primarily ** for experimentation's sake. */ LIBMODE_UNSUPPORTED = 0x04, + /* Elide this build from the 'all' target. */ + LIBMODE_NOT_IN_ALL = 0x08, + LIBMODE_64BIT = 0x10, /* Indicates a node.js-for-node.js build (untested and ** unsupported). */ - LIBMODE_NODEJS = 0x08, + LIBMODE_NODEJS = 0x20, /* Indicates a wasmfs build (untested and unsupported). */ - LIBMODE_WASMFS = 0x10 + LIBMODE_WASMFS = 0x40 }; /* @@ -84,9 +88,10 @@ struct BuildDef { const char *zMode; /* Name from JS_BUILD_MODES */ int flags; /* Flags from LibModeFlags */ 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. */ - const char *zWasmOut; /* zJsOut w/ .wasm extension if it needs to be renamed */ + const char *zWasmOut; /* zJsOut w/ .wasm extension if it needs to + be renamed. Do we still need this? */ const char *zCmppD; /* Extra -D... flags for c-pp */ const char *zEmcc; /* Extra flags for emcc */ }; @@ -105,44 +110,111 @@ typedef struct BuildDef BuildDef; #define C_PP_D_CUSTOM_INSTANTIATE #endif +/* List of distinct library builds. See next comment block. */ +#define BuildDefs_map(E) \ + E(canonical) \ + E(canonical64) \ + E(esm) \ + E(esm64) \ + E(bundler) \ + E(bundler64) \ + E(node) \ + E(wasmfs) + /* ** The set of WASM builds for the library (as opposed to the apps -** (fiddle, speedtest1)). This array must end with an empty sentinel -** entry. Their order is mostly insignificant, but some makefile vars -** used by some builds are set up by prior builds. Because of that, -** the (sqlite3, vanilla), (sqlite3, esm), and (sqlite3, -** bundler-friendly) builds should be defined first (in that order). +** (fiddle, speedtest1)). Their order in BuildDefs_map is mostly +** insignificant, but some makefile vars used by some builds are set +** up by prior builds. Because of that, the (sqlite3, vanilla), +** (sqlite3, esm), and (sqlite3, bundler-friendly) builds should be +** defined first (in that order). */ -const BuildDef aBuildDefs[] = { - {/* Core build */ - "sqlite3", "vanilla", 0, "$(sqlite3.js)", 0, 0, 0}, - - {/* Core ESM */ - "sqlite3", "esm", LIBMODE_ESM, "$(sqlite3.mjs)", 0, - "-Dtarget=es6-module", 0}, - - {/* Core bundler-friendly build. Untested and "not really" - ** supported, but required by the downstream npm subproject. - ** Testing these would require special-purpose node-based tools and - ** custom test apps. Or we can pass them off as-is to the npm - ** subproject and they spot failures pretty quickly ;). */ - "sqlite3", "bundler-friendly", - LIBMODE_BUNDLER_FRIENDLY | LIBMODE_ESM, - "$(dir.dout)/sqlite3-bundler-friendly.mjs", 0, - "$(c-pp.D.sqlite3-esm) -Dtarget=es6-bundler-friendly", 0}, - - {/* node.js mode. Untested and unsupported. */ - "sqlite3", "node", LIBMODE_UNSUPPORTED | LIBMODE_NODEJS, - "$(dir.dout)/sqlite3-node.mjs", "sqlite3-node.wasm", - "$(c-pp.D.sqlite3-bundler-friendly) -Dtarget=node", 0}, - - {/* Wasmfs build. Fully unsupported and largely untested. */ - "sqlite3-wasmfs", "esm" , - LIBMODE_UNSUPPORTED | LIBMODE_WASMFS | LIBMODE_ESM, - "$(dir.wasmfs)/sqlite3-wasmfs.mjs", "sqlite3-wasmfs.wasm", - "$(c-pp.D.sqlite3-bundler-friendly) -Dwasmfs", - "-sEXPORT_ES6 -sUSE_ES6_IMPORT_META"}, - {/*End-of-list sentinel*/0,0,0,0,0,0,0} +struct BuildDefs { +#define E(N) BuildDef N; + BuildDefs_map(E) +#undef E +}; +typedef struct BuildDefs BuildDefs; + +const BuildDefs oBuildDefs = { + .canonical = { + .zName ="sqlite3", .zMode = "vanilla", + .flags = 0, + .zJsOut ="$(sqlite3.js)", + .zWasmOut = 0, + .zCmppD = 0, + .zEmcc =0 + }, + + .canonical64 = { + .zName="sqlite3", .zMode= "vanilla64", + .flags= LIBMODE_NOT_IN_ALL | LIBMODE_64BIT, + .zJsOut="$(sqlite3-64bit.js)", + .zWasmOut=0, + .zCmppD=0, + .zEmcc="-sMEMORY64=1" + }, + + .esm = { + .zName="sqlite3", .zMode= "esm", + .flags= LIBMODE_ESM, + .zJsOut="$(sqlite3.mjs)", + .zWasmOut=0, + .zCmppD= "-Dtarget=es6-module", + .zEmcc=0 + }, + + .esm64 = { + .zName="sqlite3", .zMode= "esm64", + .flags= LIBMODE_NOT_IN_ALL | LIBMODE_64BIT, + .zJsOut="$(sqlite3-64bit.mjs)", + .zWasmOut=0, + .zCmppD=0, + .zEmcc="-sMEMORY64=1" + }, + + .bundler = { + /* Core bundler-friendly build. Untested and "not really" + ** supported, but required by the downstream npm subproject. + ** Testing these would require special-purpose node-based tools and + ** custom test apps. Or we can pass them off as-is to the npm + ** subproject and they spot failures pretty quickly ;). */ + .zName="sqlite3", .zMode= "bundler-friendly", + .flags=LIBMODE_BUNDLER_FRIENDLY | LIBMODE_ESM, + .zJsOut="$(dir.dout)/sqlite3-bundler-friendly.mjs", + .zWasmOut=0, + .zCmppD="$(c-pp.D.sqlite3-esm) -Dtarget=es6-bundler-friendly", + .zEmcc=0 + }, + + .bundler64 = { + .zName="sqlite3", .zMode= "bundler-friendly64", + .flags= LIBMODE_BUNDLER_FRIENDLY | LIBMODE_ESM, + .zJsOut="$(dir.dout)/sqlite3-bundler-friendly-64bit.mjs", + .zWasmOut=0, + .zCmppD="$(c-pp.D.sqlite3-esm) -Dtarget=es6-bundler-friendly", + .zEmcc="-sMEMORY64=1" + }, + + /* Entirely unsupported. */ + .node = { + .zName="sqlite3", .zMode= "node", + .flags= LIBMODE_UNSUPPORTED | LIBMODE_NODEJS, + .zJsOut="$(dir.dout)/sqlite3-node.mjs", + .zWasmOut="sqlite3-node.wasm", + .zCmppD="$(c-pp.D.sqlite3-bundler-friendly) -Dtarget=node", + .zEmcc=0 + }, + + /* Entirely unsupported. */ + .wasmfs = { + .zName="sqlite3-wasmfs", .zMode= "esm" , + .flags= LIBMODE_UNSUPPORTED | LIBMODE_WASMFS | LIBMODE_ESM, + .zJsOut="$(dir.wasmfs)/sqlite3-wasmfs.mjs", + .zWasmOut="sqlite3-wasmfs.wasm", + .zCmppD="$(c-pp.D.sqlite3-bundler-friendly) -Dwasmfs", + .zEmcc="-sEXPORT_ES6 -sUSE_ES6_IMPORT_META" + } }; /* @@ -161,6 +233,9 @@ static void mk_prologue(void){ "dir.fiddle", "dir.fiddle-debug", "MAKEFILE.fiddle", "EXPORTED_FUNCTIONS.fiddle", + /* Some core JS files... */ + "sqlite3.js", "sqlite3.mjs", + "sqlite3-64bit.js", "sqlite3-64bit.mjs", /*"just-testing",*/ 0 }; @@ -269,7 +344,9 @@ static void mk_pre_post(const char *zName /* build name */, #define zNM zName, zMode pf("%s# Begin --pre/--post flags for %s-%s\n", zBanner, zNM); - pf("c-pp.D.%s-%s = %s\n", zNM, zCmppD ? zCmppD : ""); + if( zCmppD && *zCmppD ){ + pf("c-pp.D.%s-%s = %s\n", zNM, zCmppD ? zCmppD : ""); + } pf("pre-post-%s-%s.flags ?=\n", zNM); /* --pre-js=... */ @@ -384,13 +461,11 @@ static void mk_fiddle(void){ } /* -** Emits makefile code for one build of the library, primarily defined -** by the combination of zName and zMode, each of which must be values -** from JS_BUILD_NAMES resp. JS_BUILD_MODES. +** Emits makefile code for one build of the library. */ static void mk_lib_mode(const BuildDef * pB){ const char * zWasmOut = "$(basename $@).wasm" - /* The various targets named X.js or X.mjs (zJsOut) also generate + /* The various targets named X.js or X.mjs (pB->zJsOut) also generate ** X.wasm, and we need that part of the name to perform some ** post-processing after Emscripten generates X.wasm. */; assert( pB->zName ); @@ -449,11 +524,11 @@ static void mk_lib_mode(const BuildDef * pB){ ps("\t@$(SQLITE.strip-createExportWrapper)"); /* ** The above $(bin.emcc) call will write pB->zJsOut, a.k.a. $@, and - ** will create a like-named .wasm file (zWasmOut). That .wasm file - ** name gets hard-coded into $@ so we need to, for some cases, patch - ** zJsOut to use the name sqlite3.wasm instead. Note that the - ** resulting .wasm file is identical for all builds for which zEmcc - ** is empty. + ** will create a like-named .wasm file (pB->zWasmOut). That .wasm + ** file name gets hard-coded into $@ so we need to, for some cases, + ** patch zJsOut to use the name sqlite3.wasm instead. The resulting + ** .wasm file is identical for all builds for which pB->zEmcc is + ** empty. */ if( (LIBMODE_BUNDLER_FRIENDLY & pB->flags) ){ pf("\t@echo 'Patching $@ for %s.wasm...'; \\\n", pB->zName); @@ -476,7 +551,11 @@ static void mk_lib_mode(const BuildDef * pB){ }else{ pf("\t@ls -la %s $@\n", zWasmOut); } - if( 0==(LIBMODE_UNSUPPORTED & pB->flags) ){ + + if( LIBMODE_64BIT & pB->flags ){ + pf("64bit: %s\n", pB->zJsOut); + }else if( 0==(LIBMODE_NOT_IN_ALL & pB->flags) + && 0==(LIBMODE_UNSUPPORTED & pB->flags) ){ pf("all: %s\n", pB->zJsOut); } pf("# End build [%s-%s]%s", zNM, zBanner); @@ -485,15 +564,15 @@ static void mk_lib_mode(const BuildDef * pB){ int main(void){ int rc = 0; - const BuildDef *pB = &aBuildDefs[0]; + const BuildDef *pB; pf("# What follows was GENERATED by %s. Edit at your own risk.\n", __FILE__); mk_prologue(); - for( ; pB->zName; ++pB ){ - mk_lib_mode( pB ); - } +#define E(N) mk_lib_mode(&oBuildDefs.N); + BuildDefs_map(E) +#undef E mk_fiddle(); 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", "speetest1-wasmfs.wasm"); return rc; diff --git a/manifest b/manifest index df9b2fafc0..4fa0d80a9c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Slight\scorrection\sto\sthe\sdiagram\sin\sthe\sprevious\scheckin. -D 2025-09-23T00:24:58.802 +C Add\smakefile\starget\s'64bit'\sto\sext/wasm/GNUmakefile\sto\sbuild\sthe\s64-bit\sbundles.\sIt\sdoes\snot\syet\sgenerate\scopies\sof\sthe\stest\sapps\sto\sload/test\sthem,\spending\sother\sreworking\sof\sthe\sbuild. +D 2025-09-23T02:04:07.278 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 d0c2209a0800e6ac95901a737ff5ea88f22578c825737f9cedb6b16171874ecc +F ext/wasm/GNUmakefile 39beef47c945a140f93435998f07df70e7f0157e4c198f6197dc3b8236fec7ca 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 47dc7d329aa91735113ef062fe6e191346f6273b5f26ae789be7d7a0cf09a3be +F ext/wasm/mkwasmbuilds.c fc6044341e6cdc8825ffc07db505c92f83cb62cb7c8d271f293f4dc8a8887468 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 e0dfa1e62ba6d71abe1f48969eb6f53c83f2c28d47b996ee223587d923cc282f -R 2d13553aeca3f42267324cbb5d9afab8 +P 6455af2703e78fb9b6df19cf4b46873d98ec91c3302dc0093a362d03ac48da91 +R 58099e236bc56168160faf964fe1137e U stephan -Z 052952a1d200f199839991163dab7b3f +Z 27a67ec5dfd92ddefa13deed0e4dc8eb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 79cdf76b5f..097299a308 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6455af2703e78fb9b6df19cf4b46873d98ec91c3302dc0093a362d03ac48da91 +3e2ea990ad76f9e68d514568f53eaa692a1eb11695fceb1bcc58cea00605fff9