From f589362a4f00d13b6b559be9a99c32fff59aa0d1 Mon Sep 17 00:00:00 2001 From: shess Date: Thu, 10 Sep 2015 21:10:32 -0700 Subject: [PATCH] Bring third_party/sqlite/BUILD.gn into parity with sqlite.gyp. Pull in missing defines and comments on the defines. Add USE_PREAD for Posix and HAVE_MALLOC_USABLE_SIZE for Linux. BUG=489784 Review URL: https://codereview.chromium.org/1304033006 Cr-Commit-Position: refs/heads/master@{#348329} --- third_party/sqlite/BUILD.gn | 65 +++++++++++++++++++++++++++++++++++-------- third_party/sqlite/sqlite.gyp | 29 +++++++++++++------ 2 files changed, 74 insertions(+), 20 deletions(-) diff --git a/third_party/sqlite/BUILD.gn b/third_party/sqlite/BUILD.gn index daeda7254bf1..45f3ab996d4c 100644 --- a/third_party/sqlite/BUILD.gn +++ b/third_party/sqlite/BUILD.gn @@ -49,13 +49,43 @@ if (!use_system_sqlite) { cflags = [] defines = [ "SQLITE_ENABLE_FTS3", + + # New unicode61 tokenizer with built-in tables. "SQLITE_DISABLE_FTS3_UNICODE", + + # Chromium currently does not enable fts4, disable extra code. "SQLITE_DISABLE_FTS4_DEFERRED", "SQLITE_ENABLE_ICU", "SQLITE_ENABLE_MEMORY_MANAGEMENT", "SQLITE_SECURE_DELETE", + + # Custom flag to tweak pcache pools. + # TODO(shess): This shouldn't use faux-SQLite naming. "SQLITE_SEPARATE_CACHE_POOLS", + + # TODO(shess): SQLite adds mutexes to protect structures which cross + # threads. In theory Chromium should be able to turn this off for a + # slight speed boost. "THREADSAFE", + + # SQLite can spawn threads to sort in parallel if configured + # appropriately. Chromium doesn't configure SQLite for that, and would + # prefer to control distribution to worker threads. + "SQLITE_MAX_WORKER_THREADS=0", + + # Use a read-only memory map when mmap'ed I/O is enabled to prevent memory + # stompers from directly corrupting the database. + # TODO(shess): Upstream the ability to use this define. + "SQLITE_MMAP_READ_ONLY=1", + + # NOTE(shess): Some defines can affect the amalgamation. Those should be + # added to google_generate_amalgamation.sh, and the amalgamation + # re-generated. Usually this involves disabling features which include + # keywords or syntax, for instance SQLITE_OMIT_VIRTUALTABLE omits the + # virtual table syntax entirely. Missing an item usually results in + # syntax working but execution failing. Review: + # src/src/parse.py + # src/tool/mkkeywordhash.c ] if (is_component_build) { if (is_win) { @@ -75,10 +105,13 @@ if (!use_system_sqlite) { if (is_posix) { defines += [ # Allow xSleep() call on Unix to use usleep() rather than sleep(), so it - # will have microsecond precision. Should only affect contended databases - # via the busy callback. Browser profile databases are mostly exclusive, - # but renderer databases may allow for contention. + # will have microsecond precision. Should only affect contended + # databases via the busy callback. Browser profile databases are mostly + # exclusive, but renderer databases may allow for contention. "HAVE_USLEEP=1", + + # Use pread/pwrite directly rather than emulating them. + "USE_PREAD=1", ] } if (is_linux || is_android) { @@ -88,6 +121,17 @@ if (!use_system_sqlite) { ] } + # SQLite wants to track malloc sizes. On OSX it uses malloc_size(), on + # Windows _msize(), elsewhere it handles it manually by enlarging the malloc + # and injecting a field. Enable malloc_usable_size() for Linux. + # NOTE(shess): Android does _not_ export malloc_usable_size(). + if (is_linux) { + defines += [ + "HAVE_MALLOC_H", + "HAVE_MALLOC_USABLE_SIZE", + ] + } + include_dirs = [ "amalgamation" ] configs -= [ "//build/config/compiler:chromium_code" ] @@ -130,8 +174,13 @@ if (!use_system_sqlite) { # This is used to allow the SQLITE_API definition to be different when # building sqlite3.c than it is when clients include sqlite3.h. group("sqlite") { - public_deps = [ ":chromium_sqlite3" ] - public_configs = [ ":sqlite_export", ":sqlite_config" ] + public_deps = [ + ":chromium_sqlite3", + ] + public_configs = [ + ":sqlite_export", + ":sqlite_config", + ] } if (is_linux) { @@ -181,14 +230,8 @@ if (use_system_sqlite) { defines = [ # Necessary to statically compile the extension. "SQLITE_CORE", - "SQLITE_DISABLE_FTS3_UNICODE", - "SQLITE_DISABLE_FTS4_DEFERRED", - "SQLITE_ENABLE_FTS3", "SQLITE_ENABLE_ICU", "SQLITE_ENABLE_MEMORY_MANAGEMENT", - "SQLITE_SECURE_DELETE", - "SQLITE_SEPARATE_CACHE_POOLS", - "THREADSAFE", ] sources = [ "src/ext/icu/icu.c", diff --git a/third_party/sqlite/sqlite.gyp b/third_party/sqlite/sqlite.gyp index 4fabe5e47758..be40e97908c9 100644 --- a/third_party/sqlite/sqlite.gyp +++ b/third_party/sqlite/sqlite.gyp @@ -47,15 +47,14 @@ 'target_name': 'sqlite', 'conditions': [ [ 'chromeos==1' , { - 'defines': [ - # Despite obvious warnings about not using this flag - # in deployment, we are turning off sync in ChromeOS - # and relying on the underlying journaling filesystem - # to do error recovery properly. It's much faster. - 'SQLITE_NO_SYNC', - ], - }, - ], + 'defines': [ + # Despite obvious warnings about not using this flag in deployment, + # we are turning off sync in ChromeOS and relying on the underlying + # journaling filesystem to do error recovery properly. It's much + # faster. + 'SQLITE_NO_SYNC', + ], + }], ['os_posix == 1', { 'defines': [ # Allow xSleep() call on Unix to use usleep() rather than sleep(). @@ -64,6 +63,8 @@ # profile databases are mostly exclusive, but renderer databases may # allow for contention. 'HAVE_USLEEP=1', + # Use pread/pwrite directly rather than emulating them. + 'USE_PREAD=1', ], }], ['OS == "linux" or OS == "android"', { @@ -72,6 +73,16 @@ 'fdatasync=fdatasync', ], }], + # SQLite wants to track malloc sizes. On OSX it uses malloc_size(), on + # Windows _msize(), elsewhere it handles it manually by enlarging the + # malloc and injecting a field. Enable malloc_usable_size() for Linux. + # NOTE(shess): Android does _not_ export malloc_usable_size(). + ['OS == "linux"', { + 'defines': [ + 'HAVE_MALLOC_H', + 'HAVE_MALLOC_USABLE_SIZE', + ], + }], ['use_system_sqlite', { 'type': 'none', 'direct_dependent_settings': { -- 2.11.4.GIT