Godot: Cross compiling windows with ubuntu fails on etc2comp build

Created on 18 Jun 2017  路  22Comments  路  Source: godotengine/godot

Master branch

sudo apt-get install mingw-w64

scons p=windows

It stopped working ~5-10 days ago.

thirdparty/etc2comp/EtcImage.cpp: In member function 'Etc::Image::EncodingStatus Etc::Image::Encode(Etc::Image::Format, Etc::ErrorMetric, float, unsigned int, unsigned int)':
thirdparty/etc2comp/EtcImage.cpp:259:64: error: invalid use of incomplete type 'class std::future<void>'
   std::future<void> *handle = new std::future<void>[a_uiMaxJobs];
                                                                ^
In file included from thirdparty/etc2comp/EtcImage.cpp:40:0:
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/include/c++/future:115:11: note: declaration of 'class std::future<void>'
     class future;
           ^~~~~~
thirdparty/etc2comp/EtcImage.cpp:268:12: error: invalid use of incomplete type 'class std::future<void>'
    handle[i] = async(std::launch::async, &Image::RunFirstPass, this, i, uiNumThreadsNeeded);
            ^
In file included from thirdparty/etc2comp/EtcImage.cpp:40:0:
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/include/c++/future:115:11: note: declaration of 'class std::future<void>'
     class future;
           ^~~~~~
thirdparty/etc2comp/EtcImage.cpp:268:91: error: invalid use of incomplete type 'class std::future<void>'
 ndle[i] = async(std::launch::async, &Image::RunFirstPass, this, i, uiNumThreadsNeeded);
                                                                                      ^
In file included from thirdparty/etc2comp/EtcImage.cpp:40:0:
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/include/c++/future:115:11: note: declaration of 'class std::future<void>'
     class future;
           ^~~~~~
thirdparty/etc2comp/EtcImage.cpp:275:12: error: invalid use of incomplete type 'class std::future<void>'
    handle[i].get();
            ^
In file included from thirdparty/etc2comp/EtcImage.cpp:40:0:
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/include/c++/future:115:11: note: declaration of 'class std::future<void>'
     class future;
           ^~~~~~
thirdparty/etc2comp/EtcImage.cpp:275:13: error: invalid use of incomplete type 'class std::future<void>'
    handle[i].get();
             ^
In file included from thirdparty/etc2comp/EtcImage.cpp:40:0:
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/include/c++/future:115:11: note: declaration of 'class std::future<void>'
     class future;
           ^~~~~~
thirdparty/etc2comp/EtcImage.cpp:330:107: error: invalid use of incomplete type 'class std::future<unsigned int>'
 gned int> *handleToBlockEncoders = new std::future<unsigned int>[uiNumThreadsNeeded-1];
                                                                                      ^
In file included from thirdparty/etc2comp/EtcImage.cpp:40:0:
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/include/c++/future:115:11: note: declaration of 'class std::future<unsigned int>'
     class future;
           ^~~~~~
thirdparty/etc2comp/EtcImage.cpp:334:30: error: invalid use of incomplete type 'class std::future<unsigned int>'
       handleToBlockEncoders[i] = async(std::launch::async, &Image::IterateThroughWorstBlocks, this, blocksToIterateThisPass, i, uiNumThreadsNeeded);
                              ^
In file included from thirdparty/etc2comp/EtcImage.cpp:40:0:
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/include/c++/future:115:11: note: declaration of 'class std::future<unsigned int>'
     class future;
           ^~~~~~
thirdparty/etc2comp/EtcImage.cpp:334:147: error: invalid use of incomplete type 'class std::future<unsigned int>'
 mage::IterateThroughWorstBlocks, this, blocksToIterateThisPass, i, uiNumThreadsNeeded);
                                                                                      ^
In file included from thirdparty/etc2comp/EtcImage.cpp:40:0:
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/include/c++/future:115:11: note: declaration of 'class std::future<unsigned int>'
     class future;
           ^~~~~~
thirdparty/etc2comp/EtcImage.cpp:340:50: error: invalid use of incomplete type 'class std::future<unsigned int>'
       uiIteratedBlocks += handleToBlockEncoders[i].get();
                                                  ^
In file included from thirdparty/etc2comp/EtcImage.cpp:40:0:
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/include/c++/future:115:11: note: declaration of 'class std::future<unsigned int>'
     class future;
           ^~~~~~
thirdparty/etc2comp/EtcImage.cpp:340:51: error: invalid use of incomplete type 'class std::future<unsigned int>'
       uiIteratedBlocks += handleToBlockEncoders[i].get();
                                                   ^
In file included from thirdparty/etc2comp/EtcImage.cpp:40:0:
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/include/c++/future:115:11: note: declaration of 'class std::future<unsigned int>'
     class future;
           ^~~~~~
thirdparty/etc2comp/EtcImage.cpp:343:15: warning: possible problem detected in invocation of delete [] operator: [-Wdelete-incomplete]
      delete[] handleToBlockEncoders;
               ^~~~~~~~~~~~~~~~~~~~~
thirdparty/etc2comp/EtcImage.cpp:330:33: warning: 'handleToBlockEncoders' has incomplete type
      std::future<unsigned int> *handleToBlockEncoders = new std::future<unsigned int>[uiNumThreadsNeeded-1];
                                 ^~~~~~~~~~~~~~~~~~~~~
In file included from thirdparty/etc2comp/EtcImage.cpp:40:0:
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/include/c++/future:115:11: note: declaration of 'class std::future<unsigned int>'
     class future;
           ^~~~~~
thirdparty/etc2comp/EtcImage.cpp:343:15: note: neither the destructor nor the class-specific operator delete [] will be called, even if they are declared when the class is defined
      delete[] handleToBlockEncoders;
               ^~~~~~~~~~~~~~~~~~~~~
thirdparty/etc2comp/EtcImage.cpp:356:12: error: invalid use of incomplete type 'class std::future<void>'
    handle[i] = async(std::launch::async, &Image::SetEncodingBits, this, i, a_uiJobs);
            ^
In file included from thirdparty/etc2comp/EtcImage.cpp:40:0:
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/include/c++/future:115:11: note: declaration of 'class std::future<void>'
     class future;
           ^~~~~~
thirdparty/etc2comp/EtcImage.cpp:356:84: error: invalid use of incomplete type 'class std::future<void>'
    handle[i] = async(std::launch::async, &Image::SetEncodingBits, this, i, a_uiJobs);
                                                                                    ^
In file included from thirdparty/etc2comp/EtcImage.cpp:40:0:
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/include/c++/future:115:11: note: declaration of 'class std::future<void>'
     class future;
           ^~~~~~
thirdparty/etc2comp/EtcImage.cpp:362:12: error: invalid use of incomplete type 'class std::future<void>'
    handle[i].get();
            ^
In file included from thirdparty/etc2comp/EtcImage.cpp:40:0:
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/include/c++/future:115:11: note: declaration of 'class std::future<void>'
     class future;
           ^~~~~~
thirdparty/etc2comp/EtcImage.cpp:362:13: error: invalid use of incomplete type 'class std::future<void>'
    handle[i].get();
             ^
In file included from thirdparty/etc2comp/EtcImage.cpp:40:0:
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/include/c++/future:115:11: note: declaration of 'class std::future<void>'
     class future;
           ^~~~~~
thirdparty/etc2comp/EtcImage.cpp:369:12: warning: possible problem detected in invocation of delete [] operator: [-Wdelete-incomplete]
   delete[] handle;
            ^~~~~~
thirdparty/etc2comp/EtcImage.cpp:259:22: warning: 'handle' has incomplete type
   std::future<void> *handle = new std::future<void>[a_uiMaxJobs];
                      ^~~~~~
In file included from thirdparty/etc2comp/EtcImage.cpp:40:0:
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/include/c++/future:115:11: note: declaration of 'class std::future<void>'
     class future;
           ^~~~~~
thirdparty/etc2comp/EtcImage.cpp:369:12: note: neither the destructor nor the class-specific operator delete [] will be called, even if they are declared when the class is defined
   delete[] handle;
            ^~~~~~

Edit
Kubuntu 17.04
gcc (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406

bug linuxbsd windows buildsystem

Most helpful comment

I found the trouble: by default mingw on ubuntu works in win32 mode (which doesn't support thread), if you compile with posix mode it works.

To use posix mode for mingw by default:

$ sudo update-alternatives --config x86_64-w64-mingw32-gcc
<choose x86_64-w64-mingw32-gcc-posix from the list>
$ sudo update-alternatives --config x86_64-w64-mingw32-g++
<choose x86_64-w64-mingw32-g++-posix from the list>

It maybe worth a line in the documentation, what do you think ?

All 22 comments

Ubuntu and mingw versions?

Does it fail only when cross-compiling to win32, or also to win64?

Does it fail only when cross-compiling to win32, or also to win64?

Apparently both, as @Keetz had the same issue for win64: https://pastebin.com/vsdXEifT

Trying on Mageia, it builds fine both in 32-bit and 64-bit (I built with the changes of #9455, but I don't expect they would have an influence on this issue).

MinGW-w64 5.0.1 with GCC 6.1.0.

It also builds fine on Travis CI btw, with this system:
Ubuntu 14.04.3, MinGW-w64 3.1.0 with GCC 4.8.2.

So I'm not sure why it wouldn't work with versions in between like you have.

same issue on
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)

The fix is to change distro. So far it seems to fail only on Ubuntu :P

Are you guys using WSL (windows subsystem for linux) to compile Godot for Windows? I'm having the same issue here.

gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Windows 10 version 1703 build 15063.483

Same issue here with Ubuntu 16.04 with i686-w64-mingw32-gcc (GCC) 5.3.1 20160211 :'-(

I found the trouble: by default mingw on ubuntu works in win32 mode (which doesn't support thread), if you compile with posix mode it works.

To use posix mode for mingw by default:

$ sudo update-alternatives --config x86_64-w64-mingw32-gcc
<choose x86_64-w64-mingw32-gcc-posix from the list>
$ sudo update-alternatives --config x86_64-w64-mingw32-g++
<choose x86_64-w64-mingw32-g++-posix from the list>

It maybe worth a line in the documentation, what do you think ?

Hmm still not working.
I also get this message when I switch something.

update-alternatives: warning: skip creation of /usr/bin/x86_64-w64-mingw32-gcc-6 because associated file /usr/bin/x86_64-w64-mingw32-gcc-6-posix (of link group x86_64-w64-mingw32-gcc) doesn't exist

I was having the same problem on Ubuntu, but I managed to get it working by including bits=64 in the scons command

@sketchyfun I had the same issue compiling it with either 32 or 64 bits. Changing to posix mode with the above method solved it for me.

@Xrayez I tried that, but I received the same error as @AlexHolly. Either way, hopefully a combination of this information will be of help to other people :)

  1. Use @touilleMan solution an switch to posix
  2. Use @sketchyfun solution and run with scons p=windows bits=64

It works again, thanks.

Is there a bug in the scons or why is it not using bits=64 as default on a 64bit system?

@AlexHolly in my experience it is only p=windows that doesn't use 64 bits as default. Whenever i build to x11 it defaults to 64 bits just fine.

The bits logic on Windows is pretty convoluted, both for MinGW and for MSVC, so no idea why it defaults to 32-bit. At least it seems to try to detect 64-bit so I guess it's a bug.

I believe the logic is only for MSVC, because it requires the proper compiler to be already set up. With MinGW you can have both compilers available and select the right one by changing the prefix.

so, issue or not?

Got a report on Discord of someone running into this issue on Lubuntu (version unknown) with MinGW-w64 4.0.4.

Looks like that version is buggy, so the fix would be: get a newer mingw.
Edit: There's a workaround documented above: https://github.com/godotengine/godot/issues/9258#issuecomment-315612079

does anyone know if it is possible to switch to posix in shell without manually entering the number?

If you try to build some CI you should try to use a proper docker-container where this is not needed.
This one works for me FROM debian:jessie

If not this should work.

RUN echo "1"| sudo update-alternatives --config x86_64-w64-mingw32-gcc
RUN echo "1"| sudo update-alternatives --config x86_64-w64-mingw32-g++
Was this page helpful?
0 / 5 - 0 ratings