<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 - [lto] Module asm symbols don't show in IR symbol table"
   href="https://bugs.llvm.org/show_bug.cgi?id=46502">46502</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[lto] Module asm symbols don't show in IR symbol table
          </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>enhancement
          </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>hans@chromium.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>For example:

$ cat /tmp/x.c
void foo() {}

asm(".globl bar      \n"
    "bar:            \n"
    "  xor %eax, %eax\n"
    "  ret           \n");

$ clang -c -flto=thin /tmp/x.c

$ llvm-nm x.o
---------------- T foo


I expected bar to show up in the symbol table. I can see it getting processed
by ModuleSymbolTable::CollectAsmSymbols() but it doesn't seem to make it all
the way?



But even though it's not showing in the symbol table, linking against it seems
to work:

$ cat /tmp/y.c
extern void foo();
extern void bar();

int main() {
  foo();
  bar();
  return 0;
};

$ clang -flto=thin /tmp/y.c /tmp/x.c -fuse-ld=lld

$ ./a.out && echo ok
ok


Isn't the symbol table needed to resolve the 'bar' reference? Or does it
somehow work because we're linking the LLVM modules together anyway?





pcc: I can't really tell if this is a bug or if I'm missing something about how
this works.

If it is a bug, maybe the problem is how Builder::addSymbol() in IRSymtab.cpp
bails out because the symbol isn't a GlobalValue?</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>