From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1551) id CBF783858C98; Thu, 16 May 2024 12:05:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CBF783858C98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1715861126; bh=MkekA2reyiXoBFqtaOcL36ltTt5fIyXmU6/1xgJ137w=; h=From:To:Subject:Date:From; b=OjKT9NZTUeeIcOQ5MVnrt12rSBEVaagT3s8Py3Ws1rZiHDkM/+XTJFTOE6SMyRwOt I6isnDdBYk0iTlnGd2DlVGd08vd/3U92uE5Eu4g+XqrLqH5J6+8wTojORL2+RrXjD5 Pr0ReIQSSL4YLkaTzTIGBbwRee3ER0rN8Zq1bcoo= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Pedro Alves To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Stop 'configure --enable-threading' if std::thread doesn't work X-Act-Checkin: binutils-gdb X-Git-Author: Pedro Alves X-Git-Refname: refs/heads/master X-Git-Oldrev: f01ae0392ed9e7012ae33fdcf972ee4508fb7db2 X-Git-Newrev: 3e09762b7d1243d7d75c885537f67fa66416bb8b Message-Id: <20240516120526.CBF783858C98@sourceware.org> Date: Thu, 16 May 2024 12:05:26 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D3e09762b7d12= 43d7d75c885537f67fa66416bb8b commit 3e09762b7d1243d7d75c885537f67fa66416bb8b Author: Pedro Alves Date: Tue May 14 15:43:41 2024 +0100 Stop 'configure --enable-threading' if std::thread doesn't work =20 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. =20 This patch makes that scenario cause a configuration error, like so: =20 $ /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 $ =20 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): =20 $ /home/pedro/gdb/src/configure && make ... configure: WARNING: std::thread does not work; disabling threading ... =20 This is similar to how we handle --enable-tui and missing curses. The code and error/warning messages were borrowed from there. =20 Change-Id: I73a8b580d1e2a796b23136920c0e181408ae1b22 Approved-By: Tom Tromey Diff: --- gdb/configure | 14 +++++++++++--- gdbserver/configure | 14 +++++++++++--- gdbsupport/common.m4 | 13 ++++++++++--- gdbsupport/configure | 14 +++++++++++--- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/gdb/configure b/gdb/configure index 98cd488a737..66a7ad8d256 100755 --- a/gdb/configure +++ b/gdb/configure @@ -20181,12 +20181,13 @@ if test "${enable_threading+set}" =3D set; then : *) as_fn_error $? "bad value $enableval for threading" "$LINENO" 5 ;; esac else - want_threading=3Dyes + want_threading=3Dauto fi =20 =20 # 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=3Dcpp ac_cpp=3D'$CXXCPP $CPPFLAGS' ac_compile=3D'$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -20893,11 +20894,18 @@ done LIBS=3D"$save_LIBS" CXXFLAGS=3D"$save_CXXFLAGS" =20 - if test "$want_threading" =3D "yes"; then + if test "$want_threading" !=3D "no"; then if test "$gdb_cv_cxx_std_thread" =3D "yes"; then =20 $as_echo "#define CXX_STD_THREAD 1" >>confdefs.h =20 + else + if test "$want_threading" =3D "yes"; then + as_fn_error $? "std::thread does not work; disable threading" "$LINEN= O" 5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: std::thread does no= t work; disabling threading" >&5 +$as_echo "$as_me: WARNING: std::thread does not work; disabling threading"= >&2;} + fi fi fi ac_ext=3Dc diff --git a/gdbserver/configure b/gdbserver/configure index 2da525ebf3b..3abc647acda 100755 --- a/gdbserver/configure +++ b/gdbserver/configure @@ -8888,12 +8888,13 @@ if test "${enable_threading+set}" =3D set; then : *) as_fn_error $? "bad value $enableval for threading" "$LINENO" 5 ;; esac else - want_threading=3Dyes + want_threading=3Dauto fi =20 =20 # 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=3Dcpp ac_cpp=3D'$CXXCPP $CPPFLAGS' ac_compile=3D'$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -9600,11 +9601,18 @@ done LIBS=3D"$save_LIBS" CXXFLAGS=3D"$save_CXXFLAGS" =20 - if test "$want_threading" =3D "yes"; then + if test "$want_threading" !=3D "no"; then if test "$gdb_cv_cxx_std_thread" =3D "yes"; then =20 $as_echo "#define CXX_STD_THREAD 1" >>confdefs.h =20 + else + if test "$want_threading" =3D "yes"; then + as_fn_error $? "std::thread does not work; disable threading" "$LINEN= O" 5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: std::thread does no= t work; disabling threading" >&5 +$as_echo "$as_me: WARNING: std::thread does not work; disabling threading"= >&2;} + fi fi fi ac_ext=3Dc diff --git a/gdbsupport/common.m4 b/gdbsupport/common.m4 index bef396445ba..6c317ff2450 100644 --- a/gdbsupport/common.m4 +++ b/gdbsupport/common.m4 @@ -89,10 +89,11 @@ AC_DEFUN([GDB_AC_COMMON], [ no) want_threading=3Dno ;; *) AC_MSG_ERROR([bad value $enableval for threading]) ;; esac], - [want_threading=3Dyes]) + [want_threading=3Dauto]) =20 # 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=3Dyes], [threads=3Dno]) save_LIBS=3D"$LIBS" @@ -128,10 +129,16 @@ AC_DEFUN([GDB_AC_COMMON], [ LIBS=3D"$save_LIBS" CXXFLAGS=3D"$save_CXXFLAGS" =20 - if test "$want_threading" =3D "yes"; then + if test "$want_threading" !=3D "no"; then if test "$gdb_cv_cxx_std_thread" =3D "yes"; then AC_DEFINE(CXX_STD_THREAD, 1, [Define to 1 if std::thread works.]) + else + if test "$want_threading" =3D "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 diff --git a/gdbsupport/configure b/gdbsupport/configure index a218b06ce28..19b19c42c6f 100755 --- a/gdbsupport/configure +++ b/gdbsupport/configure @@ -11662,12 +11662,13 @@ if test "${enable_threading+set}" =3D set; then : *) as_fn_error $? "bad value $enableval for threading" "$LINENO" 5 ;; esac else - want_threading=3Dyes + want_threading=3Dauto fi =20 =20 # 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=3Dcpp ac_cpp=3D'$CXXCPP $CPPFLAGS' ac_compile=3D'$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -12374,11 +12375,18 @@ done LIBS=3D"$save_LIBS" CXXFLAGS=3D"$save_CXXFLAGS" =20 - if test "$want_threading" =3D "yes"; then + if test "$want_threading" !=3D "no"; then if test "$gdb_cv_cxx_std_thread" =3D "yes"; then =20 $as_echo "#define CXX_STD_THREAD 1" >>confdefs.h =20 + else + if test "$want_threading" =3D "yes"; then + as_fn_error $? "std::thread does not work; disable threading" "$LINEN= O" 5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: std::thread does no= t work; disabling threading" >&5 +$as_echo "$as_me: WARNING: std::thread does not work; disabling threading"= >&2;} + fi fi fi ac_ext=3Dc