]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Stop 'configure --enable-threading' if std::thread doesn't work
authorPedro Alves <pedro@palves.net>
Tue, 14 May 2024 14:43:41 +0000 (15:43 +0100)
committerPedro Alves <pedro@palves.net>
Thu, 16 May 2024 12:03:58 +0000 (13:03 +0100)
Currently, if you configure gdb with explicit --enable-threading, but
then configure detects std::thread does not work, configure silently
disables threading support and continues configuring.

This patch makes that scenario cause a configuration error, like so:

 $ /home/pedro/gdb/src/configure --enable-threading && make
 ...
 configure: error: std::thread does not work; disable threading
 make[1]: *** [Makefile:11225: configure-gdbsupport] Error 1
 make[1]: Leaving directory '/home/pedro/gdb/build-windows-threads'
 make: *** [Makefile:1041: all] Error 2
 $

Additionally, if you don't explicitly pass --enable-threading, and
std::thread does not work, we will now get a warning (and the build
continues):

 $ /home/pedro/gdb/src/configure && make
 ...
 configure: WARNING: std::thread does not work; disabling threading
 ...

This is similar to how we handle --enable-tui and missing curses.  The
code and error/warning messages were borrowed from there.

Change-Id: I73a8b580d1e2a796b23136920c0e181408ae1b22
Approved-By: Tom Tromey <tom@tromey.com>
gdb/configure
gdbserver/configure
gdbsupport/common.m4
gdbsupport/configure

index 98cd488a7374311d5e001ba3d4dc02e6e4a972dd..66a7ad8d2562a76720a9aeec5c88cb370021f4b3 100755 (executable)
@@ -20181,12 +20181,13 @@ if test "${enable_threading+set}" = set; then :
     *) as_fn_error $? "bad value $enableval for threading" "$LINENO" 5 ;;
     esac
 else
-  want_threading=yes
+  want_threading=auto
 fi
 
 
   # Check for std::thread.  This does not work on some platforms, like
-  # mingw and DJGPP.
+  # mingw using the win32 threads model with gcc older than 13, and
+  # DJGPP.
   ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -20893,11 +20894,18 @@ done
   LIBS="$save_LIBS"
   CXXFLAGS="$save_CXXFLAGS"
 
-  if test "$want_threading" = "yes"; then
+  if test "$want_threading" != "no"; then
     if test "$gdb_cv_cxx_std_thread" = "yes"; then
 
 $as_echo "#define CXX_STD_THREAD 1" >>confdefs.h
 
+    else
+       if test "$want_threading" = "yes"; then
+           as_fn_error $? "std::thread does not work; disable threading" "$LINENO" 5
+       else
+           { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: std::thread does not work; disabling threading" >&5
+$as_echo "$as_me: WARNING: std::thread does not work; disabling threading" >&2;}
+       fi
     fi
   fi
   ac_ext=c
index 2da525ebf3baabdef39c53a3582c40051b40531c..3abc647acda3538b65fa5f5ef00d6403e7703384 100755 (executable)
@@ -8888,12 +8888,13 @@ if test "${enable_threading+set}" = set; then :
     *) as_fn_error $? "bad value $enableval for threading" "$LINENO" 5 ;;
     esac
 else
-  want_threading=yes
+  want_threading=auto
 fi
 
 
   # Check for std::thread.  This does not work on some platforms, like
-  # mingw and DJGPP.
+  # mingw using the win32 threads model with gcc older than 13, and
+  # DJGPP.
   ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -9600,11 +9601,18 @@ done
   LIBS="$save_LIBS"
   CXXFLAGS="$save_CXXFLAGS"
 
-  if test "$want_threading" = "yes"; then
+  if test "$want_threading" != "no"; then
     if test "$gdb_cv_cxx_std_thread" = "yes"; then
 
 $as_echo "#define CXX_STD_THREAD 1" >>confdefs.h
 
+    else
+       if test "$want_threading" = "yes"; then
+           as_fn_error $? "std::thread does not work; disable threading" "$LINENO" 5
+       else
+           { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: std::thread does not work; disabling threading" >&5
+$as_echo "$as_me: WARNING: std::thread does not work; disabling threading" >&2;}
+       fi
     fi
   fi
   ac_ext=c
index bef396445ba2d7455802104a4a3a8fa6f964f1b3..6c317ff2450387fe43c070fe983db241acaa38cd 100644 (file)
@@ -89,10 +89,11 @@ AC_DEFUN([GDB_AC_COMMON], [
     no) want_threading=no ;;
     *) AC_MSG_ERROR([bad value $enableval for threading]) ;;
     esac],
-    [want_threading=yes])
+    [want_threading=auto])
 
   # Check for std::thread.  This does not work on some platforms, like
-  # mingw and DJGPP.
+  # mingw using the win32 threads model with gcc older than 13, and
+  # DJGPP.
   AC_LANG_PUSH([C++])
   AX_PTHREAD([threads=yes], [threads=no])
   save_LIBS="$LIBS"
@@ -128,10 +129,16 @@ AC_DEFUN([GDB_AC_COMMON], [
   LIBS="$save_LIBS"
   CXXFLAGS="$save_CXXFLAGS"
 
-  if test "$want_threading" = "yes"; then
+  if test "$want_threading" != "no"; then
     if test "$gdb_cv_cxx_std_thread" = "yes"; then
       AC_DEFINE(CXX_STD_THREAD, 1,
                [Define to 1 if std::thread works.])
+    else
+       if test "$want_threading" = "yes"; then
+           AC_MSG_ERROR([std::thread does not work; disable threading])
+       else
+           AC_MSG_WARN([std::thread does not work; disabling threading])
+       fi
     fi
   fi
   AC_LANG_POP
index a218b06ce2807b7d64b1d433e0f36bdcadb12516..19b19c42c6f39a2ae2dfca7e0823c16f162b9971 100755 (executable)
@@ -11662,12 +11662,13 @@ if test "${enable_threading+set}" = set; then :
     *) as_fn_error $? "bad value $enableval for threading" "$LINENO" 5 ;;
     esac
 else
-  want_threading=yes
+  want_threading=auto
 fi
 
 
   # Check for std::thread.  This does not work on some platforms, like
-  # mingw and DJGPP.
+  # mingw using the win32 threads model with gcc older than 13, and
+  # DJGPP.
   ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -12374,11 +12375,18 @@ done
   LIBS="$save_LIBS"
   CXXFLAGS="$save_CXXFLAGS"
 
-  if test "$want_threading" = "yes"; then
+  if test "$want_threading" != "no"; then
     if test "$gdb_cv_cxx_std_thread" = "yes"; then
 
 $as_echo "#define CXX_STD_THREAD 1" >>confdefs.h
 
+    else
+       if test "$want_threading" = "yes"; then
+           as_fn_error $? "std::thread does not work; disable threading" "$LINENO" 5
+       else
+           { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: std::thread does not work; disabling threading" >&5
+$as_echo "$as_me: WARNING: std::thread does not work; disabling threading" >&2;}
+       fi
     fi
   fi
   ac_ext=c