-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Unbundle libsqlite3 #3548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unbundle libsqlite3 #3548
Conversation
Side question: will unbundling of this huge libs also speedup CI run as a lot of code will be less to compile? |
I guess that the performance improvement would not really be noticable. |
The earlier Travis build failure has been caused by Xenial's libsqlite 3.11.0-1ubuntu1, which apparently exhibits bug https://sqlite.org/src/info/ef360601. I've added a respective SKIPIF clause to work around that. It might be appropriate to backport this fix to older PHP branches as well. |
CHECK_HEADER_ADD_INCLUDE("sqlite3.h", "CFLAGS_PDO_SQLITE") && | ||
CHECK_HEADER_ADD_INCLUDE("sqlite3ext.h", "CFLAGS_PDO_SQLITE") | ||
) { | ||
EXTENSION("pdo_sqlite", "pdo_sqlite.c sqlite_driver.c sqlite_statement.c"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just making a note here, are we sure that we don't need the old CFLAGS like SQLITE_ENABLE_FTS3, SQLITE_ENABLE_FTS4, SQLITE_ENABLE_FTS5, SQLITE_ENABLE_JSON1 & SQLITE_CORE here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've grepped for these, and they are not used anywhere. However, if they were, that wouldn't work anyway, since the external libsqlite might have been compiled differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted, then we should be good to go then as I don't see any other obvious things at a glance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, those are library flags, not extension flags. Pushed a repo now https://github.com/winlibs/sqlite3.
CHECK_HEADER_ADD_INCLUDE("sqlite3.h", "CFLAGS_SQLITE3") && | ||
CHECK_HEADER_ADD_INCLUDE("sqlite3ext.h", "CFLAGS_SQLITE3") | ||
) { | ||
EXTENSION("sqlite3", "sqlite3.c", null, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as for the pdo_sqlite/config.w32 note here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some notes could be addressed, but actually looks good.
Thanks.
|
||
if test "$ZEND_DEBUG" = "yes"; then | ||
debug_flags="-DSQLITE_DEBUG=1" | ||
AC_MSG_CHECKING([for sqlite3 files in default path]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to prefer pkg-config
and fallback to the below otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I've already thought about that, but would prefer if someone more knowledgable regarding the Linux build system to do that.
CHECK_HEADER_ADD_INCLUDE("sqlite3.h", "CFLAGS_PDO_SQLITE") && | ||
CHECK_HEADER_ADD_INCLUDE("sqlite3ext.h", "CFLAGS_PDO_SQLITE") | ||
) { | ||
EXTENSION("pdo_sqlite", "pdo_sqlite.c sqlite_driver.c sqlite_statement.c"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, those are library flags, not extension flags. Pushed a repo now https://github.com/winlibs/sqlite3.
ext/pdo_sqlite/config.w32
Outdated
} | ||
if (CHECK_LIB("libsqlite3_a.lib;libsqlite3.lib", "pdo_sqlite", PHP_PDO_SQLITE) && | ||
CHECK_HEADER_ADD_INCLUDE("sqlite3.h", "CFLAGS_PDO_SQLITE") && | ||
CHECK_HEADER_ADD_INCLUDE("sqlite3ext.h", "CFLAGS_PDO_SQLITE") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be generalized into a function like it is done for OpenSSL. Not critical for now.
Also shared might be a better choice to prefer for the shared extension build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I'll see to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also remove the lib from the "PHP source code directory structure" CONTRIBUTING section
@carusogabriel Good catch! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also maybe worth updating in this patch or separately, file README.REDIST.BINS
contains a mention of the bundled sqlite library.
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 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.
We skip this test for libsqlite 3.11.0 to 3.14.1, since they have bug https://sqlite.org/src/info/ef360601.
We also extract the SETUP_SQLITE3() function for code re-use.
756480e
to
3474cbd
Compare
@petk Thanks! Done. If there are no objections, I'm going to apply this PR on the next weekend. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also remove the library from Makefile.gcov
exclusion list:
Line 60 in 257bec3
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 \ |
Thanks, @carusogabriel! |
Comment on behalf of cmb at php.net: Applied via 6083a38. |
Documented via http://svn.php.net/viewvc?view=revision&revision=345781. |
Cf. <php/php-src#3548>. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@345781 c90b9560-bf6c-de11-be94-00142212c4b1
Cf. <php/php-src#3548>. git-svn-id: http://svn.php.net/repository/phpdoc/en@345781 c90b9560-bf6c-de11-be94-00142212c4b1
Cf. <php/php-src#3548>. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@345781 c90b9560-bf6c-de11-be94-00142212c4b1
Cf. <php/php-src#3548>. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@345781 c90b9560-bf6c-de11-be94-00142212c4b1
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 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.