0

I'm trying to cross-compile a c++ file with arm-linux-gnueabi-g++.:

make CROSS_COMPILE=arm-linux-gnueabi- all

But an error occurs:

arm-linux-gnueabi-g++ -O2 -c -oa32.o PMCTestA.cpp
In file included from PMCTest.h:54:0,
                 from PMCTestA.cpp:24:
PMCTestLinux.h: In member function ‘void CCounters::GetProcessorVendor()’:
PMCTestLinux.h:63:73: error: impossible constraint in ‘asm’
make: *** [a32.o] Error 1

And here is part of the code in PMCTestLinux.h from row 61:

static void Cpuid (int Output[4], int aa) { 
    int a, b, c, d;
    __asm("cpuid" : "=a"(a),"=b"(b),"=c"(c),"=d"(d) : "a"(aa),"c"(0) : );
    Output[0] = a;
    Output[1] = b;
    Output[2] = c;
    Output[3] = d;
}

static inline void Serialize () {
    // serialize CPU
    __asm__ __volatile__ ( "xorl %%eax, %%eax \n cpuid " : : : "%eax","%ebx","%ecx","%edx" );
}

static inline int Readtsc() {
    // read time stamp counter
    int r;
    __asm__ __volatile__ ( "rdtsc" : "=a"(r) : : "%edx");    
    return r;
}

static inline int Readpmc(int nPerfCtr) {
    // read performance monitor counter number nPerfCtr
    int r;
    __asm__ __volatile__ ( "rdpmc" : "=a"(r) : "c"(nPerfCtr) : "%edx");    
    return r;
}

Does anyone know something about this error? I'm not sure if the problem is about the compiler. My system is Ubuntu 10.04 and the version of arm-linux-gnueabi-g++ is 4.7.3

Cong Wang
  • 769
  • 1
  • 9
  • 30
  • 1
    I tried compiling `Cpuid()` on `gcc-4.7 (SUSE Linux) 4.7.2 20130108` and it did not report this error. Nor does `gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2` nor `clang version 3.5-1ubuntu1 (trunk)`. – Brian Cain Jun 18 '15 at 14:35
  • 1
    This is inline x86 assembly. It will not compile for ARM. – Brett Hale Jun 18 '15 at 14:38
  • @BrettHale Thank you man. Do you know if it could be easily changed to fit ARM? – Cong Wang Jun 18 '15 at 14:48
  • 1
    This utility is exclusively for x86/x86-64. It's written by [Agner Fog](http://www.agner.org/optimize/) who has a lot of resources on x86 micro- optimization and architecture analysis. You're out of luck, I'm afraid. – Brett Hale Jun 18 '15 at 15:07

0 Answers0