Closed stuta closed 2 years ago
I created xmake file to compile the shared library, no errors with this.
-- xmake -rv -F sqlitemc-xmake.lua
-- build files are in: build/macosx/arm64/release/libsqlite3mc.dylib (build/{{os}}/{{arch}}/release)
-- NOTE: 'SQLITE_USE_URI' will cause shared database not to work, tempfile is not created
--
add_rules("mode.release")
target("sqlite3mc")
add_ldflags("-lpthread", "-ldl", "-lm")
add_shflags("-lpthread", "-ldl", "-lm")
set_kind("shared")
add_files("src/sqlite3mc.c")
set_languages("c99")
set_optimize("fastest")
add_defines('SQLITE_ENABLE_RTREE', 'SQLITE_ENABLE_GEOPOLY', 'SQLITE_ENABLE_FTS4', 'SQLITE_ENABLE_FTS5', 'SQLITE_ENABLE_EXPLAIN_COMMENTS',
'SQLITE_ENABLE_DBPAGE_VTAB', 'SQLITE_ENABLE_STMTVTAB', 'SQLITE_ENABLE_DBSTAT_VTAB', 'SQLITE_ENABLE_SESSION',
'SQLITE_ENABLE_JSON1', 'SQLITE_ENABLE_MATH_FUNCTIONS')
add_defines('SQLITE_SOUNDEX', 'SQLITE_ENABLE_COLUMN_METADATA', 'SQLITE_ENABLE_DESERIALIZE', 'SQLITE_ENABLE_EXTFUNC', 'SQLITE_ENABLE_CARRAY')
add_defines('SQLITE_ENABLE_CARRAY', 'SQLITE_ENABLE_FILEIO', 'SQLITE_ENABLE_SERIES', 'SQLITE_ENABLE_UUID', 'SQLITE_ENABLE_REGEXP')
add_defines('SQLITE_DQS=0', 'SQLITE_MAX_ATTACHED=10', 'SQLITE_ENABLE_FTS3', 'SQLITE_ENABLE_FTS3_PARENTHESIS', 'SQLITE_CORE',
'SQLITE_ENABLE_CSV')
add_defines('SQLITE_TEMP_STORE=2', 'SQLITE_ENABLE_SHA3', 'SQLITE_USER_AUTHENTICATION')
-- add_defines('SQLITE_THREADSAFE=0', 'SQLITE_SECURE_DELETE=0') -- disabled for performance
-- add_defines('SQLITE_ENABLE_PREUPDATE_HOOK')
M1 macs give error
clang: error: the clang compiler does not support '-march=native'
if makefile containsARM_FLAGS = -march=native
.
Unfortunately, I don't have access to a M1 mac system. Under Linux it is necessary to specify -march=native
, so that the compiler actually compiles the code for AES hardware support without error messages. Maybe clang simply doesn't need this flag.
Compiling gives a warning:
In file included from ../src/sqlite3mc.c:91: ../src/sqlite3patched.c:15677:22: warning: redefinition of typedef 'PgHdr' is a C11 feature [-Wtypedef-redefinition] typedef struct PgHdr PgHdr; ^ ../src/sqlite3patched.c:10384:22: note: previous definition is here typedef struct PgHdr PgHdr;
Thanks for reporting. I will fix this warning for the next release.
Adding -march=native
is not a good solution when the program should run on customers' computers also. After testing in windows using msys2 I found that adding the following defines were enough to make it compile.
add_cflags("-msse4.2", "-maes")
I created a windows make build. I copied sqlite3mc.def to main level and modified it because I had added SQLITE_THREADSAFE=0 and it caused errors on missing mutex functions to be exported.
-- xmake f -p mingw -F sqlitemc-xmake.lua
-- xmake f -p mingw -F sqlitemc-xmake.lua -a i386 --sdk=C:\Users\xxx\scoop\apps\msys2\current\clang32
-- xmake -rv -F sqlitemc-xmake.lua
-- build files are in: build/mingw/x86_64/release/libsqlite3mc.dylib
add_rules("mode.release")
target("sqlite3mc")
add_cflags("-msse4.2", "-maes") -- add_cflags("-march=native")
add_ldflags("-lpthread", "-lm")
add_shflags("-lpthread", "-lm")
add_shflags("sqlite3mc.def", {force = true})
set_kind("shared")
add_files("src/sqlite3mc.c", "src/sqlite3mc.rc")
set_languages("c99")
set_optimize("fastest")
add_defines('SQLITE_ENABLE_RTREE', 'SQLITE_ENABLE_GEOPOLY', 'SQLITE_ENABLE_FTS4', 'SQLITE_ENABLE_FTS5', 'SQLITE_ENABLE_EXPLAIN_COMMENTS',
'SQLITE_ENABLE_DBPAGE_VTAB', 'SQLITE_ENABLE_STMTVTAB', 'SQLITE_ENABLE_DBSTAT_VTAB', 'SQLITE_ENABLE_STAT4',
'SQLITE_OMIT_AUTOINIT', 'SQLITE_DEFAULT_MEMSTATUS=0', 'SQLITE_ENABLE_UNLOCK_NOTIFY', 'SQLITE_ENABLE_SESSION',
'SQLITE_ENABLE_JSON1', 'SQLITE_ENABLE_MATH_FUNCTIONS', 'SQLITE_SOUNDEX', 'SQLITE_ENABLE_COLUMN_METADATA',
'SQLITE_ENABLE_DESERIALIZE', 'SQLITE_ENABLE_EXTFUNC', 'SQLITE_ENABLE_CARRAY', 'SQLITE_ENABLE_FILEIO', 'SQLITE_ENABLE_SERIES',
'SQLITE_ENABLE_UUID', 'SQLITE_ENABLE_REGEXP', 'SQLITE_DQS=0', 'SQLITE_CORE', 'SQLITE_ENABLE_CSV', 'SQLITE_TEMP_STORE=2',
'SQLITE_USE_URI')
-- add_defines('SQLITE_THREADSAFE=0', 'SQLITE_SECURE_DELETE=0') -- disable for performance
add_defines('SQLITE_ENABLE_SHA3', 'SQLITE_USER_AUTHENTICATION') -- encrypted database
-- add_defines('SQLITE_ENABLE_PREUPDATE_HOOK', 'SQLITE_ENABLE_FTS3', 'SQLITE_ENABLE_FTS3_PARENTHESIS')
Adding
-march=native
is not a good solution when the program should run on customers' computers also. After testing in windows using msys2 I found that adding the following defines were enough to make it compile.add_cflags("-msse4.2", "-maes")
Actually, the build files coming with SQLite3 Multiple Ciphers use exactly these flages, when the platform is a x86 one.
Only for ARM platforms the flag -march=native
is used.
At least for gcc the flags -maes
and -msse4.2
are listed as i86 options - and they are required to enable the compiler to properly compile AES hardware support.
For ARM targets however, I'm not sure whether any specific flags are required to enable NEON support which includes AES hardware support.
M1 macs give error
clang: error: the clang compiler does not support '-march=native'
if makefile containsARM_FLAGS = -march=native
.Compiling gives a warning: