Description:
GNU C/C++ 5.3.0 compiler for sparc have a faulty shift-or optimization that recently hit MySQL Cluster 7.5.4 release build, see details in Bug#24941880 SPARC COMPILER BUG DUE TO SIGNED INT IN SHIFT OPERATIONS
Bug#24941880 was fixed by refactoring to avoid a known instance of the faulty optimization.
-fexpensive-optimizations should be turned off to avoid this faulty optimization also for potentially undetected instances.
Most likely the bug in question is GCC Bug 67781 and should been fixed in 5.4.0 and 6.0
Bug 67781 - [5 Regression] wrong code generated on big-endian with -O1 -fexpensive-optimizations
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67781
How to repeat:
Compile and run below code on sparc with GNU C or C++ 5.3.0
struct X
{
int i;
unsigned short s;
};
unsigned __attribute__((noinline)) f(struct X x)
{
return x.s | (x.i << 16);
}
int
main()
{
struct X x;
x.i = 0x00001234;
x.s = 0x5678;
unsigned y = f(x);
/* Succeed (return 0) if compiler have bug */
return y == 0x12345678 ? 1 : 0;
}
Suggested fix:
Add cmake check using above code, and turn off expensive optimizations if compiler is found faulty.
This should be pushed at least to 5.7/7.5 and up since we currently build releases affected by bug.
Alternatively upgrade to newer compiler and verify bug is gone.
And let any other building using 5.3.0 on sparc be on their own.