On 3/17/22 09:56, Martin Storsjö wrote:

However, autotools does some dubious choices here. If I'm configuring a cross compiler, and I do have x86_64-w64-mingw32-gcc but I don't have x86_64-w64-mingw32-g++ because I built only with --enable-languages=c, the configure script does this detection:

checking for x86_64-w64-mingw32-g++... no
checking for x86_64-w64-mingw32-c++... no
checking for x86_64-w64-mingw32-gpp... no
checking for x86_64-w64-mingw32-aCC... no
checking for x86_64-w64-mingw32-CC... no
checking for x86_64-w64-mingw32-cxx... no
checking for x86_64-w64-mingw32-cc++... no
checking for x86_64-w64-mingw32-cl.exe... no
checking for x86_64-w64-mingw32-FCC... no
checking for x86_64-w64-mingw32-KCC... no
checking for x86_64-w64-mingw32-RCC... no
checking for x86_64-w64-mingw32-xlC_r... no
checking for x86_64-w64-mingw32-xlC... no
checking for x86_64-w64-mingw32-clang++... no
checking for g++... g++
configure: WARNING: using cross tools not prefixed with host triplet

So instead of concluding that it didn't find any C++ compiler, it picks up the host (in my case, linux) C++ compiler instead. It gives a warning about it, but still proceeds, and any condition in the code would be enabled as it _did_ find a C++ commpiler. Building then later fails like this:

g++ -DHAVE_CONFIG_H -I. -I..  -m64 "-I/opt/gcc-mingw/x86_64-w64-mingw32/include"   -Wall -Wextra -Wformat -Wstrict-aliasing -Wshadow -Wpacked -Winline  -g -O2 -MT libsrc/lib64_libcomsupp_a-comsupp.o -MD -MP -MF libsrc/.deps/lib64_libcomsupp_a-comsupp.Tpo -c -o libsrc/lib64_libcomsupp_a-comsupp.o `test -f 'libsrc/comsupp.cpp' || echo '../'`libsrc/comsupp.cpp
g++: error: unrecognized command line option '-m64'
Makefile:69208: recipe for target 'libsrc/lib64_libcomsupp_a-comsupp.o' failed

This was on aarch64 linux, where GCC doesn't support the -m64 option. On x86_64 linux, where GCC does support the option, compiling of the file instead fails because it can't understand the Windows headers that are included when building it.

Thus, TL;DR, technically this particular instance of C++ in mingw-w64-crt could be tolerable, but we must be very very careful about any addition of new C++ sources there. But the patch as is does indeed break setting up environments without a C++ compiler, which worked just fine before.


Jacek, do you have any advice on autotools, for making it not accidentally pick up incorrect (host) compilers when the real intended one is missing?


Yeah, this autotools behaviour looks buggy. I don't know how it's intended to be used, I'm CCing NightStrike hoping that he knows better what's going on. I can see some possible solution, but it would be nice to understand root of the problem:


- We could use something like AC_COMPILE_IFELSE with input like:

#ifndef __MINGW32__

#error ...

#endif

and skip C++ sources if that test fails.


- We could just get rid of AC_PROG_CXX macro and instead check if $(CC) supports -xc++ option. If it does, use it for C++ sources, skip otherwise.


- Use inline implementation. Those functions look easy enough for that. I guess the dependency is pulled by our comutil.h, or is it the application itself that calls them?


Thanks,

Jacek



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to