https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124234
Bug ID: 124234
Summary: Internal Compiler Error: in expand_fn_using_insn, at
internal-fn.cc:268 when cross-compiling for
mips64r5900el-ps2-elf
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: carter.rennick at gmail dot com
Target Milestone: ---
Created attachment 63782
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63782&action=edit
-freport-bug output
Any use of std::print or std::println triggers an internal compiler error when
building for PlayStation 2 MIPS (mips64r5900el-ps2-elf) via ps2dev, which
appears to be using GCC 15.2.0 internally.
Minimum reproducible example:
#include <print>
int main(){ std::println("Hello, World!"); }
Repro steps (since this is associated with a specific and pretty niche platform
I do not know if I can simplify the repro steps any further than this):
* Use the ps2dev/ps2dev:latest docker container
* Bare minimum CMake:
cmake_minimum_required (VERSION 3.20)
project ("TestProject" LANGUAGES CXX)
add_executable(TestProject "Main.cpp")
target_compile_features(TestProject PUBLIC cxx_std_23)
```
* Create src/Main.cpp with the above C++ code.
* Configure CMake with the following arguments, and then build:
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release
-DCMAKE_TOOLCHAIN_FILE=$PS2DEV/share/ps2dev.cmake
You should see this compiler output:
```
[ 50%] Building CXX object CMakeFiles/TestProject.dir/src/Main.cpp.obj
Using built-in specs.
COLLECT_GCC=/usr/local/ps2dev/ee/bin/mips64r5900el-ps2-elf-g++
Target: mips64r5900el-ps2-elf
Configured with: ../configure --quiet --prefix=/usr/local/ps2dev/ee
--target=mips64r5900el-ps2-elf --enable-languages=c,c++ --with-float=hard
--with-sysroot=/usr/local/ps2dev/ee/mips64r5900el-ps2-elf
--with-native-system-header-dir=/include --with-newlib --disable-libssp
--disable-multilib --disable-nls --disable-tls --enable-cxx-flags=-G0
--enable-threads=posix --silent
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.2.0 (GCC)
COLLECT_GCC_OPTIONS='-I' '/usr/local/ps2dev/ps2sdk/ee/include' '-I'
'/usr/local/ps2dev/ps2sdk/common/include' '-I'
'/usr/local/ps2dev/gsKit/include' '-I' '/usr/local/ps2dev/ps2sdk/ports/include'
'-D' '_EE' '-D' 'PS2' '-D' '__PS2__' '-O2' '-G' '0' '-O3' '-D' 'NDEBUG'
'-std=gnu++23' '-v' '-save-temps' '-freport-bug' '-MD' '-MT'
'CMakeFiles/TestProject.dir/src/Main.cpp.obj' '-MF'
'CMakeFiles/TestProject.dir/src/Main.cpp.obj.d' '-o'
'CMakeFiles/TestProject.dir/src/Main.cpp.obj' '-c' '-march=r5900'
'-mhard-float' '-msingle-float' '-mno-llsc' '-mno-shared' '-mplt' '-dumpdir'
'CMakeFiles/TestProject.dir/src/'
/usr/local/ps2dev/ee/libexec/gcc/mips64r5900el-ps2-elf/15.2.0/cc1plus -E
-quiet -v -I /usr/local/ps2dev/ps2sdk/ee/include -I
/usr/local/ps2dev/ps2sdk/common/include -I /usr/local/ps2dev/gsKit/include -I
/usr/local/ps2dev/ps2sdk/ports/include -MD
CMakeFiles/TestProject.dir/src/Main.cpp.d -MF
CMakeFiles/TestProject.dir/src/Main.cpp.obj.d -MT
CMakeFiles/TestProject.dir/src/Main.cpp.obj -D _EE -D PS2 -D __PS2__ -D NDEBUG
/usr/local/sdl-test/src/Main.cpp -G 0 -march=r5900 -mhard-float -msingle-float
-mno-llsc -mno-shared -mplt -std=gnu++23 -freport-bug -O2 -O3 -fpch-preprocess
-o CMakeFiles/TestProject.dir/src/Main.cpp.ii
ignoring nonexistent directory
"/usr/local/ps2dev/ee/mips64r5900el-ps2-elf/usr/local/include"
ignoring duplicate directory
"/usr/local/ps2dev/ee/mips64r5900el-ps2-elf/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/ps2dev/ps2sdk/ee/include
/usr/local/ps2dev/ps2sdk/common/include
/usr/local/ps2dev/gsKit/include
/usr/local/ps2dev/ps2sdk/ports/include
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/15.2.0/../../../../mips64r5900el-ps2-elf/include/c++/15.2.0
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/15.2.0/../../../../mips64r5900el-ps2-elf/include/c++/15.2.0/mips64r5900el-ps2-elf
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/15.2.0/../../../../mips64r5900el-ps2-elf/include/c++/15.2.0/backward
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/15.2.0/include
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/15.2.0/include-fixed
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/15.2.0/../../../../mips64r5900el-ps2-elf/include
End of search list.
COLLECT_GCC_OPTIONS='-I' '/usr/local/ps2dev/ps2sdk/ee/include' '-I'
'/usr/local/ps2dev/ps2sdk/common/include' '-I'
'/usr/local/ps2dev/gsKit/include' '-I' '/usr/local/ps2dev/ps2sdk/ports/include'
'-D' '_EE' '-D' 'PS2' '-D' '__PS2__' '-O2' '-G' '0' '-O3' '-D' 'NDEBUG'
'-std=gnu++23' '-v' '-save-temps' '-freport-bug' '-MD' '-MT'
'CMakeFiles/TestProject.dir/src/Main.cpp.obj' '-MF'
'CMakeFiles/TestProject.dir/src/Main.cpp.obj.d' '-o'
'CMakeFiles/TestProject.dir/src/Main.cpp.obj' '-c' '-march=r5900'
'-mhard-float' '-msingle-float' '-mno-llsc' '-mno-shared' '-mplt' '-dumpdir'
'CMakeFiles/TestProject.dir/src/'
/usr/local/ps2dev/ee/libexec/gcc/mips64r5900el-ps2-elf/15.2.0/cc1plus
-fpreprocessed CMakeFiles/TestProject.dir/src/Main.cpp.ii -G 0 -quiet -dumpdir
CMakeFiles/TestProject.dir/src/ -dumpbase Main.cpp.cpp -dumpbase-ext .cpp
-march=r5900 -mhard-float -msingle-float -mno-llsc -mno-shared -mplt -O2 -O3
-std=gnu++23 -version -freport-bug -o CMakeFiles/TestProject.dir/src/Main.cpp.s
GNU C++23 (GCC) version 15.2.0 (mips64r5900el-ps2-elf)
compiled by GNU C version 14.2.0, GMP version 6.3.0, MPFR version
4.2.1-p1, MPC version 1.3.1, isl version none
warning: MPFR header version 4.2.1-p1 differs from library version 4.2.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: d8363d029790d6f4b7bac5890fe15d10
during RTL pass: expand
In file included from
/usr/local/ps2dev/ee/mips64r5900el-ps2-elf/include/c++/15.2.0/bits/stl_algobase.h:76,
from
/usr/local/ps2dev/ee/mips64r5900el-ps2-elf/include/c++/15.2.0/array:45,
from
/usr/local/ps2dev/ee/mips64r5900el-ps2-elf/include/c++/15.2.0/format:45,
from
/usr/local/ps2dev/ee/mips64r5900el-ps2-elf/include/c++/15.2.0/print:43,
from /usr/local/sdl-test/src/Main.cpp:1:
In function 'constexpr int std::__countl_zero(_Tp) [with _Tp = __int128
unsigned]',
inlined from 'constexpr int std::__bit_width(_Tp) [with _Tp = __int128
unsigned]' at
/usr/local/ps2dev/ee/mips64r5900el-ps2-elf/include/c++/15.2.0/bit:388:38,
inlined from 'constexpr unsigned int std::__detail::__to_chars_len_2(_Tp)
[with _Tp = __int128 unsigned]' at
/usr/local/ps2dev/ee/mips64r5900el-ps2-elf/include/c++/15.2.0/charconv:121:30,
inlined from 'constexpr std::to_chars_result
std::__detail::__to_chars_2(char*, char*, _Tp) [with _Tp = __int128 unsigned]'
at
/usr/local/ps2dev/ee/mips64r5900el-ps2-elf/include/c++/15.2.0/charconv:294:46,
inlined from 'constexpr std::to_chars_result std::__to_chars_i(char*,
char*, _Tp, int) [with _Tp = __int128 unsigned]' at
/usr/local/ps2dev/ee/mips64r5900el-ps2-elf/include/c++/15.2.0/charconv:355:31,
inlined from 'constexpr std::to_chars_result std::to_chars(char*, char*,
__int128 unsigned, int)' at
/usr/local/ps2dev/ee/mips64r5900el-ps2-elf/include/c++/15.2.0/charconv:378:161,
inlined from 'typename std::basic_format_context<_Out, _CharT>::iterator
std::__format::__formatter_int<_CharT>::format(_Int,
std::basic_format_context<_Out, _CharT>&) const [with _Int = __int128; _Out =
std::__format::_Sink_iter<char>; _CharT = char]' at
/usr/local/ps2dev/ee/mips64r5900el-ps2-elf/include/c++/15.2.0/format:1606:24:
/usr/local/ps2dev/ee/mips64r5900el-ps2-elf/include/c++/15.2.0/bit:209:37:
internal compiler error: in expand_fn_using_insn, at internal-fn.cc:268
209 | return __builtin_clzg(__x, _Nd);
| ^
0x1acf4ee diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
???:0
0x1ae0232 internal_error(char const*, ...)
???:0
0x66b28a fancy_abort(char const*, int, char const*)
???:0
Please submit a full bug report, with preprocessed source.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Preprocessed source stored into /tmp/ccHAAedd.out file, please attach this to
your bugreport.
gmake[2]: *** [CMakeFiles/TestProject.dir/build.make:79:
CMakeFiles/TestProject.dir/src/Main.cpp.obj] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:87: CMakeFiles/TestProject.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
```
I am unsure of how to update the compiler version used by ps2dev so I have not
tried a newer GCC version. I am also unclear on who's responsibility it is to
fix this, so I also reported the issue to ps2dev:
https://github.com/ps2dev/ps2dev/issues/121