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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to