Build sqlite for windows appropriately

My problem doesn’t matter how I build sqlite - my binary is much slower than the pre-compiled sqlite on the download page (about 3-6 times depending on the request).

I use sqlite3.h and sqlite3.c from an amalgam source:

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

When compiling sqlite, I added the following flags:

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 with both MINGW and MSVS 2010.

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

Any help would be appreciated.

+6
source share
1 answer

Follow the SQLite wiki guide : how to compile and check which Make arguments are passed to the compiler. My first suspect would be -O4 , because it understands the highest GCC level - -O3 , and even this usually turns out to be worse than -O2 or -Os (since the small size == there is no processor cache, and -O3 inflates the binary code very badly )

Although I see that the approach is different: Build On Windows Without Tcl uses -O2 , but ticket # 931 uses the damned -O4 "Gentoo Ricer mode". In any case, these optimization switches are not worth much unless you specify the target architecture: try -march=core2 -march=native or -march=native for automatic detection, but remember that such code will not work on earlier processors. -march=nocona will work on something newer than Pentium 4, and still gives the compiler many opportunities for useful optimizations.

+2
source

Source: https://habr.com/ru/post/886143/


All Articles