From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id lD1AJmXAUWE+QQAAWB0awg (envelope-from ) for ; Mon, 27 Sep 2021 09:00:21 -0400 Received: by simark.ca (Postfix, from userid 112) id 8B9B41EE25; Mon, 27 Sep 2021 09:00:21 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_DYNAMIC, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 4F54A1E4A3 for ; Mon, 27 Sep 2021 09:00:20 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 97A513858405 for ; Mon, 27 Sep 2021 13:00:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 97A513858405 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1632747619; bh=PkhLqTjiQzl/upMClZXz37AcxFvpaQ/wuiqNP15AjTY=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=yUOeZHWJ5vopYAXWfl1uP7pWf7bpgc2LZqNSGfvA6ml4v/N6hyL9F1kmTHBK+kBUc yOlwLP6UCqBzNNkZQCCFiQ5MndW4UfO0Ex/wpxGNqeZQQ3QZetKJ3sMb4l3oGgclOH CAB/ARER2nVdXNlUJgTzLV0/NAbMpFpCdk3KUUn0= Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 6F0813858405 for ; Mon, 27 Sep 2021 13:00:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6F0813858405 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A664C22146; Mon, 27 Sep 2021 12:59:59 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 88D6413A7F; Mon, 27 Sep 2021 12:59:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id v0lDIE/AUWGtegAAMHmgww (envelope-from ); Mon, 27 Sep 2021 12:59:59 +0000 Subject: Re: [PATCH, master+11][gdb/build] Add CXX_DIALECT to CXX To: Simon Marchi , gdb-patches@sourceware.org References: <20210908121519.GA17723@delia> <73d742e2-c0c5-d641-83cb-ea12bc24cade@polymtl.ca> Message-ID: Date: Mon, 27 Sep 2021 14:59:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <73d742e2-c0c5-d641-83cb-ea12bc24cade@polymtl.ca> Content-Type: multipart/mixed; boundary="------------D0306F2C6DDD2602C33F7EEB" Content-Language: en-US X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" This is a multi-part message in MIME format. --------------D0306F2C6DDD2602C33F7EEB Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 9/23/21 4:27 PM, Simon Marchi wrote: > > > On 2021-09-08 8:15 a.m., Tom de Vries wrote: >> Hi, >> >> The problem reported in PR28318 is that when using a gcc version that (while >> supporting c++11) does not support c++11 by default, the configure test for >> std::thread support will fail. >> >> If gdb would use the default AX_CXX_COMPILE_STDCXX from autoconf, then we'd >> have: >> ... >> CXX="g++ -std=gnu++11" >> ... >> and the test for std::thread support would succeed. >> >> Instead, gdb uses a custom AX_CXX_COMPILE_STDCXX (see commit 0bcda685399) >> which does: >> ... >> CXX=g++ >> CXX_DIALECT=-std=gnu++11 >> ... >> >> We could add $CXX_DIALECT to the test for std::thread support, but that would >> have to be repeated for each added c++ support test. >> >> Instead, fix this by doing: >> ... >> CXX="g++ -std=gnu++11" >> CXX_DIALECT=-std=gnu++11 >> ... >> >> The code added in gdb/ax_cxx_compile_stdcxx.m4 is copied from the default >> AX_CXX_COMPILE_STDCXX from autoconf. > > From autoconf-archive? > Yes, updated. > At first glance, it looks like CXX_DIALECT would not be needed anymore, > since it's only used to be appended to CXX in Makefiles. So now it > would end up twice in the command-line, which is not harmful but not > useful. > > However, if we look at the original explanation of why we have this > local modification: > > We need to tweak AX_CXX_COMPILE_STDCXX a bit though. Pristine > upstream AX_CXX_COMPILE_STDCXX appends -std=gnu++11 to CXX directly. > That doesn't work for us, because the top level Makefile passes CXX > down to subdirs, and that overrides whatever gdb/Makefile may set CXX > to. The result would be that a make invocation from the build/gdb/ > directory would use "g++ -std=gnu++11" as expected, while a make > invocation at the top level would not. > > So instead of having AX_CXX_COMPILE_STDCXX set CXX directly, tweak it > to AC_SUBST a separate variable -- CXX_DIALECT -- and use '$(CXX) > (CXX_DIALECT)' to compile/link. > > https://gitlab.com/gnutools/binutils-gdb/-/commit/0bcda68539948828795564b35a497dc69c27f768 > > So it sounds like we need both (and your patch is correct): > > - the switch in CXX for the std::thread tests (and other tests) > - the switch in CXX_DIALECT so it can be appended in Makefiles, to > counteract the fact that the top-level Makefile overrides CXX > > This should probably be explained in the comment, because that situation > is strange, and people might wonder why we end up with two -std=... > switches, and might try to "fix" it. Ack, I've rewritten the commit log to make this more clear (and copied part of you comments). Any further comments? Thanks, - Tom --------------D0306F2C6DDD2602C33F7EEB Content-Type: text/x-patch; charset=UTF-8; name="0001-gdb-build-Add-CXX_DIALECT-to-CXX.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0001-gdb-build-Add-CXX_DIALECT-to-CXX.patch" [gdb/build] Add CXX_DIALECT to CXX Say we use a gcc version that (while supporting c++11) does not support c++11 by default, and needs an -std setting to enable it. If gdb would use the default AX_CXX_COMPILE_STDCXX from autoconf-archive, then we'd have: ... CXX="g++ -std=gnu++11" ... That mechanism however has the following problem (quoting from commit 0bcda685399): ... the top level Makefile passes CXX down to subdirs, and that overrides whatever gdb/Makefile may set CXX to. The result would be that a make invocation from the build/gdb/ directory would use "g++ -std=gnu++11" as expected, while a make invocation at the top level would not. ... Commit 0bcda685399 fixes this by using a custom AX_CXX_COMPILE_STDCXX which does: ... CXX=g++ CXX_DIALECT=-std=gnu++11 ... The problem reported in PR28318 is that using the custom instead of the default AX_CXX_COMPILE_STDCXX makes the configure test for std::thread support fail. We could simply add $CXX_DIALECT to the test for std::thread support, but that would have to be repeated for each added c++ support test. Instead, fix this by doing: ... CXX="g++ -std=gnu++11" CXX_DIALECT=-std=gnu++11 ... This is somewhat awkward, since it results in -std=gnu++11 occuring twice in some situations: ... $ touch src/gdb/dwarf2/read.c $ ( cd build/gdb; make V=1 dwarf2/read.o ) g++-4.8 -std=gnu++11 -x c++ -std=gnu++11 ... ... However, both settings are needed: - the switch in CXX for the std::thread tests (and other tests) - the switch in CXX_DIALECT so it can be appended in Makefiles, to counteract the fact that the top-level Makefile overrides CXX The code added in gdb/ax_cxx_compile_stdcxx.m4 is copied from the default AX_CXX_COMPILE_STDCXX from autoconf-archive. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28318 --- gdb/ax_cxx_compile_stdcxx.m4 | 8 ++++++++ gdb/configure | 8 ++++++++ gdbserver/configure | 8 ++++++++ gdbsupport/configure | 8 ++++++++ 4 files changed, 32 insertions(+) diff --git a/gdb/ax_cxx_compile_stdcxx.m4 b/gdb/ax_cxx_compile_stdcxx.m4 index 413755a2e88..29d8e10bcc4 100644 --- a/gdb/ax_cxx_compile_stdcxx.m4 +++ b/gdb/ax_cxx_compile_stdcxx.m4 @@ -94,6 +94,10 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl CXX="$ac_save_CXX"]) if eval test x\$$cachevar = xyes; then CXX_DIALECT="$switch" + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi ac_success=yes break fi @@ -118,6 +122,10 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl CXX="$ac_save_CXX"]) if eval test x\$$cachevar = xyes; then CXX_DIALECT="$switch" + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi ac_success=yes break fi diff --git a/gdb/configure b/gdb/configure index f0b1af4a6ea..98badb46cfd 100755 --- a/gdb/configure +++ b/gdb/configure @@ -5841,6 +5841,10 @@ eval ac_res=\$$cachevar $as_echo "$ac_res" >&6; } if eval test x\$$cachevar = xyes; then CXX_DIALECT="$switch" + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi ac_success=yes break fi @@ -6160,6 +6164,10 @@ eval ac_res=\$$cachevar $as_echo "$ac_res" >&6; } if eval test x\$$cachevar = xyes; then CXX_DIALECT="$switch" + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi ac_success=yes break fi diff --git a/gdbserver/configure b/gdbserver/configure index b227167e270..f05c1a9b976 100755 --- a/gdbserver/configure +++ b/gdbserver/configure @@ -5625,6 +5625,10 @@ eval ac_res=\$$cachevar $as_echo "$ac_res" >&6; } if eval test x\$$cachevar = xyes; then CXX_DIALECT="$switch" + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi ac_success=yes break fi @@ -5944,6 +5948,10 @@ eval ac_res=\$$cachevar $as_echo "$ac_res" >&6; } if eval test x\$$cachevar = xyes; then CXX_DIALECT="$switch" + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi ac_success=yes break fi diff --git a/gdbsupport/configure b/gdbsupport/configure index a9dd02c5b72..ae6047865ae 100755 --- a/gdbsupport/configure +++ b/gdbsupport/configure @@ -6520,6 +6520,10 @@ eval ac_res=\$$cachevar $as_echo "$ac_res" >&6; } if eval test x\$$cachevar = xyes; then CXX_DIALECT="$switch" + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi ac_success=yes break fi @@ -6839,6 +6843,10 @@ eval ac_res=\$$cachevar $as_echo "$ac_res" >&6; } if eval test x\$$cachevar = xyes; then CXX_DIALECT="$switch" + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi ac_success=yes break fi --------------D0306F2C6DDD2602C33F7EEB--