1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-10-23 21:49:02 +03:00

Improve support for --with-tcl in cross-compilation environments, as discussed in [forum:fe9e99eb27c8c2ba|forum thread 2026-08-15T18:21:17Z].

FossilOrigin-Name: d4330c79a477bab7e86aba860813f4f83e9af5ef8067698fcdf41efd6a0e8516
This commit is contained in:
stephan
2026-10-04 19:51:51 +00:00
3 changed files with 126 additions and 69 deletions

View File

@@ -231,27 +231,36 @@ proc sqlite-configure {buildMode configScript} {
}
}
# Options for TCL support
# Options for Tcl support
tcl {
{canonical} {
tcl=1
=> {Disable components which require TCL, including all tests.
This tree requires TCL for code generation but can use the in-tree
copy of autosetup/jimsh0.c for that. The SQLite TCL extension and the
=> {Disable components which require Tcl, including all tests.
This tree requires Tcl for code generation but can use the in-tree
copy of autosetup/jimsh0.c for that. The SQLite Tcl extension and the
test code require a canonical tclsh.}
with-tcl:DIR
=> {Directory containing tclConfig.sh or a directory one level up from
that, from which we can derive a directory containing tclConfig.sh.
A dir name of "prefix" is equivalent to the directory specified by
the --prefix flag.}
the --prefix flag.
This determines the Tcl that SQLite will link against. It
does not affect the Tcl that is executed as part of the
build.}
with-tclsh:PATH
=> {Full pathname of tclsh to use. It is used for (A) trying to find
tclConfig.sh and (B) all TCL-based code generation. Use --with-tcl
unless you have a specific need for this flag. Warning: if its
containing dir has multiple tclsh versions, it may select the
wrong tclConfig.sh!}
=> {Full pathname of tclsh to use. It is used for all Tcl-based
code generation.
Additionally, when doing a native (build = host) build, it
may also be used as a legacy fallback to find tclConfig.sh
if --with-tcl does not say where that is. Relying on that
is not recommended. Warning: if its containing dir has
multiple tclsh versions, it may select the wrong
tclConfig.sh! The safe thing is to only pass --with-tclsh
if one also passes --with-tcl.}
static-tclsqlite3=0
=> {Statically-link tclsqlite3. This only works if TCL support is
=> {Statically-link tclsqlite3. This only works if Tcl support is
enabled and all requisite libraries are available in
static form. Note that glibc is unable to fully statically
link certain libraries required by tclsqlite3, so this won't
@@ -444,7 +453,7 @@ proc sqlite-configure {buildMode configScript} {
if {[catch {options {}} msg xopts]} {
# Workaround for <https://github.com/msteveb/autosetup/issues/73>
# where [options] behaves oddly on _some_ TCL builds when it's
# where [options] behaves oddly on _some_ Tcl builds when it's
# called from deeper than the global scope.
dict incr xopts -level
return {*}$xopts $msg
@@ -1906,39 +1915,59 @@ proc sqlite-handle-wasi-sdk {} {
}; # sqlite-handle-wasi-sdk
########################################################################
# TCL...
# Tcl...
#
# sqlite-check-tcl performs most of the --with-tcl and --with-tclsh
# handling. Some related bits and pieces are performed before and
# after that function is called.
#
# Important [define]'d vars:
# Important [define]'d vars. They can be split into library and tool vars.
#
# - HAVE_TCL indicates whether we have a tclsh suitable for building
# the TCL SQLite extension and, by extension, the testing
# infrastructure. This must only be 1 for environments where
# tclConfig.sh can be found.
# Tcl library vars:
#
# - TCLSH_CMD is the path to the canonical tclsh or "". It never
# refers to jimtcl.
# - HAVE_TCL indicates whether we have the Tcl that the SQLite Tcl
# extension will be linked with, and so whether that extension is
# built. This is 1 for environments where tclConfig.sh can be found.
# That file describes a library to link against, so whether any tclsh
# can be run is a separate matter, and none is needed for this.
#
# - TCL_CONFIG_SH is the path to tclConfig.sh or "".
#
# - TCLLIBDIR is the dir to which libtclsqlite3 gets installed.
#
# Tcl tool vars:
#
# - TCLSH_CMD is the path to the canonical tclsh or "". It never
# refers to jimtcl.
#
# - BTCLSH = the path to the tcl interpreter used for in-tree code
# generation. It may be jimtcl or the canonical tclsh but may not
# be empty - this tree requires TCL to generated numerous
# generation. It may be jimtcl or the canonical tclsh but may not be
# empty, as Tcl code is run as part of the build to generate numerous
# components.
#
# If --tcl or --with-tcl are provided but no TCL is found, this
# The two configure CLI flags are separated by which set of variables
# they affect. --with-tcl affects only Tcl library vars, and
# --with-tclsh almost only affects Tcl tool vars. There is just one
# exception: when compiling natively, a tclsh is asked where its own
# tclConfig.sh is if --with-tcl is not passed.
#
# This distinction is good in any event to separate concerns, but it is
# especially important for cross compilation. In that case, the Tcl that
# SQLite links against will be one that runs on the host platform, while
# the Tcl that SQLite's build scripts use at build time will run on the
# build platform. Mixing up the two flags and the two kinds of vars is
# likely to break cross compilation; that is why the one exception to
# the separation is strictly confined to the native compilation case.
# See: https://sqlite.org/forum/forumpost/fe9e99eb27c8c2ba
#
# If --tcl or --with-tcl are provided but no Tcl is found, this
# function fails fatally. If they are not explicitly provided then
# failure to find TCL is not fatal but a loud warning will be emitted.
# failure to find Tcl is not fatal but a loud warning will be emitted.
#
proc sqlite-check-tcl {} {
define TCLSH_CMD false ; # Significant is that it exits with non-0
define HAVE_TCL 0 ; # Will be enabled via --tcl or a successful search
define TCLLIBDIR "" ; # Installation dir for TCL extension lib
define TCLLIBDIR "" ; # Installation dir for Tcl extension lib
define TCL_CONFIG_SH ""; # full path to tclConfig.sh
# Clear out all vars which would harvest from tclConfig.sh so that
@@ -1949,8 +1978,8 @@ proc sqlite-check-tcl {} {
file delete -force ".tclenv.sh"; # ensure no stale state from previous configures.
if {![opt-bool tcl]} {
proj-indented-notice {
NOTE: TCL is disabled via --disable-tcl. This means that none
of the TCL-based components will be built, including tests
NOTE: Tcl is disabled via --disable-tcl. This means that none
of the Tcl-based components will be built, including tests
and sqlite3_analyzer.
}
return
@@ -1977,23 +2006,39 @@ proc sqlite-check-tcl {} {
set doConfigLookup 1 ; # set to 0 to test the tclConfig.sh-not-found cases
if {"" ne $with_tclsh} {
# --with-tclsh was provided or found above. Validate it and use it
# to trump any value passed via --with-tcl=DIR.
# --with-tclsh was provided or found above. Validate it and, if
# nothing better is to be had, ask it where its tclConfig.sh is.
# The two name different things: the shell runs here, whereas
# tclConfig.sh describes the library the extension is linked
# against. The shell is a guide to that only when neither
# --with-tcl=DIR says where it is nor cross compiling puts it on
# another platform entirely.
if {![file-isexec $with_tclsh]} {
proj-fatal "TCL shell $with_tclsh is not executable"
proj-fatal "Tcl shell $with_tclsh is not executable"
} else {
define TCLSH_CMD $with_tclsh
#msg-result "Using tclsh: $with_tclsh"
}
if {$doConfigLookup &&
[catch {exec $with_tclsh $::autosetup(libdir)/find_tclconfig.tcl} result] == 0} {
set with_tcl $result
}
if {"" ne $with_tcl && [file isdir $with_tcl]} {
msg-result "$with_tclsh recommends the tclConfig.sh from $with_tcl"
if {"" ne $with_tcl} {
# --with-tcl was given explicitly; do not second-guess it with tclsh.
} elseif {$::sqliteConfig(is-cross-compiling)} {
# This tclsh runs on the build platform, so the tclConfig.sh it would
# recommend describes Tcl for here, not for the host platform.
proj-warn "Cannot ask $with_tclsh to recommend a tclConfig.sh because we are cross compiling."
# Leave with_tcl empty and do not set use_tcl either way so the $libdir
# search below can still attempt to find one.
} else {
proj-warn "$with_tclsh is unable to recommend a tclConfig.sh"
set use_tcl 0
if {$doConfigLookup &&
[catch {exec $with_tclsh $::autosetup(libdir)/find_tclconfig.tcl} result] == 0} {
set with_tcl $result
}
if {"" ne $with_tcl && [file isdir $with_tcl]} {
msg-result "$with_tclsh recommends the tclConfig.sh from $with_tcl"
} else {
proj-warn "$with_tclsh is unable to recommend a tclConfig.sh"
set use_tcl 0
}
}
}
set cfg ""
@@ -2040,7 +2085,7 @@ proc sqlite-check-tcl {} {
break
}
define TCL_CONFIG_SH $cfg
# Export a subset of tclConfig.sh to the current TCL-space. If $cfg
# 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.
proj-tclConfig-sh-to-autosetup $cfg
@@ -2076,7 +2121,7 @@ proc sqlite-check-tcl {} {
set tcllibdir [get-env TCLLIBDIR ""]
set sq3Ver [get-define PACKAGE_VERSION]
if {"" eq $tcllibdir} {
# Attempt to extract TCLLIBDIR from TCL's $auto_path
# Attempt to extract TCLLIBDIR from Tcl's $auto_path
if {"" ne $with_tclsh &&
[catch {exec echo "puts stdout \$auto_path" | "$with_tclsh"} result] == 0} {
foreach i $result {
@@ -2097,57 +2142,65 @@ proc sqlite-check-tcl {} {
if {[file-isexec $with_tclsh]} {
msg-result "Using tclsh: $with_tclsh"
if {$cfg ne ""} {
define HAVE_TCL 1
} else {
proj-warn "Found tclsh but no tclConfig.sh."
}
}
# tclConfig.sh describes what the extension is built against.
# Whether a tclsh can be run here is a separate question, affecting
# code generation and the test suite.
if {$cfg ne ""} {
define HAVE_TCL 1
} elseif {[file-isexec $with_tclsh]} {
proj-warn "Found tclsh (${with_tclsh}) but no tclConfig.sh."
}
show-notices
# If TCL is not found: if it was explicitly requested then fail
# If Tcl is not found: if it was explicitly requested then fail
# fatally, else just emit a warning. If we can find the APIs needed
# to generate a working JimTCL then that will suffice for build-time
# TCL purposes (see: proc sqlite-determine-codegen-tcl).
# to generate a working JimTcl then that will suffice for build-time
# Tcl purposes (see: proc sqlite-determine-codegen-tcl).
if {![get-define HAVE_TCL] &&
([proj-opt-was-provided tcl] || [proj-opt-was-provided with-tcl])} {
proj-fatal "TCL support was requested but no tclConfig.sh could be found."
proj-fatal "Tcl support was requested but no tclConfig.sh could be found."
}
if {"" eq $cfg} {
proj-assert {0 == [get-define HAVE_TCL]}
proj-indented-notice {
WARNING: Cannot find a usable tclConfig.sh file. Use
--with-tcl=DIR to specify a directory where tclConfig.sh can be
found. SQLite does not use TCL internally, but some optional
components require TCL, including tests and sqlite3_analyzer.
found. SQLite does not use Tcl internally, but some optional
components require Tcl, including tests and sqlite3_analyzer.
}
}
}; # sqlite-check-tcl
########################################################################
# sqlite-determine-codegen-tcl checks which TCL to use as a code
# sqlite-determine-codegen-tcl checks which Tcl to use as a code
# generator. By default, prefer jimsh simply because we have it
# in-tree (it's part of autosetup) unless --with-tclsh=X is used, in
# which case prefer X.
#
# Returns the human-readable name of the TCL it selects. Fails fatally
# if it cannot detect a TCL appropriate for code generation.
# Returns the human-readable name of the Tcl it selects. Fails fatally
# if it cannot detect a Tcl appropriate for code generation.
#
# Defines:
#
# - BTCLSH = the TCL shell used for code generation. It may set this
# - BTCLSH = the Tcl shell used for code generation. It may set this
# to an unexpanded makefile var name.
#
# - CFLAGS_JIMSH = any flags needed for buildng a BTCLSH-compatible
# jimsh. The defaults may be passed on to configure as
# CFLAGS_JIMSH=...
proc sqlite-determine-codegen-tcl {} {
msg-result "Checking for TCL to use for code generation... "
msg-result "Checking for Tcl to use for code generation... "
define CFLAGS_JIMSH [proj-get-env CFLAGS_JIMSH {-O1}]
set cgtcl [opt-val with-tclsh jimsh]
if {"jimsh" ne $cgtcl} {
# When --with-tclsh=X is used, use that for all TCL purposes,
# including in-tree code generation, per developer request.
define BTCLSH "\$(TCLSH_CMD)"
# When --with-tclsh=X is used, generate code with X rather than with
# the in-tree jimsh, per developer request.
#
# Name it directly rather than through the $(TCLSH_CMD) makefile
# var, which gets set to "false" when the extension is not built,
# but we need code generation regardless of whether the extension
# is built.
define BTCLSH $cgtcl
return $cgtcl
}
set flagsToRestore {CC CFLAGS AS_CFLAGS CPPFLAGS AS_CPPFLAGS LDFLAGS LINKFLAGS LIBS CROSS}
@@ -2163,7 +2216,7 @@ proc sqlite-determine-codegen-tcl {} {
# block.
foreach flag $flagsToRestore {define $flag ""}
define CC [get-define CC_FOR_BUILD]
# These headers are technically optional for JimTCL but necessary if
# These headers are technically optional for JimTcl but necessary if
# we want to use it for code generation:
set sysh [cc-check-includes dirent.h sys/time.h]
# jimsh0.c hard-codes #define's for HAVE_DIRENT_H and
@@ -2172,6 +2225,9 @@ proc sqlite-determine-codegen-tcl {} {
# so that we can avoid the situation that we later, at
# make-time, try to compile jimsh but it then fails due to
# missing headers (i.e. fail earlier rather than later).
#
# One of HAVE_REALPATH or HAVE__FULLPATH are required here for
# jimsh's [file normalize] to work.
if {$sysh && [cc-check-functions realpath]} {
define-append CFLAGS_JIMSH -DHAVE_REALPATH
define BTCLSH "\$(JIMSH)"
@@ -2218,7 +2274,7 @@ proc sqlite-determine-codegen-tcl {} {
proc sqlite-handle-tcl {} {
sqlite-check-tcl
if {"canonical" ne $::sqliteConfig(build-mode)} return
msg-result "TCL for code generation: [sqlite-determine-codegen-tcl]"
msg-result "Tcl for code generation: [sqlite-determine-codegen-tcl]"
# Determine the base name of the Tcl extension's DLL
#

View File

@@ -1,5 +1,5 @@
C In\sQRF,\sadd\sthe\szero-pad\sflag\sto\sthe\sdefault\sfloating-point\sformat\sin\noutput\smodes\sthat\srender\sJSON\sor\sINSERT,\sso\sthat\sinfinities\sare\sshown\nas\s9e999\sor\ssimilar\sinstead\sof\sas\s"Inf".\n[bugs:/info/2026-10-04T05:35:43Z|Bug\s2026-10-04T05:35:43Z]
D 2026-10-04T16:23:01.635
C Improve\ssupport\sfor\s--with-tcl\sin\scross-compilation\senvironments,\sas\sdiscussed\sin\s[forum:fe9e99eb27c8c2ba|forum\sthread\s2026-08-15T18:21:17Z].
D 2026-10-04T19:51:51.315
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -48,7 +48,7 @@ F autosetup/find_tclconfig.tcl 3394bcd1aad45d6af48262f50808d4f0ac4f1088ba8fa9d08
F autosetup/jimsh0.c daf13a86959fe2d055ed42d9417ceb63d698ae4b71bde959a0979ab729a83819
F autosetup/pkg-config.tcl 4e635bf39022ff65e0d5434339dd41503ea48fc53822c9c5bde88b02d3d952ba
F autosetup/proj.tcl 67683f214977a416baafc4c1020f9940ff047a7306b2292c5872d6287460b7d5
F autosetup/sqlite-config.tcl ab8665286daf9ca1af3e682756ffe7a503557810d004b5bed1617697e83db7be
F autosetup/sqlite-config.tcl 062c021fb0377cb9091135d6805b5e1c697b5276c642c72fe1245c9feee9e4e4
F autosetup/system.tcl 51d4be76cd9a9074704b584e5c9cbba616202c8468cf9ba8a4f8294a7ab1dba9
F autosetup/teaish/README.txt b40071e6f8506500a2f7f71d5fc69e0bf87b9d7678dd9da1e5b4d0acbf40b1ca
F autosetup/teaish/core.tcl e014dd95900c7f9a34e8e0f460f47e94841059827bce8b4c49668b0c7ae3f1a0
@@ -2278,8 +2278,9 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
P 13d8921bcabc4a5a5295652d29982ae18cf0190299ee9e655c7e0f2b4d658de9
R 0ceba5ad22fd1ee5ba51bdbe29be0267
U drh
Z d39b9be8ac32d01a2cfeb392365ca86d
P f63139ba68bc7df770bbd3c26bcd760c479889fb45fa921e9e225e38c9e2044c 41f095e34974da53170200719a069c0a30110e27a1db85f562bbe744a40e9a80
R 771ec5fa0646617381291d7cfe227f57
T +closed 41f095e34974da53170200719a069c0a30110e27a1db85f562bbe744a40e9a80 Closed\sby\sintegrate-merge.
U stephan
Z 644ec730ae144cd98eb5e04d50c3db8f
# Remove this line to create a well-formed Fossil manifest.

View File

@@ -1 +1 @@
f63139ba68bc7df770bbd3c26bcd760c479889fb45fa921e9e225e38c9e2044c
d4330c79a477bab7e86aba860813f4f83e9af5ef8067698fcdf41efd6a0e8516