[llvm-bugs] [Bug 25821] New: “illegal thread-local reference to regular symbol” error on a TLS variable

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Dec 14 07:40:50 PST 2015


            Bug ID: 25821
           Summary: “illegal thread-local reference to regular symbol”
                    error on a TLS variable
           Product: lld
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: joel.cornett at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Linking fails with the message "illegal thread-local reference to regular
symbol" when attempting to create a dylib which references an external TLS
variable declared with `__thread`.

In `foo.cc`:

    extern __thread int x;

    void foo() { ++x; }

The compile step is (this works fine):

    $CXX -stdlib=libc++ -std=c++11 -fvisibility=hidden -fPIC -o foo.cc.o -c

The linking step (where the error is thrown):

    $CXX -stdlib=libc++ -std=c++11 -fvisibility=hidden -dynamiclib
-Wl,-undefined,dynamic_lookup -o libfoo.dylib foo.cpp.o

Now this works fine in gcc (5 and 4.9.3) on the same platform. I understand
there are differences in the implementation of `__thread`, but I cannot find
any documentation addressing this specific issue anywhere, so I assume this is
a bug.

Version info:

    $ $CXX --version
    Apple LLVM version 7.0.2 (clang-700.1.81)
    Target: x86_64-apple-darwin14.5.0
    Thread model: posix

    $ ld -v
    @(#)PROGRAM:ld  PROJECT:ld64-253.9
    configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h
armv6m armv7k armv7m armv7em (tvOS)
    LTO support using: Apple LLVM 7.0.2 (clang-700.1.81)

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/20151214/51848f03/attachment.html>

More information about the llvm-bugs mailing list