Index: Makefile.in ================================================================== --- Makefile.in +++ Makefile.in @@ -619,14 +619,21 @@ FUZZCHECK_SRC += $(TOP)/ext/recover/sqlite3recover.c FUZZCHECK_SRC += $(TOP)/test/vt02.c DBFUZZ_OPT = ST_OPT = -DSQLITE_OS_KV_OPTIONAL + +# In wasi-sdk builds, disable the CLI shell build in the "all" target. +SQLITE3_SHELL_TARGET_ = sqlite3$(TEXE) +SQLITE3_SHELL_TARGET_1 = +SQLITE3_SHELL_TARGET = $(SQLITE3_SHELL_TARGET_@HAVE_WASI_SDK@) + # This is the default Makefile target. The objects listed here # are what get build when you type just "make" with no arguments. # -all: sqlite3.h libsqlite3.la sqlite3$(TEXE) $(HAVE_TCL:1=libtclsqlite3.la) +all: sqlite3.h libsqlite3.la $(SQLITE3_SHELL_TARGET) \ + $(HAVE_TCL:1=libtclsqlite3.la) Makefile: $(TOP)/Makefile.in ./config.status sqlite3.pc: $(TOP)/sqlite3.pc.in Index: configure ================================================================== --- configure +++ configure @@ -798,10 +798,11 @@ BUILD_EXEEXT TEMP_STORE ALLOWRELEASE SQLITE_THREADSAFE BUILD_CC +HAVE_WASI_SDK RELEASE VERSION program_prefix TCLLIBDIR TCLSH_CMD @@ -890,10 +891,11 @@ with_pic enable_fast_install with_gnu_ld enable_libtool_lock enable_largefile +with_wasi_sdk enable_threadsafe enable_releasemode enable_tempstore enable_tcl with_tcl @@ -1577,10 +1579,12 @@ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] + --with-wasi-sdk=DIR directory containing the WASI SDK. Triggers + cross-compile to WASM. --with-tcl=DIR directory containing tcl configuration (tclConfig.sh) --with-readline-lib specify readline library --with-readline-inc specify readline include paths @@ -3936,17 +3940,17 @@ if ${lt_cv_nm_interface+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:3941: $ac_compile\"" >&5) + (eval echo "\"\$as_me:3945: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:3944: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:3948: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:3947: output\"" >&5) + (eval echo "\"\$as_me:3951: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* @@ -5148,11 +5152,11 @@ fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 5153 "configure"' > conftest.$ac_ext + echo '#line 5157 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then @@ -6673,15 +6677,15 @@ # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6678: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6682: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6682: \$? = $ac_status" >&5 + echo "$as_me:6686: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 @@ -7012,15 +7016,15 @@ # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7017: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7021: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7021: \$? = $ac_status" >&5 + echo "$as_me:7025: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 @@ -7117,15 +7121,15 @@ # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7122: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7126: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7126: \$? = $ac_status" >&5 + echo "$as_me:7130: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp @@ -7172,15 +7176,15 @@ # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7177: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7181: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7181: \$? = $ac_status" >&5 + echo "$as_me:7185: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp @@ -9552,11 +9556,11 @@ lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9557 "configure" +#line 9561 "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif @@ -9648,11 +9652,11 @@ lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9653 "configure" +#line 9657 "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif @@ -10389,10 +10393,72 @@ $as_echo "$as_me: Version set to $VERSION" >&6;} RELEASE=`cat $srcdir/VERSION` { $as_echo "$as_me:${as_lineno-$LINENO}: Release set to $RELEASE" >&5 $as_echo "$as_me: Release set to $RELEASE" >&6;} + + +########## +# Handle --with-wasi-sdk=DIR +# +# This must be early because it changes the toolchain. +# + +# Check whether --with-wasi-sdk was given. +if test "${with_wasi_sdk+set}" = set; then : + withval=$with_wasi_sdk; with_wasisdk=${withval} +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for WASI SDK directory" >&5 +$as_echo_n "checking for WASI SDK directory... " >&6; } +if ${ac_cv_c_wasi_sdk+:} false; then : + $as_echo_n "(cached) " >&6 +else + + # First check to see if --with-tcl was specified. + if test x"${with_wasi_sdk}" != x ; then + if ! test -d "${with_wasi_sdk}" ; then + as_fn_error $? "${with_wasi_sdk} directory doesn't exist" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_wasi_sdk}: using wasi-sdk clang, disabling: tcl, CLI shell, DLL" >&5 +$as_echo "${with_wasi_sdk}: using wasi-sdk clang, disabling: tcl, CLI shell, DLL" >&6; } + use_wasi_sdk=yes + else + use_wasi_sdk=no + fi + +fi + +if test "${use_wasi_sdk}" = "no" ; then + HAVE_WASI_SDK="" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +else + HAVE_WASI_SDK=1 +# Changing --host and --target have no effect here except to possibly +# cause confusion. autoconf has finished processing them by this +# point. +# +# host_alias=wasm32-wasi +# target=wasm32-wasi +# +# Merely changing CC and LD to the wasi-sdk's is enough to get +# sqlite3.o building in WASM format. + CC="${with_wasi_sdk}/bin/clang" + LD="${with_wasi_sdk}/bin/wasm-ld" + RANLIB="${with_wasi_sdk}/bin/llvm-ranlib" + cross_compiling=yes + enable_threadsafe=no + use_tcl=no + enable_tcl=no + # libtool is apparently hard-coded to use gcc for linking DLLs, so + # we disable the DLL build... + enable_shared=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi + ######### # Locate a compiler for the build machine. This compiler should # generate command-line programs that run on the build machine. @@ -11265,10 +11331,11 @@ fi ######### # See whether we should use the amalgamation to build + # Check whether --enable-amalgamation was given. if test "${enable_amalgamation+set}" = set; then : enableval=$enable_amalgamation; fi Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -68,15 +68,15 @@ # # The filename extension for executables on the # target platform. "" for Unix and ".exe" for windows. # # This configure.in file is easy to reuse on other projects. Just -# change the argument to AC_INIT(). And disable any features that +# change the argument to AC_INIT. And disable any features that # you don't need (for example BLT) by erasing or commenting out # the corresponding code. # -AC_INIT(sqlite, m4_esyscmd([cat VERSION | tr -d '\n'])) +AC_INIT([sqlite],[m4_esyscmd(cat VERSION | tr -d '\n')]) dnl Make sure the local VERSION file matches this configure script sqlite_version_sanity_check=`cat $srcdir/VERSION | tr -d '\n'` if test "$PACKAGE_VERSION" != "$sqlite_version_sanity_check" ; then AC_MSG_ERROR([configure script is out of date: @@ -86,11 +86,11 @@ fi ######### # Programs needed # -AC_PROG_LIBTOOL +LT_INIT AC_PROG_INSTALL ######### # Enable large file support (if special flags are necessary) # @@ -155,10 +155,60 @@ AC_MSG_NOTICE(Version set to $VERSION) AC_SUBST(VERSION) RELEASE=`cat $srcdir/VERSION` AC_MSG_NOTICE(Release set to $RELEASE) AC_SUBST(RELEASE) + +########## +# Handle --with-wasi-sdk=DIR +# +# This must be early because it changes the toolchain. +# +AC_ARG_WITH(wasi-sdk, +AS_HELP_STRING([--with-wasi-sdk=DIR], + [directory containing the WASI SDK. Triggers cross-compile to WASM.]), with_wasisdk=${withval}) +AC_MSG_CHECKING([for WASI SDK directory]) +AC_CACHE_VAL(ac_cv_c_wasi_sdk,[ + # First check to see if --with-tcl was specified. + if test x"${with_wasi_sdk}" != x ; then + if ! test -d "${with_wasi_sdk}" ; then + AC_MSG_ERROR([${with_wasi_sdk} directory doesn't exist]) + fi + AC_MSG_RESULT([${with_wasi_sdk}: using wasi-sdk clang, disabling: tcl, CLI shell, DLL]) + use_wasi_sdk=yes + else + use_wasi_sdk=no + fi +]) +if test "${use_wasi_sdk}" = "no" ; then + HAVE_WASI_SDK="" + AC_MSG_RESULT([no]) +else + HAVE_WASI_SDK=1 +# Changing --host and --target have no effect here except to possibly +# cause confusion. autoconf has finished processing them by this +# point. +# +# host_alias=wasm32-wasi +# target=wasm32-wasi +# +# Merely changing CC and LD to the wasi-sdk's is enough to get +# sqlite3.o building in WASM format. + CC="${with_wasi_sdk}/bin/clang" + LD="${with_wasi_sdk}/bin/wasm-ld" + RANLIB="${with_wasi_sdk}/bin/llvm-ranlib" + cross_compiling=yes + enable_threadsafe=no + use_tcl=no + enable_tcl=no + # libtool is apparently hard-coded to use gcc for linking DLLs, so + # we disable the DLL build... + enable_shared=no + AC_MSG_RESULT([yes]) +fi +AC_SUBST(HAVE_WASI_SDK) + ######### # Locate a compiler for the build machine. This compiler should # generate command-line programs that run on the build machine. # @@ -177,11 +227,11 @@ ########## # Do we want to support multithreaded use of sqlite # AC_ARG_ENABLE(threadsafe, -AC_HELP_STRING([--disable-threadsafe],[Disable mutexing])) +AS_HELP_STRING([--disable-threadsafe],[Disable mutexing])) AC_MSG_CHECKING([whether to support threadsafe operation]) if test "$enable_threadsafe" = "no"; then SQLITE_THREADSAFE=0 AC_MSG_RESULT([no]) else @@ -197,11 +247,11 @@ ########## # Do we want to support release # AC_ARG_ENABLE(releasemode, -AC_HELP_STRING([--enable-releasemode],[Support libtool link to release mode]),,enable_releasemode=no) +AS_HELP_STRING([--enable-releasemode],[Support libtool link to release mode]),,enable_releasemode=no) AC_MSG_CHECKING([whether to support shared library linked as release mode or not]) if test "$enable_releasemode" = "no"; then ALLOWRELEASE="" AC_MSG_RESULT([no]) else @@ -212,11 +262,11 @@ ########## # Do we want temporary databases in memory # AC_ARG_ENABLE(tempstore, -AC_HELP_STRING([--enable-tempstore],[Use an in-ram database for temporary tables (never,no,yes,always)]),,enable_tempstore=no) +AS_HELP_STRING([--enable-tempstore],[Use an in-ram database for temporary tables (never,no,yes,always)]),,enable_tempstore=no) AC_MSG_CHECKING([whether to use an in-ram database for temporary tables]) case "$enable_tempstore" in never ) TEMP_STORE=0 AC_MSG_RESULT([never]) @@ -252,11 +302,19 @@ AC_MSG_RESULT(yes) else AC_MSG_RESULT(unknown) fi if test "$CYGWIN" != "yes"; then - AC_CYGWIN + m4_warn([obsolete], +[AC_CYGWIN is obsolete: use AC_CANONICAL_HOST and check if $host_os +matches *cygwin*])dnl +AC_CANONICAL_HOST +case $host_os in + *cygwin* ) CYGWIN=yes;; + * ) CYGWIN=no;; +esac + fi if test "$CYGWIN" = "yes"; then BUILD_EXEEXT=.exe else BUILD_EXEEXT=$EXEEXT @@ -287,14 +345,14 @@ # This code is derived from the SC_PATH_TCLCONFIG and SC_LOAD_TCLCONFIG # macros in the in the tcl.m4 file of the standard TCL distribution. # Those macros could not be used directly since we have to make some # minor changes to accomodate systems that do not have TCL installed. # -AC_ARG_ENABLE(tcl, AC_HELP_STRING([--disable-tcl],[do not build TCL extension]), +AC_ARG_ENABLE(tcl, AS_HELP_STRING([--disable-tcl],[do not build TCL extension]), [use_tcl=$enableval],[use_tcl=yes]) if test "${use_tcl}" = "yes" ; then - AC_ARG_WITH(tcl, AC_HELP_STRING([--with-tcl=DIR],[directory containing tcl configuration (tclConfig.sh)]), with_tclconfig=${withval}) + AC_ARG_WITH(tcl, AS_HELP_STRING([--with-tcl=DIR],[directory containing tcl configuration (tclConfig.sh)]), with_tclconfig=${withval}) AC_MSG_CHECKING([for Tcl configuration]) AC_CACHE_VAL(ac_cv_c_tclconfig,[ # First check to see if --with-tcl was specified. if test x"${with_tclconfig}" != x ; then if test -f "${with_tclconfig}/tclConfig.sh" ; then @@ -472,15 +530,15 @@ TARGET_READLINE_LIBS="" TARGET_READLINE_INC="" TARGET_HAVE_READLINE=0 TARGET_HAVE_EDITLINE=0 AC_ARG_ENABLE([editline], - [AC_HELP_STRING([--enable-editline],[enable BSD editline support])], + [AS_HELP_STRING([--enable-editline],[enable BSD editline support])], [with_editline=$enableval], [with_editline=auto]) AC_ARG_ENABLE([readline], - [AC_HELP_STRING([--disable-readline],[disable readline support])], + [AS_HELP_STRING([--disable-readline],[disable readline support])], [with_readline=$enableval], [with_readline=auto]) if test x"$with_editline" != xno; then sLIBS=$LIBS @@ -492,11 +550,11 @@ fi if test x"$with_readline" != xno; then found="yes" AC_ARG_WITH([readline-lib], - [AC_HELP_STRING([--with-readline-lib],[specify readline library])], + [AS_HELP_STRING([--with-readline-lib],[specify readline library])], [with_readline_lib=$withval], [with_readline_lib="auto"]) if test "x$with_readline_lib" = xauto; then save_LIBS="$LIBS" LIBS="" @@ -507,11 +565,11 @@ else TARGET_READLINE_LIBS="$with_readline_lib" fi AC_ARG_WITH([readline-inc], - [AC_HELP_STRING([--with-readline-inc],[specify readline include paths])], + [AS_HELP_STRING([--with-readline-inc],[specify readline include paths])], [with_readline_inc=$withval], [with_readline_inc="auto"]) if test "x$with_readline_inc" = xauto; then AC_CHECK_HEADER(readline.h, [found="yes"], [ found="no" @@ -552,11 +610,11 @@ # AC_SEARCH_LIBS(fdatasync, [rt]) ######### # check for debug enabled -AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],[enable debugging & verbose explain])) +AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],[enable debugging & verbose explain])) AC_MSG_CHECKING([build type]) if test "${enable_debug}" = "yes" ; then TARGET_DEBUG="-DSQLITE_DEBUG=1 -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE -O0" AC_MSG_RESULT([debug]) else @@ -565,11 +623,12 @@ fi AC_SUBST(TARGET_DEBUG) ######### # See whether we should use the amalgamation to build -AC_ARG_ENABLE(amalgamation, AC_HELP_STRING([--disable-amalgamation], + +AC_ARG_ENABLE(amalgamation, AS_HELP_STRING([--disable-amalgamation], [Disable the amalgamation and instead build all files separately])) if test "${enable_amalgamation}" = "no" ; then USE_AMALGAMATION=0 fi AC_SUBST(USE_AMALGAMATION) @@ -580,11 +639,11 @@ AC_SEARCH_LIBS(deflate, z, [HAVE_ZLIB="-DSQLITE_HAVE_ZLIB=1"], [HAVE_ZLIB=""]) AC_SUBST(HAVE_ZLIB) ######### # See whether we should allow loadable extensions -AC_ARG_ENABLE(load-extension, AC_HELP_STRING([--disable-load-extension], +AC_ARG_ENABLE(load-extension, AS_HELP_STRING([--disable-load-extension], [Disable loading of external extensions]),,[enable_load_extension=yes]) if test "${enable_load_extension}" = "yes" ; then OPT_FEATURE_FLAGS="" AC_SEARCH_LIBS(dlopen, dl) else @@ -593,11 +652,11 @@ ########## # Do we want to support math functions # AC_ARG_ENABLE(math, -AC_HELP_STRING([--disable-math],[Disable math functions])) +AS_HELP_STRING([--disable-math],[Disable math functions])) AC_MSG_CHECKING([whether to support math functions]) if test "$enable_math" = "no"; then AC_MSG_RESULT([no]) else AC_MSG_RESULT([yes]) @@ -607,11 +666,11 @@ ########## # Do we want to support JSON functions # AC_ARG_ENABLE(json, -AC_HELP_STRING([--disable-json],[Disable JSON functions])) +AS_HELP_STRING([--disable-json],[Disable JSON functions])) AC_MSG_CHECKING([whether to support JSON functions]) if test "$enable_json" = "no"; then AC_MSG_RESULT([no]) OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_OMIT_JSON" else @@ -619,27 +678,27 @@ fi ######## # The --enable-all argument is short-hand to enable # multiple extensions. -AC_ARG_ENABLE(all, AC_HELP_STRING([--enable-all], +AC_ARG_ENABLE(all, AS_HELP_STRING([--enable-all], [Enable FTS4, FTS5, Geopoly, RTree, Sessions])) ########## # Do we want to support memsys3 and/or memsys5 # AC_ARG_ENABLE(memsys5, - AC_HELP_STRING([--enable-memsys5],[Enable MEMSYS5])) + AS_HELP_STRING([--enable-memsys5],[Enable MEMSYS5])) AC_MSG_CHECKING([whether to support MEMSYS5]) if test "${enable_memsys5}" = "yes"; then OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS5" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi AC_ARG_ENABLE(memsys3, - AC_HELP_STRING([--enable-memsys3],[Enable MEMSYS3])) + AS_HELP_STRING([--enable-memsys3],[Enable MEMSYS3])) AC_MSG_CHECKING([whether to support MEMSYS3]) if test "${enable_memsys3}" = "yes" -a "${enable_memsys5}" = "no"; then OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_MEMSYS3" AC_MSG_RESULT([yes]) else @@ -646,30 +705,30 @@ AC_MSG_RESULT([no]) fi ######### # See whether we should enable Full Text Search extensions -AC_ARG_ENABLE(fts3, AC_HELP_STRING([--enable-fts3], +AC_ARG_ENABLE(fts3, AS_HELP_STRING([--enable-fts3], [Enable the FTS3 extension])) AC_MSG_CHECKING([whether to support FTS3]) if test "${enable_fts3}" = "yes" ; then OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS3" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi -AC_ARG_ENABLE(fts4, AC_HELP_STRING([--enable-fts4], +AC_ARG_ENABLE(fts4, AS_HELP_STRING([--enable-fts4], [Enable the FTS4 extension])) AC_MSG_CHECKING([whether to support FTS4]) if test "${enable_fts4}" = "yes" -o "${enable_all}" = "yes" ; then AC_MSG_RESULT([yes]) OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS4" AC_SEARCH_LIBS([log],[m]) else AC_MSG_RESULT([no]) fi -AC_ARG_ENABLE(fts5, AC_HELP_STRING([--enable-fts5], +AC_ARG_ENABLE(fts5, AS_HELP_STRING([--enable-fts5], [Enable the FTS5 extension])) AC_MSG_CHECKING([whether to support FTS5]) if test "${enable_fts5}" = "yes" -o "${enable_all}" = "yes" ; then AC_MSG_RESULT([yes]) OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_FTS5" @@ -679,11 +738,11 @@ fi ######### # See whether we should enable the LIMIT clause on UPDATE and DELETE # statements. -AC_ARG_ENABLE(update-limit, AC_HELP_STRING([--enable-update-limit], +AC_ARG_ENABLE(update-limit, AS_HELP_STRING([--enable-update-limit], [Enable the UPDATE/DELETE LIMIT clause])) AC_MSG_CHECKING([whether to support LIMIT on UPDATE and DELETE statements]) if test "${enable_update_limit}" = "yes" ; then OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT" AC_MSG_RESULT([yes]) @@ -691,11 +750,11 @@ AC_MSG_RESULT([no]) fi ######### # See whether we should enable GEOPOLY -AC_ARG_ENABLE(geopoly, AC_HELP_STRING([--enable-geopoly], +AC_ARG_ENABLE(geopoly, AS_HELP_STRING([--enable-geopoly], [Enable the GEOPOLY extension]), [enable_geopoly=yes],[enable_geopoly=no]) AC_MSG_CHECKING([whether to support GEOPOLY]) if test "${enable_geopoly}" = "yes" -o "${enable_all}" = "yes" ; then OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_GEOPOLY" @@ -705,11 +764,11 @@ AC_MSG_RESULT([no]) fi ######### # See whether we should enable RTREE -AC_ARG_ENABLE(rtree, AC_HELP_STRING([--enable-rtree], +AC_ARG_ENABLE(rtree, AS_HELP_STRING([--enable-rtree], [Enable the RTREE extension])) AC_MSG_CHECKING([whether to support RTREE]) if test "${enable_rtree}" = "yes" ; then OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_RTREE" AC_MSG_RESULT([yes]) @@ -717,11 +776,11 @@ AC_MSG_RESULT([no]) fi ######### # See whether we should enable the SESSION extension -AC_ARG_ENABLE(session, AC_HELP_STRING([--enable-session], +AC_ARG_ENABLE(session, AS_HELP_STRING([--enable-session], [Enable the SESSION extension])) AC_MSG_CHECKING([whether to support SESSION]) if test "${enable_session}" = "yes" -o "${enable_all}" = "yes" ; then OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_SESSION" OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_PREUPDATE_HOOK" @@ -781,11 +840,11 @@ BUILD_CFLAGS=$ac_temp_BUILD_CFLAGS ######### # See whether we should use GCOV -AC_ARG_ENABLE(gcov, AC_HELP_STRING([--enable-gcov], +AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov], [Enable coverage testing using gcov])) if test "${use_gcov}" = "yes" ; then USE_GCOV=1 else USE_GCOV=0 @@ -810,9 +869,10 @@ ######### # Generate the output files. # AC_SUBST(BUILD_CFLAGS) -AC_OUTPUT([ +AC_CONFIG_FILES([ Makefile sqlite3.pc ]) +AC_OUTPUT Index: src/os_unix.c ================================================================== --- src/os_unix.c +++ src/os_unix.c @@ -93,11 +93,12 @@ #include #include /* amalgamator: keep */ #include #include /* amalgamator: keep */ #include -#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 +#if (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) \ + && !defined(SQLITE_WASI) # include #endif #if SQLITE_ENABLE_LOCKING_STYLE # include @@ -181,13 +182,50 @@ /* ** Maximum supported symbolic links */ #define SQLITE_MAX_SYMLINKS 100 +/* +** Remove and stub certain info for WASI (WebAssembly System +** Interface) builds. +*/ +#ifdef SQLITE_WASI +# undef HAVE_FCHMOD +# undef HAVE_FCHOWN +# undef HAVE_MREMAP +# define HAVE_MREMAP 0 +# ifndef SQLITE_DEFAULT_UNIX_VFS +# define SQLITE_DEFAULT_UNIX_VFS "unix-dotfile" + /* ^^^ should SQLITE_DEFAULT_UNIX_VFS be "unix-none"? */ +# endif +# ifndef F_RDLCK +# define F_RDLCK 0 +# define F_WRLCK 1 +# define F_UNLCK 2 +# if __LONG_MAX == 0x7fffffffL +# define F_GETLK 12 +# define F_SETLK 13 +# define F_SETLKW 14 +# else +# define F_GETLK 5 +# define F_SETLK 6 +# define F_SETLKW 7 +# endif +# endif +#else /* !SQLITE_WASI */ +# ifndef HAVE_FCHMOD +# define HAVE_FCHMOD +# endif +#endif /* SQLITE_WASI */ + +#ifdef SQLITE_WASI +# define osGetpid(X) (pid_t)1 +#else /* Always cast the getpid() return type for compatibility with ** kernel modules in VxWorks. */ -#define osGetpid(X) (pid_t)getpid() +# define osGetpid(X) (pid_t)getpid() +#endif /* ** Only set the lastErrno if the error code is a real error and not ** a normal expected return code of SQLITE_BUSY or SQLITE_OK */ @@ -455,11 +493,15 @@ { "pwrite64", (sqlite3_syscall_ptr)0, 0 }, #endif #define osPwrite64 ((ssize_t(*)(int,const void*,size_t,off64_t))\ aSyscall[13].pCurrent) +#if defined(HAVE_FCHMOD) { "fchmod", (sqlite3_syscall_ptr)fchmod, 0 }, +#else + { "fchmod", (sqlite3_syscall_ptr)0, 0 }, +#endif #define osFchmod ((int(*)(int,mode_t))aSyscall[14].pCurrent) #if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE { "fallocate", (sqlite3_syscall_ptr)posix_fallocate, 0 }, #else @@ -491,18 +533,20 @@ #else { "geteuid", (sqlite3_syscall_ptr)0, 0 }, #endif #define osGeteuid ((uid_t(*)(void))aSyscall[21].pCurrent) -#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 +#if (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) \ + && !defined(SQLITE_WASI) { "mmap", (sqlite3_syscall_ptr)mmap, 0 }, #else { "mmap", (sqlite3_syscall_ptr)0, 0 }, #endif #define osMmap ((void*(*)(void*,size_t,int,int,int,off_t))aSyscall[22].pCurrent) -#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 +#if (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) \ + && !defined(SQLITE_WASI) { "munmap", (sqlite3_syscall_ptr)munmap, 0 }, #else { "munmap", (sqlite3_syscall_ptr)0, 0 }, #endif #define osMunmap ((int(*)(void*,size_t))aSyscall[23].pCurrent) Index: src/shell.c.in ================================================================== --- src/shell.c.in +++ src/shell.c.in @@ -109,11 +109,11 @@ #include #include #if !defined(_WIN32) && !defined(WIN32) # include -# if !defined(__RTP__) && !defined(_WRS_KERNEL) +# if !defined(__RTP__) && !defined(_WRS_KERNEL) && !defined(SQLITE_WASI) # include # endif #endif #if (!defined(_WIN32) && !defined(WIN32)) || defined(__MINGW32__) # include @@ -198,11 +198,11 @@ # endif #else /* Make sure isatty() has a prototype. */ extern int isatty(int); -# if !defined(__RTP__) && !defined(_WRS_KERNEL) +# if !defined(__RTP__) && !defined(_WRS_KERNEL) && !defined(SQLITE_WASI) /* popen and pclose are not C89 functions and so are ** sometimes omitted from the header */ extern FILE *popen(const char*,const char*); extern int pclose(FILE*); # else @@ -11500,11 +11500,11 @@ return 0; } if( home_dir ) return home_dir; #if !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) \ - && !defined(__RTP__) && !defined(_WRS_KERNEL) + && !defined(__RTP__) && !defined(_WRS_KERNEL) && !defined(SQLITE_WASI) { struct passwd *pwent; uid_t uid = getuid(); if( (pwent=getpwuid(uid)) != NULL) { home_dir = pwent->pw_dir; Index: src/sqlite.h.in ================================================================== --- src/sqlite.h.in +++ src/sqlite.h.in @@ -10529,10 +10529,23 @@ ** builds on processors without floating point support. */ #ifdef SQLITE_OMIT_FLOATING_POINT # undef double #endif + +#if defined(__wasi__) +# undef SQLITE_WASI +# define SQLITE_WASI 1 +# undef SQLITE_OMIT_WAL +# define SQLITE_OMIT_WAL 1/* because it requires shared memory APIs */ +# ifndef SQLITE_OMIT_LOAD_EXTENSION +# define SQLITE_OMIT_LOAD_EXTENSION +# endif +# ifndef SQLITE_THREADSAFE +# define SQLITE_THREADSAFE 0 +# endif +#endif #ifdef __cplusplus } /* End of the 'extern "C"' block */ #endif #endif /* SQLITE3_H */