Running a binary built with -O4 or higher on a machine other than the build machine may lead to an illegal instruction

Technote (troubleshooting)

Problem(Abstract)

Attempts to run a binary built with -O4 (or higher) using XL C/C++ compiler may fail with an illegal instruction at run time on a machine other than the build machine.

Cause

The compiler automatically uses the -qarch=auto suboption when you compile at -O4 or -O5, and it assumes that your compilation machine and your target execution machine are the same.

Resolving the problem

If you compile on a POWER5-based system and specify -O4, the default setting for -qarch is set to PWR5.

If the compilation machine is newer than the target machine, the generated binary may contain instruction sets that are not present on the target machine, which will result in an illegal instruction at run time.

You can override this behavior by specifying the -qarch option after the -O4 or -O5 compiler option.