@@ -35,7 +35,7 @@ TCC += -I${TOP}/ext/fts3 -I${TOP}/ext/async -I${TOP}/ext/session
3535TCC += -I${TOP}/ext/userauth
3636
3737# Define this for the autoconf-based build, so that the code knows it can
38- # include the generated config .h
38+ # include the generated sqlite_cfg .h
3939#
4040TCC += -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite
4141
@@ -184,7 +184,7 @@ LIBOBJS0 = alter.lo analyze.lo attach.lo auth.lo \
184184 main.lo malloc.lo mem0.lo mem1.lo mem2.lo mem3.lo mem5.lo \
185185 memdb.lo memjournal.lo \
186186 mutex.lo mutex_noop.lo mutex_unix.lo mutex_w32.lo \
187- notify.lo opcodes.lo os.lo os_unix.lo os_win.lo \
187+ notify.lo opcodes.lo os.lo os_kv.lo os_unix.lo os_win.lo \
188188 pager.lo parse.lo pcache.lo pcache1.lo pragma.lo prepare.lo printf.lo \
189189 random.lo resolve.lo rowset.lo rtree.lo \
190190 sqlite3session.lo select.lo sqlite3rbu.lo status.lo stmt.lo \
@@ -257,6 +257,7 @@ SRC = \
257257 $(TOP ) /src/os.h \
258258 $(TOP ) /src/os_common.h \
259259 $(TOP ) /src/os_setup.h \
260+ $(TOP ) /src/os_kv.c \
260261 $(TOP ) /src/os_unix.c \
261262 $(TOP ) /src/os_win.c \
262263 $(TOP ) /src/os_win.h \
@@ -377,7 +378,7 @@ SRC += \
377378 opcodes.h \
378379 parse.c \
379380 parse.h \
380- config .h \
381+ sqlite_cfg .h \
381382 shell.c \
382383 sqlite3.h
383384
@@ -433,6 +434,9 @@ TESTSRC = \
433434 $(TOP ) /ext/fts3/fts3_term.c \
434435 $(TOP ) /ext/fts3/fts3_test.c \
435436 $(TOP ) /ext/session/test_session.c \
437+ $(TOP ) /ext/recover/sqlite3recover.c \
438+ $(TOP ) /ext/recover/dbdata.c \
439+ $(TOP ) /ext/recover/test_recover.c \
436440 $(TOP ) /ext/rbu/test_rbu.c
437441
438442# Statically linked extensions
@@ -492,6 +496,7 @@ TESTSRC2 = \
492496 $(TOP ) /src/main.c \
493497 $(TOP ) /src/mem5.c \
494498 $(TOP ) /src/os.c \
499+ $(TOP ) /src/os_kv.c \
495500 $(TOP ) /src/os_unix.c \
496501 $(TOP ) /src/os_win.c \
497502 $(TOP ) /src/pager.c \
@@ -555,7 +560,7 @@ HDR = \
555560 $(TOP ) /src/vdbeInt.h \
556561 $(TOP ) /src/vxworks.h \
557562 $(TOP ) /src/whereInt.h \
558- config .h
563+ sqlite_cfg .h
559564
560565# Header files used by extensions
561566#
@@ -621,7 +626,10 @@ SHELL_OPT += -DSQLITE_ENABLE_DBSTAT_VTAB
621626SHELL_OPT += -DSQLITE_ENABLE_BYTECODE_VTAB
622627SHELL_OPT += -DSQLITE_ENABLE_OFFSET_SQL_FUNC
623628FUZZERSHELL_OPT =
624- FUZZCHECK_OPT = -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_OSS_FUZZ
629+ FUZZCHECK_OPT += -I$(TOP ) /test
630+ FUZZCHECK_OPT += -I$(TOP ) /ext/recover
631+ FUZZCHECK_OPT += -DSQLITE_OMIT_LOAD_EXTENSION
632+ FUZZCHECK_OPT += -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_OSS_FUZZ
625633FUZZCHECK_OPT += -DSQLITE_MAX_MEMORY=50000000
626634FUZZCHECK_OPT += -DSQLITE_PRINTF_PRECISION_LIMIT=1000
627635FUZZCHECK_OPT += -DSQLITE_ENABLE_FTS4
@@ -631,8 +639,14 @@ FUZZCHECK_OPT += -DSQLITE_ENABLE_RTREE
631639FUZZCHECK_OPT += -DSQLITE_ENABLE_GEOPOLY
632640FUZZCHECK_OPT += -DSQLITE_ENABLE_DBSTAT_VTAB
633641FUZZCHECK_OPT += -DSQLITE_ENABLE_BYTECODE_VTAB
634- FUZZCHECK_SRC = $(TOP ) /test/fuzzcheck.c $(TOP ) /test/ossfuzz.c $(TOP ) /test/fuzzinvariants.c
642+ FUZZCHECK_SRC += $(TOP ) /test/fuzzcheck.c
643+ FUZZCHECK_SRC += $(TOP ) /test/ossfuzz.c
644+ FUZZCHECK_SRC += $(TOP ) /test/fuzzinvariants.c
645+ FUZZCHECK_SRC += $(TOP ) /ext/recover/dbdata.c
646+ FUZZCHECK_SRC += $(TOP ) /ext/recover/sqlite3recover.c
647+ FUZZCHECK_SRC += $(TOP ) /test/vt02.c
635648DBFUZZ_OPT =
649+ ST_OPT = -DSQLITE_OS_KV_OPTIONAL
636650
637651# This is the default Makefile target. The objects listed here
638652# are what get build when you type just "make" with no arguments.
@@ -681,7 +695,7 @@ fuzzershell$(TEXE): $(TOP)/tool/fuzzershell.c sqlite3.c sqlite3.h
681695 $(LTLINK ) -o $@ $(FUZZERSHELL_OPT ) \
682696 $(TOP ) /tool/fuzzershell.c sqlite3.c $(TLIBS )
683697
684- fuzzcheck$(TEXE ) : $(FUZZCHECK_SRC ) sqlite3.c sqlite3.h
698+ fuzzcheck$(TEXE ) : $(FUZZCHECK_SRC ) sqlite3.c sqlite3.h $( FUZZCHECK_DEP )
685699 $(LTLINK ) -o $@ $(FUZZCHECK_OPT ) $(FUZZCHECK_SRC ) sqlite3.c $(TLIBS )
686700
687701ossshell$(TEXE ) : $(TOP ) /test/ossfuzz.c $(TOP ) /test/ossshell.c sqlite3.c sqlite3.h
@@ -938,6 +952,9 @@ pcache1.lo: $(TOP)/src/pcache1.c $(HDR) $(TOP)/src/pcache.h
938952os.lo : $(TOP ) /src/os.c $(HDR )
939953 $(LTCOMPILE ) $(TEMP_STORE ) -c $(TOP ) /src/os.c
940954
955+ os_kv.lo : $(TOP ) /src/os_kv.c $(HDR )
956+ $(LTCOMPILE ) $(TEMP_STORE ) -c $(TOP ) /src/os_kv.c
957+
941958os_unix.lo : $(TOP ) /src/os_unix.c $(HDR )
942959 $(LTCOMPILE ) $(TEMP_STORE ) -c $(TOP ) /src/os_unix.c
943960
@@ -1102,6 +1119,9 @@ SHELL_SRC = \
11021119 $(TOP ) /ext/expert/sqlite3expert.h \
11031120 $(TOP ) /ext/misc/zipfile.c \
11041121 $(TOP ) /ext/misc/memtrace.c \
1122+ $(TOP ) /ext/recover/dbdata.c \
1123+ $(TOP ) /ext/recover/sqlite3recover.c \
1124+ $(TOP ) /ext/recover/sqlite3recover.h \
11051125 $(TOP ) /src/test_windirent.c
11061126
11071127shell.c : $(SHELL_SRC ) $(TOP ) /tool/mkshellc.tcl
@@ -1281,6 +1301,12 @@ valgrindfuzz: fuzzcheck$(TEXT) $(FUZZDATA) sessionfuzz$(TEXE) $(TOP)/test/sessio
12811301tcltest : ./testfixture$(TEXE )
12821302 ./testfixture$(TEXE ) $(TOP ) /test/veryquick.test $(TESTOPTS )
12831303
1304+ # Runs all the same tests cases as the "tcltest" target but uses
1305+ # the testrunner.tcl script to run them in multiple cores
1306+ # concurrently.
1307+ testrunner : testfixture$(TEXE )
1308+ ./testfixture$(TEXE ) $(TOP ) /test/testrunner.tcl
1309+
12841310# Minimal testing that runs in less than 3 minutes
12851311#
12861312quicktest : ./testfixture$(TEXE )
@@ -1381,7 +1407,7 @@ LogEst$(TEXE): $(TOP)/tool/logest.c sqlite3.h
13811407wordcount$(TEXE ) : $(TOP ) /test/wordcount.c sqlite3.lo
13821408 $(LTLINK ) -o $@ $(TOP ) /test/wordcount.c sqlite3.lo $(TLIBS )
13831409
1384- speedtest1$(TEXE ) : $(TOP ) /test/speedtest1.c sqlite3.c
1410+ speedtest1$(TEXE ) : $(TOP ) /test/speedtest1.c sqlite3.c Makefile
13851411 $(LTLINK ) $(ST_OPT ) -o $@ $(TOP ) /test/speedtest1.c sqlite3.c $(TLIBS )
13861412
13871413startup$(TEXE ) : $(TOP ) /test/startup.c sqlite3.c
@@ -1470,6 +1496,7 @@ clean:
14701496 rm -rf .libs .deps
14711497 rm -f lemon$(BEXE ) lempar.c parse.* sqlite* .tar.gz
14721498 rm -f mkkeywordhash$(BEXE ) keywordhash.h
1499+ rm -f mksourceid$(BEXE )
14731500 rm -f * .da * .bb * .bbg gmon.out
14741501 rm -rf tsrc .target_source
14751502 rm -f tclsqlite3$(TEXE )
@@ -1494,7 +1521,8 @@ clean:
14941521 rm -f threadtest5
14951522
14961523distclean : clean
1497- rm -f config.h config.log config.status libtool Makefile sqlite3.pc
1524+ rm -f sqlite_cfg.h config.log config.status libtool Makefile sqlite3.pc \
1525+ $(TESTPROGS )
14981526
14991527#
15001528# Windows section
@@ -1514,133 +1542,8 @@ sqlite3.dll: $(REAL_LIBOBJ) sqlite3.def
15141542 $(TCC ) -shared -o $@ sqlite3.def \
15151543 -Wl," --strip-all" $(REAL_LIBOBJ )
15161544
1517-
15181545#
1519- # fiddle/wasm section
1520- #
1521- fiddle_dir = ext/fiddle
1522- fiddle_dir_abs = $(TOP ) /$(fiddle_dir )
1523- # ^^^ some emcc opts require absolute paths
1524- fiddle_html = $(fiddle_dir ) /fiddle.html
1525- fiddle_module_js = $(fiddle_dir ) /fiddle-module.js
1526- sqlite3_wasm_js = $(fiddle_dir ) /sqlite3.js
1527- sqlite3_wasm = $(fiddle_dir ) /sqlite3.wasm
1528- # emcc_opt = -O0
1529- # emcc_opt = -O1
1530- # emcc_opt = -O2
1531- # emcc_opt = -O3
1532- emcc_opt = -Oz
1533- emcc_flags = $(emcc_opt ) -sALLOW_TABLE_GROWTH -sSTRICT_JS \
1534- -sENVIRONMENT=web -sMODULARIZE \
1535- -sEXPORTED_RUNTIME_METHODS=@$(fiddle_dir_abs ) /EXPORTED_RUNTIME_METHODS \
1536- -sDYNAMIC_EXECUTION=0 \
1537- -I. $(SHELL_OPT )
1538- $(fiddle_module_js ) : Makefile sqlite3.c shell.c \
1539- $(fiddle_dir)/EXPORTED_RUNTIME_METHODS \
1540- $(fiddle_dir)/EXPORTED_FUNCTIONS.fiddle
1541- emcc -o $@ $(emcc_flags) \
1542- -sEXPORT_NAME =initFiddleModule \
1543- -sEXPORTED_FUNCTIONS=@$(fiddle_dir_abs ) /EXPORTED_FUNCTIONS.fiddle \
1544- sqlite3.c shell.c
1545- gzip < $@ > $@.gz
1546- gzip < $(fiddle_dir)/fiddle-module.wasm > $(fiddle_dir)/fiddle-module.wasm.gz
1547- $(sqlite3_wasm_js ) : Makefile sqlite3.c \
1548- $(fiddle_dir)/sqlite3-api.js \
1549- $(fiddle_dir)/EXPORTED_RUNTIME_METHODS \
1550- $(fiddle_dir)/EXPORTED_FUNCTIONS.sqlite3-api
1551- emcc -o $@ $(emcc_flags) \
1552- -sEXPORT_NAME =initSqlite3Module \
1553- -sEXPORTED_FUNCTIONS=@$(fiddle_dir_abs ) /EXPORTED_FUNCTIONS.sqlite3-api \
1554- --post-js=$(fiddle_dir ) /sqlite3-api.js \
1555- --no-entry \
1556- sqlite3.c
1557- gzip < $@ > $@.gz
1558- gzip < $(sqlite3_wasm) > $(sqlite3_wasm).gz
1559- gzip < $(fiddle_dir)/sqlite3-api.js > $(fiddle_dir)/sqlite3-api.js.gz
1560- $(fiddle_dir ) /fiddle.js.gz : $(fiddle_dir ) /fiddle.js
1561- gzip < $< > $@
1562- $(fiddle_dir ) /sqlite3-api.js.gz : $(fiddle_dir ) /sqlite3-api.js
1563- gzip < $< > $@
1564-
1565- fiddle_generated = $(fiddle_module_js ) $(fiddle_module_js ) .gz \
1566- $(fiddle_dir ) /fiddle-module.wasm \
1567- $(fiddle_dir ) /fiddle-module.wasm.gz \
1568- $(fiddle_dir ) /fiddle.js.gz
1569- sqlite3_wasm_generated = \
1570- $(sqlite3_wasm ) $(sqlite3_wasm ) .gz \
1571- $(sqlite3_wasm_js ) $(sqlite3_wasm_js ) .gz \
1572- $(fiddle_dir ) /sqlite3.js.gz \
1573- $(fiddle_dir ) /sqlite3-api.js.gz
1574-
1575- clean-wasm :
1576- rm -f $(fiddle_generated ) $(sqlite3_wasm_generated )
1577- clean : clean-wasm
1578- fiddle : $(fiddle_module_js ) $(fiddle_dir ) /fiddle.js.gz
1579- sqlite3-wasm : $(sqlite3_wasm_js )
1580- wasm : fiddle sqlite3-wasm
1581- # #######################################################################
1582- # Explanation of the emcc build flags follows. Full docs for these can
1583- # be found at:
1584- #
1585- # https://github.com/emscripten-core/emscripten/blob/main/src/settings.js
1586- #
1587- # -sENVIRONMENT=web: elides bootstrap code related to non-web JS
1588- # environments like node.js. Removing this makes the output a tiny
1589- # tick larger but hypothetically makes it more portable to
1590- # non-browser JS environments.
1591- #
1592- # -sMODULARIZE: changes how the generated code is structured to avoid
1593- # declaring a global Module object and instead installing a function
1594- # which loads and initialized the module. The function is named...
1595- #
1596- # -sEXPORT_NAME=jsFunctionName (see -sMODULARIZE)
1597- #
1598- # -sEXPORTED_RUNTIME_METHODS=@/absolute/path/to/file: a file
1599- # containing a list of emscripten-supplied APIs, one per line, which
1600- # must be exported into the generated JS. Must be an absolute path!
1601- #
1602- # -sEXPORTED_FUNCTIONS=@/absolute/path/to/file: a file containing a
1603- # list of C functions, one per line, which must be exported via wasm
1604- # so they're visible to JS. C symbols names in that file must all
1605- # start with an underscore for reasons known only to the emcc
1606- # developers. e.g., _sqlite3_open_v2 and _sqlite3_finalize. Must be
1607- # an absolute path!
1608- #
1609- # -sSTRICT_JS ensures that the emitted JS code includes the 'use
1610- # strict' option. Note that -sSTRICT is more broadly-scoped and
1611- # results in build errors.
1612- #
1613- # -sALLOW_TABLE_GROWTH is required for (at a minimum) the UDF-binding
1614- # feature.
1615- #
1616- # -sDYNAMIC_EXECUTION=0 disables eval() and the Function constructor.
1617- # If the build runs without these, it's preferable to use this flag
1618- # because certain execution environments disallow those constructs.
1619- # This flag is not strictly necessary, however.
1620- #
1621- # -sWASM_BIGINT is UNTESTED but "should" allow the int64-using C APIs
1622- # to work with JS/wasm, insofar as the JS environment supports the
1623- # BigInt type. That support requires an extremely recent browser:
1624- # Safari didn't get that support until late 2020.
1625- #
1626- # --no-entry: for compiling library code with no main(). If this is
1627- # not supplied and the code has a main(), it is called as part of the
1628- # module init process. Note that main() is #if'd out of shell.c
1629- # (renamed) when building in wasm mode.
1630- #
1631- # --pre-js/--post-js=FILE relative or absolute paths to JS files to
1632- # prepend/append to the emcc-generated bootstrapping JS. It's
1633- # easier/faster to develop with separate JS files (reduces rebuilding
1634- # requirements) but certain configurations, namely -sMODULARIZE, may
1635- # require using at least a --pre-js file. They can be used
1636- # individually and need not be paired.
1637- #
1638- # -O0..-O3 and -Oz: optimization levels affect not only C-style
1639- # optimization but whether or not the resulting generated JS code
1640- # gets minified. -O0 compiles _much_ more quickly than -O3 or -Oz,
1641- # and doesn't minimize any JS code, so is recommended for
1642- # development. -O3 or -Oz are recommended for deployment, but
1643- # primarily because -Oz will shrink the wasm file notably. JS-side
1644- # minification makes little difference in terms of overall
1645- # distributable size.
1646- # #######################################################################
1546+ # Fiddle app
1547+ #
1548+ fiddle : sqlite3.c shell.c
1549+ make -C ext/wasm fiddle emcc_opt=-Os
0 commit comments