bebbo / amiga-gcc

The GNU C-Compiler with Binutils and other useful tools for cross development for Amiga
GNU General Public License v2.0
312 stars 66 forks source link

Missing string overload for stoi() #346

Closed StephenCWills closed 1 year ago

StephenCWills commented 1 year ago

We've been receiving the following error when building DevilutionX using the amigadev/crosstools:m68k-amigaos image for the past couple days.

[ 68%] Building CXX object Source/CMakeFiles/libdevilutionx.dir/pfile.cpp.obj
/root/repo/Source/pfile.cpp: In lambda function:
/root/repo/Source/pfile.cpp:287:36: error: invalid initialization of reference of type 'const wstring& {aka const std::__cxx11::basic_string<wchar_t>&}' from expression of type 'const string {aka const std::__cxx11::basic_string<char>}'
   int countFromMapFile = std::stoi(counterAsString);
                                    ^~~~~~~~~~~~~~~
In file included from /opt/m68k-amigaos/lib/gcc/m68k-amigaos/6.5.0b/include/c++/string:52:0,
                 from /opt/m68k-amigaos/lib/gcc/m68k-amigaos/6.5.0b/include/c++/stdexcept:39,
                 from /opt/m68k-amigaos/lib/gcc/m68k-amigaos/6.5.0b/include/c++/array:39,
                 from /root/repo/Source/DiabloUI/diabloui.h:4,
                 from /root/repo/Source/pfile.h:10,
                 from /root/repo/Source/pfile.cpp:6:
/opt/m68k-amigaos/lib/gcc/m68k-amigaos/6.5.0b/include/c++/bits/basic_string.h:5547:3: note: in passing argument 1 of 'int std::__cxx11::stoi(const wstring&, std::size_t*, int)'
   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
   ^~~~

The error indicates that the compiler is selecting the wstring overload of the stoi() function, but the counterAsString variable is of type string. TBH, I'm only guessing that it means the overload for string is missing, but I don't really know what's going on.

FYI, I get the same error when testing our builds against amigadev/crosstools:m68k-amigaos-gcc10. If it helps, I also reproduced it by attempting to compile the following program with /opt/m68k-amigaos/bin/m68k-amigaos-g++.

#include <string>

int main() {
    std::string hello("0");
    int num = std::stoi(hello);
    return num;
}
MBeijer commented 1 year ago

To add some information, both gcc6 and gcc13.1 images were built May 26, 2023, 11:00 AM. Let me know when I should rebuild. :)

bebbo commented 1 year ago

To add some information, both gcc6 and gcc13.1 images were built May 26, 2023, 11:00 AM. Let me know when I should rebuild. :)

it's time for a rebuild.

make clean-gcc update
make min -j128

(adjust the 128 to your cpu count)

MBeijer commented 1 year ago

new images for gcc6 and gcc13.1 built

StephenCWills commented 1 year ago

Seems to still be an issue on the new images.

AJenbo commented 1 year ago

Confirmed for both containers

bebbo commented 1 year ago

sorry for the inconvenience... we need another round, since one symbol was still missing and the libstdc++ build did not enable the missing functions. => hit it!

MBeijer commented 1 year ago

new images built

AJenbo commented 1 year ago

GCC6 successfully build. Here is the test result for that container: https://output.circle-artifacts.com/output/job/98db29fb-4468-4f7b-bdd6-8e4be046faa7/artifacts/0/devilutionx_m68k

AJenbo commented 1 year ago

GCC13.1 also successfully build now: https://output.circle-artifacts.com/output/job/b4f4aa1b-7810-43ff-8b28-b378381ab263/artifacts/0/devilutionx_m68k