简体   繁体   中英

Debian linux compile fails: asm impossible constraint

Here's an area I have no idea where to begin with. I'm trying to compile a binary which is using G3Dlite. I've already come across an undefined "__decl" that I had to define since there was not definition in platform.h. After that, the compiler stopped on this error:

./dep/include/g3dlite/G3D/AtomicInt32.h:124:44: error: impossible constraint in 'asm'

line 124 is in this function:

 /** Returns zero if the result is zero after decrement, non-zero otherwise.*/
int32 decrement() {
    #if defined(G3D_WIN32)
        // Note: returns the newly decremented value
        return InterlockedDecrement(&m_value);
        #elif defined(G3D_LINUX)  || defined(G3D_FREEBSD)
        unsigned char nz;

        asm volatile ("lock; decl %1;\n\t"
                      "setnz %%al"
                      : "=a" (nz)
                      : "m" (m_value)
                      : "memory", "cc");
        return nz;
   #elif defined(G3D_OSX)
        // Note: returns the newly decremented value
        return OSAtomicDecrement32(&m_value);
   #endif
}

I'm not sure what the issue is on linux. This code was checked out and compiled on other platforms fine, so I'm wondering if it's an issue with the g3d code or my local OS.

arcemu@raspberrypi ~ $ uname -a && gcc --version && cmake --version
Linux raspberrypi 3.1.9+ #168 PREEMPT Sat Jul 14 18:56:31 BST 2012 armv6l GNU/Linux
gcc (Debian 4.6.3-8+rpi1) 4.6.3
cmake version 2.8.9-rc1

I've read a number of related posts which seem to indicate something about 'modified' not being supported any longer.

Can anyone point out a good place to start troubleshooting this?

Thanks.

The output constraint specifies an x86 register (EAX), which is impossible on an arm cpu. Also, the lock prefix is platform-specific to x86, and the decl and setnz instructions are not supported on arm as well.

This is the output constraint:

    : "=a" (nz)

It is telling gcc to use the register eax to hold the result and then copy it to the variable nz .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM