<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 --- - Template instantiation with user-defined type generates hidden symbol when building a shared library from a .o with -fvisibility=hidden"
   href="http://llvm.org/bugs/show_bug.cgi?id=16937">16937</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Template instantiation with user-defined type generates hidden symbol when building a shared library from a .o with -fvisibility=hidden
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.3
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>FreeBSD
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>rakuco@FreeBSD.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=11070" name="attach_11070" title="Reduction + Makefile that calls nm.">attachment 11070</a> <a href="attachment.cgi?id=11070&action=edit" title="Reduction + Makefile that calls nm.">[details]</a></span>
Reduction + Makefile that calls nm.

(Sorry if the title sounded unclear)

Consider the following:
  struct __attribute__((visibility("default"))) Foo {
    template<typename T> void f(const T&) {}
  };

  struct SomeType {};
  template void Foo::f<SomeType>(const SomeType&);

So if I have a class with default visibility and a template method that has an
instantiation with a user-defined type, the .o file generated with "clang++ -c
-fvisibility=hidden" will generate _ZN3Foo1fI8SomeTypeEEvRKT_ as a global weak
symbol, but when using that .o to generate a shared library, the resulting .so
will have _ZN3Foo1fI8SomeTypeEEvRKT_ as a local symbol in the text section, as
if the __attribute__ marker in the class had been discarded.

Generating the .so directly from the .cpp file produces a shared library with
_ZN3Foo1fI8SomeTypeEEvRKT_ as a global weak symbol, as will instantiating the
template method with a type such as int.

GCC makes _ZN3Foo1fI8SomeTypeEEvRKT_ a global weak symbol in both the .o and
the .so.</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>