Skip to content

Commit 06f51da

Browse files
committed
Reduce the size of sqlite_extra_binaries
* Removed optional features from libsqlite3. Someone wanting a full SQLite experience should compile their own * Optimise for size for all binaries and libsqlite3
1 parent efd8a57 commit 06f51da

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

tools/vend.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -365,16 +365,16 @@ def __post_init__(self):
365365
lib_sqlite=True,
366366
),
367367
# these two are in the withdrawn 3.52.0 release
368-
#Extra(
368+
# Extra(
369369
# name="sqlite3_showtmlog",
370370
# type="executable",
371371
# sources=["tool/showtmlog.c"],
372372
# description="Makes human/csv readable output from a tmstmpvfs log file",
373-
#),
374-
#Extra(
373+
# ),
374+
# Extra(
375375
# name="tmstmpvfs",
376376
# description="VFS shim that writes timestamps and other tracing information to the reserved bytes of each page, and also generates corresponding log files",
377-
#),
377+
# ),
378378
]
379379

380380
import os
@@ -643,7 +643,8 @@ def do_build(what: set[str], verbose: bool, fail_fast: bool = False):
643643

644644
SQLITE_LIB_NAME = "sqlite3_tool"
645645

646-
lib_enables = "CARRAY COLUMN_METADATA DBPAGE_VTAB DBSTAT_VTAB FTS4 FTS5 GEOPOLY MATH_FUNCTIONS PERCENTILE PREUPDATE_HOOK RTREE SESSION STAT4".split()
646+
# required for sqlite3_rsync - enabling everything adds 320kb to wheel
647+
lib_enables = "DBPAGE_VTAB".split()
647648

648649
macros = [(f"SQLITE_ENABLE_{enable}", 1) for enable in lib_enables]
649650

@@ -652,7 +653,6 @@ def do_build(what: set[str], verbose: bool, fail_fast: bool = False):
652653
[
653654
("SQLITE_USE_URI", 1),
654655
("SQLITE_THREADSAFE", 2),
655-
("SQLITE_ENABLE_COLUMN_METADATA", 1),
656656
]
657657
)
658658

@@ -672,11 +672,21 @@ def do_build(what: set[str], verbose: bool, fail_fast: bool = False):
672672
lib_resource = resource_file(
673673
build_dir, compiler, Extra(name="libsqlite3", description="SQLite 3 library", doc="")
674674
)
675+
676+
# optimize just sqlite library for size - reduces size by 200kb
677+
match ci.name:
678+
case "gcc" | "clang":
679+
optimize_for_size = ["-Os"]
680+
case "msvc":
681+
optimize_for_size = ["/O1"]
682+
case _:
683+
optimize_for_size = []
684+
675685
lib_objs = compiler.compile(
676686
[str(pathlib.Path("sqlite3") / "sqlite3.c"), lib_resource] + zlib_sources,
677687
output_dir=str(build_dir),
678688
macros=macros,
679-
extra_preargs=compile_extra_preargs,
689+
extra_preargs=(compile_extra_preargs or []) + optimize_for_size,
680690
)
681691
# dlopen libraries are different than shared libraries so flags have to be given
682692
so_link_flags = None
@@ -819,7 +829,9 @@ def do_build(what: set[str], verbose: bool, fail_fast: bool = False):
819829
+ (zlib_sources if extra.lib_zlib else []),
820830
output_dir=str(build_dir),
821831
include_dirs=include_dirs,
822-
extra_preargs=compile_extra_preargs,
832+
extra_preargs=compile_extra_preargs
833+
if extra.type == "extension"
834+
else (compile_extra_preargs or []) + optimize_for_size,
823835
macros=extra.defines,
824836
)
825837

0 commit comments

Comments
 (0)