Compare commits

...

21 Commits

Author SHA1 Message Date
drh
70d390134c Call fflush() on ".echo" output from the shell, so that the output to
stdout is aligned with output to stderr.

FossilOrigin-Name: c38b9db3c4f71706a7d211424da64311e6e5daf64b224565a6d82d4b1a68e261
2024-11-16 18:54:46 +00:00
drh
18689b8fb2 Fix argument expansion in sqlite-tclsh on Windows such that if an argument
does not match a filename even after glob expansion, it is appended to the
argument list verbatim.

FossilOrigin-Name: cd942dce148c9d8f5a94cee61923aad8d1b732b807e004005f78323be30c02e7
2024-11-16 17:39:34 +00:00
stephan
50faa8d17e Handle DESTDIR at an earlier phase in buildtclext.tcl to account for the is-writable-dir check and to filter out //zipfs: dirs as (im)possible installation targets.
FossilOrigin-Name: d2e8c161a14fbbcc52c50dfd9274c9969e3c273e2cb7cbf2f865541af9f39ead
2024-11-16 17:09:55 +00:00
stephan
f6c7cc606e Add the --destdir flag to the tclextension-install makefile target.
FossilOrigin-Name: d1663cf05f7dcaafd479bacf083b6b774f34fd3db89012b49599d30817eb174f
2024-11-16 14:30:43 +00:00
stephan
d8f6222bee Add --destdir flag support to buildtclext.tcl, but do not yet add that to the makefile (so that this change can be cherrypicked to the 3.47 build).
FossilOrigin-Name: 67a3ca0c013b6a9da3b2c50ffc86b96b14454d1e45fa90d3b0a238488a783e79
2024-11-16 14:29:51 +00:00
stephan
4b24cb2a3a Rename tool/tclConfigShToTcl.sh to tool/tclConfigShToAutoDef.sh in the name of pedantic correctness.
FossilOrigin-Name: a7dd196d99ee7c75b92a03915f2b370e3f4c598eb8521b90af1cb5dd7f9ee49c
2024-11-16 10:42:33 +00:00
stephan
d676227f2c configure: tiny simplification of proj-assert.
FossilOrigin-Name: bfdc416b561937aa74483bf96c042e701e6f98997150f1f1a6b165cddd40d8d1
2024-11-16 09:00:31 +00:00
drh
178ce6287b Enhance the vfstrace extension such that the output can be controlled using
the "PRAGMA vfstrace('...');" statement.  See header comment on the source code
for details.

FossilOrigin-Name: 96105d33597765c23dbd490b3aa0c2273731d1970d7041720e9f043dbe3517b3
2024-11-15 20:39:41 +00:00
stephan
1adf87592f In the interest of minimizing downstream disruption, set the soname of libsqlite3.so to (by default) its legacy value of libsqlite3.so.0 and unconditionally create (or replace) a symlink with that name at install-time, in addition to the newer-named symlinks.
FossilOrigin-Name: 0773677b553e032e992266c6c75e10565729238df3ef52b56602a92cf651bea7
2024-11-15 19:42:49 +00:00
stephan
e69b4d757e Generic auto.def cleanups. No functional differences.
FossilOrigin-Name: 02aceb8c138b5b8f38c75aa0792efa12f14b002083df6141cf56ea0602d3174b
2024-11-15 16:35:24 +00:00
stephan
48c8447574 buildtclext.tcl: work around a case, reported in [forum:0683a49cb02f31a1|forum post 0683a49cb0], in which package maintainers edit their copy of tclConfig.sh to change the TCL_SHLIB_LD command.
FossilOrigin-Name: e24a3efec8c168b69d665ab20e8d715210208e6cf291ac93549fdd175a9009d6
2024-11-15 15:31:13 +00:00
stephan
2eb9605e81 configure: add optional pkg-config support for detecting ICU.
FossilOrigin-Name: 3e5b8077c6c6ce72ecab3110eb45943b9765372df789088982dbd6046a7c2523
2024-11-15 10:53:57 +00:00
stephan
ece4bf60ff When checking pkg-config for ICU support use icu-io instead of icu-uc, as that contains all requires libs on Linux and BSD.
FossilOrigin-Name: 6ca457542e1dceac2d68fe3d29ff1f0beb31a77ca3073bd7d8a6c62faabcdc1d
2024-11-15 10:47:11 +00:00
stephan
aa85c8c854 configure script doc additions for the ICU feature check.
FossilOrigin-Name: 1925a68fc2323f0788aac9c3c2bb3005182eb3286037bc383181b6aa150d4270
2024-11-15 10:12:03 +00:00
stephan
75ed9f819f An experiment in optionally using pkg-config to determine the libs to link in for ICU support, but its ldflags is missing one required lib on both Linux and OpenBSD. Keeping this for later reference, as it demonstrates how to use pkg-config from autosetup.
FossilOrigin-Name: 09caa94c9e846f9b3669b3f1acbb26b24b8bfcc9e512f17ea074dd92745c2597
2024-11-15 10:07:57 +00:00
stephan
f121ffbde3 Fix typo in the handling of the new --dev flag which caused it to set the --debug flag instead of the --with-debug flag (the former is for autosetup's internal use).
FossilOrigin-Name: 81202d2ab5963fdcf20555b6d0b31cc955ac27f1cd87656faea5c0611c9a2ee8
2024-11-14 19:34:28 +00:00
stephan
009601d534 Remove $prefix/include from the default -I path because it can cause the build to pick up an unintended copy of sqlite3.h. Extend the ICU configure support (the origin of -I$prefix/include) to enable fetching the -I path from icu-config and apply it only to those objects which need it.
FossilOrigin-Name: f778dfdd6d6a4975c903d8ca0ebfb4fa917d543289136ea0ab740cb47d2510c1
2024-11-14 19:25:23 +00:00
drh
59c80e0533 Add new makefile target "sqlite3d" (where the "d" means either "development" or
"debug") that always uses separate source files, regardless of the 
--disable-amalgmation setting.

FossilOrigin-Name: 91da205beb7e5cab7a76be98e4cfddc4fb4c07022825ea645bc97f331c6bcdaa
2024-11-14 19:06:00 +00:00
stephan
c096d6add6 Add --enable-dev configure flag which sets various other flags.
FossilOrigin-Name: ea79c363a42484357ac4ac3422f3466e5bc5cb56e5b2a06a3dc4ec90fea1c190
2024-11-14 17:52:59 +00:00
stephan
17e7e16b3b Remove unused sqlite_cfg.h.in from the build.
FossilOrigin-Name: bba54e26de56ddf804990f5cd9a1978a14580f06c5771a79803907013df8491e
2024-11-14 16:06:36 +00:00
drh
ea13658566 Remove some obsolete macros from the CLI.
FossilOrigin-Name: 5c4eb625709eda24b11a0437b150a60fc1497c136a4a2ab2b9d559d893dd397a
2024-11-14 15:55:19 +00:00
11 changed files with 410 additions and 150 deletions

View File

@ -153,7 +153,8 @@ LDFLAGS.dlopen = @LDFLAGS_DLOPEN@
LDFLAGS.readline = @LDFLAGS_READLINE@
CFLAGS.readline = @CFLAGS_READLINE@
LDFLAGS.icu = @LDFLAGS_ICU@
LDFLAGS.soname.libsqlite3 = @LDFLAGS_SONAME_LIBSQLITE3@
CFLAGS.icu = @CFLAGS_ICU@
LDFLAGS.libsqlite3.soname = @LDFLAGS_LIBSQLITE3_SONAME@
ENABLE_SHARED = @ENABLE_SHARED@
ENABLE_STATIC = @ENABLE_STATIC@
HAVE_WASI_SDK = @HAVE_WASI_SDK@
@ -168,11 +169,6 @@ T.cc.sqlite = $(T.cc) @TARGET_DEBUG@
# all builds.
#
T.cc.sqlite += -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite
#
# -I$(prefix)/include is primarily so that the ICU
# headers can be found.
#
T.cc.sqlite += -I$(prefix)/include
#
# $(JIMSH) and $(CFLAGS.jimsh) are documented in main.mk. $(JIMSH)

176
auto.def
View File

@ -12,7 +12,7 @@
#
# JimTCL: https://jim.tcl.tk
#
use cc cc-db cc-shared cc-lib proj
use cc cc-db cc-shared cc-lib proj pkg-config
# $DUMP_DEFINES_TXT is the file emitted by --dump-defines, intended
# only for build debugging and not part of the public build interface.
@ -182,7 +182,9 @@ set flags {
# <icu>
with-icu-ldflags:LDFLAGS
=> {Enable SQLITE_ENABLE_ICU and add the given linker flags for the ICU libraries}
with-icu-config:=auto => {Enable SQLITE_ENABLE_ICU and fetch linker flags from the given icu-config binary}
with-icu-cflags:CFLAGS
=> {Apply extra CFLAGS/CPPFLAGS necessary for building with ICU. e.g. -I/usr/local/include}
with-icu-config:=auto => {Enable SQLITE_ENABLE_ICU. Value must be one of: auto, pkg-config, /path/to/icu-config}
icu-collations=0 => {Enable SQLITE_ENABLE_ICU_COLLATIONS. Requires --with-icu-ldflags=... or --with-icu-config}
# </icu>
# <alternative-builds>
@ -194,13 +196,9 @@ set flags {
test-status => {Enable status of tests}
gcov=0 => {Enable coverage testing using gcov}
linemacros => {Enable #line macros in the amalgamation}
dev => {Enable dev-mode build: automatically enables certain other flags}
dump-defines=0 => {Dump autosetup defines to $DUMP_DEFINES_TXT (for build debugging)}
#soname:=none => {SONAME for libsqlite3.so}
#^^^ we "could", but arguably shouldn't, support clients passing a
# value of libsqlite3.so.0 for compatibility with clients which
# linked against a pre-3.48 build.
# Maybe we should support values of --soname=(none,auto,legacy), where auto means
# to use the 3.48+ value of libsqlite3.so.3..
soname:=legacy => {SONAME for libsqlite3.so. Must be one of: none, auto, legacy}
# </developer>
}
if {"" ne $DUMP_DEFINES_JSON} {
@ -232,7 +230,7 @@ msg-result "Source dir = $srcdir"
msg-result "Build dir = $::autosetup(builddir)"
msg-result "Configuring SQLite version $PACKAGE_VERSION"
if {1} {
apply {{} {
#
# SQLITE_AUTORECONFIG contains make target rules for re-running the
# configure script with the same arguments it was initially invoked
@ -245,13 +243,13 @@ if {1} {
if {[string match {*[ &;$*"]*} $arg]} { return '$arg' }
return $arg
}
define-append SQLITE_AUTORECONFIG cd [squote $::autosetup(builddir)] && [squote $srcdir/configure]
define-append SQLITE_AUTORECONFIG cd [squote $::autosetup(builddir)] && [squote $::srcdir/configure]
#{*}$::autosetup(argv) breaks with --flag='val with spaces', so...
foreach arg $::autosetup(argv) {
define-append SQLITE_AUTORECONFIG [squote $arg]
}
rename squote ""
}
}}
# Are we cross-compiling?
set isCrossCompiling [proj-is-cross-compiling]
@ -319,10 +317,20 @@ if {"" eq [proj-bin-define install]} {
define CFLAGS [proj-get-env CFLAGS {-g -O2}]
define BUILD_CFLAGS [proj-get-env BUILD_CFLAGS {-g}]
proj-if-opt-truthy dev {
# --enable-dev needs to come early so that the downstream tests
# which check for these flags will show the user their updated
# state.
proj-opt-set all 1
proj-opt-set with-debug 1
proj-opt-set amalgamation 0
define CFLAGS [get-env CFLAGS {-O0 -g}]
}
########################################################################
# Handle --with-wasi-sdk=DIR
#
# This MUST be run early on because it may change the toolchain and
# This must be run early on because it may change the toolchain and
# disable a number of config options.
proc sqlite-check-wasi-sdk {} {
set wasiSdkDir [opt-val with-wasi-sdk] ; # ??? [lindex [opt-val with-wasi-sdk] end]
@ -340,7 +348,7 @@ proc sqlite-check-wasi-sdk {} {
# Disable numerous options which we know either can't work or are
# not useful in this build...
msg-result "Using wasi-sdk clang. Disabling CLI shell modifying config flags:"
# Boolean flags which must be switched off:
# Boolean (--enable-/--disable-) flags which must be switched off:
foreach opt {
editline
gcov
@ -361,6 +369,7 @@ proc sqlite-check-wasi-sdk {} {
with-emsdk
with-icu-config
with-icu-ldflags
with-icu-cflags
with-linenoise
with-tcl
} {
@ -438,36 +447,49 @@ proj-check-rpath ; # Determine proper rpath-handling flag
# It's not yet clear whether we gain anything from setting -soname,
# but not having it has been a source of anxiety for some users.
# Setting it to any value other than its historical value of
# libsqlite3.so.0 may (this is not certain) break dynamic linking of
# clients which initially linked against a legacy build.
# libsqlite3.so.0 may break dynamic linking of clients which initially
# linked against a legacy build (with its SONAME of libsqlite3.so.0).
#
# To be clear: the ABI has not changed between pre-3.48 and post-3.47
# builds, but version number 0 (pre-3.48) was a historical remnant
# from libtool which "should" have always been version number 3 but
# was not, for reasons lost to history.
#
# If the goal is to reduce downstream disruption then we need to
# retain the SONAME libsqlite3.so.0. If the goal is to "pull the
# bandaid off" then switching libsqlite3.so.3 is arguably the right
# thing to do (at the very real risk of causing a fair amount of
# downstream disruption for package maintainers).
#
# See discussion in/around:
# https://sqlite.org/forum/forumpost/0c6fc6f46b2cb3
proc sqlite-check-soname {} {
define LDFLAGS_SONAME_LIBSQLITE3 ""
apply {{} {
define LDFLAGS_LIBSQLITE3_SONAME ""
if {[proj-opt-was-provided soname]} {
set soname [opt-val soname]
} else {
return 0
set soname legacy
}
switch -exact -- $soname {
none { return 0 }
auto - 3 { set soname libsqlite3.so.3 }
legacy - 0 { set soname libsqlite3.so.0 }
auto { set soname libsqlite3.so.3 }
legacy { set soname libsqlite3.so.0 }
default {
proj-fatal "Invalid value for --soname. Use one of (none, auto, legacy)."
}
}
msg-debug "soname=$soname"
if {[proj-check-soname $soname]} {
define LDFLAGS_SONAME_LIBSQLITE3 [get-define LDFLAGS_SONAME_PREFIX]$soname
msg-result "Setting SONAME: [get-define LDFLAGS_SONAME_LIBSQLITE3]"
} else {
define LDFLAGS_LIBSQLITE3_SONAME [get-define LDFLAGS_SONAME_PREFIX]$soname
msg-result "Setting SONAME: [get-define LDFLAGS_LIBSQLITE3_SONAME]"
} elseif {[proj-opt-was-provided soname]} {
# --soname was explicitly requested but not available, so fail fatally
proj-fatal "This environment does not support SONAME."
} else {
msg-result "This environment does not support SONAME."
}
return sqlite-check-soname ""
}
sqlite-check-soname
}}
proj-define-for-opt shared ENABLE_SHARED "Build shared library?"
@ -630,7 +652,7 @@ proc sqlite-check-tcl {} {
# Export a subset of tclConfig.sh to the current TCL-space. If $cfg
# is an empty string, this emits empty-string entries for the
# various options we're interested in.
eval [exec "${srcdir}/tool/tclConfigShToTcl.sh" "$cfg"]
eval [exec "${srcdir}/tool/tclConfigShToAutoDef.sh" "$cfg"]
if {"" eq $with_tclsh && $cfg ne ""} {
# We have tclConfig.sh but no tclsh. Attempt to locate a tclsh
@ -704,7 +726,6 @@ proc sqlite-check-tcl {} {
}
}
}; # sqlite-check-tcl
sqlite-check-tcl
########################################################################
@ -1111,47 +1132,85 @@ proj-if-opt-truthy math {
# Handles these flags:
#
# --with-icu-ldflags=LDFLAGS
# --with-icu-config[=/path/to/icu-config]
# --with-icu-cflags=CFLAGS
# --with-icu-config[=auto | pkg-config | /path/to/icu-config]
# --enable-icu-collations
#
# If both icu-ldflags and icu-config are provided, they are
# cumulative. If neither are provided, icu-collations is not honored
# and a warning is emitted if it is provided.
# --with-icu-config values:
#
# - auto: use the first one of (pkg-config, icu-config) found on the
# system.
# - pkg-config: use only pkg-config to determine flags
# - /path/to/icu-config: use that to determine flags
#
# If --with-icu-config is used as neither pkg-config nor icu-config
# are found, fail fatally.
#
# If both --with-icu-ldflags and --with-icu-config are provided, they
# are cumulative. If neither are provided, icu-collations is not
# honored and a warning is emitted if it is provided.
#
# Design note: though we can automatically enable ICU if the
# icu-config binary is found, we specifically do not. ICU is always an
# opt-in feature.
# icu-config binary or (pkg-config icu-io) are found, we specifically
# do not. ICU is always an opt-in feature.
#
# Maintenance reminder: check-in 09caa94c9e84 added pkg-config support
# to this but the result fails to link on both Linux and OpenBSD
# (other systems were untested) because the pkg-config results are
# missing a required library.
proc sqlite-check-icu {} {
define LDFLAGS_ICU [join [opt-val with-icu-ldflags ""]]
define CFLAGS_ICU [join [opt-val with-icu-cflags ""]]
# Flags sets seen in the wild for ICU:
# - -licui18n -licuuc -licudata
# - -licui18n -licuuc
# - /usr/local/bin/icu-config --ldflags
#
if {[proj-opt-was-provided with-icu-config]} {
set bin [opt-val with-icu-config]
if {"auto" eq $bin} {
set bin [proj-first-bin-of \
[get-define prefix]/bin/icu-config \
set icuConfigBin [opt-val with-icu-config]
set tryIcuConfigBin 1; # set to 0 if we end up using pkg-config
if {"auto" eq $icuConfigBin || "pkg-config" eq $icuConfigBin} {
if {[pkg-config-init 0] && [pkg-config icu-io]} {
# Maintenance reminder: historical docs say to use both of
# (icu-io, icu-uc). icu-uc lacks a required lib and icu-io has
# all of them on tested OSes.
set tryIcuConfigBin 0
define LDFLAGS_ICU [get-define PKG_ICU_IO_LDFLAGS]
define-append LDFLAGS_ICU [get-define PKG_ICU_IO_LIBS]
define CFLAGS_ICU [get-define PKG_ICU_IO_CFLAGS]
} elseif {"pkg-config" eq $icuConfigBin} {
proj-fatal "pkg-config cannot find package icu-io"
} else {
proj-assert {"auto" eq $icuConfigBin}
}
}
if {$tryIcuConfigBin} {
if {"auto" eq $icuConfigBin} {
set icuConfigBin [proj-first-bin-of \
/usr/local/bin/icu-config \
/usr/bin/icu-config]
if {"" eq $bin} {
proj-fatal "--with-icu-config=auto cannot find icu-config binary"
if {"" eq $icuConfigBin} {
proj-fatal "--with-icu-config=auto cannot find (pkg-config icu-io) or icu-config binary"
}
}
if {[file-isexec $bin]} {
set x [exec $bin --ldflags]
if {[file-isexec $icuConfigBin]} {
set x [exec $icuConfigBin --ldflags]
if {"" eq $x} {
proj-fatal "$bin --ldflags returned no data"
proj-fatal "$icuConfigBin --ldflags returned no data"
}
define-append LDFLAGS_ICU $x
set x [exec $icuConfigBin --cppflags]
define-append CFLAGS_ICU $x
} else {
proj-fatal "--with-icu-config=$bin does not refer to an executable"
}
}
set flags [define LDFLAGS_ICU [string trim [get-define LDFLAGS_ICU]]]
if {"" ne $flags} {
}
set ldflags [define LDFLAGS_ICU [string trim [get-define LDFLAGS_ICU]]]
set cflags [define CFLAGS_ICU [string trim [get-define CFLAGS_ICU]]]
if {"" ne $ldflags} {
sqlite-add-feature-flag -shell -DSQLITE_ENABLE_ICU
msg-result "Enabling ICU support with libs: $flags"
msg-result "Enabling ICU support with flags: $ldflags $cflags"
if {[opt-bool icu-collations]} {
msg-result "Enabling ICU collations."
sqlite-add-feature-flag -shell -DSQLITE_ENABLE_ICU_COLLATIONS
@ -1166,9 +1225,9 @@ proc sqlite-check-icu {} {
sqlite-check-icu
########################################################################
# Emscripten SDK for building the web-based wasm components.
#
proc sqlite-check-emsdk {} {
# Check for the Emscripten SDK for building the web-based wasm
# components.
apply {{} {
set emccsh $::srcdir/tool/emcc.sh
if {![get-define HAVE_WASI_SDK] && [proj-check-emsdk]} {
define EMCC_WRAPPER $emccsh
@ -1178,8 +1237,7 @@ proc sqlite-check-emsdk {} {
define EMCC_WRAPPER ""
file delete -force $emccsh
}
}
sqlite-check-emsdk
}}
########################################################################
# Check for log(3) in libm and die with an error if it is not
@ -1202,6 +1260,7 @@ proc affirm-have-math {featureName} {
msg-result "Feature flags..."
foreach {boolFlag featureFlag ifSetEvalThis} {
all {} {
# The 'all' option must be first in this list.
proj-opt-set fts4
proj-opt-set fts5
proj-opt-set geopoly
@ -1254,7 +1313,7 @@ foreach {boolFlag featureFlag} {
#########################################################################
# Show the final feature flag sets:
if {1} {
apply {{} {
set oFF [get-define OPT_FEATURE_FLAGS]
if {"" ne $oFF} {
define OPT_FEATURE_FLAGS [lsort -unique $oFF]
@ -1266,7 +1325,7 @@ if {1} {
msg-result "Shell options: [get-define OPT_SHELL]"
}
unset oFF
}
}}
########################################################################
# "Re-export" the autoconf-conventional --XYZdir flags into something
@ -1285,20 +1344,13 @@ proj-remap-autoconf-dir-vars
# Potential TODO (unclear): in sqlite3.pc.in, do we need to include
# any CFLAGS_READLINE, CFLAGS_ZLIB, etc in its "Cflags:" section?
proj-make-from-dot-in -touch Makefile sqlite3.pc
if {0} {
# Requires a hand-written sqlite_cfg.h.in...
proj-make-from-dot-in sqlite_cfg.h
# vs...
} else {
# Requires no input template...
make-config-header sqlite_cfg.h \
make-config-header sqlite_cfg.h \
-bare {SIZEOF_* HAVE_DECL_*} \
-none {HAVE_CFLAG_* LDFLAGS_* SH_* SQLITE_AUTORECONFIG
TARGET_* USE_GCOV TCL_*} \
-auto {HAVE_* PACKAGE_*} \
-none *
proj-touch sqlite_cfg.h ; # help avoid frequent unnecessary @SQLITE_AUTORECONFIG@
}
proj-touch sqlite_cfg.h ; # help avoid frequent unnecessary @SQLITE_AUTORECONFIG@
########################################################################
# Some build-dev/debug-only output

View File

@ -85,8 +85,7 @@ proc proj-assert {script {descr ""}} {
if {1 == [get-env proj-assert 0]} {
msg-result [proj-bold "asserting: $script"]
}
set x {expr }
append x \{ $script \}
set x "expr \{ $script \}"
if {![uplevel 1 $x]} {
if {"" eq $descr} {
set descr $script
@ -1207,9 +1206,8 @@ proc proj-which-linenoise {dotH} {
proc proj-remap-autoconf-dir-vars {} {
set prefix [get-define prefix]
set exec_prefix [get-define exec_prefix $prefix]
# Note that the ${...} here refers to make-side var derefs, not
# TCL-side vars. They must be formulated such that they are legal
# for use in (A) makefiles, (B) pkgconfig files, and (C) TCL's
# The following var derefs must be formulated such that they are
# legal for use in (A) makefiles, (B) pkgconfig files, and (C) TCL's
# [subst] command. i.e. they must use the form ${X}.
foreach {flag makeVar makeDeref} {
exec-prefix exec_prefix ${prefix}

View File

@ -106,6 +106,26 @@
** the shell.c source file will know to include the -vfstrace command-line
** option and (2) you must compile and link the three source files
** shell,c, test_vfstrace.c, and sqlite3.c.
**
** RUNTIME CONTROL OF VFSTRACE OUTPUT
**
** The application can use the "vfstrace" pragma to control which VFS
** APIs are traced. To disable all output:
**
** PRAGMA vfstrace('-all');
**
** To enable all output (which is the default setting):
**
** PRAGMA vfstrace('+all');
**
** Individual APIs can be enabled or disabled by name, with or without
** the initial "x" character. For example, to set up for tracing lock
** primatives only:
**
** PRAGMA vfstrace('-all, +Lock,Unlock,ShmLock');
**
** The argument to the vfstrace pragma ignores capitalization and any
** characters other than alphabetics, '+', and '-'.
*/
#include <stdlib.h>
#include <string.h>
@ -119,6 +139,8 @@ typedef struct vfstrace_info vfstrace_info;
struct vfstrace_info {
sqlite3_vfs *pRootVfs; /* The underlying real VFS */
int (*xOut)(const char*, void*); /* Send output here */
unsigned int mTrace; /* Mask of interfaces to trace */
u8 bOn; /* Tracing on/off */
void *pOutArg; /* First argument to xOut */
const char *zVfsName; /* Name of this trace-VFS */
sqlite3_vfs *pTraceVfs; /* Pointer back to the trace VFS */
@ -135,6 +157,38 @@ struct vfstrace_file {
sqlite3_file *pReal; /* The real underlying file */
};
/*
** Bit values for vfstrace_info.mTrace.
*/
#define VTR_CLOSE 0x00000001
#define VTR_READ 0x00000002
#define VTR_WRITE 0x00000004
#define VTR_TRUNC 0x00000008
#define VTR_SYNC 0x00000010
#define VTR_FSIZE 0x00000020
#define VTR_LOCK 0x00000040
#define VTR_UNLOCK 0x00000080
#define VTR_CRL 0x00000100
#define VTR_FCTRL 0x00000200
#define VTR_SECSZ 0x00000400
#define VTR_DEVCHAR 0x00000800
#define VTR_SHMLOCK 0x00001000
#define VTR_SHMMAP 0x00002000
#define VTR_SHMBAR 0x00004000
#define VTR_SHMUNMAP 0x00008000
#define VTR_OPEN 0x00010000
#define VTR_DELETE 0x00020000
#define VTR_ACCESS 0x00040000
#define VTR_FULLPATH 0x00080000
#define VTR_DLOPEN 0x00100000
#define VTR_DLERR 0x00200000
#define VTR_DLSYM 0x00400000
#define VTR_DLCLOSE 0x00800000
#define VTR_RAND 0x01000000
#define VTR_SLEEP 0x02000000
#define VTR_CURTIME 0x04000000
#define VTR_LASTERR 0x08000000
/*
** Method declarations for vfstrace_file.
*/
@ -199,11 +253,13 @@ static void vfstrace_printf(
){
va_list ap;
char *zMsg;
if( pInfo->bOn ){
va_start(ap, zFormat);
zMsg = sqlite3_vmprintf(zFormat, ap);
va_end(ap);
pInfo->xOut(zMsg, pInfo->pOutArg);
sqlite3_free(zMsg);
}
}
/*
@ -302,6 +358,13 @@ static void strappend(char *z, int *pI, const char *zAppend){
*pI = i;
}
/*
** Turn tracing output on or off according to mMask.
*/
static void vfstraceOnOff(vfstrace_info *pInfo, unsigned int mMask){
pInfo->bOn = (pInfo->mTrace & mMask)!=0;
}
/*
** Close an vfstrace-file.
*/
@ -309,6 +372,7 @@ static int vfstraceClose(sqlite3_file *pFile){
vfstrace_file *p = (vfstrace_file *)pFile;
vfstrace_info *pInfo = p->pInfo;
int rc;
vfstraceOnOff(pInfo, VTR_CLOSE);
vfstrace_printf(pInfo, "%s.xClose(%s)", pInfo->zVfsName, p->zFName);
rc = p->pReal->pMethods->xClose(p->pReal);
vfstrace_print_errcode(pInfo, " -> %s\n", rc);
@ -331,6 +395,7 @@ static int vfstraceRead(
vfstrace_file *p = (vfstrace_file *)pFile;
vfstrace_info *pInfo = p->pInfo;
int rc;
vfstraceOnOff(pInfo, VTR_READ);
vfstrace_printf(pInfo, "%s.xRead(%s,n=%d,ofst=%lld)",
pInfo->zVfsName, p->zFName, iAmt, iOfst);
rc = p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst);
@ -350,6 +415,7 @@ static int vfstraceWrite(
vfstrace_file *p = (vfstrace_file *)pFile;
vfstrace_info *pInfo = p->pInfo;
int rc;
vfstraceOnOff(pInfo, VTR_WRITE);
vfstrace_printf(pInfo, "%s.xWrite(%s,n=%d,ofst=%lld)",
pInfo->zVfsName, p->zFName, iAmt, iOfst);
rc = p->pReal->pMethods->xWrite(p->pReal, zBuf, iAmt, iOfst);
@ -364,6 +430,7 @@ static int vfstraceTruncate(sqlite3_file *pFile, sqlite_int64 size){
vfstrace_file *p = (vfstrace_file *)pFile;
vfstrace_info *pInfo = p->pInfo;
int rc;
vfstraceOnOff(pInfo, VTR_TRUNC);
vfstrace_printf(pInfo, "%s.xTruncate(%s,%lld)", pInfo->zVfsName, p->zFName,
size);
rc = p->pReal->pMethods->xTruncate(p->pReal, size);
@ -388,6 +455,7 @@ static int vfstraceSync(sqlite3_file *pFile, int flags){
if( flags & ~(SQLITE_SYNC_FULL|SQLITE_SYNC_DATAONLY) ){
sqlite3_snprintf(sizeof(zBuf)-i, &zBuf[i], "|0x%x", flags);
}
vfstraceOnOff(pInfo, VTR_SYNC);
vfstrace_printf(pInfo, "%s.xSync(%s,%s)", pInfo->zVfsName, p->zFName,
&zBuf[1]);
rc = p->pReal->pMethods->xSync(p->pReal, flags);
@ -402,6 +470,7 @@ static int vfstraceFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){
vfstrace_file *p = (vfstrace_file *)pFile;
vfstrace_info *pInfo = p->pInfo;
int rc;
vfstraceOnOff(pInfo, VTR_FSIZE);
vfstrace_printf(pInfo, "%s.xFileSize(%s)", pInfo->zVfsName, p->zFName);
rc = p->pReal->pMethods->xFileSize(p->pReal, pSize);
vfstrace_print_errcode(pInfo, " -> %s,", rc);
@ -430,6 +499,7 @@ static int vfstraceLock(sqlite3_file *pFile, int eLock){
vfstrace_file *p = (vfstrace_file *)pFile;
vfstrace_info *pInfo = p->pInfo;
int rc;
vfstraceOnOff(pInfo, VTR_LOCK);
vfstrace_printf(pInfo, "%s.xLock(%s,%s)", pInfo->zVfsName, p->zFName,
lockName(eLock));
rc = p->pReal->pMethods->xLock(p->pReal, eLock);
@ -444,6 +514,7 @@ static int vfstraceUnlock(sqlite3_file *pFile, int eLock){
vfstrace_file *p = (vfstrace_file *)pFile;
vfstrace_info *pInfo = p->pInfo;
int rc;
vfstraceOnOff(pInfo, VTR_UNLOCK);
vfstrace_printf(pInfo, "%s.xUnlock(%s,%s)", pInfo->zVfsName, p->zFName,
lockName(eLock));
rc = p->pReal->pMethods->xUnlock(p->pReal, eLock);
@ -458,6 +529,7 @@ static int vfstraceCheckReservedLock(sqlite3_file *pFile, int *pResOut){
vfstrace_file *p = (vfstrace_file *)pFile;
vfstrace_info *pInfo = p->pInfo;
int rc;
vfstraceOnOff(pInfo, VTR_CRL);
vfstrace_printf(pInfo, "%s.xCheckReservedLock(%s,%d)",
pInfo->zVfsName, p->zFName);
rc = p->pReal->pMethods->xCheckReservedLock(p->pReal, pResOut);
@ -477,6 +549,7 @@ static int vfstraceFileControl(sqlite3_file *pFile, int op, void *pArg){
char zBuf2[100];
char *zOp;
char *zRVal = 0;
vfstraceOnOff(pInfo, VTR_FCTRL);
switch( op ){
case SQLITE_FCNTL_LOCKSTATE: zOp = "LOCKSTATE"; break;
case SQLITE_GET_LOCKPROXYFILE: zOp = "GET_LOCKPROXYFILE"; break;
@ -505,6 +578,79 @@ static int vfstraceFileControl(sqlite3_file *pFile, int op, void *pArg){
case SQLITE_FCNTL_POWERSAFE_OVERWRITE: zOp = "POWERSAFE_OVERWRITE"; break;
case SQLITE_FCNTL_PRAGMA: {
const char *const* a = (const char*const*)pArg;
if( a[1] && strcmp(a[1],"vfstrace")==0 && a[2] ){
const u8 *zArg = (const u8*)a[2];
if( zArg[0]>='0' && zArg[0]<=9 ){
pInfo->mTrace = (sqlite3_uint64)strtoll(a[2], 0, 0);
}else{
static const struct {
const char *z;
unsigned int m;
} aKw[] = {
{ "all", 0xffffffff },
{ "close", VTR_CLOSE },
{ "read", VTR_READ },
{ "write", VTR_WRITE },
{ "truncate", VTR_TRUNC },
{ "sync", VTR_SYNC },
{ "filesize", VTR_FSIZE },
{ "lock", VTR_LOCK },
{ "unlock", VTR_UNLOCK },
{ "checkreservedlock", VTR_CRL },
{ "filecontrol", VTR_FCTRL },
{ "sectorsize", VTR_SECSZ },
{ "devicecharacteristics", VTR_DEVCHAR },
{ "shmlock", VTR_SHMLOCK },
{ "shmmap", VTR_SHMMAP },
{ "shmummap", VTR_SHMUNMAP },
{ "shmbarrier", VTR_SHMBAR },
{ "open", VTR_OPEN },
{ "delete", VTR_DELETE },
{ "access", VTR_ACCESS },
{ "fullpathname", VTR_FULLPATH },
{ "dlopen", VTR_DLOPEN },
{ "dlerror", VTR_DLERR },
{ "dlsym", VTR_DLSYM },
{ "dlclose", VTR_DLCLOSE },
{ "randomness", VTR_RAND },
{ "sleep", VTR_SLEEP },
{ "currenttime", VTR_CURTIME },
{ "currenttimeint64", VTR_CURTIME },
{ "getlasterror", VTR_LASTERR },
};
int onOff = 1;
while( zArg[0] ){
int jj, n;
while( zArg[0]!=0 && zArg[0]!='-' && zArg[0]!='+'
&& !isalpha(zArg[0]) ) zArg++;
if( zArg[0]==0 ) break;
if( zArg[0]=='-' ){
onOff = 0;
zArg++;
}else if( zArg[0]=='+' ){
onOff = 1;
zArg++;
}
while( !isalpha(zArg[0]) ){
if( zArg[0]==0 ) break;
zArg++;
}
if( zArg[0]=='x' && isalpha(zArg[1]) ) zArg++;
for(n=0; isalpha(zArg[n]); n++){}
for(jj=0; jj<sizeof(aKw)/sizeof(aKw[0]); jj++){
if( sqlite3_strnicmp(aKw[jj].z,(const char*)zArg,n)==0 ){
if( onOff ){
pInfo->mTrace |= aKw[jj].m;
}else{
pInfo->mTrace &= ~aKw[jj].m;
}
break;
}
}
zArg += n;
}
}
}
sqlite3_snprintf(sizeof(zBuf), zBuf, "PRAGMA,[%s,%s]",a[1],a[2]);
zOp = zBuf;
break;
@ -600,6 +746,7 @@ static int vfstraceSectorSize(sqlite3_file *pFile){
vfstrace_file *p = (vfstrace_file *)pFile;
vfstrace_info *pInfo = p->pInfo;
int rc;
vfstraceOnOff(pInfo, VTR_SECSZ);
vfstrace_printf(pInfo, "%s.xSectorSize(%s)", pInfo->zVfsName, p->zFName);
rc = p->pReal->pMethods->xSectorSize(p->pReal);
vfstrace_printf(pInfo, " -> %d\n", rc);
@ -613,6 +760,7 @@ static int vfstraceDeviceCharacteristics(sqlite3_file *pFile){
vfstrace_file *p = (vfstrace_file *)pFile;
vfstrace_info *pInfo = p->pInfo;
int rc;
vfstraceOnOff(pInfo, VTR_DEVCHAR);
vfstrace_printf(pInfo, "%s.xDeviceCharacteristics(%s)",
pInfo->zVfsName, p->zFName);
rc = p->pReal->pMethods->xDeviceCharacteristics(p->pReal);
@ -639,6 +787,7 @@ static int vfstraceShmLock(sqlite3_file *pFile, int ofst, int n, int flags){
int rc;
char zLck[100];
int i = 0;
vfstraceOnOff(pInfo, VTR_SHMLOCK);
memcpy(zLck, "|0", 3);
if( flags & SQLITE_SHM_UNLOCK ) strappend(zLck, &i, "|UNLOCK");
if( flags & SQLITE_SHM_LOCK ) strappend(zLck, &i, "|LOCK");
@ -670,6 +819,7 @@ static int vfstraceShmMap(
vfstrace_file *p = (vfstrace_file *)pFile;
vfstrace_info *pInfo = p->pInfo;
int rc;
vfstraceOnOff(pInfo, VTR_SHMMAP);
vfstrace_printf(pInfo, "%s.xShmMap(%s,iRegion=%d,szRegion=%d,isWrite=%d,*)",
pInfo->zVfsName, p->zFName, iRegion, szRegion, isWrite);
rc = p->pReal->pMethods->xShmMap(p->pReal, iRegion, szRegion, isWrite, pp);
@ -679,6 +829,7 @@ static int vfstraceShmMap(
static void vfstraceShmBarrier(sqlite3_file *pFile){
vfstrace_file *p = (vfstrace_file *)pFile;
vfstrace_info *pInfo = p->pInfo;
vfstraceOnOff(pInfo, VTR_SHMBAR);
vfstrace_printf(pInfo, "%s.xShmBarrier(%s)\n", pInfo->zVfsName, p->zFName);
p->pReal->pMethods->xShmBarrier(p->pReal);
}
@ -686,6 +837,7 @@ static int vfstraceShmUnmap(sqlite3_file *pFile, int delFlag){
vfstrace_file *p = (vfstrace_file *)pFile;
vfstrace_info *pInfo = p->pInfo;
int rc;
vfstraceOnOff(pInfo, VTR_SHMUNMAP);
vfstrace_printf(pInfo, "%s.xShmUnmap(%s,delFlag=%d)",
pInfo->zVfsName, p->zFName, delFlag);
rc = p->pReal->pMethods->xShmUnmap(p->pReal, delFlag);
@ -713,6 +865,7 @@ static int vfstraceOpen(
p->zFName = zName ? fileTail(zName) : "<temp>";
p->pReal = (sqlite3_file *)&p[1];
rc = pRoot->xOpen(pRoot, zName, p->pReal, flags, pOutFlags);
vfstraceOnOff(pInfo, VTR_OPEN);
vfstrace_printf(pInfo, "%s.xOpen(%s,flags=0x%x)",
pInfo->zVfsName, p->zFName, flags);
if( p->pReal->pMethods ){
@ -758,6 +911,7 @@ static int vfstraceDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
sqlite3_vfs *pRoot = pInfo->pRootVfs;
int rc;
vfstraceOnOff(pInfo, VTR_DELETE);
vfstrace_printf(pInfo, "%s.xDelete(\"%s\",%d)",
pInfo->zVfsName, zPath, dirSync);
rc = pRoot->xDelete(pRoot, zPath, dirSync);
@ -778,6 +932,7 @@ static int vfstraceAccess(
vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
sqlite3_vfs *pRoot = pInfo->pRootVfs;
int rc;
vfstraceOnOff(pInfo, VTR_ACCESS);
vfstrace_printf(pInfo, "%s.xAccess(\"%s\",%d)",
pInfo->zVfsName, zPath, flags);
rc = pRoot->xAccess(pRoot, zPath, flags, pResOut);
@ -800,6 +955,7 @@ static int vfstraceFullPathname(
vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
sqlite3_vfs *pRoot = pInfo->pRootVfs;
int rc;
vfstraceOnOff(pInfo, VTR_FULLPATH);
vfstrace_printf(pInfo, "%s.xFullPathname(\"%s\")",
pInfo->zVfsName, zPath);
rc = pRoot->xFullPathname(pRoot, zPath, nOut, zOut);
@ -814,6 +970,7 @@ static int vfstraceFullPathname(
static void *vfstraceDlOpen(sqlite3_vfs *pVfs, const char *zPath){
vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
sqlite3_vfs *pRoot = pInfo->pRootVfs;
vfstraceOnOff(pInfo, VTR_DLOPEN);
vfstrace_printf(pInfo, "%s.xDlOpen(\"%s\")\n", pInfo->zVfsName, zPath);
return pRoot->xDlOpen(pRoot, zPath);
}
@ -826,6 +983,7 @@ static void *vfstraceDlOpen(sqlite3_vfs *pVfs, const char *zPath){
static void vfstraceDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){
vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
sqlite3_vfs *pRoot = pInfo->pRootVfs;
vfstraceOnOff(pInfo, VTR_DLERR);
vfstrace_printf(pInfo, "%s.xDlError(%d)", pInfo->zVfsName, nByte);
pRoot->xDlError(pRoot, nByte, zErrMsg);
vfstrace_printf(pInfo, " -> \"%s\"", zErrMsg);
@ -847,6 +1005,7 @@ static void (*vfstraceDlSym(sqlite3_vfs *pVfs,void *p,const char *zSym))(void){
static void vfstraceDlClose(sqlite3_vfs *pVfs, void *pHandle){
vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
sqlite3_vfs *pRoot = pInfo->pRootVfs;
vfstraceOnOff(pInfo, VTR_DLCLOSE);
vfstrace_printf(pInfo, "%s.xDlOpen()\n", pInfo->zVfsName);
pRoot->xDlClose(pRoot, pHandle);
}
@ -858,6 +1017,7 @@ static void vfstraceDlClose(sqlite3_vfs *pVfs, void *pHandle){
static int vfstraceRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){
vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
sqlite3_vfs *pRoot = pInfo->pRootVfs;
vfstraceOnOff(pInfo, VTR_RAND);
vfstrace_printf(pInfo, "%s.xRandomness(%d)\n", pInfo->zVfsName, nByte);
return pRoot->xRandomness(pRoot, nByte, zBufOut);
}
@ -869,6 +1029,8 @@ static int vfstraceRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){
static int vfstraceSleep(sqlite3_vfs *pVfs, int nMicro){
vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
sqlite3_vfs *pRoot = pInfo->pRootVfs;
vfstraceOnOff(pInfo, VTR_SLEEP);
vfstrace_printf(pInfo, "%s.xSleep(%d)\n", pInfo->zVfsName, nMicro);
return pRoot->xSleep(pRoot, nMicro);
}
@ -878,21 +1040,37 @@ static int vfstraceSleep(sqlite3_vfs *pVfs, int nMicro){
static int vfstraceCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){
vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
sqlite3_vfs *pRoot = pInfo->pRootVfs;
return pRoot->xCurrentTime(pRoot, pTimeOut);
int rc;
vfstraceOnOff(pInfo, VTR_CURTIME);
vfstrace_printf(pInfo, "%s.xCurrentTime()", pInfo->zVfsName);
rc = pRoot->xCurrentTime(pRoot, pTimeOut);
vfstrace_printf(pInfo, " -> %.17g\n", *pTimeOut);
return rc;
}
static int vfstraceCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *pTimeOut){
vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
sqlite3_vfs *pRoot = pInfo->pRootVfs;
return pRoot->xCurrentTimeInt64(pRoot, pTimeOut);
int rc;
vfstraceOnOff(pInfo, VTR_CURTIME);
vfstrace_printf(pInfo, "%s.xCurrentTimeInt64()", pInfo->zVfsName);
rc = pRoot->xCurrentTimeInt64(pRoot, pTimeOut);
vfstrace_printf(pInfo, " -> %lld\n", *pTimeOut);
return rc;
}
/*
** Return th3 most recent error code and message
** Return the most recent error code and message
*/
static int vfstraceGetLastError(sqlite3_vfs *pVfs, int iErr, char *zErr){
static int vfstraceGetLastError(sqlite3_vfs *pVfs, int nErr, char *zErr){
vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
sqlite3_vfs *pRoot = pInfo->pRootVfs;
return pRoot->xGetLastError(pRoot, iErr, zErr);
int rc;
vfstraceOnOff(pInfo, VTR_LASTERR);
vfstrace_printf(pInfo, "%s.xGetLastError(%d,zBuf)", pInfo->zVfsName, nErr);
if( nErr ) zErr[0] = 0;
rc = pRoot->xGetLastError(pRoot, nErr, zErr);
vfstrace_printf(pInfo, " -> zBuf[] = \"%s\", rc = %d\n", nErr?zErr:"", rc);
return rc;
}
/*
@ -986,6 +1164,8 @@ int vfstrace_register(
pInfo->pOutArg = pOutArg;
pInfo->zVfsName = pNew->zName;
pInfo->pTraceVfs = pNew;
pInfo->mTrace = 0xffffffff;
pInfo->bOn = 1;
vfstrace_printf(pInfo, "%s.enabled_for(\"%s\")\n",
pInfo->zVfsName, pRoot->zName);
return sqlite3_vfs_register(pNew, makeDefault);

63
main.mk
View File

@ -162,6 +162,7 @@ LDFLAGS.pthread ?= -lpthread
LDFLAGS.dlopen ?= -ldl
LDFLAGS.shobj ?= -shared
LDFLAGS.icu ?= # -licui18n -licuuc -licudata
CFLAGS.icu ?=
LDFLAGS.soname.libsqlite3 ?=
# libreadline (or a workalike):
# To activate readline in the shell: SHELL_OPT = -DHAVE_READLINE=1
@ -1388,7 +1389,8 @@ all: lib
# Dynamic libsqlite3
#
$(libsqlite3.SO): $(LIBOBJ)
$(T.link.shared) -o $@ $(LIBOBJ) $(LDFLAGS.soname.libsqlite3) $(LDFLAGS.libsqlite3)
$(T.link.shared) -o $@ $(LIBOBJ) $(LDFLAGS.soname.libsqlite3) \
$(LDFLAGS.libsqlite3) $(LDFLAGS.libsqlite3.soname)
$(libsqlite3.SO)-1: $(libsqlite3.SO)
$(libsqlite3.SO)-0 $(libsqlite3.SO)-:
so: $(libsqlite3.SO)-$(ENABLE_SHARED)
@ -1400,9 +1402,13 @@ all: so
#
# - libsqlite3.so.$(PACKAGE_VERSION)
# - libsqlite3.so.3 =symlink-> libsqlite3.so.$(PACKAGE_VERSION)
# - libsqlite3.so.0 =symlink-> libsqlite3.so.$(PACKAGE_VERSION) (see below)
# - libsqlite3.so =symlink-> libsqlite3.so.3
#
# Regarding the historcal installation name of libsqlite3.so.0.8.6:
# The link named libsqlite3.so.0 is provided in an attempt to reduce
# downstream disruption when performing upgrades from pre-3.48 to a
# version 3.48 or higher. That name is considered a legacy remnant
# and will eventually be removed from this installation process.
#
# Historically libtool installed the library like so:
#
@ -1416,13 +1422,12 @@ all: so
# compatibility for systems which have libraries installed using those
# conventions:
#
# 1) If libsqlite3.so.0 is found in the target installation directory
# then it and libsqlite3.so.0.8.6 are re-linked to point to the
# newer-style names. We cannot retain both the old and new
# installation because they both share the high-level name
# $(libsqlite3.SO). The down-side of this is that it may well upset
# packaging tools when we replace libsqlite3.so (from a legacy
# package) with a new symlink.
# 1) If libsqlite3.so.0.8.6 is found in the target installation
# directory then it is re-linked to point to the newer-style
# names. We cannot retain both the old and new installation because
# they both share the high-level name $(libsqlite3.SO). The
# down-side of this is that it may upset packaging tools when we
# replace libsqlite3.so (from a legacy package) with a new symlink.
#
# 2) If INSTALL_SO_086_LINKS=1 and point (1) does not apply then links
# to the legacy-style names are created. The primary intent of this
@ -1436,25 +1441,24 @@ all: so
#
install-so-1: $(install-dir.lib) $(libsqlite3.SO)
$(INSTALL) $(libsqlite3.SO) "$(install-dir.lib)"
@echo "Setting up SO symlinks..."; \
@echo "Setting up $(libsqlite3.SO) symlinks..."; \
cd "$(install-dir.lib)" || exit $$?; \
rm -f $(libsqlite3.SO).3 $(libsqlite3.SO).$(PACKAGE_VERSION) || exit $$?; \
rm -f $(libsqlite3.SO).3 $(libsqlite3.SO).0 $(libsqlite3.SO).$(PACKAGE_VERSION) || exit $$?; \
mv $(libsqlite3.SO) $(libsqlite3.SO).$(PACKAGE_VERSION) || exit $$?; \
ln -s $(libsqlite3.SO).$(PACKAGE_VERSION) $(libsqlite3.SO) || exit $$?; \
ln -s $(libsqlite3.SO).$(PACKAGE_VERSION) $(libsqlite3.SO).3 || exit $$?; \
ln -s $(libsqlite3.SO).3 $(libsqlite3.SO) || exit $$?; \
ls -la $(libsqlite3.SO) $(libsqlite3.SO).3*; \
if [ -e $(libsqlite3.SO).0 ]; then \
echo "ACHTUNG: legacy libtool-compatible install found. Re-linking it..."; \
rm -f libsqlite3.la $(libsqlite3.SO).0* || exit $$?; \
ln -s $(libsqlite3.SO).$(PACKAGE_VERSION) $(libsqlite3.SO).0 || exit $$?; \
ls -la $(libsqlite3.SO) $(libsqlite3.SO).[03]*; \
if [ -e $(libsqlite3.SO).0.8.6 ]; then \
echo "ACHTUNG: legacy libtool-compatible install found. Re-linking it..."; \
rm -f libsqlite3.la $(libsqlite3.SO).0.8.6 || exit $$?; \
ln -s $(libsqlite3.SO).$(PACKAGE_VERSION) $(libsqlite3.SO).0.8.6 || exit $$?; \
ls -la $(libsqlite3.SO).0*; \
ls -la $(libsqlite3.SO).0.8.6; \
elif [ x1 = "x$(INSTALL_SO_086_LINKS)" ]; then \
echo "ACHTUNG: installing legacy libtool-style links because INSTALL_SO_086_LINKS=1"; \
rm -f libsqlite3.la $(libsqlite3.SO).0* || exit $$?; \
ln -s $(libsqlite3.SO).$(PACKAGE_VERSION) $(libsqlite3.SO).0 || exit $$?; \
rm -f libsqlite3.la $(libsqlite3.SO).0.8.6 || exit $$?; \
ln -s $(libsqlite3.SO).$(PACKAGE_VERSION) $(libsqlite3.SO).0.8.6 || exit $$?; \
ls -la $(libsqlite3.SO).0*; \
ls -la $(libsqlite3.SO).0.8.6; \
fi
install-so-0 install-so-:
install-so: install-so-$(ENABLE_SHARED)
@ -1532,7 +1536,7 @@ tclextension: tclsqlite3.c
# to find it.
#
tclextension-install: tclsqlite3.c
$(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl --cc "$(T.cc)" $(CFLAGS.tclextension)
$(TCLSH_CMD) $(TOP)/tool/buildtclext.tcl --destdir "$(DESTDIR)" --cc "$(T.cc)" $(CFLAGS.tclextension)
#
# Uninstall the SQLite TCL extension that is used by $TCLSH_CMD.
@ -1915,9 +1919,22 @@ threadtest5: sqlite3.c $(TOP)/test/threadtest5.c
$(T.link) $(TOP)/test/threadtest5.c sqlite3.c -o $@ $(LDFLAGS.libsqlite3)
xbin: threadtest5
# The standard CLI is built using the amalgamation since it uses
# special compile-time options that are interpreted by individual
# source files within the amalgamation.
#
sqlite3$(T.exe): shell.c sqlite3.c
$(T.link) -o $@ \
shell.c sqlite3.c \
$(CFLAGS.readline) $(SHELL_OPT) $(CFLAGS.icu) \
$(LDFLAGS.libsqlite3) $(LDFLAGS.readline)
# The "sqlite3d" CLI is build using separate source files. This
# is useful during development and debugging.
#
sqlite3d$(T.exe): shell.c $(LIBOBJS0)
$(T.link) -o $@ \
shell.c $(LIBOBJS0) \
$(CFLAGS.readline) $(SHELL_OPT) \
$(LDFLAGS.libsqlite3) $(LDFLAGS.readline)
@ -2124,7 +2141,7 @@ shell.c: $(SHELL_DEP) $(TOP)/tool/mkshellc.tcl $(B.tclsh) # has_tclsh84
#
DEPS_EXT_COMMON = $(DEPS_OBJ_COMMON) $(EXTHDR)
icu.o: $(TOP)/ext/icu/icu.c $(DEPS_EXT_COMMON)
$(T.cc.extension) -c $(TOP)/ext/icu/icu.c
$(T.cc.extension) -c $(TOP)/ext/icu/icu.c $(CFLAGS.icu)
fts3.o: $(TOP)/ext/fts3/fts3.c $(DEPS_EXT_COMMON)
$(T.cc.extension) -c $(TOP)/ext/fts3/fts3.c
@ -2139,7 +2156,7 @@ fts3_hash.o: $(TOP)/ext/fts3/fts3_hash.c $(DEPS_EXT_COMMON)
$(T.cc.extension) -c $(TOP)/ext/fts3/fts3_hash.c
fts3_icu.o: $(TOP)/ext/fts3/fts3_icu.c $(DEPS_EXT_COMMON)
$(T.cc.extension) -c $(TOP)/ext/fts3/fts3_icu.c
$(T.cc.extension) -c $(TOP)/ext/fts3/fts3_icu.c $(CFLAGS.icu)
fts3_porter.o: $(TOP)/ext/fts3/fts3_porter.c $(DEPS_EXT_COMMON)
$(T.cc.extension) -c $(TOP)/ext/fts3/fts3_porter.c

View File

@ -1,9 +1,9 @@
C Fix\sa\sstate\smakefile\sdependency\swhich\srefered\sto\sthe\snow-removed\ssqlite_cfg.h.in.
D 2024-11-14T16:00:45.775
C Call\sfflush()\son\s".echo"\soutput\sfrom\sthe\sshell,\sso\sthat\sthe\soutput\sto\nstdout\sis\saligned\swith\soutput\sto\sstderr.
D 2024-11-16T18:54:46.664
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d
F Makefile.in d941328627467c1bc2f13861b0bf5dc1e0c4669c072eec20b37285777f41d289
F Makefile.in 2c90ab3183f810086878a784c323b7816238a5e6943d267c25a71edc623a05a3
F Makefile.linux-generic bd3e3cacd369821a6241d4ea1967395c962dfe3057e38cb0a435cee0e8b789d0
F Makefile.msc a92237976eb92c5efaa0dd2524746aec12c196e12df8d4dbff9543a4648c3312
F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159
@ -13,7 +13,7 @@ F art/icon-80x90.gif 65509ce3e5f86a9cd64fe7fca2d23954199f31fe44c1e09e208c80fb83d
F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2
F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90
F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2
F auto.def 7dbe7bebe9c3bea4de674053339964b4b26cff5e2fdc20948acc723b5080bffd
F auto.def 94f0f4a697e8221d5c7ca561771a3afabb0e707922daad89b60908b87a8e399b
F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903
F autoconf/Makefile.am adedc1324b6a87fdd1265ddd336d2fb7d4f36a0e77b86ea553ae7cc4ea239347
F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac
@ -49,7 +49,7 @@ F autosetup/cc-shared.tcl 4f024e94a47f427ba61de1739f6381ef0080210f9fae89112d5c1d
F autosetup/cc.tcl c0fcc50ca91deff8741e449ddad05bcd08268bc31177e613a6343bbd1fd3e45f
F autosetup/jimsh0.c d40e381ea4526a067590e7b91bd4b2efa6d4980d286f908054c647b3df4aee14
F autosetup/pkg-config.tcl 4e635bf39022ff65e0d5434339dd41503ea48fc53822c9c5bde88b02d3d952ba
F autosetup/proj.tcl 9772d3f89634089add92e2238551a59a5c764d501327f6eb433dca7f98138802
F autosetup/proj.tcl 96fe16b87c9feb9c1cf2682280f678c659bc52c09fca5de02afc2f7ec5bfb154
F autosetup/system.tcl 51d4be76cd9a9074704b584e5c9cbba616202c8468cf9ba8a4f8294a7ab1dba9
F configure 9a00b21dfd13757bbfb8d89b30660a89ec1f8f3a79402b8f9f9b6fc475c3303a x
F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad
@ -450,7 +450,7 @@ F ext/misc/urifuncs.c f71360d14fa9e7626b563f1f781c6148109462741c5235ac63ae0f8917
F ext/misc/uuid.c 5bb2264c1b64d163efa46509544fd7500cb8769cb7c16dd52052da8d961505cf
F ext/misc/vfslog.c 3932ab932eeb2601dbc4447cb14d445aaa9fbe43b863ef5f014401c3420afd20
F ext/misc/vfsstat.c a85df08654743922a19410d7b1e3111de41bb7cd07d20dd16eda4e2b808d269d
F ext/misc/vfstrace.c 72b7cda31777173b0ca78c6c92968c17aba635682205945e394fff27b377bb81
F ext/misc/vfstrace.c 2f68da859f87be350ede0e8eb94f754219d406161c1595250fc0ca55907460f6
F ext/misc/vtablog.c 1100250ce8782db37c833e3a9a5c9a3ecf1af5e15b8325572b82e6e0a138ffb5
F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd
F ext/misc/wholenumber.c 0fa0c082676b7868bf2fa918e911133f2b349bcdceabd1198bba5f65b4fc0668
@ -696,7 +696,7 @@ F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65a
F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2
F ext/wasm/wasmfs.make bc8bb227f35d5bd3863a7bd2233437c37472a0d81585979f058f9b9b503bef35
F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0
F main.mk cd92df46e074ce11466d43530cfe23cef48ac541aee4714181369e3fe92df05a
F main.mk e2287ed82f924c9d54493634dc7bb10797b8ef69ce7becef62d6a453337d5a45
F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421
@ -775,7 +775,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe
F src/shell.c.in 45e69e4e69576847a5b49aeac624c9ffad5666697ce037d38bc331a56733765f
F src/shell.c.in 469039a2a09603bf32f47b5c4ddc61e8b980139919db1f46000241357f5f3588
F src/sqlite.h.in 4d93768709c53b7c653a63817a82d5a8625264ca0d8cdf99967ba147bdcf2aa6
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54
@ -783,7 +783,7 @@ F src/sqliteInt.h 77be043f8694f4a8702d0ee882022b2e5a6489a0493e77c5d9a73f1efc5a2c
F src/sqliteLimit.h 6993c9cfe3af5b8169ae0e5f15627fc15596726d4f1dc90a221309f79715ce88
F src/status.c cb11f8589a6912af2da3bb1ec509a94dd8ef27df4d4c1a97e0bcf2309ece972b
F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1
F src/tclsqlite.c ff2dc3ec1bd318ee7a45d6b246a367703d5fb2a4c8da99d675ee7eb987b3a153
F src/tclsqlite.c c4b0b27b0ad34e4af085040a1ebe94a35ad5161663cd905d1b947f7884691bff
F src/tclsqlite.h 65e2c761446e1c9fa0342b7d2612a703483643c8b6a316d12a65b745a4727395
F src/test1.c 2d507751bfb4aa254dc22588ef1e3c5c5cfcb2e636d0e6e1fa0bbd307669c2a8
F src/test2.c 7ebc518e6735939d8979273a6f7b1d9b5702babf059f6ad62499f7f60a9eb9a3
@ -2105,7 +2105,7 @@ F tool/GetTclKit.bat d84033c6a93dfe735d247f48ba00292a1cc284dcf69963e5e672444e045
F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91
F tool/build-all-msvc.bat c817b716e0edeecaf265a6775b63e5f45c34a6544f1d4114a222701ed5ac79ab x
F tool/build-shell.sh 369c4b171cc877ad974fef691e4da782b4c1e99fe8f4361316c735f64d49280f
F tool/buildtclext.tcl b64d250517b148e644d26fcbc097851867a0df52cd4bafe9bcd94b8421e1428a
F tool/buildtclext.tcl 12b49ae392006251d110f051d22036f7807d7ea1602780f4c165154b12567397
F tool/cg_anno.tcl c1f875f5a4c9caca3d59937b16aff716f8b1883935f1b4c9ae23124705bc8099 x
F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2
F tool/cktclsh.sh 6075eef9c6b9ba4b38fef2ca2a66d25f2311bd3c610498d18a9b01f861629cca
@ -2189,8 +2189,8 @@ F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43
F tool/stripccomments.c 20b8aabc4694d0d4af5566e42da1f1a03aff057689370326e9269a9ddcffdc37
F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d
F tool/symbols.sh 1612bd947750e21e7b47befad5f6b3825b06cce0705441f903bf35ced65ae9b9
F tool/tclConfigShToAutoDef.sh 44ec55046d86a3febb2cb3e099399b41794e80e9cd138eee7b9b016f819e882b x
F tool/tclConfigShToMake.sh 7c065d81c2d178e15e45a77372c6e5a38b5a1b08755301cd6f20a3a862db7312 x
F tool/tclConfigShToTcl.sh 44ec55046d86a3febb2cb3e099399b41794e80e9cd138eee7b9b016f819e882b x
F tool/varint.c 5d94cb5003db9dbbcbcc5df08d66f16071aee003
F tool/vdbe-compress.tcl fa2f37ab39b2a0087fafb6a7f3ce19503e25e624ffa8ed9951717ab72920c088
F tool/vdbe_profile.tcl 3ac5a4a9449f4baf77059358ea050db3e34395ccf59c5464d29b91746d5b961e
@ -2198,8 +2198,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 6148f2d39237a85edb399e5c2beb305dccd99ca8c0cf143e8c2ddc0fc1d9e916
R c8ff2644822f8bbab8e63072254a5a68
U stephan
Z 54ae5ab64b4869b51425727dae4b6b51
P cd942dce148c9d8f5a94cee61923aad8d1b732b807e004005f78323be30c02e7
R c6e3e7808022fc93197afc8ff5529a17
U drh
Z 8206467963ac0d5803b490ec391283d6
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
9a726b4be8ddd4b388478024a0952cfd4f0b9f665ab69119a6de0b996ac72216
c38b9db3c4f71706a7d211424da64311e6e5daf64b224565a6d82d4b1a68e261

View File

@ -12237,7 +12237,10 @@ static int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){
}
static void echo_group_input(ShellState *p, const char *zDo){
if( ShellHasFlag(p, SHFLG_Echo) ) sqlite3_fprintf(p->out, "%s\n", zDo);
if( ShellHasFlag(p, SHFLG_Echo) ){
sqlite3_fprintf(p->out, "%s\n", zDo);
fflush(p->out);
}
}
#ifdef SQLITE_SHELL_FIDDLE
@ -13276,15 +13279,10 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
char *zHome;
char *zHistory;
int nHistory;
#if CIO_WIN_WC_XLATE
# define SHELL_CIO_CHAR_SET (stdout_is_console? " (UTF-16 console I/O)" : "")
#else
# define SHELL_CIO_CHAR_SET ""
#endif
sqlite3_fprintf(stdout,
"SQLite version %s %.19s%s\n" /*extra-version-info*/
"SQLite version %s %.19s\n" /*extra-version-info*/
"Enter \".help\" for usage hints.\n",
sqlite3_libversion(), sqlite3_sourceid(), SHELL_CIO_CHAR_SET);
sqlite3_libversion(), sqlite3_sourceid());
if( warnInmemoryDb ){
sputz(stdout, "Connected to a ");
printBold("transient in-memory database");

View File

@ -4037,9 +4037,12 @@ static const char *tclsh_main_loop(void){
"if {[file exists $arg]} {\n"
"lappend new $arg\n"
"} else {\n"
"set once 0\n"
"foreach match [lsort [glob -nocomplain $arg]] {\n"
"lappend new $match\n"
"set once 1\n"
"}\n"
"if {!$once} {lappend new $arg}\n"
"}\n"
"}\n"
"set argv $new\n"

View File

@ -15,6 +15,7 @@ Options:
--info Show info on existing SQLite TCL extension installs
--install-only Install an extension previously build
--uninstall Uninstall the extension
--destdir DIR Installation root (used by "make install DESTDIR=...")
Other options are retained and passed through into the compiler.}
@ -25,6 +26,7 @@ set uninstall 0
set infoonly 0
set CC {}
set OPTS {}
set DESTDIR ""; # --destdir "$(DESTDIR)"
for {set ii 0} {$ii<[llength $argv]} {incr ii} {
set a0 [lindex $argv $ii]
if {$a0=="--install-only"} {
@ -42,6 +44,9 @@ for {set ii 0} {$ii<[llength $argv]} {incr ii} {
} elseif {$a0=="--cc" && $ii+1<[llength $argv]} {
incr ii
set CC [lindex $argv $ii]
} elseif {$a0=="--destdir" && $ii+1<[llength $argv]} {
incr ii
set DESTDIR [lindex $argv $ii]
} elseif {[string match -* $a0]} {
append OPTS " $a0"
} else {
@ -140,12 +145,15 @@ if {$tcl_platform(platform)=="windows"} {
if {[string length $OPTS]>1} {
append LDFLAGS $OPTS
}
set CMD [subst $cmd]
if {$TCLMAJOR>8} {
set OUT libtcl9sqlite$VERSION.$SUFFIX
} else {
set OUT libsqlite$VERSION.$SUFFIX
}
set @ $OUT; # Workaround for https://sqlite.org/forum/forumpost/0683a49cb02f31a1
# in which Gentoo edits their tclConfig.sh to include an soname
# linker flag which includes ${@} (the target file's name).
set CMD [subst $cmd]
}
# Show information about prior installs
@ -193,7 +201,15 @@ if {$install} {
#
set DEST {}
foreach dir $auto_path {
if {[file writable $dir]} {
if {[string match //*:* $dir]} {
# We can't install to //zipfs: paths
continue
} elseif {"" ne $DESTDIR && ![file writable $DESTDIR]} {
continue
}
set dir ${DESTDIR}$dir
if {[file writable $dir] || "" ne $DESTDIR} {
# the dir will be created later ^^^^^^^^
set DEST $dir
break
} elseif {[glob -nocomplain $dir/sqlite3*/pkgIndex.tcl]!=""} {
@ -211,7 +227,7 @@ if {$install} {
puts "to work around this problem.\n"
puts "These are the (unwritable) \$auto_path directories:\n"
foreach dir $auto_path {
puts " * $dir"
puts " * ${DESTDIR}$dir"
}
exit 1
}