Hi Alex, Thanks for the suggestions. On Sat, Oct 05, 2024 at 01:28:57PM +0200, a1ex@dismail.de wrote:
Hi Rodrigo,
Regarding this issue[1], I have found couple of ways to address this:
The easiest way is to do AC_PROG_CXX before AC_PROG_CC:
--- a/configure.ac Sat Oct 5 13:15:28 2024 +++ b/configure.ac Sat Oct 5 13:15:48 2024 @@ -124,8 +124,8 @@ if test "x$enable_ssl" != "x"; then AC_MSG_ERROR([The flag --enable-ssl is deprecated, use --enable-tls]) fi
-AC_PROG_CC AC_PROG_CXX +AC_PROG_CC AC_PROG_RANLIB AC_PROG_CPP
Which now errors out when no working compiler is found: 'configure: error: C++ compiler cannot create executables'
I think it relies on a detail of the implementation, so I don't think we can trust it to always work. I cannot believe that in 2024 it is still not considered a bug...
Alternately, we can add a check to verify if the complier actually exists, and if not, exit. Something like this:
dnl ------------------------------------------------------------ dnl AC_PROG_CXX will set CXX=g++ even if it finds no useable C++ dnl compiler, so we have to check whether the program named by dnl CXX exists. dnl ------------------------------------------------------------ dnl AC_PROG_CXX AC_PATH_PROG(REAL_CXX, $CXX) HAVE_CXX=no if test -n "$REAL_CXX"; then HAVE_CXX=yes fi if HAVE_CXX="no"; then echo "Error: No working C++ compiler found!" exit 1 fi
This is probably better, but even if the C++ compiler is in the path, it doesn't mean it actually works. I think something like this may be more strict, as we test that it can compile a simple C++ program: diff --git a/configure.ac b/configure.ac index 5c308cb7..7d156b81 100644 --- a/configure.ac +++ b/configure.ac @@ -129,6 +129,19 @@ AC_PROG_CXX AC_PROG_RANLIB AC_PROG_CPP +AC_MSG_CHECKING(if C++ compiler '$CXX' works) +AC_LANG_PUSH([C++]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #ifndef __cplusplus + #error "No C++ support, AC_PROG_CXX failed" + #endif + ]])], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT(no) + AC_MSG_FAILURE([C++ compiler doesn't work])] +) +AC_LANG_POP([C++]) + dnl ---------------------------- dnl Check our char and int types dnl ---------------------------- Outputs this when configured with the non-existent iguana C++ compiler: $ ../configure CXX=iguana ... checking whether the compiler supports GNU C++... no checking whether iguana accepts -g... no checking for iguana option to enable C++11 features... unsupported checking for iguana option to enable C++98 features... unsupported checking dependency style of iguana... none checking for ranlib... ranlib checking how to run the C preprocessor... gcc -E checking if C++ compiler 'iguana' works... no configure: error: in '/home/ram/dev/dillo/git/build': configure: error: C++ compiler doesn't work See 'config.log' for more details Best, Rodrigo.