Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: Tom de Vries <tdevries@suse.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH, master+11][gdb/build] Add CXX_DIALECT to CXX
Date: Mon, 4 Oct 2021 12:16:52 -0400	[thread overview]
Message-ID: <efd742fa-c5c5-b69c-4e61-da6f1cf8c705@polymtl.ca> (raw)
In-Reply-To: <6cb21c7a-5701-2909-7142-ef9b7296ad3e@suse.de>

On 2021-10-04 09:58, Tom de Vries wrote:
> On 9/27/21 2:59 PM, Tom de Vries via Gdb-patches wrote:
>> 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?
>>
> 
> I'll commit this tomorrow, unless there are further comments.
> 
> Thanks,
> - Tom

That LGTM, thanks.

Simon

      reply	other threads:[~2021-10-04 16:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-08 12:15 Tom de Vries via Gdb-patches
2021-09-20 23:04 ` [PING][PATCH, " Tom de Vries via Gdb-patches
2021-09-23 14:27 ` [PATCH, " Simon Marchi via Gdb-patches
2021-09-23 14:33   ` Pedro Alves
2021-09-27 12:59   ` Tom de Vries via Gdb-patches
2021-10-04 13:58     ` Tom de Vries via Gdb-patches
2021-10-04 16:16       ` Simon Marchi via Gdb-patches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=efd742fa-c5c5-b69c-4e61-da6f1cf8c705@polymtl.ca \
    --to=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    --cc=tdevries@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox