Search code examples
c++aixdbx

Compiling static template functions on AIX 7.1 xlc++


Our source code has a bunch of standalone static template functions. I need to compile it on AIX 7.1 Power 7 system with IBM's native xlc++ compiler. Using static keyword with standalone functions is obsoleted practice and it's not supported by xlc++, so to get my program compiled I removed that keyword from function declarations. After the program compiled successfully, the first run crashed ( on Linux/g++ it's perfectly stable with the same input data).

I tried to debug with dbx, but debugger complained about internal error and segmentation fault in extend_brk. No memory quotas is used, so it's not a memory/disk space shortage. System is configured to create full core dump, program compiled with -g option. All libraries are linked statically, so it's not a problem with throwing exceptions in shared libraries. 1) Is it possible to compile static template functions on xlc++ without removing static keyword, so I can be sure that all code is the same as in RHEL system? 2) Why debugger doesn't work?


Solution

  • It appears that I had 32/64 bit portability issue, removing static keyword is harmless in that situation. Problem had gone away after I added the following line at my .kshrc file:

    export OBJECT_MODE=64
    

    By default, IBM XL compilers run in 32 bit mode, even on 64 bit AIX 7.1 systems. To overwrite default behavior, programmer can set environment variable or supply -q64 parameter to compiler.