SQLite

Check-in [f0ad6b1b32]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Minor tweaks to, and consolidation of, the wasm-related build flags.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f0ad6b1b324f9c0f4340f6cf9584884d1206b56fe1010db43bcbef324e713ea3
User & Date: stephan 2022-06-01 14:52:23.135
Context
2022-06-01
16:04
fiddle: added another UI element to the list of those which are disabled during long-running activities. Added DB.close() binding to the Worker-based wasm binding. (check-in: 5933163ed1 user: stephan tags: trunk)
14:52
Minor tweaks to, and consolidation of, the wasm-related build flags. (check-in: f0ad6b1b32 user: stephan tags: trunk)
14:32
Fix a minor problem in the Tcl "incrblob" command. This does not affect the SQLite core. (check-in: e96feccc21 user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to Makefile.in.
1525
1526
1527
1528
1529
1530
1531
1532




1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
sqlite3_wasm_js = $(fiddle_dir)/sqlite3.js
sqlite3_wasm = $(fiddle_dir)/sqlite3.wasm
#emcc_opt = -O0
#emcc_opt = -O1
#emcc_opt = -O2
#emcc_opt = -O3
emcc_opt = -Oz
emcc_flags = $(emcc_opt) -sALLOW_TABLE_GROWTH -I. $(SHELL_OPT)




$(fiddle_module_js): Makefile sqlite3.c shell.c \
    $(fiddle_dir)/EXPORTED_RUNTIME_METHODS \
    $(fiddle_dir)/EXPORTED_FUNCTIONS.fiddle
	emcc -o $@ $(emcc_flags) \
        -sENVIRONMENT=web \
        -sMODULARIZE \
        -sEXPORT_NAME=initFiddleModule \
        -sEXPORTED_RUNTIME_METHODS=@$(fiddle_dir_abs)/EXPORTED_RUNTIME_METHODS \
        -sEXPORTED_FUNCTIONS=@$(fiddle_dir_abs)/EXPORTED_FUNCTIONS.fiddle \
        sqlite3.c shell.c
	gzip < $@ > $@.gz
	gzip < $(fiddle_dir)/fiddle-module.wasm > $(fiddle_dir)/fiddle-module.wasm.gz
$(sqlite3_wasm_js): Makefile sqlite3.c \
    $(fiddle_dir)/sqlite3-api.js \
    $(fiddle_dir)/EXPORTED_RUNTIME_METHODS \
    $(fiddle_dir)/EXPORTED_FUNCTIONS.sqlite3-api
	emcc -o $@ $(emcc_flags) \
        -sENVIRONMENT=web \
        -sMODULARIZE \
        -sEXPORT_NAME=initSqlite3Module \
        -sEXPORTED_RUNTIME_METHODS=@$(fiddle_dir_abs)/EXPORTED_RUNTIME_METHODS \
        -sEXPORTED_FUNCTIONS=@$(fiddle_dir_abs)/EXPORTED_FUNCTIONS.sqlite3-api \
        --post-js=$(fiddle_dir)/sqlite3-api.js \
        --no-entry \
        sqlite3.c
	gzip < $@ > $@.gz
	gzip < $(sqlite3_wasm) > $(sqlite3_wasm).gz
	gzip < $(fiddle_dir)/sqlite3-api.js > $(fiddle_dir)/sqlite3-api.js.gz







|
>
>
>
>




<
<

<









<
<

<







1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540


1541

1542
1543
1544
1545
1546
1547
1548
1549
1550


1551

1552
1553
1554
1555
1556
1557
1558
sqlite3_wasm_js = $(fiddle_dir)/sqlite3.js
sqlite3_wasm = $(fiddle_dir)/sqlite3.wasm
#emcc_opt = -O0
#emcc_opt = -O1
#emcc_opt = -O2
#emcc_opt = -O3
emcc_opt = -Oz
emcc_flags = $(emcc_opt) -sALLOW_TABLE_GROWTH -sSTRICT_JS \
        -sENVIRONMENT=web -sMODULARIZE \
        -sEXPORTED_RUNTIME_METHODS=@$(fiddle_dir_abs)/EXPORTED_RUNTIME_METHODS \
        -sDYNAMIC_EXECUTION=0 \
        -I. $(SHELL_OPT)
$(fiddle_module_js): Makefile sqlite3.c shell.c \
    $(fiddle_dir)/EXPORTED_RUNTIME_METHODS \
    $(fiddle_dir)/EXPORTED_FUNCTIONS.fiddle
	emcc -o $@ $(emcc_flags) \


        -sEXPORT_NAME=initFiddleModule \

        -sEXPORTED_FUNCTIONS=@$(fiddle_dir_abs)/EXPORTED_FUNCTIONS.fiddle \
        sqlite3.c shell.c
	gzip < $@ > $@.gz
	gzip < $(fiddle_dir)/fiddle-module.wasm > $(fiddle_dir)/fiddle-module.wasm.gz
$(sqlite3_wasm_js): Makefile sqlite3.c \
    $(fiddle_dir)/sqlite3-api.js \
    $(fiddle_dir)/EXPORTED_RUNTIME_METHODS \
    $(fiddle_dir)/EXPORTED_FUNCTIONS.sqlite3-api
	emcc -o $@ $(emcc_flags) \


        -sEXPORT_NAME=initSqlite3Module \

        -sEXPORTED_FUNCTIONS=@$(fiddle_dir_abs)/EXPORTED_FUNCTIONS.sqlite3-api \
        --post-js=$(fiddle_dir)/sqlite3-api.js \
        --no-entry \
        sqlite3.c
	gzip < $@ > $@.gz
	gzip < $(sqlite3_wasm) > $(sqlite3_wasm).gz
	gzip < $(fiddle_dir)/sqlite3-api.js > $(fiddle_dir)/sqlite3-api.js.gz
1576
1577
1578
1579
1580
1581
1582
1583



1584
1585
1586
1587
1588
1589
1590
clean-wasm:
	rm -f $(fiddle_generated) $(sqlite3_wasm_generated)
clean: clean-wasm
fiddle: $(fiddle_module_js) $(fiddle_dir)/fiddle.js.gz
sqlite3-wasm: $(sqlite3_wasm_js)
wasm: fiddle sqlite3-wasm
########################################################################
# Explanation of the emcc build flags:



#
# -sENVIRONMENT=web: elides bootstrap code related to non-web JS
#  environments like node.js. Removing this makes the output a tiny
#  tick larger but hypothetically makes it more portable to
#  non-browser JS environments.
#
# -sMODULARIZE: changes how the generated code is structured to avoid







|
>
>
>







1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
clean-wasm:
	rm -f $(fiddle_generated) $(sqlite3_wasm_generated)
clean: clean-wasm
fiddle: $(fiddle_module_js) $(fiddle_dir)/fiddle.js.gz
sqlite3-wasm: $(sqlite3_wasm_js)
wasm: fiddle sqlite3-wasm
########################################################################
# Explanation of the emcc build flags follows. Full docs for these can
# be found at:
#
#  https://github.com/emscripten-core/emscripten/blob/main/src/settings.js
#
# -sENVIRONMENT=web: elides bootstrap code related to non-web JS
#  environments like node.js. Removing this makes the output a tiny
#  tick larger but hypothetically makes it more portable to
#  non-browser JS environments.
#
# -sMODULARIZE: changes how the generated code is structured to avoid
1599
1600
1601
1602
1603
1604
1605

















1606
1607
1608
1609
1610
1611
1612
#
# -sEXPORTED_FUNCTIONS=@/absolute/path/to/file: a file containing a
#  list of C functions, one per line, which must be exported via wasm
#  so they're visible to JS. C symbols names in that file must all
#  start with an underscore for reasons known only to the emcc
#  developers. e.g., _sqlite3_open_v2 and _sqlite3_finalize. Must be
#  an absolute path!

















#
# --no-entry: for compiling library code with no main(). If this is
#  not supplied and the code has a main(), it is called as part of the
#  module init process. Note that main() is #if'd out of shell.c
#  (renamed) when building in wasm mode.
#
# --pre-js/--post-js=FILE relative or absolute paths to JS files to







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
#
# -sEXPORTED_FUNCTIONS=@/absolute/path/to/file: a file containing a
#  list of C functions, one per line, which must be exported via wasm
#  so they're visible to JS. C symbols names in that file must all
#  start with an underscore for reasons known only to the emcc
#  developers. e.g., _sqlite3_open_v2 and _sqlite3_finalize. Must be
#  an absolute path!
#
# -sSTRICT_JS ensures that the emitted JS code includes the 'use
#  strict' option. Note that -sSTRICT is more broadly-scoped and
#  results in build errors.
#
# -sALLOW_TABLE_GROWTH is required for (at a minimum) the UDF-binding
#  feature.
#
# -sDYNAMIC_EXECUTION=0 disables eval() and the Function constructor.
#  If the build runs without these, it's preferable to use this flag
#  because certain execution environments disallow those constructs.
#  This flag is not strictly necessary, however.
#
# -sWASM_BIGINT is UNTESTED but "should" allow the int64-using C APIs
#  to work with JS/wasm, insofar as the JS environment supports the
#  BigInt type. That support requires an extremely recent browser:
#  Safari didn't get that support until late 2020.
#
# --no-entry: for compiling library code with no main(). If this is
#  not supplied and the code has a main(), it is called as part of the
#  module init process. Note that main() is #if'd out of shell.c
#  (renamed) when building in wasm mode.
#
# --pre-js/--post-js=FILE relative or absolute paths to JS files to