Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building sqlite for windows in a proper way

My problem is no matter how I build sqlite - my binary is much slower than the precompiled one on sqlite download page (about 3 - 6 times depending on the query).

I am using sqlite3.h and sqlite3.c from the amalgamation source:

http://www.sqlite.org/sqlite-amalgamation-3070602.zip

I have added the following flags when compiling sqlite:

gcc
-s -O4 -I. -fomit-frame-pointer
-DNDEBUG
-DSQLITE_OS_WIN=1
-DSQLITE_HAVE_READLINE=0
-DSQLITE_THREADSAFE=1
-DSQLITE_TEMP_STORE=2
-DSQLITE_ENABLE_RTREE
-DSQLITE_ENABLE_FTS3
-DSQLITE_OMIT_COMPILEOPTION_DIAGS
-DSQLITE_ENABLE_COLUMN_METADATA
-DNO_TCL

I built it both with MINGW and with MSVS 2010.

Does anyone one know how to build sqlite to get the same binary as on download page ?

Any help would be appreciated.

like image 249
user483071 Avatar asked Apr 18 '11 13:04

user483071


People also ask

Is there a GUI for SQLite?

SQLiteStudio. The SQLiteStudio tool is a free GUI tool for managing SQLite databases. It is free, portable, intuitive, and cross-platform. SQLite tool also provides some of the most important features to work with SQLite databases such as importing, exporting data in various formats including CSV, XML, and JSON.

Can I use SQLite for desktop application?

SQLite is often used as the on-disk file format for desktop applications such as version control systems, financial analysis tools, media cataloging and editing suites, CAD packages, record keeping programs, and so forth. The traditional File/Open operation calls sqlite3_open() to attach to the database file.


1 Answers

Follow the guide on SQLite wiki : How to compile and check what are the arguments Make passes to the compiler. My first suspect would be -O4, as the highest level GCC understands is -O3, and even this usually turns out worse than -O2 or -Os (because small size == no CPU cache misses, and -O3 bloats the binary really badly).

Although I can see the approach differs: Build On Windows Without Tcl uses -O2, but ticket #931 uses the damned -O4 "Gentoo Ricer Mode". Either way, those optimization switches aren't worth much without specifying target architecture: try -march=core2 or -march=native for auto-detection, but remember that such code won't work on earlier CPUs. -march=nocona will work on anything newer than Pentium 4 and still gives the compiler a lot of room for useful optimizations.

like image 51
skolima Avatar answered Oct 05 '22 22:10

skolima