1

I'm trying to compile code on aix using g++ since xlC support of c++11 is very limited.

I'm having trouble to link my code with aix shared libraries because of the different name mangling.

xlC supports name mangling replacement (-qnamemangling=v13), but IBM doesn't gave the sources, so I need to recompile using g++ (or xlclang++) with xlC name mangling.

xlC version is V16.1

Is it possible to replace the name mangling of g++ (or xlclang++) to match xlC?

Is there other alternative?

SHR
  • 7,940
  • 9
  • 38
  • 57
  • Well, C++ doesn't standardize binary file-formats; object modules and libraries of different compilers are very unlikely to be compatible. – Lorinczy Zsigmond Jun 12 '19 at 16:40

1 Answers1

2

xlC and g++ are not compatible on AIX. They use different object models and standard libraries.

There is an xlclang++ compiler in XLC++ 16.1 with full C++11 support, however, it is also not interoperable with xlC because compatibility was broken with C++11. xlclang++ uses a standard library based on libc++ (LLVM) while xlC uses its own legacy libC.a library. Compatibility through C is retained so your options are recompile or rework your interfaces to non-recompiled C++ interfaces to go through a C-layer.

  • I can link with `extern "C"` function, therefore I guess it not so different. I thought about replacing the mangling methods of `g++` or something like this. – SHR Jun 16 '19 at 07:22
  • 1
    You can use extern "C", however, be careful because once you cross from xlC to xlclang++ compiled code, you should assume C++ types will be laid out differently. Consider: extern "C" void foo(std::vector &v); If the vector is created on the xlC side and used on the xlclang++ side, there's no expectation this will work (even for user-defined C++ types.) The compilers changed the mangling to spare you. Using extern "C" is an override that you know what you're doing. – Chris Bowler Jun 17 '19 at 12:55