From: stephan Date: Fri, 19 Sep 2025 19:28:13 +0000 (+0000) Subject: Initial build-side tweaks to pave the way for a 64-bit WASM build. Such a build does... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a09a8ffa62f1962d590a9f78b3fcd04c295f5897;p=thirdparty%2Fsqlite.git Initial build-side tweaks to pave the way for a 64-bit WASM build. Such a build does not yet work for reasons given in the makefile comments, but is an eventual goal. FossilOrigin-Name: fe2e1681b6dac81508ab67d1247e1f92018c9998386789846d1715c2cc13d6a8 --- diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index d5a2dde607..2787e456eb 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -443,6 +443,35 @@ cflags.common = -I. -I$(dir $(sqlite3.c)) # disables certain features if BigInt is not enabled and such builds # _are not tested_ on any regular basis. emcc.WASM_BIGINT ?= 1 +emcc.MEMORY64 ?= 0 +######################################################################## +# https://emscripten.org/docs/tools_reference/settings_reference.html#memory64 +# +# -sMEMORY64=1 fails to load, erroring with: +# invalid memory limits flags 0x5 +# (enable via --experimental-wasm-memory64) +# +# -sMEMORY64=2 builds and loads but dies when we do things like: +# +# new Uint8Array(wasm.heap8u().buffer, ptr, n) +# +# because ptr is now a BigInt, so is invalid for passing to arguments +# which have strict must-be-a-Number requirements. That aspect will +# make any eventual port to 64-bit address space painful, as such +# constructs are found all over the place in the source code. We can +# potentially replace all such uses with Number(ptr) as a +# workaround. WASM 3.0[^wasm3] says that browsers will be limited to +# 16gb, which is still well, well within range of +# Number.MAX_SAFE_INTEGER. i.e. such a hack, though unsightly, would +# seem to pose no inherent problems. The hard part will be finding all +# such cases. +# +# [^wasm3]: https://webassembly.org/news/2025-09-17-wasm-3.0/ +######################################################################## + +ifneq (0,$(emcc.MEMORY64)) + SQLITE.CALL.C-PP.FILTER.global += -D64bit +endif # emcc_opt = optimization-related flags. These are primarily used by # the various oX targets. build times for -O levels higher than 0 are @@ -703,6 +732,7 @@ endif emcc.jsflags += -sINITIAL_MEMORY=$(emcc.INITIAL_MEMORY.$(emcc.INITIAL_MEMORY)) # /INITIAL_MEMORY ######################################################################## +emcc.jsflags += -sMEMORY64=$(emcc.MEMORY64) emcc.jsflags += $(emcc.environment) emcc.jsflags += -sSTACK_SIZE=512KB @@ -751,21 +781,6 @@ emcc.jsflags += -sLLD_REPORT_UNDEFINED #emcc.jsflags += --experimental-pic --unresolved-symbols=ingore-all --import-undefined #emcc.jsflags += --unresolved-symbols=ignore-all -######################################################################## -# -sMEMORY64=1 fails to load, erroring with: -# invalid memory limits flags 0x5 -# (enable via --experimental-wasm-memory64) -# -# ^^^^ MEMORY64=2 builds and loads but dies when we do things like: -# -# new Uint8Array(wasm.heap8u().buffer, ptr, n) -# -# because ptr is now a BigInt, so is invalid for passing to arguments -# which have strict must-be-a-Number requirements. That aspect will -# make any eventual port to 64-bit address space extremely painful, as -# such constructs are found all over the place in the source code. -######################################################################## - ######################################################################## # -sSINGLE_FILE: # https://github.com/emscripten-core/emscripten/blob/main/src/settings.js @@ -1050,10 +1065,12 @@ emcc.speedtest1.common += -sDYNAMIC_EXECUTION=0 emcc.speedtest1.common += --minify 0 emcc.speedtest1.common += -sEXPORT_NAME=$(sqlite3.js.init-func) emcc.speedtest1.common += -sWASM_BIGINT=$(emcc.WASM_BIGINT) +emcc.speedtest1.common += -sMEMORY64=$(emcc.MEMORY64) + speedtest1.exit-runtime0 = -sEXIT_RUNTIME=0 speedtest1.exit-runtime1 = -sEXIT_RUNTIME=1 # Re -sEXIT_RUNTIME=1 vs 0: if it's 1 and speedtest1 crashes, we get -# this error from emscripten: +# this error from Emscripten: # # > native function `free` called after runtime exit (use # NO_EXIT_RUNTIME to keep it alive after main() exits)) diff --git a/ext/wasm/fiddle.make b/ext/wasm/fiddle.make index 6bdf441959..4eb00df40e 100644 --- a/ext/wasm/fiddle.make +++ b/ext/wasm/fiddle.make @@ -31,6 +31,7 @@ fiddle.emcc-flags = \ $(emcc.cflags) $(emcc_opt_full) \ --minify 0 \ -sALLOW_TABLE_GROWTH \ + -sMEMORY64=$(emcc.MEMORY64) \ -sABORTING_MALLOC \ -sSTRICT_JS=0 \ -sENVIRONMENT=web,worker \ diff --git a/manifest b/manifest index 96632b87bd..ff320204c3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improve\simposter\stables:\s(1)\sRead-only\sunless\swriteable_schema=ON\n(2)\s--unsafe-testing\sno\slonger\srequired\s(3)\sDoes\snot\sinterfere\swith\nPRAGMA\sintegrity_check. -D 2025-09-19T17:33:29.757 +C Initial\sbuild-side\stweaks\sto\spave\sthe\sway\sfor\sa\s64-bit\sWASM\sbuild.\sSuch\sa\sbuild\sdoes\snot\syet\swork\sfor\sreasons\sgiven\sin\sthe\smakefile\scomments,\sbut\sis\san\seventual\sgoal. +D 2025-09-19T19:28:13.136 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 89e18d6e4783841a5236930b988df27e02317b3ac440a1a5571de4a79df3c8e7 +F ext/wasm/GNUmakefile 946daf72e222a2b247988edcbd2c77ec3c3670e84a43fc24ceed8219cb0687c6 F ext/wasm/README-dist.txt f01081a850ce38a56706af6b481e3a7878e24e42b314cfcd4b129f0f8427066a F ext/wasm/README.md 66ace67ae98a45e4116f2ca5425b716887bcee4d64febee804ff6398e1ae9ec7 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -631,7 +631,7 @@ F ext/wasm/demo-worker1.html 2c178c1890a2beb5a5fecb1453e796d067a4b8d3d2a04d65ca2 F ext/wasm/demo-worker1.js 08720227e98fa5b44761cf6e219269cee3e9dd0421d8d91459535da776950314 F ext/wasm/dist.make 57f5da2f0de5a297b5a0bc39ffec736380050578240ab24d864c2ff1b3634a3b F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c95839afd8b05862f -F ext/wasm/fiddle.make ea505d11aa2a89551e1693ed4c71ee6a163364ca14f806dda295d0beb26ec0ea +F ext/wasm/fiddle.make 732b5ba2d5c164080f7918eb4a82447a0039254867d775ba7603bd8bce2b6ac3 F ext/wasm/fiddle/fiddle-worker.js b5da00e3b13e8a33c8cbd53a0f90a24c3540751bd069908b98879587ebc3bb7e F ext/wasm/fiddle/fiddle.js f0b96f978c7c77fea8d092aa79c77849ce111d7b1ba60ffba07675009682184e F ext/wasm/fiddle/index.html 17c7d6b21f40fbf462162c4311b63d760b065e419d9f5a96534963b0e52af940 @@ -2175,9 +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 79af65a694fbbb3d501fb2ebd835c259ca644e0dafdd71eeb9f0a7c0e9128a1e ad152ddc4bcf6cfe840b9a36ab76a5ec36afdb1dd96eb7697e4b3df1bf63b00d -R 40cb735bce42a3fc7ea066af39f44a8e -T +closed ad152ddc4bcf6cfe840b9a36ab76a5ec36afdb1dd96eb7697e4b3df1bf63b00d -U drh -Z 249a850104d161bbd5ac157b5bff477d +P a4430d262b3e129d7f00be1661af563907d7b2e98560a9847cd399129f91247b +R cda4be0bb539fed68e1ae4d24e2df308 +U stephan +Z 62e7416b244f16716aa667b8fa388c54 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index afeff93b0e..c9fdc53313 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a4430d262b3e129d7f00be1661af563907d7b2e98560a9847cd399129f91247b +fe2e1681b6dac81508ab67d1247e1f92018c9998386789846d1715c2cc13d6a8