From patchwork Tue May 14 18:43:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 90144 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0B5DA384AB5C for ; Tue, 14 May 2024 18:44:08 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by sourceware.org (Postfix) with ESMTPS id 59D7A3858D35 for ; Tue, 14 May 2024 18:43:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 59D7A3858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 59D7A3858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715712227; cv=none; b=WUAu8PJTBtIwiJFMo2l0iJZSlt8s6PAdAh+aa/XpQFqZy1cIgSC4O9hJd5l3cmpIfCqhHtCOsoOfeWqkHe1Bv0O7WtBkrNYGoDZrAw3PoMae8JlBsYaTItnC0WTfK6m2NG23gW6znaWY1kuJgXN3Xh3rrxoFaonGw3tvWFbmPEU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715712227; c=relaxed/simple; bh=Srpm/SYd31jZYW0AZyGq+Xo3xdD57rPRfAf4fA50Cg8=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=JldRJIIxawP3p+74G1mOoY0Qjud1T1bKF+yLWdOdsDUKjbHLjzJ/2W1xHeXlbntG5/OCoKkdtPAeWoI/6Oe1dEWA4wafVHdVFkypRdPIeOwpizAvOc5dc5hkAgi8kYa1uheipKXjtRKEyg7ao1dGJt2oJ+iNDSMm5ufi1DvO7QY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-420180b5897so17371175e9.3 for ; Tue, 14 May 2024 11:43:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715712224; x=1716317024; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ad8+0AFEuZHFmTRzW8b93CSNjxNd0nfEvk8PsyhfqsA=; b=uC6UgAdAMZ8wfh7X2Y/LQZ/lVjifg4sMGhNI8APnyKmwVB4ACecgOEe/H/f0JUMPFc E1r/EmjsVjXo38sGJjWjJeaUTlSvqDB6vk62ZMHtukqz+sVSahQ5eRQBerIkb7UFm+GX rnbB6ix2Ht6BMg5tykAmowUWLdCdWiWWG6TKx3NnT6H7qjFQL7QU+E4L2Gmm7fOyWAOe Z8EOiGOSrSJk59odfamUjU+Ns+gk7z44Bl1RxTPrulxFYgiUFRQLIMVOYpgNwngakC4L yTmZZpnxc57xzPpZfj7MT/mnp44ou2ZACImOjLFJHBu1/NSf7LqmrBBrU39oJeqdMtjA 13ow== X-Gm-Message-State: AOJu0YwZqLChySD8J7tOUWSPcbnI6PZC6DXb1NmXWuuY0BtbTGPE03iJ 3OC54Y7zTEnjDXr9Bcgi41iPDN4xivGxSyjra/KFJAZU65KhWreEqbMudpgd X-Google-Smtp-Source: AGHT+IEXZGrovVs4knlFZyEMZMBmk4HdxdHS6XW4dNglqc4nVT/tV13VQ3bkH/Sk9T0XSpxyKSIchA== X-Received: by 2002:a05:600c:4e88:b0:420:1551:96ab with SMTP id 5b1f17b1804b1-42015519952mr54277205e9.10.1715712223731; Tue, 14 May 2024 11:43:43 -0700 (PDT) Received: from localhost ([2001:8a0:f907:4900:4004:2cd3:ab4d:2d0f]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-41fd11ef80esm200492315e9.39.2024.05.14.11.43.43 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 May 2024 11:43:43 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH] Stop 'configure --enable-threading' if std::thread doesn't work Date: Tue, 14 May 2024 19:43:41 +0100 Message-ID: <20240514184341.1399428-1-pedro@palves.net> X-Mailer: git-send-email 2.43.2 MIME-Version: 1.0 X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org 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 --- gdb/configure | 14 +++++++++++--- gdbserver/configure | 14 +++++++++++--- gdbsupport/common.m4 | 13 ++++++++++--- gdbsupport/configure | 14 +++++++++++--- 4 files changed, 43 insertions(+), 12 deletions(-) base-commit: 414aa6987f21a814851e5f3113388a3616993fa3 diff --git a/gdb/configure b/gdb/configure index 98cd488a737..15c9cfe0937 100755 --- a/gdb/configure +++ b/gdb/configure @@ -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 14, 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 diff --git a/gdbserver/configure b/gdbserver/configure index 2da525ebf3b..538ffd8acd2 100755 --- a/gdbserver/configure +++ b/gdbserver/configure @@ -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 14, 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 diff --git a/gdbsupport/common.m4 b/gdbsupport/common.m4 index bef396445ba..f4fc81d1e0a 100644 --- a/gdbsupport/common.m4 +++ b/gdbsupport/common.m4 @@ -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 14, 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 diff --git a/gdbsupport/configure b/gdbsupport/configure index a218b06ce28..52d14c18740 100755 --- a/gdbsupport/configure +++ b/gdbsupport/configure @@ -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 14, 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