I'm trying cross-compile MongoDB to a custom Linux. It compiles fine with Linux, but when using the cross compiler toolchain, it complains about this code.
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;
}
The compiler error is as below.
_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.
The complained line 123:44
is end of the the line before : "memory", "cc");
Was also looked at the other parts of the code, which compiled asm code, was also looks similar. do not know what happened with this one.
Please advice what's wrong with this.