From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SKkMNPGOTGE4FwAAWB0awg (envelope-from ) for ; Thu, 23 Sep 2021 10:28:01 -0400 Received: by simark.ca (Postfix, from userid 112) id D2F2D1EE25; Thu, 23 Sep 2021 10:28:01 -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 0782C1EE14 for ; Thu, 23 Sep 2021 10:28:01 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8C08B385802E for ; Thu, 23 Sep 2021 14:28:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8C08B385802E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1632407280; bh=r4I6OAiD/B0atO6gi1ERvTsQ4qnWGTvMJQ8tLFA1S8s=; 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=gS9u3rH5hn9W/+PsFZz+4G/dDLhsX+vY3W+iuAvkjGHK34/wVmh/pkJrR3riH2ttl 4RcbR9X9SkYmrp1NpdOO4LWx52/TiN1u1NOdhtmsbZjzPnpoxaVc6cmDtIVhgTsfLN BYUQR8GPUtendM8laMnhNBG751BjFeAGTDHfRscI= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 62FB13858D34 for ; Thu, 23 Sep 2021 14:27:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 62FB13858D34 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 18NERYZa007835 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Sep 2021 10:27:39 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 18NERYZa007835 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 9AE8E1EE14; Thu, 23 Sep 2021 10:27:34 -0400 (EDT) Subject: Re: [PATCH, master+11][gdb/build] Add CXX_DIALECT to CXX To: Tom de Vries , gdb-patches@sourceware.org References: <20210908121519.GA17723@delia> Message-ID: <73d742e2-c0c5-d641-83cb-ea12bc24cade@polymtl.ca> Date: Thu, 23 Sep 2021 10:27:34 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210908121519.GA17723@delia> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 23 Sep 2021 14:27:34 +0000 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: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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? 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. Simon