<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 4, 2016 at 4:04 PM, Roland McGrath <span dir="ltr"><<a href="mailto:mcgrathr@google.com" target="_blank">mcgrathr@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Kostya, do you remember the exact original case in glibc for 22830 and<br>
what glibc change fixed it?<br></blockquote><div>Sadly, no.  </div><div>I only know that the code was reduced from the code that was setting these attributes for strtol. </div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I vaguely recall the case, but not enough to find the actual change<br>
and compare it to the new scenarios.<br>
I suspect that the original case was easy to fix because it was just<br>
that the hidden_proto magic had been put in the wrong place.<br>
<br>
The fstat/__fxstat case is harder.  The original declaration of<br>
__fxstat and the extern inline (that is, 'extern __inline<br>
__attribute__ ((__gnu_inline__))') definition of fstat (which calls<br>
__fxstat) is in the installed header, while the hidden_proto (i.e.<br>
redeclaration with asm label) is in the wrapper header (and<br>
necessarily must come after the #include of the installed header).<br>
<br>
A GNU extern inline case is one where the rationale I mentioned in<br>
<a href="https://llvm.org/bugs/show_bug.cgi?id=22830#c1" rel="noreferrer" target="_blank">https://llvm.org/bugs/show_bug.cgi?id=22830#c1</a> for Clang not being<br>
able to match GCC's semantics might not really apply: you never need<br>
to emit the code for fstat before the redeclaration, because you only<br>
ever inline it and never emit an actual function.<br>
<br>
Perhaps there is a defensible reason that Clang really cannot match<br>
the GNU semantics even for this case.  Regardless, Clang really needs<br>
to thoroughly document its semantics for every language extension when<br>
its semantics are not completely identical to the GNU language<br>
extension's semantics.<br>
<br>
If Clang's asm labels extension persists in having semantics<br>
incompatible with the original semantics of the asm labels extension<br>
invented by GNU, we might be able to work around it adequately in the<br>
glibc build just by making sure __USE_EXTERN_INLINES is not defined<br>
during the build.<br>
<div><div><br>
<br>
On Mon, Jan 4, 2016 at 3:39 PM, Kostya Serebryany <<a href="mailto:kcc@google.com" target="_blank">kcc@google.com</a>> wrote:<br>
> Thanks for checking, Nick!<br>
> +Roland, FYI (recent changes in clang break compilation of all of the<br>
> glibc),<br>
> similar to <a href="https://llvm.org/bugs/show_bug.cgi?id=22830#c1" rel="noreferrer" target="_blank">https://llvm.org/bugs/show_bug.cgi?id=22830#c1</a><br>
><br>
> On Mon, Jan 4, 2016 at 3:21 PM, Nick Lewycky <<a href="mailto:nicholas@mxc.ca" target="_blank">nicholas@mxc.ca</a>> wrote:<br>
>><br>
>> On 01/04/2016 01:40 PM, Kostya Serebryany wrote:<br>
>>><br>
>>><br>
>>><br>
>>> On Thu, Dec 17, 2015 at 5:03 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a><br>
>>> <mailto:<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>>> wrote:<br>
>>><br>
>>>     On Thu, Dec 17, 2015 at 3:59 PM, Nick Lewycky via cfe-commits<br>
>>>     <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a> <mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>>><br>
>>> wrote:<br>
>>><br>
>>>         On 12/17/2015 10:47 AM, Kostya Serebryany wrote:<br>
>>><br>
>>>             I am now observing this error message when building glibc<br>
>>>             with clang<br>
>>>             (from trunk):<br>
>>>             ../include/string.h:101:28: error: cannot apply asm label to<br>
>>>             function<br>
>>>             after its first use<br>
>>>             libc_hidden_builtin_proto (memcpy)<br>
>>>             (many more instances)<br>
>>><br>
>>><br>
>>>             Do you think this is a bug in glibc code, or the error<br>
>>>             message could be<br>
>>>             more relaxed?<br>
>>><br>
>>><br>
>>>         Could you email me a .i copy of a failing build? That will help<br>
>>>         me decide whether it's a bug in the error or in glibc.<br>
>>><br>
>>><br>
>>> [sorry for delay,]<br>
>>> here is the preprocessed source file from glibc:<br>
>>> % clang      ~/tmp/a.i 2>&1 | grep error:<br>
>>> ../include/sys/stat.h:16:28: error: cannot apply asm label to function<br>
>>> after its first use<br>
>>> ../include/sys/stat.h:17:30: error: cannot apply asm label to function<br>
>>> after its first use<br>
>>> ../include/sys/stat.h:18:28: error: cannot apply asm label to function<br>
>>> after its first use<br>
>>> ../include/sys/stat.h:19:30: error: cannot apply asm label to function<br>
>>> after its first use<br>
>>> ...<br>
>>><br>
>>><br>
>>>     Also PR22830 comment 1 seems relevant here.<br>
>>><br>
>>><br>
>>> Probably, but since this is a very recent regression in clang I thought<br>
>>> I should report it.<br>
>><br>
>><br>
>> This looks like it's WAI:<br>
>><br>
>> 3783    extern int __fxstat (int __ver, int __fildes, struct stat<br>
>> *__stat_buf)<br>
>> 3784         __attribute__ ((__nothrow__ )) ;<br>
>> ...<br>
>> 3827    extern __inline int<br>
>> 3828    __attribute__ ((__nothrow__ )) fstat (int __fd, struct stat<br>
>> *__statbuf)<br>
>> 3829    {<br>
>> 3830      return __fxstat (1, __fd, __statbuf);<br>
>> 3831    }<br>
>> ...<br>
>> 3910    extern __typeof (__fxstat) __fxstat __asm__ ("" "__GI___fxstat")<br>
>> __attribute__ ((visibility ("hidden")));<br>
>><br>
>> This is exactly the situation where GCC and Clang will emit a different .o<br>
>> file.<br>
>><br>
>> Nick<br>
>><br>
>>>             On Fri, Dec 11, 2015 at 1:28 PM, Nick Lewycky via cfe-commits<br>
>>>             <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
>>>             <mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>><br>
>>>             <mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
>>><br>
>>>             <mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>>>> wrote:<br>
>>><br>
>>>                  Author: nicholas<br>
>>>                  Date: Fri Dec 11 15:28:55 2015<br>
>>>                  New Revision: 255371<br>
>>><br>
>>>                  URL:<br>
>>>             <a href="http://llvm.org/viewvc/llvm-project?rev=255371&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=255371&view=rev</a><br>
>>>                  Log:<br>
>>>                  Error on redeclaring with a conflicting asm label and<br>
>>>             on redeclaring<br>
>>>                  with an asm label after the first ODR-use. Detects<br>
>>>             problems like the<br>
>>>                  one in PR22830 where gcc and clang both compiled the<br>
>>>             file but with<br>
>>>                  different behaviour.<br>
>>><br>
>>>                  Added:<br>
>>>                       cfe/trunk/test/Sema/asm-label.c<br>
>>>                  Modified:<br>
>>><br>
>>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
>>>                       cfe/trunk/lib/Sema/SemaDecl.cpp<br>
>>><br>
>>>                  Modified:<br>
>>>             cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
>>>                  URL:<br>
>>><br>
>>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=255371&r1=255370&r2=255371&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=255371&r1=255370&r2=255371&view=diff</a><br>
>>><br>
>>><br>
>>> ==============================================================================<br>
>>>                  ---<br>
>>>             cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
>>> (original)<br>
>>>                  +++<br>
>>>             cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Dec<br>
>>> 11<br>
>>>                  15:28:55 2015<br>
>>>                  @@ -4259,6 +4259,9 @@ def err_tag_definition_of_typedef<br>
>>>             : Erro<br>
>>>                    def err_conflicting_types : Error<"conflicting types<br>
>>>             for %0">;<br>
>>>                    def err_different_pass_object_size_params : Error<<br>
>>>                      "conflicting pass_object_size attributes on<br>
>>>             parameters">;<br>
>>>                  +def err_late_asm_label_name : Error<<br>
>>>                  +  "cannot apply asm label to<br>
>>>             %select{variable|function}0 after its<br>
>>>                  first use">;<br>
>>>                  +def err_different_asm_label : Error<"conflicting asm<br>
>>>             label">;<br>
>>>                    def err_nested_redefinition : Error<"nested<br>
>>>             redefinition of %0">;<br>
>>>                    def err_use_with_wrong_tag : Error<<br>
>>>                      "use of %0 with tag type that does not match<br>
>>>             previous declaration">;<br>
>>><br>
>>>                  Modified: cfe/trunk/lib/Sema/SemaDecl.cpp<br>
>>>                  URL:<br>
>>><br>
>>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=255371&r1=255370&r2=255371&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=255371&r1=255370&r2=255371&view=diff</a><br>
>>><br>
>>><br>
>>> ==============================================================================<br>
>>>                  --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)<br>
>>>                  +++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Dec 11 15:28:55<br>
>>>             2015<br>
>>>                  @@ -2379,9 +2379,24 @@ void<br>
>>>             Sema::mergeDeclAttributes(NamedDecl<br>
>>>                      if (!Old->hasAttrs() && !New->hasAttrs())<br>
>>>                        return;<br>
>>><br>
>>>                  -  // attributes declared post-definition are currently<br>
>>>             ignored<br>
>>>                  +  // Attributes declared post-definition are currently<br>
>>>             ignored.<br>
>>>                      checkNewAttributesAfterDef(*this, New, Old);<br>
>>><br>
>>>                  +  if (AsmLabelAttr *NewA =<br>
>>> New->getAttr<AsmLabelAttr>()) {<br>
>>>                  +    if (AsmLabelAttr *OldA =<br>
>>>             Old->getAttr<AsmLabelAttr>()) {<br>
>>>                  +      if (OldA->getLabel() != NewA->getLabel()) {<br>
>>>                  +        // This redeclaration changes __asm__ label.<br>
>>>                  +        Diag(New->getLocation(),<br>
>>>             diag::err_different_asm_label);<br>
>>>                  +        Diag(OldA->getLocation(),<br>
>>>             diag::note_previous_declaration);<br>
>>>                  +      }<br>
>>>                  +    } else if (Old->isUsed()) {<br>
>>>                  +      // This redeclaration adds an __asm__ label to a<br>
>>>             declaration<br>
>>>                  that has<br>
>>>                  +      // already been ODR-used.<br>
>>>                  +      Diag(New->getLocation(),<br>
>>>             diag::err_late_asm_label_name)<br>
>>>                  +        << isa<FunctionDecl>(Old) <<<br>
>>>                  New->getAttr<AsmLabelAttr>()->getRange();<br>
>>>                  +    }<br>
>>>                  +  }<br>
>>>                  +<br>
>>>                      if (!Old->hasAttrs())<br>
>>>                        return;<br>
>>><br>
>>><br>
>>>                  Added: cfe/trunk/test/Sema/asm-label.c<br>
>>>                  URL:<br>
>>><br>
>>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/asm-label.c?rev=255371&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/asm-label.c?rev=255371&view=auto</a><br>
>>><br>
>>><br>
>>> ==============================================================================<br>
>>>                  --- cfe/trunk/test/Sema/asm-label.c (added)<br>
>>>                  +++ cfe/trunk/test/Sema/asm-label.c Fri Dec 11 15:28:55<br>
>>>             2015<br>
>>>                  @@ -0,0 +1,30 @@<br>
>>>                  +// RUN: %clang_cc1 -verify %s<br>
>>>                  +<br>
>>>                  +void f();<br>
>>>                  +void f() __asm__("fish");<br>
>>>                  +void g();<br>
>>>                  +<br>
>>>                  +void f() {<br>
>>>                  +  g();<br>
>>>                  +}<br>
>>>                  +void g() __asm__("gold");  // expected-error{{cannot<br>
>>>             apply asm<br>
>>>                  label to function after its first use}}<br>
>>>                  +<br>
>>>                  +void h() __asm__("hose");  // expected-note{{previous<br>
>>>             declaration<br>
>>>                  is here}}<br>
>>>                  +void h() __asm__("hair");  //<br>
>>>             expected-error{{conflicting asm label}}<br>
>>>                  +<br>
>>>                  +int x;<br>
>>>                  +int x __asm__("xenon");<br>
>>>                  +int y;<br>
>>>                  +<br>
>>>                  +int test() { return y; }<br>
>>>                  +<br>
>>>                  +int y __asm__("yacht");  // expected-error{{cannot<br>
>>>             apply asm label<br>
>>>                  to variable after its first use}}<br>
>>>                  +<br>
>>>                  +int z __asm__("zebra");  // expected-note{{previous<br>
>>>             declaration is<br>
>>>                  here}}<br>
>>>                  +int z __asm__("zooms");  //<br>
>>>             expected-error{{conflicting asm label}}<br>
>>>                  +<br>
>>>                  +<br>
>>>                  +// No diagnostics on the following.<br>
>>>                  +void __real_readlink() __asm("readlink");<br>
>>>                  +void readlink() __asm("__protected_readlink");<br>
>>>                  +void readlink() { __real_readlink(); }<br>
>>><br>
>>><br>
>>>                  _______________________________________________<br>
>>>                  cfe-commits mailing list<br>
>>>             <a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
>>>             <mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>><br>
>>>             <mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
>>>             <mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>>><br>
>>>             <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
>>><br>
>>><br>
>>><br>
>>>         _______________________________________________<br>
>>>         cfe-commits mailing list<br>
>>>         <a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a> <mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>><br>
>>>         <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
>>><br>
>>><br>
>>><br>
>><br>
><br>
</div></div></blockquote></div><br></div></div>