Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7942 Discussions

Intel C++ Compiler for Linux: mangling constructors & destructors

Alexey-Kukanov
Employee
538 Views

Hello,

working on TBB(probably no need to say we build it with Intel C++ Compiler), I need to analyze what symbols the library is expected to export. Currently I experience some lack of information with regard to mangling rules for constructors and destructors. Seems that in addition to in-charge and not-in-charge ctors/dtors generated by GCC, Intel compiler generates a couple more mangled as C9/D9. For example, the following list of symbols is generated for tbb::pipeline:

0000b2da T _ZN3tbb8pipelineC1Ev
0000b338 T _ZN3tbb8pipelineC2Ev
0000b300 T _ZN3tbb8pipelineC9Ev
0000b0b8 T _ZN3tbb8pipelineD0Ev
0000afde T _ZN3tbb8pipelineD1Ev
0000b2b2 T _ZN3tbb8pipelineD2Ev
0000b006 T _ZN3tbb8pipelineD9Ev

Could someone pleaseprovide me some information about what these additional ctor&dtor are for, in which cases they are used, and whatever else can be useful to know about it?

Thanks.

0 Kudos
4 Replies
John_O_Intel
Employee
538 Views
Hi,
These are internal functions that the compiler generates calls to, you should be able to verifiy by looking at generated assembly file. icpc/icc is binary compatible with g++, the ctor/dtor calls will be the entry points allowing binary compatibility - ie you can link object code created by icpc with g++ if you pass the correct icc libs to the linker.

Regards,
JohnO
0 Kudos
Judith_W_Intel
Employee
538 Views
We have chosen to implement the ABI slightly different than gcc but are nonetheless compliant. Gcc clones the C1 and C2 constructors while we don't. Example:
A() { printf("hi"); }
In this case both C1 and C2 functions will have the call to printf in gcc's implementation.
In our implementation we have one call to printf that exists in the "C9" function and C1 and C2 call the C9. You can think of the C9 function as you would any other routine created by the compiler. The ABI doesn't forbid us from naming it like this and it happens to be convenient.
There is an exception to this rule: vararg constructors. These must also be cloned so you won't see a C9 at all for these.
0 Kudos
Alexey-Kukanov
Employee
538 Views

Thanks for the explanations.

Did I get it right that C9/D9 are strictly internal functions only called from the gcc-compliant ctors/dtors and never called directly from user code, and so I could safely leave those local to the library, provided that "regular" ctors and dtors are exported?

0 Kudos
Judith_W_Intel
Employee
538 Views

yes, that is correct.

0 Kudos
Reply