0
0
mirror of https://github.com/sqlite/sqlite.git synced 2024-11-21 19:29:09 +01:00

When --with-wasi-sdk is active, temporarily swap CC and CC_FOR_BUILD for purposes of looking for APIs required by B.cc.

FossilOrigin-Name: 435f2ee818d7181551c6860b6bc4db97f82d76b58fd82765a6cf49e2d02ff18c
This commit is contained in:
stephan 2024-10-31 06:38:30 +00:00
parent c6cfc8e3ea
commit 0e07bc36d9
3 changed files with 75 additions and 60 deletions

121
auto.def
View File

@ -225,7 +225,6 @@ define PACKAGE_URL {https://sqlite.org}
define PACKAGE_VERSION $PACKAGE_VERSION
define PACKAGE_STRING "[get-define PACKAGE_NAME] $PACKAGE_VERSION"
define PACKAGE_BUGREPORT [get-define PACKAGE_URL]/forum
msg-result "srcdir = $srcdir"
msg-result "top_srcdir = $top_srcdir"
msg-result [proj-bold "Configuring SQLite version $PACKAGE_VERSION"]
@ -242,7 +241,7 @@ foreach arg $::autosetup(argv) {
}
# Are we cross-compiling?
set cross_compiling [proj-is-cross-compiling]
set isCrossCompiling [proj-is-cross-compiling]
if {![file exists sqlite3.pc.in]} {
msg-result "This appears to be an out-of-tree build."
}
@ -314,41 +313,51 @@ define BUILD_CFLAGS [get-env BUILD_CFLAGS {-g}]
########################################################################
# Handle --with-wasi-sdk=DIR
#
# This must be early because it may change the toolchain and disable
# several config options.
# 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]
define HAVE_WASI_SDK 0
#puts "x wasiSdkDir=$wasiSdkDir foo=[lindex [opt-val with-wasi-sdk] end]"
if {$wasiSdkDir eq ""} {
return 0
} elseif {$::cross_compiling} {
} elseif {$::isCrossCompiling} {
proj-fatal "Cannot combine --with-wasi-sdk with cross-compilation"
}
msg-result "Checking WASI SDK directory \[$wasiSdkDir]... "
#puts "prefix = [prefix $wasiSdkDir/bin {clang ld}]"
proj-affirm-files-exist -v {*}[prefix "$wasiSdkDir/bin/" {clang wasm-ld}]
msg-result "Using wasi-sdk clang, disabling: tcl, CLI shell, DLL, loadable extensions, threading"
define HAVE_WASI_SDK 1
define WASI_SDK_DIR $wasiSdkDir
proj-opt-set load-extension 0 ;# ==> --disable-load-extension
proj-opt-set threadsafe 0 ;# ==> --threadsafe=0
proj-opt-set tcl 0 ;# ==> --disable-tcl
proj-opt-set shared 0 ;# ==> --disable-shared
set cross_compiling 1
# Disable numerous options which we know either can't work or are
# not useful in this build...
msg-result [proj-bold "Using wasi-sdk clang. Disabling CLI shell and forcing:"]
foreach opt {
editline
gcov
load-extension
readline
shared
tcl
threadsafe
} {
msg-result " --disable-$opt"
proj-opt-set $opt 0
}
# Remember that we now have a discrepancy beteween
# $::isCrossCompiling and [proj-is-cross-compiling].
set ::isCrossCompiling 1
# Changing --host and --target have no effect here except to possibly
# cause confusion. autoconf has finished processing them by this
# point.
#
# Changing --host and --target have no effect here except to
# possibly cause confusion. Autosetup 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.
# XXX CC="${wasiSdkDir}/bin/clang"
# XXX LD="${wasiSdkDir}/bin/wasm-ld"
# XXX RANLIB="${wasiSdkDir}/bin/llvm-ranlib"
#
define CC "${wasiSdkDir}/bin/clang"
define LD "${wasiSdkDir}/bin/wasm-ld"
#define STRIP "${wasiSdkDir}/bin/strip"
@ -387,7 +396,7 @@ cc-check-includes \
inttypes.h
if {[cc-check-includes zlib.h] && [proj-check-function-in-lib deflate z]} {
# TODO: port over the more sophisticated zlib search from the fossil auto.def
# TODO? port over the more sophisticated zlib search from the fossil auto.def
define HAVE_ZLIB 1
define LDFLAGS_ZLIB -lz
sqlite-add-shell-opt -DSQLITE_HAVE_ZLIB=1
@ -648,45 +657,51 @@ proc sqlite-determine-codegen-tcl {} {
msg-result "Checking for TCL to use for code generation... "
define CFLAGS_JIMSH {}
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)"
} else {
# 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]
if {$sysh && [cc-check-functions realpath]} {
define-append CFLAGS_JIMSH -DHAVE_REALPATH
define BTCLSH "\$(JIMSH)"
} elseif {$sysh && [cc-check-functions _fullpath]} {
# _fullpath() is a Windows API
define-append CFLAGS_JIMSH -DHAVE__FULLPATH
define BTCLSH "\$(JIMSH)"
} elseif {[file exists [get-define TCLSH_CMD]]} {
set cgtcl [get-define TCLSH_CMD]
define-push {CC} {
# We have to swap CC to CC_FOR_BUILD for purposes of the various
# [cc-...] tests below. Recall that --with-wasi-sdk may have
# swapped out CC with one which is not appropriate for this block.
define CC [get-define CC_FOR_BUILD]
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)"
} else {
# One last-ditch effort to find TCLSH_CMD: use info from
# tclConfig.sh to try to find a tclsh
if {"" eq [get-define TCLSH_CMD]} {
set tpre [get-define TCL_EXEC_PREFIX]
if {"" ne $tpre} {
set tv [get-define TCL_VERSION]
if {[file-isexec "${tpre}/bin/tclsh${tv}"]} {
define TCLSH_CMD "${tpre}/bin/tclsh${tv}"
} elseif {[file-isexec "${tpre}/bin/tclsh"]} {
define TCLSH_CMD "${tpre}/bin/tclsh"
# 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]
if {$sysh && [cc-check-functions realpath]} {
define-append CFLAGS_JIMSH -DHAVE_REALPATH
define BTCLSH "\$(JIMSH)"
} elseif {$sysh && [cc-check-functions _fullpath]} {
# _fullpath() is a Windows API
define-append CFLAGS_JIMSH -DHAVE__FULLPATH
define BTCLSH "\$(JIMSH)"
} elseif {[file exists [get-define TCLSH_CMD]]} {
set cgtcl [get-define TCLSH_CMD]
define BTCLSH "\$(TCLSH_CMD)"
} else {
# One last-ditch effort to find TCLSH_CMD: use info from
# tclConfig.sh to try to find a tclsh
if {"" eq [get-define TCLSH_CMD]} {
set tpre [get-define TCL_EXEC_PREFIX]
if {"" ne $tpre} {
set tv [get-define TCL_VERSION]
if {[file-isexec "${tpre}/bin/tclsh${tv}"]} {
define TCLSH_CMD "${tpre}/bin/tclsh${tv}"
} elseif {[file-isexec "${tpre}/bin/tclsh"]} {
define TCLSH_CMD "${tpre}/bin/tclsh"
}
}
}
set cgtcl [get-define TCLSH_CMD]
if {![file exists $cgtcl]} {
proj-fatal "Cannot find a tclsh to use for code generation."
}
define BTCLSH "\$(TCLSH_CMD)"
}
set cgtcl [get-define TCLSH_CMD]
if {![file exists $cgtcl]} {
proj-fatal "Cannot find a tclsh to use for code generation."
}
define BTCLSH "\$(TCLSH_CMD)"
}
}
}; # CC swap-out
return $cgtcl
}; # sqlite-determine-codegen-tcl
msg-result "TCL for code generation: [sqlite-determine-codegen-tcl]"
@ -859,7 +874,7 @@ proc sqlite-check-line-editing {} {
set rlInc [opt-val with-readline-cflags auto]
if {"auto" eq $rlInc} {
set rlInc ""
if {$::cross_compiling} {
if {$::isCrossCompiling} {
# ^^^ this check is derived from the legacy configure script.
proj-warn "Skipping check for readline.h because we're cross-compiling."
} else {

View File

@ -1,5 +1,5 @@
C Change\sdefault\sCFLAGS\sto\s{-g\s-O2}\sto\smatch\sthe\slegacy\sbuild.
D 2024-10-31T05:47:56.652
C When\s--with-wasi-sdk\sis\sactive,\stemporarily\sswap\sCC\sand\sCC_FOR_BUILD\sfor\spurposes\sof\slooking\sfor\sAPIs\srequired\sby\sB.cc.
D 2024-10-31T06:38:30.018
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md c5b4009dca54d127d2d6033c22fd9cc34f53bedb6ef12c7cbaa468381c74ab28
@ -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 b4d03e1a29472666304c17e4cad8957bf9608fdb69ba604fae42280cfe6d76b1
F auto.def d1e7ea57121be95dce59cd908a72e871c3217664d9a9cd6bcfbefbb602d94f67
F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903
F autoconf/Makefile.am adedc1324b6a87fdd1265ddd336d2fb7d4f36a0e77b86ea553ae7cc4ea239347
F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac
@ -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 1d2ecae1304d9f677bd50eaae6bd9cb25cb75c611d88a30839f5287a7a97d7d5
R 7bbd44495a31d853a8cdadac4c7a9a6c
P 511774942903277b3d38f28336599667df20f94a8de79746b6c236b827b7ffc6
R 826bef03c13c186e5e25d69159376b65
U stephan
Z d036e10613b3c2839c9ebbb2201382e3
Z 31d99618f66414cd664007258185ba71
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
511774942903277b3d38f28336599667df20f94a8de79746b6c236b827b7ffc6
435f2ee818d7181551c6860b6bc4db97f82d76b58fd82765a6cf49e2d02ff18c