Skip to content
Permalink
Browse files

Unbundle libsqlite3

Since there is no need to patch libsqlite3 for our purposes, and since
libsqlite3 ≥ 3.3.9 (which is our current requirement) is widely
available on distros, there is no reason anymore to bundle the library.

Besides removing the bundled libsqlite, and adapting the configuration
respectively, we also fix the use of the SQLITE_ENABLE_COLUMN_METADATA
compile time constant to detect whether sqlite3_column_table_name() is
available by a working feature detection (otherwise bug_42589.phpt
would fail).  We also skip bug73068.phpt for libsqlite 3.11.0 to
3.14.1 which have a bug (<https://sqlite.org/src/info/ef360601>).

We also completely drop support for the obscure pdo_sqlite_external
extension (which could have been enabled on Windows only by passing
`--pdo-sqlite-external` to configure), since it is not needed anymore.

Furthermore, we remove references to the bundled libsqlite from
Makefile.gcov, CONTRIBUTING.md and README.REDIST.BINS.
  • Loading branch information
cmb69 committed Oct 6, 2018
1 parent 61330b0 commit 6083a387a81dbbd66d6316a3a12a63f06d5f7109
@@ -17,6 +17,7 @@ addons:
- libsasl2-dev
- libxpm-dev
- libzip-dev
- libsqlite3-dev


services:
@@ -154,9 +154,6 @@ locations.
└─ ...
└─ skeleton/ # Skeleton for developing new extensions with `ext/ext_skel.php`
└─ ...
└─ sqlite3/
├─ libsqlite/ # https://www.sqlite.org mirror: https://github.com/mackyle/sqlite
└─ ...
└─ standard/
└─ html_tables/
├─ mappings/ # https://www.unicode.org/Public/MAPPINGS/
@@ -57,7 +57,7 @@ php_lcov.info: lcov-test
cp $$x.bbg lcov_data/$$y.bbg ; \
fi; \
done; \
for dir in ext/bcmath/libbcmath ext/date/lib ext/fileinfo/libmagic ext/gd/libgd ext/mbstring/libmbfl ext/mbstring/oniguruma ext/pcre/pcre2lib ext/sqlite3/libsqlite ext/xmlrpc/libxmlrpc ext/zip/lib; do \
for dir in ext/bcmath/libbcmath ext/date/lib ext/fileinfo/libmagic ext/gd/libgd ext/mbstring/libmbfl ext/mbstring/oniguruma ext/pcre/pcre2lib ext/xmlrpc/libxmlrpc ext/zip/lib; do \
if test -d lcov_data/$$dir; then \
rm -rf lcov_data/$$dir ; \
fi; \
@@ -1,22 +1,21 @@
1. libmagic (ext/fileinfo) see ext/fileinfo/libmagic/LICENSE
2. Oniguruma (ext/mbstring) see ext/mbstring/oniguruma/COPYING
3. libmbfl (ext/mbstring) see ext/mbstring/libmbfl/LICENSE
4. pcre2lib (ext/pcre)
5. ext/standard crypt
6. ext/standard crypt's blowfish implementation
7. Sqlite/Sqlite3 ext/sqlite3 ext/sqlite
8. ext/standard/rand
9. ext/standard/scanf
10. ext/standard/strnatcmp.c
11. ext/standard/uuencode
12. libxmlrpc ext/xmlrpc
13. main/snprintf.c
14. main/strlcat
15. main/strlcpy
16. libgd see ext/gd/libgd/COPYING
17. ext/phar portions of tar implementations
18. ext/phar/zip.c portion extracted from libzip
19. libbcmath (ext/bcmath) see ext/bcmath/libbcmath/COPYING.LIB
1. libmagic (ext/fileinfo) see ext/fileinfo/libmagic/LICENSE
2. Oniguruma (ext/mbstring) see ext/mbstring/oniguruma/COPYING
3. libmbfl (ext/mbstring) see ext/mbstring/libmbfl/LICENSE
4. pcre2lib (ext/pcre)
5. ext/standard crypt
6. ext/standard crypt's blowfish implementation
7. ext/standard/rand
8. ext/standard/scanf
9. ext/standard/strnatcmp.c
10. ext/standard/uuencode
11. libxmlrpc ext/xmlrpc
12. main/snprintf.c
13. main/strlcat
14. main/strlcpy
15. libgd see ext/gd/libgd/COPYING
16. ext/phar portions of tar implementations
17. ext/phar/zip.c portion extracted from libzip
18. libbcmath (ext/bcmath) see ext/bcmath/libbcmath/COPYING.LIB


4. pcre2lib (ext/pcre)
@@ -195,16 +194,7 @@ Blowfish library (I can't be sure if I would think of something if I
hadn't seen his code).


7. Sqlite/Sqlite3 ext/sqlite3 ext/sqlite

The author disclaims copyright to this source code. In place of
a legal notice, here is a blessing:
May you do good and not evil.
May you find forgiveness for yourself and forgive others.
May you share freely, never taking more than you give.


8. ext/standard/rand
7. ext/standard/rand

The following php_mt_...() functions are based on a C++ class MTRand by
Richard J. Wagner. For more information see the web page at
@@ -258,7 +248,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


9. ext/standard/scanf
8. ext/standard/scanf

scanf.c --

@@ -306,7 +296,7 @@ permission to use and distribute the software in accordance with the
terms specified in this license.


10. ext/standard/strnatcmp.c
9. ext/standard/strnatcmp.c

strnatcmp.c -- Perform 'natural order' comparisons of strings in C.
Copyright (C) 2000 by Martin Pool <mbp@humbug.org.au>
@@ -328,7 +318,7 @@ freely, subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.


11. ext/standard/uuencode
10. ext/standard/uuencode

Portions of this code are based on Berkeley's uuencode/uudecode
implementation.
@@ -365,7 +355,7 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.


12. libxmlrpc ext/xmlrpc
11. libxmlrpc ext/xmlrpc

Copyright 2000 Epinions, Inc.

@@ -390,7 +380,7 @@ NEGLIGENCE), EVEN IF EPINIONS, INC. IS AWARE OF THE POSSIBILITY OF SUCH
DAMAGES.


13. main/snprintf.c
12. main/snprintf.c

Copyright (c) 2002, 2006 Todd C. Miller <Todd.Miller@courtesan.com>

@@ -465,8 +455,8 @@ SIO stdio-replacement strx_* functions by Panos Tsirigotis
<panos@alumni.cs.colorado.edu> for xinetd.


14. main/strlcat
15. main/strlcpy
13. main/strlcat
14. main/strlcpy

Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
All rights reserved.
@@ -494,7 +484,7 @@ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


17. ext/phar portions of tar implementations
16. ext/phar portions of tar implementations

portions of tar implementations in ext/phar - phar_tar_octal() are based on an
implementation by Tim Kientzle from libarchive, licensed with this license:
@@ -523,7 +513,7 @@ implementation by Tim Kientzle from libarchive, licensed with this license:
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


18. ext/phar/zip.c portion extracted from libzip
17. ext/phar/zip.c portion extracted from libzip

zip_dirent.c -- read directory entry (local or central), clean dirent
Copyright (C) 1999, 2003, 2004, 2005 Dieter Baron and Thomas Klausner
@@ -31,78 +31,50 @@ if test "$PHP_PDO_SQLITE" != "no"; then

php_pdo_sqlite_sources_core="pdo_sqlite.c sqlite_driver.c sqlite_statement.c"

if test "$PHP_PDO_SQLITE" != "yes"; then
SEARCH_PATH="$PHP_PDO_SQLITE /usr/local /usr" # you might want to change this
SEARCH_FOR="/include/sqlite3.h" # you most likely want to change this
if test -r $PHP_PDO_SQLITE/$SEARCH_FOR; then # path given as parameter
PDO_SQLITE_DIR=$PHP_PDO_SQLITE
else # search default path list
AC_MSG_CHECKING([for sqlite3 files in default path])
for i in $SEARCH_PATH ; do
if test -r $i/$SEARCH_FOR; then
PDO_SQLITE_DIR=$i
AC_MSG_RESULT(found in $i)
fi
done
fi
if test -z "$PDO_SQLITE_DIR"; then
AC_MSG_RESULT([not found])
AC_MSG_ERROR([Please reinstall the sqlite3 distribution])
fi

PHP_ADD_INCLUDE($PDO_SQLITE_DIR/include)

LIBNAME=sqlite3
LIBSYMBOL=sqlite3_open

PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
[
PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $PDO_SQLITE_DIR/$PHP_LIBDIR, PDO_SQLITE_SHARED_LIBADD)
AC_DEFINE(HAVE_PDO_SQLITELIB,1,[ ])
],[
AC_MSG_ERROR([wrong sqlite lib version or lib not found])
],[
-L$PDO_SQLITE_DIR/$PHP_LIBDIR -lm
])
PHP_CHECK_LIBRARY(sqlite3,sqlite3_key,[
AC_DEFINE(HAVE_SQLITE3_KEY,1, [have commercial sqlite3 with crypto support])
])
PHP_CHECK_LIBRARY(sqlite3,sqlite3_close_v2,[
AC_DEFINE(HAVE_SQLITE3_CLOSE_V2, 1, [have sqlite3_close_v2])
])

PHP_SUBST(PDO_SQLITE_SHARED_LIBADD)
PHP_NEW_EXTENSION(pdo_sqlite, $php_pdo_sqlite_sources_core, $ext_shared,,-I$pdo_cv_inc_path)
else
# use bundled libs
if test "$enable_maintainer_zts" = "yes"; then
threadsafe_flags="-DSQLITE_THREADSAFE=1"
else
threadsafe_flags="-DSQLITE_THREADSAFE=0"
fi

AC_DEFINE(HAVE_SQLITE3_CLOSE_V2, 1, [have sqlite3_close_v2])
other_flags="-DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_CORE=1 -DSQLITE_ENABLE_COLUMN_METADATA=1"

dnl As long as intl is not shared we can have ICU support
if test "$PHP_INTL" = "yes" && test "$PHP_INTL_SHARED" != "yes"; then
other_flags="$other_flags -DSQLITE_ENABLE_ICU=1"
SEARCH_PATH="$PHP_PDO_SQLITE /usr/local /usr" # you might want to change this
SEARCH_FOR="/include/sqlite3.h" # you most likely want to change this
if test -r $PHP_PDO_SQLITE/$SEARCH_FOR; then # path given as parameter
PDO_SQLITE_DIR=$PHP_PDO_SQLITE
else # search default path list
AC_MSG_CHECKING([for sqlite3 files in default path])
for i in $SEARCH_PATH ; do
if test -r $i/$SEARCH_FOR; then
PDO_SQLITE_DIR=$i
AC_MSG_RESULT(found in $i)
fi
done
fi
if test -z "$PDO_SQLITE_DIR"; then
AC_MSG_RESULT([not found])
AC_MSG_ERROR([Please reinstall the sqlite3 distribution])
fi

if test "$PHP_SQLITE3" != "yes"; then
PHP_ADD_SOURCES(PHP_EXT_DIR(sqlite3), libsqlite/sqlite3.c)
fi
PHP_ADD_INCLUDE($PDO_SQLITE_DIR/include)

PHP_NEW_EXTENSION(pdo_sqlite,
$php_pdo_sqlite_sources_core,
$ext_shared,,-DPDO_SQLITE_BUNDLED=1 $other_flags $threadsafe_flags -I$pdo_cv_inc_path)
LIBNAME=sqlite3
LIBSYMBOL=sqlite3_open

PHP_SUBST(PDO_SQLITE_SHARED_LIBADD)
PHP_ADD_EXTENSION_DEP(pdo_sqlite, sqlite3)
PHP_ADD_INCLUDE($abs_srcdir/ext/sqlite3/libsqlite)
PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
[
PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $PDO_SQLITE_DIR/$PHP_LIBDIR, PDO_SQLITE_SHARED_LIBADD)
AC_DEFINE(HAVE_PDO_SQLITELIB,1,[ ])
],[
AC_MSG_ERROR([wrong sqlite lib version or lib not found])
],[
-L$PDO_SQLITE_DIR/$PHP_LIBDIR -lm
])
PHP_CHECK_LIBRARY(sqlite3,sqlite3_key,[
AC_DEFINE(HAVE_SQLITE3_KEY,1, [have commercial sqlite3 with crypto support])
])
PHP_CHECK_LIBRARY(sqlite3,sqlite3_close_v2,[
AC_DEFINE(HAVE_SQLITE3_CLOSE_V2, 1, [have sqlite3_close_v2])
])
PHP_CHECK_LIBRARY(sqlite3,sqlite3_column_table_name,[
AC_DEFINE(HAVE_SQLITE3_COLUMN_TABLE_NAME, 1, [have sqlite3_column_table_name])
])

AC_CHECK_FUNCS(usleep nanosleep)
fi
PHP_SUBST(PDO_SQLITE_SHARED_LIBADD)
PHP_NEW_EXTENSION(pdo_sqlite, $php_pdo_sqlite_sources_core, $ext_shared,,-I$pdo_cv_inc_path)

dnl Solaris fix
PHP_CHECK_LIBRARY(rt, fdatasync, [PHP_ADD_LIBRARY(rt,, PDO_SQLITE_SHARED_LIBADD)])
@@ -3,23 +3,12 @@
ARG_WITH("pdo-sqlite", "for pdo_sqlite support", "no");

if (PHP_PDO_SQLITE != "no") {
EXTENSION("pdo_sqlite", "pdo_sqlite.c sqlite_driver.c sqlite_statement.c", null, "/DSQLITE_THREADSAFE=" + (PHP_ZTS == "yes" ? "1" : "0") + " /D SQLITE_ENABLE_FTS3=1 /D SQLITE_ENABLE_FTS4=1 /D SQLITE_ENABLE_FTS5=1 /D SQLITE_ENABLE_JSON1=1 /D SQLITE_ENABLE_COLUMN_METADATA=1 /D SQLITE_CORE=1 /I" + configure_module_dirname + "/../sqlite3/libsqlite /I" + configure_module_dirname);

ADD_EXTENSION_DEP('pdo_sqlite', 'pdo');
// If pdo_sqlite is static, and sqlite3 is also static, then we don't add a second copy of the sqlite3 libs
if (PHP_PDO_SQLITE_SHARED || PHP_SQLITE3_SHARED || PHP_SQLITE3 == 'no') {
ADD_SOURCES(configure_module_dirname + "/../sqlite3/libsqlite", "sqlite3.c", "pdo_sqlite");
}
}
if (SETUP_SQLITE3("pdo_sqlite", PHP_PDO_SQLITE, PHP_PDO_SQLITE_SHARED)) {
EXTENSION("pdo_sqlite", "pdo_sqlite.c sqlite_driver.c sqlite_statement.c");

ARG_WITH("pdo-sqlite-external", "for pdo_sqlite support from an external dll", "no");
if (PHP_PDO_SQLITE_EXTERNAL != "no") {
if (CHECK_HEADER_ADD_INCLUDE("sqlite3.h", "CFLAGS_PDO_SQLITE_EXTERNAL", PHP_PDO_SQLITE_EXTERNAL + ";" + PHP_PHP_BUILD + "\\include\\sqlite3") &&
CHECK_LIB("sqlite3-import.lib", "pdo_sqlite_external", PHP_PDO_SQLITE_EXTERNAL + ";" + PHP_PHP_BUILD + "\\lib")
&& ADD_EXTENSION_DEP('pdo_sqlite_external', 'pdo') ) {
EXTENSION("pdo_sqlite_external", "pdo_sqlite.c sqlite_driver.c sqlite_statement.c", null, "/I" + configure_module_dirname, null, "ext\\pdo_sqlite_external");
ADD_EXTENSION_DEP('pdo_sqlite', 'pdo');
AC_DEFINE("HAVE_SQLITE3_COLUMN_TABLE_NAME", 1, "have sqlite3_column_table_name");
} else {
WARNING("pdo-sqlite-external support can't be enabled, libraries or headers are missing")
PHP_PDO_SQLITE_EXTERNAL = "no"
WARNING("pdo_sqlite not enabled; libraries and/or headers not found");
}
}
@@ -331,7 +331,7 @@ static int pdo_sqlite_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *ret
add_assoc_string(return_value, "sqlite:decl_type", (char *)str);
}

#ifdef SQLITE_ENABLE_COLUMN_METADATA
#ifdef HAVE_SQLITE3_COLUMN_TABLE_NAME
str = sqlite3_column_table_name(S->stmt, colno);
if (str) {
add_assoc_string(return_value, "table", (char *)str);
@@ -3,13 +3,13 @@
ARG_WITH("sqlite3", "SQLite 3 support", "no");

if (PHP_SQLITE3 != "no") {
ADD_FLAG("CFLAGS_SQLITE3", "/D SQLITE_THREADSAFE=" + (PHP_ZTS == "yes" ? "1" : "0") + " /D SQLITE_ENABLE_FTS3=1 /D SQLITE_ENABLE_FTS4=1 /D SQLITE_ENABLE_FTS5=1 /D SQLITE_ENABLE_JSON1=1 /D SQLITE_ENABLE_COLUMN_METADATA=1 /D SQLITE_CORE=1 /D SQLITE_API=__declspec(dllexport) ");
EXTENSION("sqlite3", "sqlite3.c", null, "/I" + configure_module_dirname + "/libsqlite /I" + configure_module_dirname + " /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");

ADD_SOURCES(configure_module_dirname + "/libsqlite", "sqlite3.c", "sqlite3");

AC_DEFINE("HAVE_SQLITE3", 1, "SQLite support");
AC_DEFINE("HAVE_SQLITE3_ERRSTR", 1, "have sqlite3_errstr function")
AC_DEFINE("HAVE_SQLITE3_CLOSE_V2", 1, "have sqlite3_close_v2")
PHP_INSTALL_HEADERS("ext/sqlite3", "libsqlite/sqlite3.h");
if (SETUP_SQLITE3("sqlite3", PHP_SQLITE3, PHP_SQLITE3_SHARED)) {
EXTENSION("sqlite3", "sqlite3.c", null, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");

AC_DEFINE("HAVE_SQLITE3", 1, "SQLite support");
AC_DEFINE("HAVE_SQLITE3_ERRSTR", 1, "have sqlite3_errstr function");
AC_DEFINE("HAVE_SQLITE3_CLOSE_V2", 1, "have sqlite3_close_v2");
} else {
WARNING("sqlite3 not enabled; libraries and/or headers not found");
}
}

0 comments on commit 6083a38

Please sign in to comment.
You can’t perform that action at this time.