[PATCH 0/2] MR10399: configure: Look for an actual C++ compiler.
Instead of assuming the C compiler can compile C++. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10399
From: Rémi Bernon <rbernon@codeweavers.com> Instead of assuming the C compiler can compile C++. --- configure.ac | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 89243b45be0..65a6bbfcaf7 100644 --- a/configure.ac +++ b/configure.ac @@ -94,9 +94,9 @@ AC_ARG_WITH(wine64, AS_HELP_STRING([--with-wine64=DIR],[use the 64-bit Wine i AC_CANONICAL_HOST AC_SUBST(srcdir) -AS_IF([test "x$enable_sast" = xyes],[CC=${CC:-clang} -with_mingw=${with_mingw:-clang} -AC_CHECK_PROGS(SARIF_CONVERTER,sarif-converter,false)]) +AS_IF([test "x$enable_sast" = xyes],[CC=${CC:-clang}; CXX=${CXX:-clang++} + with_mingw=${with_mingw:-clang} + AC_CHECK_PROGS(SARIF_CONVERTER,sarif-converter,false)]) dnl **** Check for some programs **** @@ -419,27 +419,36 @@ do *) mingw_cpu=$wine_arch ;; esac case "x$with_mingw" in - xclang|x*/clang) AS_VAR_SET(${wine_arch}_CC,$with_mingw) ;; - xllvm-mingw) AS_VAR_SET(${wine_arch}_CC,${mingw_cpu}-w64-mingw32-clang) ;; + xclang|x*/clang) AS_VAR_SET(${wine_arch}_CC,$with_mingw) + AS_VAR_SET(${wine_arch}_CXX,${with_mingw}++) ;; + xllvm-mingw) AS_VAR_SET(${wine_arch}_CC,${mingw_cpu}-w64-mingw32-clang) + AS_VAR_SET(${wine_arch}_CXX,${mingw_cpu}-w64-mingw32-clang++) ;; esac AS_VAR_IF([${wine_arch}_CC],[], [case $wine_arch in aarch64) AC_CHECK_PROGS(aarch64_CC,[aarch64-w64-mingw32-clang aarch64-w64-mingw32-gcc clang],[false]) + AC_CHECK_PROGS(aarch64_CXX,[aarch64-w64-mingw32-clang++ aarch64-w64-mingw32-g++ clang++],[false]) ;; arm64ec) AC_CHECK_PROGS(arm64ec_CC,[arm64ec-w64-mingw32-clang arm64ec-w64-mingw32-gcc clang],[false]) + AC_CHECK_PROGS(arm64ec_CXX,[arm64ec-w64-mingw32-clang++ arm64ec-w64-mingw32-g++ clang++],[false]) ;; arm) AC_CHECK_PROGS(arm_CC,[armv7-w64-mingw32-clang armv7-w64-mingw32-gcc clang],[false]) + AC_CHECK_PROGS(arm_CXX,[armv7-w64-mingw32-clang++ armv7-w64-mingw32-g++ clang++],[false]) ;; i386) ac_prefix_list="m4_foreach([cc],[gcc,clang],m4_foreach([cpu],[i686,i586,i486,i386],[cpu-w64-mingw32-cc ]))" AC_CHECK_PROGS(i386_CC,[$ac_prefix_list clang],[false]) + ac_prefix_list="m4_foreach([cc],[g++,clang++],m4_foreach([cpu],[i686,i586,i486,i386],[cpu-w64-mingw32-cc ]))" + AC_CHECK_PROGS(i386_CXX,[$ac_prefix_list clang++],[false]) ;; x86_64) ac_prefix_list="m4_foreach([cc],[gcc,clang],m4_foreach([cpu],[x86_64,amd64],[cpu-w64-mingw32-cc ]))" AC_CHECK_PROGS(x86_64_CC,[$ac_prefix_list clang],[false]) + ac_prefix_list="m4_foreach([cc],[g++,clang++],m4_foreach([cpu],[x86_64,amd64],[cpu-w64-mingw32-cc ]))" + AC_CHECK_PROGS(x86_64_CXX,[$ac_prefix_list clang++],[false]) ;; esac wine_try_msvc=yes], -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10399
From: Rémi Bernon <rbernon@codeweavers.com> There's no reason to assume user provided CFLAGS would work for C++. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 65a6bbfcaf7..bd28ea51207 100644 --- a/configure.ac +++ b/configure.ac @@ -456,9 +456,9 @@ do CPPFLAGS="" AS_VAR_SET_IF([${wine_arch}_CFLAGS],[],[AS_VAR_SET([${wine_arch}_CFLAGS],[${CROSSCFLAGS:-"-g -O2"}])]) + AS_VAR_SET_IF([${wine_arch}_CXXFLAGS],[],[AS_VAR_SET([${wine_arch}_CXXFLAGS],[${CROSSCFLAGS:-"-g -O2"}])]) AS_VAR_SET_IF([${wine_arch}_LDFLAGS],[],[AS_VAR_SET([${wine_arch}_LDFLAGS],[$CROSSLDFLAGS])]) AS_VAR_SET_IF([${wine_arch}_CXX],[],[AS_VAR_COPY([${wine_arch}_CXX],[${wine_arch}_CC])]) - AS_VAR_SET_IF([${wine_arch}_CXXFLAGS],[],[AS_VAR_COPY([${wine_arch}_CXXFLAGS],[${wine_arch}_CFLAGS])]) AS_VAR_COPY([CC],[${wine_arch}_CC]) AS_VAR_COPY([CXX],[${wine_arch}_CXX]) AS_VAR_COPY([CFLAGS],[${wine_arch}_CFLAGS]) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10399
I don't think we can support potentially different compilers between C and C++. What's the use case for this? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10399#note_132985
No specific use case but I don't think it's right to use the C compiler to compile C++. It mostly works in general because they have heuristics about file name and switch to C++ mode, but it's not right to rely on it. We should either look for and use an actual C++ compiler, or pass -xc++ flag to the C compiler (which is then probably compiler-specific). -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10399#note_132986
Is there an actual compiler where this is an issue? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10399#note_132987
I don't know but I don't think it should be the question here. This is against most standard practices, where CXX environment variable drives the C++ compiler while CC drives the C compiler. If we cannot support different C/C++ compiler for some reason, we should IMO error on that case only, not rely on non-standard compiler behavior. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10399#note_132989
That seems like it would add a lot of complexity for little benefit. We are already not using the standard variables anyway because the C++ compiler is only used on the PE side. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10399#note_132998
Note that you can already use different C/C++ compilers if you want to, only it's up to you to make sure they are compatible. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10399#note_133003
Then why do we use the C compiler by default? It only adds a requirement on it having heuristics and ability to detect and switch to C++ mode. This requires sources to have specific extensions, which is not something we can enforce in third party projects anyway, and they all explicitly check and use the C++ compiler to build their C++ sources. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10399#note_133006
Anyway, I know I'm not going to convince you but using the wrong compiler just because it's more convenient looks wrong to me. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10399#note_133008
This merge request was closed by Rémi Bernon. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10399
If you wanted to do a `s/gcc/g++/` on the detected compiler that would be fine, at least we could still assume that they are compatible. Note that choosing between C and C++ in makedep is going to be based on the extension anyway, so it's not going to solve that issue. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10399#note_133009
participants (2)
-
Alexandre Julliard (@julliard) -
Rémi Bernon