Search code examples
c++gccassemblyicc

Why do gcc and icc produce asm with the same label names for C++ functions?


I compiled a simple C++ function with gcc and icc.

void modify_array(int* arr, int size) {
    for (int i=0; i<size; i++) {
        arr[i] += 1;
    }
}

I was surprised to see that gcc and icc produce assembly with the same label names.

    .globl __Z12modify_arrayPii
Z12modify_arrayPii:
...

Why are they consistent? What is the meaning behind these label names?


Solution

  • Intel state that they are making deliberate efforts to give ABI compatibility with GCC with the Linux version of ICC. While the GCC maintainers state that they are making deliberate efforts to give a stable ABI by following an industry C++ ABI standard. This helps keep a stable environment which aids Intel's rather successful efforts.

    So it certainly is not by coincidence but by design that they use the same name mangling as part of providing the same ABI.