public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: Florian Weimer <fw@deneb.enyo.de>
Cc: kamlesh kumar <kamleshbhalui@gmail.com>,
	libc-alpha@sourceware.org, Andreas Schwab <schwab@suse.de>,
	Brooks Moses <bmoses@google.com>
Subject: Re: [PATCH] For Adding clang check
Date: Fri, 29 Nov 2019 10:58:00 -0000	[thread overview]
Message-ID: <20191129105759.GX11522@redhat.com> (raw)
In-Reply-To: <87a78fay23.fsf@mid.deneb.enyo.de>

On 29/11/19 09:25 +0100, Florian Weimer wrote:
>* kamlesh kumar:
>
>> It fixes this.
>> https://bugs.llvm.org/show_bug.cgi?id=44169
>
>What's the rationale for the condition?  What's special about Clang
>3.5?
>
>My understanding is that a compiler needs support for asm aliases
>*and* the C++ library headers need to be compatible.  Is there a way
>to determine if libc++ is compatible?

Libc++ already checks for this macro in its <string.h> wrapper:
https://github.com/llvm/llvm-project/blob/master/libcxx/include/string.h#L62

If the __CORRECT_ISO_CPP_STRING_H_PROTO macro is *not* defined after
doing #include_next <string.h> (to get the libc header) then libc++
makes use of a Clang extension to declare new overloads:
https://github.com/llvm/llvm-project/blob/master/libcxx/include/string.h#L70

The _LIBCPP_PREFERRED_OVERLOAD macro is defined as:
#    define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))

That Clang-only attribute means the compiler will use the new
overloads in preference to the libc strchr. A non-standard extension
is needed because according to the C++ rules the new overloads should
be ambiguous with the one that was declared by libc's <string.h>.


>For libstdc++ with GCC, the
>compiler version check covers libstdc++ implicity, but that does not
>apply to Clang, or libc++ with either compiler.

Libstdc++ with GCC already works.

Libstdc++ with Clang needs this patch.

If I'm reading the libc++ code right ...

Libc++ with GCC should already work, because the __GNUC_PREREQ will
pass and libc++ is already aware of the existence and effects of the
__CORRECT_ISO_CPP_STRING_H_PROTO macro. (I doubt libc++ works with
ancient GCC versions, but if it does they'll get the wrong signatures
... well tough luck, use a newer GCC).

Libc++ with Clang doesn't need this patch, because it uses the Clang
extension, but after this patch it would no longer need to use the
extension. The right signatures would be declared by glibc.

So of the four combinations, two already work and are unaffected by
this patch. One already works and is affected, but not in a way users
will notice (the correct signatures are already there, the patch just
changes whether they come from glibc or libc++). And one doesn't
currently work but is fixed by the patch.

I think the patch is right.


  parent reply	other threads:[~2019-11-29 10:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-28 18:47 Kamlesh Kumar
2019-11-28 18:52 ` Florian Weimer
2019-11-29  0:47   ` kamlesh kumar
2019-11-29  8:26     ` Florian Weimer
2019-11-29  9:50       ` kamlesh kumar
2019-11-29 10:58       ` Jonathan Wakely [this message]
2019-11-29 11:38         ` Florian Weimer
2019-12-05 15:51           ` Florian Weimer

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=20191129105759.GX11522@redhat.com \
    --to=jwakely@redhat.com \
    --cc=bmoses@google.com \
    --cc=fw@deneb.enyo.de \
    --cc=kamleshbhalui@gmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).