<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - ThinLTO on Aarch64 fails to handle aliases to overridden weak functions"
   href="https://bugs.llvm.org/show_bug.cgi?id=42542">42542</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ThinLTO on Aarch64 fails to handle aliases to overridden weak functions
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>new bugs
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>C code that defines an alias to a weak function, which is then referred to in
assembly code that also overrides the same weak function, fails to compile with
-flto=thin on Aarch64:

$ cat alias.c
__attribute__((__weak__)) int __a(int n)
{
        return n;
}
int a(int n)  __attribute__((__alias__("__a")));

int main()
{
        return __a(0);
}

$ cat alias.s
.arch armv8-a

__a:
        b a
.globl __a

$ clang -flto=thin -fvisibility=hidden -fuse-ld=lld --target=aarch64-linux-gnu-
alias.s alias.c
Alias must point to a definition
i32 (i32)* @a
LLVM ERROR: Broken module found, compilation aborted!
clang-9: error: linker command failed with exit code 1 (use -v to see
invocation)

Using -flto instead of -flto=thin works.

This bug prevents us from compiling the Linux kernel with ThinLTO, as explained
here:
<a href="https://github.com/ClangBuiltLinux/linux/issues/509">https://github.com/ClangBuiltLinux/linux/issues/509</a></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>