Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue Report]: MinGW build fails on gcc 13 due to error in mingw-std-threads #6901

Open
seadra opened this issue Jan 15, 2024 · 6 comments
Open

Comments

@seadra
Copy link

seadra commented Jan 15, 2024

Operating System

Linux x64

DevilutionX version

1.5.1

Describe

Following the compilation instructions from here. Several issues:

  1. The script Packaging/windows/mingw-prep64.sh doesn't handle zlib as claimed, manually installed the package mingw-w64-zlib from AUR (I'm on Arch Linux).
  2. Running cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE=../CMake/platforms/mingwcc64.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DDEVILUTIONX_SYSTEM_BZIP2=OFF fails with
-- The C compiler identification is GNU 13.1.0
-- The CXX compiler identification is GNU 13.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- 📚 zlib: dynamic system library
-- 📚 bzip2: static library from source
-- 📚 SDL2: dynamic system library
-- Found SDL_image
-- 📚 SDL_image: dynamic system library
-- Found fmt 10.2.0
-- 📚 libfmt: dynamic system library
-- Found PkgConfig: /usr/bin/x86_64-w64-mingw32-pkg-config (found version "2.1.0") 
-- Suitable system SDL_audiolib package not found, will use SDL_audiolib from source
-- 📚 SDL_audiolib: static library from source
-- Performing Test HAVE_STD_CLAMP
-- Performing Test HAVE_STD_CLAMP - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- 📚 libsodium: dynamic system library
-- Found sodium: /usr/x86_64-w64-mingw32/lib/libsodium.dll.a (found version "1.0.18") 
-- Suitable system simpleini package not found, will use simpleini from source
-- 📚 simpleini: static library from source
-- Found ZLIB: /usr/x86_64-w64-mingw32/lib/libz.dll.a (found version "1.3")  
CMake Deprecation Warning at build/_deps/libzt-src/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Deprecation Warning at build/_deps/mingw-std-threads-src/CMakeLists.txt:2 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Deprecation Warning at build/_deps/mingw-std-threads-src/cmake_stdheaders_generator/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


cmake_stdheaders_generator: output_include_path set to /home/salviati/Downloads/devilutionX-1.5.1/build/_deps/mingw-std-threads-build/cmake_stdheaders_generator/cmake_stdheaders_generator
cmake_stdheaders_generator: MINGW_STDTHREADS_DIR: /home/salviati/Downloads/devilutionX-1.5.1/build/_deps/mingw-std-threads-src
Matched: </usr/x86_64-w64-mingw32/include/c++/13.1.0/condition_variable>
Matched: </usr/x86_64-w64-mingw32/include/c++/13.1.0/future>
Matched: </usr/x86_64-w64-mingw32/include/c++/13.1.0/mutex>
Matched: </usr/x86_64-w64-mingw32/include/c++/13.1.0/shared_mutex>
Matched: </usr/x86_64-w64-mingw32/include/c++/13.1.0/thread>
-- Found Gettext: /usr/bin/msgmerge (found version "0.22.4") 
-- Configuring done (59.3s)
CMake Error in CMakeLists.txt:
  IMPORTED_IMPLIB not set for imported target "fmt::fmt" configuration
  "Release".


CMake Error in CMakeLists.txt:
  IMPORTED_IMPLIB not set for imported target "fmt::fmt" configuration
  "Release".


-- Generating done (0.1s)
CMake Generate step failed.  Build files cannot be regenerated correctly.

To Reproduce

Follow the build instructions from here

Expected Behavior

Successful build

Additional context

No response

@seadra
Copy link
Author

seadra commented Jan 15, 2024

Adding -DDEVILUTIONX_SYSTEM_LIBFMT=OFF seems to be working as a workaround. However, running make, the compilation itself fails with the message

In file included from /home/user/devilutionX-1.5.1/build/_deps/mingw-std-threads-build/cmake_stdheaders_generator/cmake_stdheaders_generator/future:10:
/home/user/devilutionX-1.5.1/build/_deps/mingw-std-threads-src/mingw.future.h:355:17: error: ‘__async_result_of’ was not declared in this scope; did you mean ‘std::__async_result_of’?
  355 |   friend future<__async_result_of<_Fn, _Args...>> async (std::launch, _Fn &&, _Args&&...);
      |                 ^~~~~~~~~~~~~~~~~
      |                 std::__async_result_of
/usr/x86_64-w64-mingw32/include/c++/13.1.0/future:197:11: note: ‘std::__async_result_of’ declared here
  197 |     using __async_result_of = typename __invoke_result<
      |           ^~~~~~~~~~~~~~~~~
/home/user/devilutionX-1.5.1/build/_deps/mingw-std-threads-src/mingw.future.h:355:48: error: template argument 1 is invalid
  355 |   friend future<__async_result_of<_Fn, _Args...>> async (std::launch, _Fn &&, _Args&&...);
      |                                                ^~
/home/user/devilutionX-1.5.1/build/_deps/mingw-std-threads-src/mingw.future.h:702:17: error: ‘__async_result_of’ was not declared in this scope; did you mean ‘std::__async_result_of’?
  702 |   friend future<__async_result_of<_Fn, _Args...>> async (std::launch, _Fn &&, _Args&&...);
      |                 ^~~~~~~~~~~~~~~~~
      |                 std::__async_result_of
/usr/x86_64-w64-mingw32/include/c++/13.1.0/future:197:11: note: ‘std::__async_result_of’ declared here
  197 |     using __async_result_of = typename __invoke_result<
      |           ^~~~~~~~~~~~~~~~~
/home/user/devilutionX-1.5.1/build/_deps/mingw-std-threads-src/mingw.future.h:702:48: error: template argument 1 is invalid
  702 |   friend future<__async_result_of<_Fn, _Args...>> async (std::launch, _Fn &&, _Args&&...);
      |                                                ^~
/home/user/devilutionX-1.5.1/build/_deps/mingw-std-threads-src/mingw.future.h:805:17: error: ‘__async_result_of’ was not declared in this scope; did you mean ‘std::__async_result_of’?
  805 |   friend future<__async_result_of<_Fn, _Args...>> async (std::launch, _Fn &&, _Args&&...);
      |                 ^~~~~~~~~~~~~~~~~
      |                 std::__async_result_of
/usr/x86_64-w64-mingw32/include/c++/13.1.0/future:197:11: note: ‘std::__async_result_of’ declared here
  197 |     using __async_result_of = typename __invoke_result<
      |           ^~~~~~~~~~~~~~~~~
/home/user/devilutionX-1.5.1/build/_deps/mingw-std-threads-src/mingw.future.h:805:48: error: template argument 1 is invalid
  805 |   friend future<__async_result_of<_Fn, _Args...>> async (std::launch, _Fn &&, _Args&&...);
      |                                                ^~
/home/user/devilutionX-1.5.1/build/_deps/mingw-std-threads-src/mingw.future.h:848:18: error: ‘class mingw_stdthread::future<mingw_stdthread::detail::Empty> mingw_stdthread::future<mingw_stdthread::detail::Empty>::future’ is private within this context
  848 |   shared_future (future<void> && source) noexcept
      |                  ^~~~~~~~~~~~
/home/user/devilutionX-1.5.1/build/_deps/mingw-std-threads-src/mingw.future.h:416:7: note: declared private here
  416 | class shared_future : future<T>
      |       ^~~~~~~~~~~~~
/home/user/devilutionX-1.5.1/build/_deps/mingw-std-threads-src/mingw.future.h:853:36: error: ‘class mingw_stdthread::future<mingw_stdthread::detail::Empty> mingw_stdthread::future<mingw_stdthread::detail::Empty>::future’ is private within this context
  853 |   shared_future<void> & operator= (future<void> && source) noexcept
      |                                    ^~~~~~~~~~~~
/home/user/devilutionX-1.5.1/build/_deps/mingw-std-threads-src/mingw.future.h:416:7: note: declared private here
  416 | class shared_future : future<T>
      |       ^~~~~~~~~~~~~
/home/user/devilutionX-1.5.1/build/_deps/mingw-std-threads-src/mingw.future.h:924:8: error: ‘uses_allocator’ is not a class template
  924 | struct uses_allocator<promise<T>, Alloc> : std::true_type
      |        ^~~~~~~~~~~~~~
/home/user/devilutionX-1.5.1/build/_deps/mingw-std-threads-src/mingw.future.h:1025:3: error: redefinition of ‘template<class Function, class ... Args> std::future<typename std::__invoke_result<typename std::decay<_Tp>::type, typename std::decay<_Types>::type ...>::type> std::async(Function&&, Args&& ...)’
 1025 |   async(Function&& f, Args&&... args)
      |   ^~~~~
/usr/x86_64-w64-mingw32/include/c++/13.1.0/future:1828:5: note: ‘template<class _Fn, class ... _Args> std::future<typename std::__invoke_result<typename std::decay<_Tp>::type, typename std::decay<_Types>::type ...>::type> std::async(_Fn&&, _Args&& ...)’ previously declared here
 1828 |     async(_Fn&& __fn, _Args&&... __args)
      |     ^~~~~
/home/user/devilutionX-1.5.1/build/_deps/mingw-std-threads-src/mingw.future.h:1042:3: error: redefinition of ‘template<class Function, class ... Args> std::future<typename std::__invoke_result<typename std::decay<_Tp>::type, typename std::decay<_Types>::type ...>::type> std::async(launch, Function&&, Args&& ...)’
 1042 |   async(std::launch policy, Function&& f, Args&&... args)
      |   ^~~~~
/usr/x86_64-w64-mingw32/include/c++/13.1.0/future:1794:5: note: ‘template<class _Fn, class ... _Args> std::future<typename std::__invoke_result<typename std::decay<_Tp>::type, typename std::decay<_Types>::type ...>::type> std::async(launch, _Fn&&, _Args&& ...)’ previously declared here
 1794 |     async(launch __policy, _Fn&& __fn, _Args&&... __args)
      |     ^~~~~
make[2]: *** [Source/CMakeFiles/libdevilutionx.dir/build.make:1277: Source/CMakeFiles/libdevilutionx.dir/dvlnet/abstract_net.cpp.obj] Error 1
make[2]: *** Waiting for unfinished jobs....
/home/user/devilutionX-1.5.1/Source/platform/locale.cpp: In lambda function:
/home/user/devilutionX-1.5.1/Source/platform/locale.cpp:127:33: warning: moving a temporary object prevents copy elision [-Wpessimizing-move]
  127 |                 return std::move(IetfToPosix(utf8Buffer));
      |                        ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/home/user/devilutionX-1.5.1/Source/platform/locale.cpp:127:33: note: remove ‘std::move’ call
make[1]: *** [CMakeFiles/Makefile2:2272: Source/CMakeFiles/libdevilutionx.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

@AJenbo
Copy link
Member

AJenbo commented Jan 15, 2024

The instructions are for Debian and Fedora, not Arch.

Since the CI is successfully building it looks like a system specific issue: https://github.com/diasurgical/devilutionX/actions/runs/7495821381/job/20406635578

Adding -DDEVILUTIONX_SYSTEM_LIBFMT=OFF seems to be working as a workaround.

Probably the version installed on your system is incompatible.

Regarding the other issues, try GCC 10 since that is what is currently being used on the test build.

I don't have a working install of Arch and find the install process to much of a hazel for me to maintain support for it, so I'm going to close this issue, but you are welcome to contribute an improvements to the guide and build scripts that can help it work better for Arch setups.

@AJenbo AJenbo closed this as not planned Won't fix, can't repro, duplicate, stale Jan 15, 2024
@AJenbo
Copy link
Member

AJenbo commented Jan 15, 2024

If you need help, I would suggest the Discord chat or Discussion section.

@seadra
Copy link
Author

seadra commented Jan 15, 2024

I'm OK with switching to other distributions so can we re-open this?

I installed Debian 12.4.0 to test the instructions since you say it works on Debian, but unfortunately it doesn't. The compilation fails with the following error:

[ 65%] Built target SDL_image
In file included from /home/user/Downloads/devilutionX-1.5.1/build/_deps/mingw-std-threads-build/cmake_stdheaders_generator/cmake_stdheaders_generator/thread:10,
                 from /home/user/Downloads/devilutionX-1.5.1/build/_deps/libzt-src/ext/concurrentqueue/concurrentqueue.h:71,
                 from /home/user/Downloads/devilutionX-1.5.1/build/_deps/libzt-src/src/Events.cpp:24:
/home/user/Downloads/devilutionX-1.5.1/build/_deps/mingw-std-threads-src/mingw.thread.h:330:24: error: ‘class mingw_stdthread::thread’ conflicts with a previous declaration
  330 | using mingw_stdthread::thread;
      |                        ^~~~~~
In file included from /usr/lib/gcc/x86_64-w64-mingw32/12-win32/include/c++/stop_token:35,
                 from /usr/lib/gcc/x86_64-w64-mingw32/12-win32/include/c++/thread:40,
                 from /home/user/Downloads/devilutionX-1.5.1/build/_deps/mingw-std-threads-build/cmake_stdheaders_generator/cmake_stdheaders_generator/thread:9:
/usr/lib/gcc/x86_64-w64-mingw32/12-win32/include/c++/bits/std_thread.h:61:9: note: previous declaration ‘class std::thread’
   61 |   class thread
      |         ^~~~~~
cc1plus: note: unrecognized command-line option ‘-Wno-everything’ may have been intended to silence earlier diagnostics
gmake[2]: *** [_deps/libzt-build/CMakeFiles/zt-static.dir/build.make:107: _deps/libzt-build/CMakeFiles/zt-static.dir/src/Events.cpp.obj] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:2209: _deps/libzt-build/CMakeFiles/zt-static.dir/all] Error 2

@seadra
Copy link
Author

seadra commented Jan 15, 2024

This suggests there is an issue with mingw threading library that needs to be fixed eventually since distros won't maintain gcc 10 forever.

The build you linked to is Ubuntu 22.04.3 LTS, which uses gcc 10 according to you. Current Arch has gcc 13.1, current release of Debian (and presumably Ubuntu) has gcc 12 in their mingw packages.

@StephenCWills
Copy link
Member

I'm OK with switching to other distributions so can we re-open this?

If someone can figure out what's going on with the MinGW threading library, that would be great. I believe this issue is related.
meganz/mingw-std-threads#79

Sadly, there's been no update since Aug 2021. But it looks like a handful of projects have come up with workarounds.

@StephenCWills StephenCWills reopened this Jan 15, 2024
@StephenCWills StephenCWills changed the title [Issue Report]: MinGW build fails on Linux with error IMPORTED_IMPLIB not set for imported target "fmt::fmt" [Issue Report]: MinGW build fails on gcc 13 due to error in mingw-std-threads Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants