[LLVMbugs] [Bug 10113] New: Explicit template instantiation with default visibility fails to generate global symbols for certain types

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jun 9 11:17:18 PDT 2011


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

           Summary: Explicit template instantiation with default
                    visibility fails to generate global symbols for
                    certain types
           Product: clang
           Version: 2.9
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: 691D2C6C-B023-46A5-B1D7-ACCBA4713A87 at uuid-mail.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


Explicit template instantiation does not (always) result in an exported symbol
when compiling with ‘-fvisibility=hidden’ despite setting the visibility
attribute to ‘default’ for the template prototype.

Example source (lib.cc):

    #include <string>

    template <typename T> __attribute__((__visibility__("default")))
    void foo (T value) { /* dummmy */ }

    template void foo (std::string value);
    template void foo (int value);

Building with clang++ and dumping global symbols:

    % clang++ -dynamiclib -fvisibility=hidden lib.cc -o lib.dylib && nm -g
lib.dylib|c++filt 
    0000000000000f30 T void foo<int>(int)
                     U dyld_stub_binder

Building with g++ and dumping global symbols:

    % g++ -dynamiclib -fvisibility=hidden lib.cc -o lib.dylib && nm -g
lib.dylib|c++filt 
    0000000000000f0c T void foo<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > >(std::basic_string<char, std::char_traits<char>,
std::allocator<char> >)
    0000000000000f16 T void foo<int>(int)
                     U ___gxx_personality_v0
                     U dyld_stub_binder

Notice that the std::string specialization is missing when using clang++.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list