public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexander Hans <ahans@neuralpropulsion.com>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: libstdc++ <libstdc++@gcc.gnu.org>
Subject: Re: Re: [committed] libstdc++: Allow Clang to use <stdatomic.h> before C++23
Date: Wed, 4 Jan 2023 21:06:50 +0000	[thread overview]
Message-ID: <MW4PR19MB56559308F111C026CC5B661CDEF59@MW4PR19MB5655.namprd19.prod.outlook.com> (raw)
In-Reply-To: <CACb0b4=tzrLW4ByApqbEoVp698QGgrNXqEh_rsVOzEiSbS6_PA@mail.gmail.com>

Hi,

Thanks for your prompt reply. Now things are much clearer!


> Then Bazel is broken. The assumption that "there are no name clashes
> between C++ and C header files" has never been true.

> I suppose we could support that silliness like this:
> [...]
> But I don't really like having to patch libstdc++ to support broken tools.

I agree that libstdc++ is not the right place to fix this. But thanks for the
patch in any case, that's better than my unconditional #else and I'll keep
it in mind. That would also allow me to work around the issue.

Regarding your question why this happens in the first place:

> Why does Bazel even need to know those directories? It should not be
> adding them for compiling C code nor for compiling C++ code, because
> GCC does that automatically (and gets it right).

Bazel can detect a local toolchain and use it. Then everything works as
expected. But it can also support some other toolchain, contained in some
archive you tell it to download from somewhere. I'm trying to integrate
gcc 12 via this route and do this based on some existing Bazel rules that are
pretty close to what I need [1]. They call gcc passing -nostdinc and giving
the include directories via -isystem arguments. However, some preliminary
testing suggests you should actually use only --sysroot for that and avoid
-nostdinc and any extra -isystem arguments. If that's true, the fix should
happen in the gcc toolchain-specific Bazel rules. The section I quoted
about the cxx_builtin_include_directories parameter and the assumption
that there are no name clashes is probably not an issue: I believe this
is only about telling Bazel where those files live, so that it can make them
available (Bazel is all about hermetic builds and to that end it wants to
know exactly what is used for the build). Using --sysroot, they will be
made available for C compilations as well, but ignored as you explained.
The only unclean part about this is that we cannot tell Bazel which
toolchain-supplied files a C-only build depends on (it will always be both,
C and C++ files), but that is acceptable.

Thanks again!

Alex

[1] https://github.com/aspect-build/gcc-toolchain

  parent reply	other threads:[~2023-01-04 21:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <MW4PR19MB565558FEC45E0F908D8B0C0BDEF59@MW4PR19MB5655.namprd19.prod.outlook.com>
2023-01-04 16:57 ` Jonathan Wakely
2023-01-04 17:02   ` Jonathan Wakely
2023-01-04 21:06   ` Alexander Hans [this message]
2023-01-20 14:23     ` Jonathan Wakely

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=MW4PR19MB56559308F111C026CC5B661CDEF59@MW4PR19MB5655.namprd19.prod.outlook.com \
    --to=ahans@neuralpropulsion.com \
    --cc=jwakely@redhat.com \
    --cc=libstdc++@gcc.gnu.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).