Support clients passing in LDFLAGS to configure/make, but in a more limited form than the legacy build it (i.e. only to select targets rather than all targets). Rename make-side internal uses of CFLAGS to CFLAGS.env for consistency with the new LDFLAGS.env. See discussion in [forum:5fcbea40f3|forum thread 5fcbea40f3].

FossilOrigin-Name: a5e07e8063ad50f2cf46b6be568717adc9604bd6dbf926a526de43bda2996ad0
This commit is contained in:
stephan 2024-11-08 06:22:15 +00:00
parent 6f95d95015
commit 3b306aac6e
4 changed files with 68 additions and 31 deletions

View File

@ -117,13 +117,28 @@ CC = @CC@
B.cc = @CC_FOR_BUILD@ @BUILD_CFLAGS@
T.cc = $(CC)
#
# CFLAGS is problematic because it is frequently overridden when
# invoking make, which loses things like -fPIC. So... let's avoid
# using it directly and instead add a level of indirection. We
# combine CFLAGS and CPPFLAGS here because that's the way the legacy
# build did it.
# $(CFLAGS) is problematic because it is frequently overridden when
# invoking make, which loses things like -fPIC. So... we avoid using
# it directly and instead add a level of indirection. We combine
# $(CFLAGS) and $(CPPFLAGS) here because that's the way the legacy
# build did it and many builds rely on that. See main.mk for more
# details.
#
# Historical note: the pre-3.48 build only honored CPPFLAGS at
# configure-time, and expanded them into the generated Makefile. There
# are, in that build, no uses of CPPFLAGS in the configure-expanded
# Makefile. Ergo: if a client configures with CPPFLAGS=... and then
# explicitly passes CFLAGS=... to make, the CPPFLAGS will be
# lost. That behavior is retained in 3.48+ because also honoring
# CPPFLAGS at make-time may have undesired side effects on any number
# of builds.
#
CFLAGS = @CFLAGS@ @CPPFLAGS@
#
# $(LDFLAGS) is documented in main.mk.
#
LDFLAGS = @LDFLAGS@
#
# CFLAGS.core is documented in main.mk.
#
@ -148,6 +163,9 @@ T.cc.sqlite = $(T.cc) @TARGET_DEBUG@
# Define -D_HAVE_SQLITE_CONFIG_H so that the code knows it
# can include the generated sqlite_cfg.h.
#
# main.mk will fill out T.cc.sqlite with additional flags common to
# all builds.
#
T.cc.sqlite += -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite
#
# -I$(prefix)/include is primarily so that the ICU
@ -155,9 +173,6 @@ T.cc.sqlite += -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite
#
T.cc.sqlite += -I$(prefix)/include
#
# main.mk will fill out T.cc.sqlite with some flags common to all builds.
#
# $(JIMSH) and $(CFLAGS.jimsh) are documented in main.mk. $(JIMSH)
# must start with a path component so that it can be invoked as a
@ -231,12 +246,6 @@ TCL_CONFIG_SH = @TCL_CONFIG_SH@
#TCL_EXEC_PREFIX = @TCL_EXEC_PREFIX@
#TCL_VERSION = @TCL_VERSION@
#
# $(TCLLIB_RPATH) is calculated by the configure script. Its counterpart
# in tclConfig.sh (TCL_LD_SEARCH_FLAGS) is defined in such a way as to
# make it incompatible with static makefiles.
#
#TCLLIB_RPATH = @TCLLIB_RPATH@
#
# $(TCLLIBDIR) = where to install the tcl plugin. If this is empty, it
# is calculated at make-time by the targets which need it but we
# export it here so that it can be set at configure-time, so that

46
main.mk
View File

@ -263,17 +263,41 @@ all: sqlite3.h sqlite3.c
########################################################################
########################################################################
#
# $(CFLAGS.env) holds the environment-provided $(CFLAGS).
#
# $(CFLAGS) should ideally only contain flags which are relevant for
# all binaries built for the target platform. However, many people
# like to pass it to "make" without realizing that it applies to
# dozens of apps, and they override core flags when doing so. To help
# work around that, we expect core-most CFLAGS (only), e.g. -fPIC, to
# be set in $(CFLAGS.core). That enables people to pass their other
# CFLAGS without triggering, e.g., "recompile with -fPIC" errors.
# dozens of deliverables, and they override core flags (like -fPIC)
# when doing so. To help work around that, we expect all core-most
# CFLAGS, e.g. -fPIC, to be set in $(CFLAGS.core). That enables people
# to pass their other CFLAGS without triggering, e.g., "recompile with
# -fPIC" errors.
#
# Historical note: the pre-3.48 build does not honor CPPFLAGS passed
# to make, so we do not do so here. Both the legacy and 3.48+ builds
# support CPPFLAGS passed at configure-time.
#
CFLAGS.core ?=
T.cc += $(CFLAGS.core) $(CFLAGS)
CFLAGS.env = $(CFLAGS)
T.cc += $(CFLAGS.core) $(CFLAGS.env)
#
# $(LDFLAGS.env) represents any LDFLAGS=... the client passes to
# make or configure. The historical build enabled passing-on of
# user-provided LDFLAGS, and some folks rely on that for obscure uses,
# so we do the same here, with the caveats that:
#
# 1) The legacy build applied such LDFLAGS to all link operations for
# all deliverables.
#
# 2) The 3.48+ build applies them (as of this writing) more
# selectively: search this file LDFLAGS.env to see where they're
# set. As of this writing, they only affect targets which use
# $(LDFLAGS.libsqlite3) - see that var's docs for details.
#
LDFLAGS.env = $(LDFLAGS)
#
# The difference between $(OPT_FEATURE_FLAGS) and $(OPTS) is that the
@ -346,8 +370,8 @@ T.link = $(T.cc.sqlite) $(T.link.extras)
T.link.shared = $(T.link) $(LDFLAGS.shobj)
#
# LDFLAGS.libsqlite3 should be used with any deliverable for which any
# of the following apply:
# $(LDFLAGS.libsqlite3) should be used with any deliverable for which
# any of the following apply:
#
# - Results in building libsqlite3.so
# - Compiles sqlite3.c in to an application
@ -361,7 +385,8 @@ T.link.shared = $(T.link) $(LDFLAGS.shobj)
LDFLAGS.libsqlite3 = \
$(LDFLAGS.rpath) $(LDFLAGS.pthread) \
$(LDFLAGS.math) $(LDFLAGS.dlopen) \
$(LDFLAGS.zlib) $(LDFLAGS.icu)
$(LDFLAGS.zlib) $(LDFLAGS.icu) \
$(LDFLAGS.env)
#
# $(install-dir.XYZ) = dirs for installation.
@ -1474,7 +1499,10 @@ tclsqlite3.c: sqlite3.c
echo '#endif /* USE_SYSTEM_SQLITE */' >>tclsqlite3.c
cat $(TOP)/src/tclsqlite.c >>tclsqlite3.c
CFLAGS.tclextension = $(CFLAGS.intree_includes) $(CFLAGS) $(OPT_FEATURE_FLAGS) $(OPTS)
#
# $(CFLAGS.tclextension) = CFLAGS for the tclextension* targets.
#
CFLAGS.tclextension = $(CFLAGS.intree_includes) $(CFLAGS.env) $(OPT_FEATURE_FLAGS) $(OPTS)
#
# Build the SQLite TCL extension in a way that make it compatible
# with whatever version of TCL is running as $TCLSH_CMD, possibly defined

View File

@ -1,9 +1,9 @@
C Disable\ssetting\sof\sthe\sSONAME\s(enabled\sby\s[2a2419ef742]),\sas\sit's\snot\sclear\swhether\sblindly\ssetting\sthe\sSONAME,\swhich\snow\sdiffers\sfrom\sits\shistorical\svalue,\swill\scause\smore\sgrief\sthan\sit\ssolves.\sAdd\sa\s(disabled)\sexperiment\swhich\spermits\ssetting\s(or\snot)\sthe\sSONAME\sto\sthe\slegacy\sor\scurrent\svalues.\sThis\schange\sis\sup\sfor\sfurther\schange\sas\sexperimentation\sproves\swhether\swe\struly\sneed/want\sthe\sSONAME.\sSee\sdiscussion\sin/around\s[forum:0c6fc6f46b2cb3|forum\spost\s0c6fc6f46b2cb3].
D 2024-11-08T05:26:26.094
C Support\sclients\spassing\sin\sLDFLAGS\sto\sconfigure/make,\sbut\sin\sa\smore\slimited\sform\sthan\sthe\slegacy\sbuild\sit\s(i.e.\sonly\sto\sselect\stargets\srather\sthan\sall\stargets).\sRename\smake-side\sinternal\suses\sof\sCFLAGS\sto\sCFLAGS.env\sfor\sconsistency\swith\sthe\snew\sLDFLAGS.env.\sSee\sdiscussion\sin\s[forum:5fcbea40f3|forum\sthread\s5fcbea40f3].
D 2024-11-08T06:22:15.700
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d
F Makefile.in 3a54957d16c3f4666922f170a19b4b51dc13be039c29394dd38caa95ade5d731
F Makefile.in 007ddc95bc4954ea83219dae8205f124b6d4af247956de3d512af2efee79218a
F Makefile.linux-generic bd3e3cacd369821a6241d4ea1967395c962dfe3057e38cb0a435cee0e8b789d0
F Makefile.msc a92237976eb92c5efaa0dd2524746aec12c196e12df8d4dbff9543a4648c3312
F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159
@ -699,7 +699,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 e9cdc9dd617abea4e60cb823bb18737753f8a4f31c03900c0d63bd569e1ef88b
F main.mk 28f98d4289bd9b07c3b9b7ee66b7128e798bf5ff8a195b8bd585637f7abf9dd8
F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421
@ -2201,8 +2201,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 108863ec7998e0a35569e3c6534b538f00d4ef87fdb316bd6a4a9a7a272bba47
R f90970b8630851bf2dd23d5bfdfec6bf
P d931456805e7d5c3379ca68b97a0a1d4ab1eb80c5e90c169cf43fc8239247d25
R 17f80016988fb1a73179c22ffceb038b
U stephan
Z a7d1a2cb3cf805ad0ba907d86397dd96
Z a78bacddad60c62677dda4a3ed053059
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
d931456805e7d5c3379ca68b97a0a1d4ab1eb80c5e90c169cf43fc8239247d25
a5e07e8063ad50f2cf46b6be568717adc9604bd6dbf926a526de43bda2996ad0