[LLVMbugs] [Bug 10123] New: Linker error when mixing visibility

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jun 11 01:10:33 PDT 2011


           Summary: Linker error when mixing visibility
           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

Created an attachment (id=6727)
 --> (http://llvm.org/bugs/attachment.cgi?id=6727)
Example project

If I define a new non-POD type in a header and then include this header from
two sources, respectively compiled with -fvisibility=hidden and
-fvisibility=default *and* -m32 then I get a linker error if both sources
instantiate the non-POD type, example of error:

   ld: bad codegen, pointer diff in _main to global weak symbol
__ZNSt6vectorIiSaIiEED1Ev for architecture i386

This is even though the shared header is enclosed in #pragma GCC visibility
push(default) … pop.

Note though that it *does* link without problems when building with -m64.

I have attached an example project with a build.sh which shows the problem.

If you wonder why I mix visibility for my sources then it is due to issue
10113, which prevents me from compiling all my sources with visibility set to

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