问题描述
我正在尝试构建此项目:https://github.com/utelle/SQLite3MultipleCiphers
特别是在以下位置找到的合并文件:https://github.com/utelle/SQLite3MultipleCiphers/releases/tag/v1.2.5
我从 _mm_aesimc_si128
函数收到此错误:
/usr/lib/gcc/x86_64-linux-gnu/9/include/wmmintrin.
h:77: error: inlining failed in call to always_inline ‘_mm_aesimc_si128’: target specific option mismatch
In file included from ../sqlite3mc/sqlite3mc_amalgamation.c:250494:
../sqlite3mc/sqlite3mc_amalgamation.c: In function ‘aesGenKeyDecrypt’:
/usr/lib/gcc/x86_64-linux-gnu/9/include/wmmintrin.h:77:1: error: inlining failed in call to always_inline ‘_mm_aesimc_si128’: target specific option mismatch
77 | _mm_aesimc_si128 (__m128i __X)
| ^~~~~~~~~~~~~~~~
../sqlite3mc/sqlite3mc_amalgamation.c:250589:26: note: called from here
我从其他问题中了解到,我的 CPU 需要支持这些内在函数,并且我需要传入编译器标志以启用它们。我认为为此我需要 AES 和 SSE4.2,因为来自 Github 代码的 Makefile.am 有 -msse4.2 -maes
用于 x86。
我正在使用 QtCreator 和 qmake,因为我正在尝试将其集成到现有的 Qt 项目中,但我现在只是想让它与新项目一起使用。
这是我的 .pro 文件,我传入了 -march=native
标志(我也尝试了 -msse4.2 -maes
,结果相同):
TEMPLATE = app
CONFIG += console c++17
CONFIG -= app_bundle qt debug_and_release
SOURCES += \
main.cpp \
sqlite3mc_amalgamation.c
HEADERS += \
sqlite3.h \
sqlite3ext.h \
sqlite3mc_amalgamation.h
QMAKE_CXXFLAGS += -march=native
检查我的架构的启用标志,并搜索 aes 和 sse 给我:
g++ -Q --help=target -march=native | egrep "(msse)|(maes)"
-maes [enabled]
-msse [enabled]
-msse2 [enabled]
-msse2avx [disabled]
-msse3 [enabled]
-msse4 [enabled]
-msse4.1 [enabled]
-msse4.2 [enabled]
-msse4a [disabled]
-msse5
-msseregparm [disabled]
检查我的 CPU 的可用扩展并搜索 sse 和 aes:
lscpu | egrep "(sse)|(aes)"
Flags: sse sse2 ssse3 sse4_1 sse4_2 aes <many other flags>
所以 SSE4.2 和 AES 都由 -march=native
启用并且我的 CPU 支持,但我仍然收到错误。
我能做些什么来克服这个错误(并希望能完成整个构建)?
解决方法
由于合并文件是一个 C 文件,它应该是:
QMAKE_CFLAGS += -march=native
不是
QMAKE_CXXFLAGS += -march=native
此外,sqlite3mc 使用 pthread 和 ldl,因此必须链接这些库:
LIBS += -pthread -ldl
进行这些更改后,它会成功构建。