<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - __attribute__((used)) possibly ignored for static function with inline assembler?"
   href="http://llvm.org/bugs/show_bug.cgi?id=21292">21292</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__attribute__((used)) possibly ignored for static function with inline assembler?
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>danalbert@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, srhines@google.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I've come across what looks like a bug in the integrated assembler. It looks
like __attribute__((used)) is being ignored.

We're seeing the following link error:
cxa_exception.o(.text.__cxa_end_cleanup+0x2): warning: relocation refers to
discarded section

The relocation at .text.__cxa_end_cleanup+0x2 is to:
<a href="https://github.com/llvm-mirror/libcxxabi/blob/master/src/cxa_exception.cpp#L314">https://github.com/llvm-mirror/libcxxabi/blob/master/src/cxa_exception.cpp#L314</a>

Removing the static keyword allows it to pass, and removing the attribute
results in an undefined reference, so clearly used is having _some_ effect.

Our compilation line (pruned to remove the uninteresting android parts):

clang++ -I external/libcxxabi/include/ -I external/libcxx/include/ -I
external/libcxxabi -c -msoft-float -ffunction-sections -fdata-sections
-funwind-tables -fstack-protector -fno-short-enums -no-canonical-prefixes
-march=armv7-a -mfloat-abi=softfp -mfpu=neon -fmessage-length=0
-fvisibility-inlines-hidden -target arm-linux-androideabi -mthumb -Os
-fomit-frame-pointer -fno-strict-aliasing  -frtti   -fPIC   -std=c++11
-fexceptions -integrated-as external/libcxxabi/src/cxa_exception.cpp

More discussion: <a href="https://android-review.googlesource.com/#/c/110170/">https://android-review.googlesource.com/#/c/110170/</a>

Possibly related:
<a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Failure to emit attribute(used) inline methods defined in nested classes"
   href="show_bug.cgi?id=19743">http://llvm.org/bugs/show_bug.cgi?id=19743</a>
<a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - __attribute__((used)) ignored in templated classes"
   href="show_bug.cgi?id=17480">http://llvm.org/bugs/show_bug.cgi?id=17480</a>

Our clang is based on r212749, so it's possible that this has been fixed
already.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>