RPCS3/rpcs3

Unable to build with gcc6

John-Gee opened this issue · 9 comments

Hello,

When I build on Linux with gcc6 it errors on this:

In file included from rpcs3-git/src/rpcs3/rpcs3/Emu/CPU/CPUThread.cpp:6:0:
rpcs3-git/src/rpcs3/rpcs3/Emu/Cell/SPUThread.h:379:31: warning: ignoring attributes on template argument ‘__m128 {aka __vector(4) float}’ [-Wignored-attributes]
std::array<__m128, 155 + 174> m_data;
^
rpcs3-git/src/rpcs3/rpcs3/Emu/Cell/SPUThread.h: In constructor ‘spu_imm_table_t::scale_table_t::scale_table_t()’:
rpcs3-git/src/rpcs3/rpcs3/Emu/Cell/SPUThread.h:386:60: error: ‘exp2’ was not declared in this scope
m_data[i + 155] = _mm_set1_ps(static_cast(exp2(i)));
^
rpcs3/CMakeFiles/rpcs3.dir/build.make:2051: recipe for target 'rpcs3/CMakeFiles/rpcs3.dir/Emu/CPU/CPUThread.cpp.o' failed
make[2]: *** [rpcs3/CMakeFiles/rpcs3.dir/Emu/CPU/CPUThread.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:607: recipe for target 'rpcs3/CMakeFiles/rpcs3.dir/all' failed
make[1]: *** [rpcs3/CMakeFiles/rpcs3.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

I am guessing it is related to this change in gcc:
Header <math.h> changes

The C++ library now provides its own <math.h> header that wraps the C library header of the same name. The C++ header defines additional overloads of some functions and ensures that all standard functions are defined as real functions and not as macros. Code which assumes that sin, cos, pow, isfinite etc. are macros may no longer compile.
https://gcc.gnu.org/gcc-6/porting_to.html

Unfortunately I have been unable to find a way to workaround this.
I hope someone else knows better.

try "using std::exp2;" in that function?

I feel dumb, yes #include math.h and std:: seem to work.
But, it brings more annoying ones:

rpcs3/rpcs3/Emu/Cell/SPUOpcodes.h: In constructor ‘spu_decoder<D, T>::spu_decoder() [with D = spu_itype::type; T = unsigned int spu_itype::type::]’:
rpcs3/rpcs3/Emu/Cell/SPUOpcodes.h:261:3: internal compiler error: in expand_expr_real_2, at expr.c:8097
[ 57%] Building CXX object rpcs3/CMakeFiles/rpcs3.dir/Emu/Cell/SPUInterpreter.cpp.o
Please submit a full bug report,
with preprocessed source if appropriate.
See https://bugs.archlinux.org/ for instructions.
rpcs3/CMakeFiles/rpcs3.dir/build.make:5021: recipe for target 'rpcs3/CMakeFiles/rpcs3.dir/Emu/Cell/SPUAnalyser.cpp.o' failed
make[2]: *
* [rpcs3/CMakeFiles/rpcs3.dir/Emu/Cell/SPUAnalyser.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
c++: internal compiler error: Segmentation fault (program cc1plus)

Better report the compiler bug, otherwise the only way is to adjust code/narrow down the cause of the crash and rewrite the code so it won't trigger the crash.

I've reported it to the GCC team, we'll see how that goes.

It has been accepted as a regression.
I'll keep this bug updated on how it goes.

I was given a patch that fixes the GCC segfault, I believe that patch will be part of 6.2 but I'm still hoping for 6.1.2 or so.

With that I was able to fix the rest of build issues and create a pull request for it.
I've made the check for GCC 6, even though up to 6.1.1 crashes, because there is nothing that can be easily done for 6.1 and 6.1.1 anyway... (If you're not aware of GCC numbering system, 6.1 is actually the first version in the 6 releases... There is no 6.0 stable build).

@John-Gee care to post GCC bug report link?

Here's one:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70869
It's not mine but it's the active one.

And it's fixed in GCC 6.2!