How to compile OCC with arm-linux-gcc

Hello all,

I’d like to test OCC inside an ARM based embedded environment.
Unfortunately, I’ve got compiling errors with arm-linux-gcc. For instance, with the file Standard_Atomic.hxx

// use x86 / x86_64 inline assembly (compatibility with alien compilers / old GCC)
int anIncResult;
__asm__ __volatile__ (
#if defined(_OCC64)
"lock xaddl %%ebx, (%%rax) \n\t"
"incl %%ebx \n\t"
: "=b" (anIncResult)
: "a" (theValue), "b" (1)
: "cc", "memory");
#else
"lock xaddl %%eax, (%%ecx) \n\t"
"incl %%eax \n\t"
: "=a" (anIncResult)
: "c" (theValue), "a" (1)
: "memory");
#endif
return anIncResult;

With OCC, it seems only Intel IC has been taken into account.
Does someone have got experiences with ARM IC cases?

Thanks a lot for your helps.
JC Mei

Denis Barbier's picture

See at the top of this file, gcc built-in functions are used if __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 is defined. It looks like your gcc version is very old.

jcmei's picture

Thanks a lot for your prompt feedback.

But when you look at the following code:

ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
// mordern g++ compiler (gcc4.4+)
// built-in functions available for appropriate CPUs (at least -march=i486 should be specified on x86 platform)

It is precised that this is on x86 platform, not for ARM. So how to proceed?

Thanks in advance for your advices.

JC Mei

Denis Barbier's picture

No, this comment does not state that this works only on x86; it says that g++ may need some flags, for instance -march=i486 when building on x86 (not sure whether this flag is still needed though).

It looks like those built-in functions are available only for gcc >= 4.5 on armv6 and after, so you may try to add -march=armv6 flag.

jcmei's picture

Thanks a lot for your helps.
I'm still trying to solve my problem with your suggestion and will keep you updated.