From 8fdd80501b8c8031939836d281a41bc205781b21 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 6 Dec 2021 10:51:15 +0100 Subject: [PATCH 1/6] bpo-45774: Harden SQLite detection - Beautify configure output - Make sure vital functions are in place --- configure | 610 +++++++++++++++++++++++++++++++++++++++++++++++--- configure.ac | 94 +++++--- pyconfig.h.in | 3 + 3 files changed, 639 insertions(+), 68 deletions(-) diff --git a/configure b/configure index 444dd675a2dda7..17a43c93c2d7b7 100755 --- a/configure +++ b/configure @@ -1713,9 +1713,11 @@ Optional Features: no) --enable-optimizations enable expensive, stable optimizations (PGO, etc.) (default is no) - --enable-loadable-sqlite-extensions - support loadable extensions in _sqlite module, see - Doc/library/sqlite3.rst (default is no) + + --enable-loadable-sqlite-extensions + support loadable extensions in the sqlite3 module, + see Doc/library/sqlite3.rst (default is no) + --enable-ipv6 enable ipv6 (with ipv4) support, see Doc/library/socket.rst (default is yes if supported) --enable-big-digits[=15|30] @@ -11898,20 +11900,47 @@ $as_echo "yes" >&6; } fi as_fn_append LIBSQLITE3_CFLAGS ' -I$(srcdir)/Modules/_sqlite' + + save_CFLAGS=$CFLAGS save_CPPFLAGS=$CPPFLAGS save_LDFLAGS=$LDFLAGS save_LIBS=$LIBS + CPPFLAGS="$LIBSQLITE3_CFLAGS $CFLAGS" LDFLAGS="$LIBSQLITE3_LIBS $LDFLAGS" ac_fn_c_check_header_mongrel "$LINENO" "sqlite3.h" "ac_cv_header_sqlite3_h" "$ac_includes_default" if test "x$ac_cv_header_sqlite3_h" = xyes; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_open_v2 in -lsqlite3" >&5 -$as_echo_n "checking for sqlite3_open_v2 in -lsqlite3... " >&6; } -if ${ac_cv_lib_sqlite3_sqlite3_open_v2+:} false; then : + have_sqlite3=yes + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + + #include + #if SQLITE_VERSION_NUMBER < 3007015 + # error "SQLite 3.7.15 or higher required" + #endif + +int +main () +{ + + ; + return 0; +} + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + have_supported_sqlite3=yes + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_bind_double in -lsqlite3" >&5 +$as_echo_n "checking for sqlite3_bind_double in -lsqlite3... " >&6; } +if ${ac_cv_lib_sqlite3_sqlite3_bind_double+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -11925,59 +11954,552 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char sqlite3_open_v2 (); +char sqlite3_bind_double (); int main () { -return sqlite3_open_v2 (); +return sqlite3_bind_double (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_sqlite3_sqlite3_open_v2=yes + ac_cv_lib_sqlite3_sqlite3_bind_double=yes else - ac_cv_lib_sqlite3_sqlite3_open_v2=no + ac_cv_lib_sqlite3_sqlite3_bind_double=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_open_v2" >&5 -$as_echo "$ac_cv_lib_sqlite3_sqlite3_open_v2" >&6; } -if test "x$ac_cv_lib_sqlite3_sqlite3_open_v2" = xyes; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_bind_double" >&5 +$as_echo "$ac_cv_lib_sqlite3_sqlite3_bind_double" >&6; } +if test "x$ac_cv_lib_sqlite3_sqlite3_bind_double" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSQLITE3 1 +_ACEOF - have_sqlite3=yes - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + LIBS="-lsqlite3 $LIBS" + +else + + have_supported_sqlite3=no + +fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_column_decltype in -lsqlite3" >&5 +$as_echo_n "checking for sqlite3_column_decltype in -lsqlite3... " >&6; } +if ${ac_cv_lib_sqlite3_sqlite3_column_decltype+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsqlite3 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sqlite3_column_decltype (); +int +main () +{ +return sqlite3_column_decltype (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_sqlite3_sqlite3_column_decltype=yes +else + ac_cv_lib_sqlite3_sqlite3_column_decltype=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_column_decltype" >&5 +$as_echo "$ac_cv_lib_sqlite3_sqlite3_column_decltype" >&6; } +if test "x$ac_cv_lib_sqlite3_sqlite3_column_decltype" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSQLITE3 1 +_ACEOF + + LIBS="-lsqlite3 $LIBS" + +else + + have_supported_sqlite3=no + +fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_column_double in -lsqlite3" >&5 +$as_echo_n "checking for sqlite3_column_double in -lsqlite3... " >&6; } +if ${ac_cv_lib_sqlite3_sqlite3_column_double+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsqlite3 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sqlite3_column_double (); +int +main () +{ +return sqlite3_column_double (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_sqlite3_sqlite3_column_double=yes +else + ac_cv_lib_sqlite3_sqlite3_column_double=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_column_double" >&5 +$as_echo "$ac_cv_lib_sqlite3_sqlite3_column_double" >&6; } +if test "x$ac_cv_lib_sqlite3_sqlite3_column_double" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSQLITE3 1 +_ACEOF + + LIBS="-lsqlite3 $LIBS" + +else + + have_supported_sqlite3=no + +fi + - #include - #if SQLITE_VERSION_NUMBER < 3007015 - # error "SQLite 3.7.15 or higher required" - #endif + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_complete in -lsqlite3" >&5 +$as_echo_n "checking for sqlite3_complete in -lsqlite3... " >&6; } +if ${ac_cv_lib_sqlite3_sqlite3_complete+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsqlite3 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sqlite3_complete (); int main () { +return sqlite3_complete (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_sqlite3_sqlite3_complete=yes +else + ac_cv_lib_sqlite3_sqlite3_complete=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_complete" >&5 +$as_echo "$ac_cv_lib_sqlite3_sqlite3_complete" >&6; } +if test "x$ac_cv_lib_sqlite3_sqlite3_complete" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSQLITE3 1 +_ACEOF + + LIBS="-lsqlite3 $LIBS" + +else + + have_supported_sqlite3=no + +fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_enable_shared_cache in -lsqlite3" >&5 +$as_echo_n "checking for sqlite3_enable_shared_cache in -lsqlite3... " >&6; } +if ${ac_cv_lib_sqlite3_sqlite3_enable_shared_cache+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsqlite3 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sqlite3_enable_shared_cache (); +int +main () +{ +return sqlite3_enable_shared_cache (); ; return 0; } +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_sqlite3_sqlite3_enable_shared_cache=yes +else + ac_cv_lib_sqlite3_sqlite3_enable_shared_cache=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_enable_shared_cache" >&5 +$as_echo "$ac_cv_lib_sqlite3_sqlite3_enable_shared_cache" >&6; } +if test "x$ac_cv_lib_sqlite3_sqlite3_enable_shared_cache" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSQLITE3 1 +_ACEOF + + LIBS="-lsqlite3 $LIBS" + +else + + have_supported_sqlite3=no +fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_progress_handler in -lsqlite3" >&5 +$as_echo_n "checking for sqlite3_progress_handler in -lsqlite3... " >&6; } +if ${ac_cv_lib_sqlite3_sqlite3_progress_handler+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsqlite3 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sqlite3_progress_handler (); +int +main () +{ +return sqlite3_progress_handler (); + ; + return 0; +} _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - have_supported_sqlite3=yes +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_sqlite3_sqlite3_progress_handler=yes else - have_supported_sqlite3=no + ac_cv_lib_sqlite3_sqlite3_progress_handler=no fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_progress_handler" >&5 +$as_echo "$ac_cv_lib_sqlite3_sqlite3_progress_handler" >&6; } +if test "x$ac_cv_lib_sqlite3_sqlite3_progress_handler" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSQLITE3 1 +_ACEOF + + LIBS="-lsqlite3 $LIBS" + +else + + have_supported_sqlite3=no + +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_result_double in -lsqlite3" >&5 +$as_echo_n "checking for sqlite3_result_double in -lsqlite3... " >&6; } +if ${ac_cv_lib_sqlite3_sqlite3_result_double+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsqlite3 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sqlite3_result_double (); +int +main () +{ +return sqlite3_result_double (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_sqlite3_sqlite3_result_double=yes +else + ac_cv_lib_sqlite3_sqlite3_result_double=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_result_double" >&5 +$as_echo "$ac_cv_lib_sqlite3_sqlite3_result_double" >&6; } +if test "x$ac_cv_lib_sqlite3_sqlite3_result_double" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSQLITE3 1 +_ACEOF + + LIBS="-lsqlite3 $LIBS" + +else + + have_supported_sqlite3=no + +fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_set_authorizer in -lsqlite3" >&5 +$as_echo_n "checking for sqlite3_set_authorizer in -lsqlite3... " >&6; } +if ${ac_cv_lib_sqlite3_sqlite3_set_authorizer+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsqlite3 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sqlite3_set_authorizer (); +int +main () +{ +return sqlite3_set_authorizer (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_sqlite3_sqlite3_set_authorizer=yes +else + ac_cv_lib_sqlite3_sqlite3_set_authorizer=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_set_authorizer" >&5 +$as_echo "$ac_cv_lib_sqlite3_sqlite3_set_authorizer" >&6; } +if test "x$ac_cv_lib_sqlite3_sqlite3_set_authorizer" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSQLITE3 1 +_ACEOF + + LIBS="-lsqlite3 $LIBS" + +else + + have_supported_sqlite3=no + +fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_trace_v2 in -lsqlite3" >&5 +$as_echo_n "checking for sqlite3_trace_v2 in -lsqlite3... " >&6; } +if ${ac_cv_lib_sqlite3_sqlite3_trace_v2+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsqlite3 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sqlite3_trace_v2 (); +int +main () +{ +return sqlite3_trace_v2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_sqlite3_sqlite3_trace_v2=yes +else + ac_cv_lib_sqlite3_sqlite3_trace_v2=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_trace_v2" >&5 +$as_echo "$ac_cv_lib_sqlite3_sqlite3_trace_v2" >&6; } +if test "x$ac_cv_lib_sqlite3_sqlite3_trace_v2" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSQLITE3 1 +_ACEOF + + LIBS="-lsqlite3 $LIBS" + +else + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_trace in -lsqlite3" >&5 +$as_echo_n "checking for sqlite3_trace in -lsqlite3... " >&6; } +if ${ac_cv_lib_sqlite3_sqlite3_trace+:} false; then : + $as_echo_n "(cached) " >&6 else - have_sqlite3=no + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsqlite3 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sqlite3_trace (); +int +main () +{ +return sqlite3_trace (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_sqlite3_sqlite3_trace=yes +else + ac_cv_lib_sqlite3_sqlite3_trace=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_trace" >&5 +$as_echo "$ac_cv_lib_sqlite3_sqlite3_trace" >&6; } +if test "x$ac_cv_lib_sqlite3_sqlite3_trace" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSQLITE3 1 +_ACEOF + + LIBS="-lsqlite3 $LIBS" + +else + + have_supported_sqlite3=no + fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_load_extension in -lsqlite3" >&5 + + + +fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_value_double in -lsqlite3" >&5 +$as_echo_n "checking for sqlite3_value_double in -lsqlite3... " >&6; } +if ${ac_cv_lib_sqlite3_sqlite3_value_double+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsqlite3 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sqlite3_value_double (); +int +main () +{ +return sqlite3_value_double (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_sqlite3_sqlite3_value_double=yes +else + ac_cv_lib_sqlite3_sqlite3_value_double=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_value_double" >&5 +$as_echo "$ac_cv_lib_sqlite3_sqlite3_value_double" >&6; } +if test "x$ac_cv_lib_sqlite3_sqlite3_value_double" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSQLITE3 1 +_ACEOF + + LIBS="-lsqlite3 $LIBS" + +else + + have_supported_sqlite3=no + +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_load_extension in -lsqlite3" >&5 $as_echo_n "checking for sqlite3_load_extension in -lsqlite3... " >&6; } if ${ac_cv_lib_sqlite3_sqlite3_load_extension+:} false; then : $as_echo_n "(cached) " >&6 @@ -12017,9 +12539,17 @@ if test "x$ac_cv_lib_sqlite3_sqlite3_load_extension" = xyes; then : have_sqlite3_load_extension=yes else have_sqlite3_load_extension=no + fi +else + + have_supported_sqlite3=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi @@ -12031,30 +12561,36 @@ LIBS=$save_LIBS -# Check for support for loadable sqlite extensions { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --enable-loadable-sqlite-extensions" >&5 $as_echo_n "checking for --enable-loadable-sqlite-extensions... " >&6; } # Check whether --enable-loadable-sqlite-extensions was given. if test "${enable_loadable_sqlite_extensions+set}" = set; then : - enableval=$enable_loadable_sqlite_extensions; if test "x$have_sqlite3_load_extension" = xno; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Your version of SQLite does not support loadable extensions" >&5 + enableval=$enable_loadable_sqlite_extensions; + if test "x$have_sqlite3_load_extension" = xno; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: n/a" >&5 +$as_echo "n/a" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Your version of SQLite does not support loadable extensions" >&5 $as_echo "$as_me: WARNING: Your version of SQLite does not support loadable extensions" >&2;} -fi + else - enable_loadable_sqlite_extensions=no -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_loadable_sqlite_extensions" >&5 -$as_echo "$enable_loadable_sqlite_extensions" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } -if test "x$enable_loadable_sqlite_extensions" = xyes; then : +$as_echo "#define PY_SQLITE_ENABLE_LOAD_EXTENSION 1" >>confdefs.h -$as_echo "#define PY_SQLITE_ENABLE_LOAD_EXTENSION 1" >>confdefs.h +fi + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi + # Check for --with-tcltk-includes=path and --with-tcltk-libs=path @@ -22866,8 +23402,8 @@ $as_echo_n "checking for stdlib extension module _sqlite3... " >&6; } *_sqlite3*) : py_cv_module__sqlite3=n/a ;; #( *) : - if test "$have_sqlite3" = "yes"; then : - if test "$have_supported_sqlite3" = "yes"; then : + if test "x$have_sqlite3" = "xyes"; then : + if test "x$have_supported_sqlite3" = "xyes"; then : py_cv_module__sqlite3=yes else py_cv_module__sqlite3=missing diff --git a/configure.ac b/configure.ac index 31544dde03fb0d..d91254e3d29ac4 100644 --- a/configure.ac +++ b/configure.ac @@ -3323,43 +3323,75 @@ PKG_CHECK_MODULES( ) AS_VAR_APPEND([LIBSQLITE3_CFLAGS], [' -I$(srcdir)/Modules/_sqlite']) -WITH_SAVE_ENV( +dnl PY_CHECK_SQLITE_FUNC(FUNCTION, IF-FOUND, IF-NOT-FOUND) +AC_DEFUN([PY_CHECK_SQLITE_FUNC], [ + AC_CHECK_LIB([sqlite3], [$1], [$2], [ + m4_ifblank([$3], [have_supported_sqlite3=no], [$3]) + ]) +]) + +WITH_SAVE_ENV([ dnl bpo-45774/GH-29507: The CPP check in AC_CHECK_HEADER can fail on FreeBSD, dnl hence CPPFLAGS instead of CFLAGS. CPPFLAGS="$LIBSQLITE3_CFLAGS $CFLAGS" LDFLAGS="$LIBSQLITE3_LIBS $LDFLAGS" AC_CHECK_HEADER([sqlite3.h], [ - AC_CHECK_LIB([sqlite3], [sqlite3_open_v2], [ - have_sqlite3=yes - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([ - #include - #if SQLITE_VERSION_NUMBER < 3007015 - # error "SQLite 3.7.15 or higher required" - #endif - ], []) - ], [have_supported_sqlite3=yes], [have_supported_sqlite3=no]) - ], [have_sqlite3=no]) - AC_CHECK_LIB([sqlite3], [sqlite3_load_extension], - [have_sqlite3_load_extension=yes], - [have_sqlite3_load_extension=no]) + have_sqlite3=yes + + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + #include + #if SQLITE_VERSION_NUMBER < 3007015 + # error "SQLite 3.7.15 or higher required" + #endif + ], []) + ], [ + have_supported_sqlite3=yes + dnl Check that required functions are in place. A lot of stuff may be + dnl omitted with SQLITE_OMIT_* compile time defines. + PY_CHECK_SQLITE_FUNC([sqlite3_bind_double]) + PY_CHECK_SQLITE_FUNC([sqlite3_column_decltype]) + PY_CHECK_SQLITE_FUNC([sqlite3_column_double]) + PY_CHECK_SQLITE_FUNC([sqlite3_complete]) + PY_CHECK_SQLITE_FUNC([sqlite3_enable_shared_cache]) + PY_CHECK_SQLITE_FUNC([sqlite3_progress_handler]) + PY_CHECK_SQLITE_FUNC([sqlite3_result_double]) + PY_CHECK_SQLITE_FUNC([sqlite3_set_authorizer]) + PY_CHECK_SQLITE_FUNC([sqlite3_trace_v2], [], [ + PY_CHECK_SQLITE_FUNC([sqlite3_trace]) + ]) + PY_CHECK_SQLITE_FUNC([sqlite3_value_double]) + AC_CHECK_LIB([sqlite3], [sqlite3_load_extension], + [have_sqlite3_load_extension=yes], + [have_sqlite3_load_extension=no] + ) + ], [ + have_supported_sqlite3=no + ]) ]) -) +]) -# Check for support for loadable sqlite extensions -AC_MSG_CHECKING(for --enable-loadable-sqlite-extensions) -AC_ARG_ENABLE(loadable-sqlite-extensions, - AS_HELP_STRING([--enable-loadable-sqlite-extensions], - [support loadable extensions in _sqlite module, see Doc/library/sqlite3.rst (default is no)]), - [AS_VAR_IF([have_sqlite3_load_extension], [no], - [AC_MSG_WARN([Your version of SQLite does not support loadable extensions])])], - [enable_loadable_sqlite_extensions=no]) -AC_MSG_RESULT($enable_loadable_sqlite_extensions) - -AS_VAR_IF([enable_loadable_sqlite_extensions], [yes], [ - AC_DEFINE(PY_SQLITE_ENABLE_LOAD_EXTENSION, 1, - [Define to 1 to build the sqlite module with loadable extensions support.]) +dnl Check for support for loadable sqlite extensions +AC_MSG_CHECKING([for --enable-loadable-sqlite-extensions]) +AC_ARG_ENABLE([loadable-sqlite-extensions], [ + AS_HELP_STRING( + [--enable-loadable-sqlite-extensions], + [support loadable extensions in the sqlite3 module, see Doc/library/sqlite3.rst (default is no)] + ) +], [ + AS_VAR_IF([have_sqlite3_load_extension], [no], [ + AC_MSG_RESULT([n/a]) + AC_MSG_WARN([Your version of SQLite does not support loadable extensions]) + ], [ + AC_MSG_RESULT([yes]) + AC_DEFINE( + [PY_SQLITE_ENABLE_LOAD_EXTENSION], [1], + [Define to 1 to build the sqlite module with loadable extensions support.] + ) + ]) +], [ + AC_MSG_RESULT([no]) ]) # Check for --with-tcltk-includes=path and --with-tcltk-libs=path @@ -6447,8 +6479,8 @@ PY_STDLIB_MOD([nis], [$LIBNSL_CFLAGS], [$LIBNSL_LIBS]) dnl PY_STDLIB_MOD([readline], [], [], [], []) PY_STDLIB_MOD([_sqlite3], - [test "$have_sqlite3" = "yes"], - [test "$have_supported_sqlite3" = "yes"], + [test "x$have_sqlite3" = "xyes"], + [test "x$have_supported_sqlite3" = "xyes"], [$LIBSQLITE3_CFLAGS], [$LIBSQLITE3_LIBS]) dnl PY_STDLIB_MOD([_tkinter], [], [], [], []) PY_STDLIB_MOD([_uuid], diff --git a/pyconfig.h.in b/pyconfig.h.in index efad243d0af8aa..55d65b082ccf5b 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -643,6 +643,9 @@ /* Define to 1 if you have the `sendfile' library (-lsendfile). */ #undef HAVE_LIBSENDFILE +/* Define to 1 if you have the `sqlite3' library (-lsqlite3). */ +#undef HAVE_LIBSQLITE3 + /* Define to 1 if you have the header file. */ #undef HAVE_LIBUTIL_H From 948a296fade59f3fbc02866c2528c740c5995eb7 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Fri, 10 Dec 2021 10:29:57 +0100 Subject: [PATCH 2/6] Address review: fix unintentional help text indentation --- configure | 4 ++-- configure.ac | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 17a43c93c2d7b7..e1dcf8de39f1ba 100755 --- a/configure +++ b/configure @@ -1714,9 +1714,9 @@ Optional Features: --enable-optimizations enable expensive, stable optimizations (PGO, etc.) (default is no) - --enable-loadable-sqlite-extensions + --enable-loadable-sqlite-extensions support loadable extensions in the sqlite3 module, - see Doc/library/sqlite3.rst (default is no) + see Doc/library/sqlite3.rst (default is no), --enable-ipv6 enable ipv6 (with ipv4) support, see Doc/library/socket.rst (default is yes if supported) diff --git a/configure.ac b/configure.ac index d91254e3d29ac4..ce18bf9bd2bdd7 100644 --- a/configure.ac +++ b/configure.ac @@ -3375,10 +3375,10 @@ dnl hence CPPFLAGS instead of CFLAGS. dnl Check for support for loadable sqlite extensions AC_MSG_CHECKING([for --enable-loadable-sqlite-extensions]) AC_ARG_ENABLE([loadable-sqlite-extensions], [ - AS_HELP_STRING( - [--enable-loadable-sqlite-extensions], - [support loadable extensions in the sqlite3 module, see Doc/library/sqlite3.rst (default is no)] - ) +AS_HELP_STRING( + [--enable-loadable-sqlite-extensions], + [support loadable extensions in the sqlite3 module, see Doc/library/sqlite3.rst (default is no)] +), ], [ AS_VAR_IF([have_sqlite3_load_extension], [no], [ AC_MSG_RESULT([n/a]) From 554d8bef59a4308a978ada1c7b51daf19a8438a2 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Fri, 10 Dec 2021 10:40:02 +0100 Subject: [PATCH 3/6] Get rid of unintentional newlines in help text Reindent contents of AC_ARG_ENABLE --- configure | 15 +++++++-------- configure.ac | 36 ++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/configure b/configure index e1dcf8de39f1ba..7569594852c2b3 100755 --- a/configure +++ b/configure @@ -1713,11 +1713,9 @@ Optional Features: no) --enable-optimizations enable expensive, stable optimizations (PGO, etc.) (default is no) - --enable-loadable-sqlite-extensions support loadable extensions in the sqlite3 module, - see Doc/library/sqlite3.rst (default is no), - + see Doc/library/sqlite3.rst (default is no) --enable-ipv6 enable ipv6 (with ipv4) support, see Doc/library/socket.rst (default is yes if supported) --enable-big-digits[=15|30] @@ -12566,16 +12564,16 @@ $as_echo_n "checking for --enable-loadable-sqlite-extensions... " >&6; } # Check whether --enable-loadable-sqlite-extensions was given. if test "${enable_loadable_sqlite_extensions+set}" = set; then : enableval=$enable_loadable_sqlite_extensions; - if test "x$have_sqlite3_load_extension" = xno; then : + if test "x$have_sqlite3_load_extension" = xno; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: n/a" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: n/a" >&5 $as_echo "n/a" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Your version of SQLite does not support loadable extensions" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Your version of SQLite does not support loadable extensions" >&5 $as_echo "$as_me: WARNING: Your version of SQLite does not support loadable extensions" >&2;} else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define PY_SQLITE_ENABLE_LOAD_EXTENSION 1" >>confdefs.h @@ -12585,9 +12583,10 @@ fi else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } + fi diff --git a/configure.ac b/configure.ac index ce18bf9bd2bdd7..1e89ce68e5948d 100644 --- a/configure.ac +++ b/configure.ac @@ -3374,25 +3374,25 @@ dnl hence CPPFLAGS instead of CFLAGS. dnl Check for support for loadable sqlite extensions AC_MSG_CHECKING([for --enable-loadable-sqlite-extensions]) -AC_ARG_ENABLE([loadable-sqlite-extensions], [ -AS_HELP_STRING( - [--enable-loadable-sqlite-extensions], - [support loadable extensions in the sqlite3 module, see Doc/library/sqlite3.rst (default is no)] -), -], [ - AS_VAR_IF([have_sqlite3_load_extension], [no], [ - AC_MSG_RESULT([n/a]) - AC_MSG_WARN([Your version of SQLite does not support loadable extensions]) +AC_ARG_ENABLE([loadable-sqlite-extensions], + AS_HELP_STRING( + [--enable-loadable-sqlite-extensions], + [support loadable extensions in the sqlite3 module, see Doc/library/sqlite3.rst (default is no)] + ), [ + AS_VAR_IF([have_sqlite3_load_extension], [no], [ + AC_MSG_RESULT([n/a]) + AC_MSG_WARN([Your version of SQLite does not support loadable extensions]) + ], [ + AC_MSG_RESULT([yes]) + AC_DEFINE( + [PY_SQLITE_ENABLE_LOAD_EXTENSION], [1], + [Define to 1 to build the sqlite module with loadable extensions support.] + ) + ]) ], [ - AC_MSG_RESULT([yes]) - AC_DEFINE( - [PY_SQLITE_ENABLE_LOAD_EXTENSION], [1], - [Define to 1 to build the sqlite module with loadable extensions support.] - ) - ]) -], [ - AC_MSG_RESULT([no]) -]) + AC_MSG_RESULT([no]) + ] +) # Check for --with-tcltk-includes=path and --with-tcltk-libs=path AC_SUBST(TCLTK_INCLUDES) From f5b0552501eb187191a5a537e640e2e111bd55d0 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Fri, 10 Dec 2021 10:45:33 +0100 Subject: [PATCH 4/6] Wrap long line --- configure.ac | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 1e89ce68e5948d..cabf687668a599 100644 --- a/configure.ac +++ b/configure.ac @@ -3376,8 +3376,10 @@ dnl Check for support for loadable sqlite extensions AC_MSG_CHECKING([for --enable-loadable-sqlite-extensions]) AC_ARG_ENABLE([loadable-sqlite-extensions], AS_HELP_STRING( - [--enable-loadable-sqlite-extensions], - [support loadable extensions in the sqlite3 module, see Doc/library/sqlite3.rst (default is no)] + [--enable-loadable-sqlite-extensions], [ + support loadable extensions in the sqlite3 module, see + Doc/library/sqlite3.rst (default is no) + ] ), [ AS_VAR_IF([have_sqlite3_load_extension], [no], [ AC_MSG_RESULT([n/a]) From e8558daab718bd0112a4551914b57463ccc31384 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Fri, 4 Mar 2022 21:24:10 +0100 Subject: [PATCH 5/6] Add NEWS item --- Misc/NEWS.d/next/Build/2022-03-04-21-24-02.bpo-45774.9AhC0r.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Build/2022-03-04-21-24-02.bpo-45774.9AhC0r.rst diff --git a/Misc/NEWS.d/next/Build/2022-03-04-21-24-02.bpo-45774.9AhC0r.rst b/Misc/NEWS.d/next/Build/2022-03-04-21-24-02.bpo-45774.9AhC0r.rst new file mode 100644 index 00000000000000..0bfc9862ef5c73 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2022-03-04-21-24-02.bpo-45774.9AhC0r.rst @@ -0,0 +1,2 @@ +``configure`` now verifies that all SQLite C APIs needed for the +:mod:`sqlite3` extension module are found. From 55f79a578023f7324a4ece5c3cd2522754f0354d Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Tue, 5 Apr 2022 10:58:04 +0200 Subject: [PATCH 6/6] Address review: normalise tests --- configure | 4 ++-- configure.ac | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 8cd8946ffb7d8f..6c24e1b53a2758 100755 --- a/configure +++ b/configure @@ -24001,8 +24001,8 @@ $as_echo "$py_cv_module_nis" >&6; } $as_echo_n "checking for stdlib extension module _sqlite3... " >&6; } if test "$py_cv_module__sqlite3" != "n/a"; then : - if test "x$have_sqlite3" = "xyes"; then : - if test "x$have_supported_sqlite3" = "xyes"; then : + if test "$have_sqlite3" = "yes"; then : + if test "$have_supported_sqlite3" = "yes"; then : py_cv_module__sqlite3=yes else py_cv_module__sqlite3=missing diff --git a/configure.ac b/configure.ac index c1d8af052c9179..286bbfb7b0ed2c 100644 --- a/configure.ac +++ b/configure.ac @@ -6832,8 +6832,8 @@ PY_STDLIB_MOD([nis], [$LIBNSL_CFLAGS], [$LIBNSL_LIBS]) dnl PY_STDLIB_MOD([readline], [], [], [], []) PY_STDLIB_MOD([_sqlite3], - [test "x$have_sqlite3" = "xyes"], - [test "x$have_supported_sqlite3" = "xyes"], + [test "$have_sqlite3" = "yes"], + [test "$have_supported_sqlite3" = "yes"], [$LIBSQLITE3_CFLAGS], [$LIBSQLITE3_LIBS]) dnl PY_STDLIB_MOD([_tkinter], [], [], [], []) PY_STDLIB_MOD([_uuid],