我正在尝试将 mongodb 交叉编译为自定义 linux。它在 linux 上编译得很好,但是当使用交叉编译器工具链时,它会抱怨这个代码。
static T compareAndSwap(volatile T* dest, T expected, T newValue) {
T result = expected;
asm volatile ("push %%eax\n\t"
"push %%ebx\n\t"
"push %%ecx\n\t"
"push %%edx\n\t"
"mov (%%edx), %%ebx\n\t"
"mov 4(%%edx), %%ecx\n\t"
"mov (%%edi), %%eax\n\t"
"mov 4(%%edi), %%edx\n\t"
"lock cmpxchg8b (%%esi)\n\t"
"mov %%eax, (%%edi)\n\t"
"mov %%edx, 4(%%edi)\n\t"
"pop %%edx\n\t"
"pop %%ecx\n\t"
"pop %%ebx\n\t"
"pop %%eax\n"
:
: "S" (dest),
"D" (&result),
"d" (&newValue)
: "memory", "cc");
return result;
}
编译器错误如下。
_party/js-1.7 -Isrc/third_party/js-1.7 src/mongo/bson/oid.cpp
src/mongo/platform/atomic_intrinsics_gcc.h: In member function 'void mongo::OID::initSequential()':
src/mongo/platform/atomic_intrinsics_gcc.h:123:44: error: impossible constraint in 'asm'
src/mongo/platform/atomic_intrinsics_gcc.h:123:44: error: impossible constraint in 'asm'
scons: *** [build/linux2/cc_gcc/cxx_toolchain-c++/mongo/bson/oid.o] Error 1
scons: building terminated because of errors.
投诉123:44
的行是之前行的结尾: "memory", "cc");
还看了看其他部分的代码,编译成asm代码,看起来也差不多。不知道这个发生了什么。
请指教这有什么问题。