[LLVMbugs] [Bug 16937] New: Template instantiation with user-defined type generates hidden symbol when building a shared library from a .o with -fvisibility=hidden

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Aug 19 16:38:35 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16937

            Bug ID: 16937
           Summary: Template instantiation with user-defined type
                    generates hidden symbol when building a shared library
                    from a .o with -fvisibility=hidden
           Product: clang
           Version: 3.3
          Hardware: PC
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rakuco at FreeBSD.org
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 11070
  --> http://llvm.org/bugs/attachment.cgi?id=11070&action=edit
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130819/30230d14/attachment.html>


More information about the llvm-bugs mailing list